diff options
author | Rahul Sabnis <rahulsabnis@google.com> | 2022-03-29 17:17:32 -0700 |
---|---|---|
committer | Rahul Sabnis <rahulsabnis@google.com> | 2022-03-29 17:18:35 -0700 |
commit | d8e063f200a7ebfbcdd9bd2ab77c3126bd5fd3bb (patch) | |
tree | 9133a0b5e3e3cba3dd3fe22de8ea073b25e4b296 /framework/java/android/bluetooth/BluetoothAdapter.java | |
parent | a6b3fac3e4477caaa84550871a2d177be240ac82 (diff) |
Update BluetoothAdapter#setScanMode to throw an IllegalArgumentException
when the the input is invalid
Tag: #feature
Bug: 202310885
Test: atest BluetoothHostTest#testSetScanMode
Ignore-AOSP-First: Fixing GTS test
Change-Id: I4cd64903de7c4b413f551ac6fd4703035e32c7b9
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothAdapter.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothAdapter.java | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java index 0a2fb4fb44..e6f91bf128 100644 --- a/framework/java/android/bluetooth/BluetoothAdapter.java +++ b/framework/java/android/bluetooth/BluetoothAdapter.java @@ -1914,6 +1914,7 @@ public final class BluetoothAdapter { * @param mode represents the desired state of the local device scan mode * * @return status code indicating whether the scan mode was successfully set + * @throws IllegalArgumentException if the mode is not a valid scan mode * @hide */ @SystemApi @@ -1927,6 +1928,10 @@ public final class BluetoothAdapter { if (getState() != STATE_ON) { return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED; } + if (mode != SCAN_MODE_NONE && mode != SCAN_MODE_CONNECTABLE + && mode != SCAN_MODE_CONNECTABLE_DISCOVERABLE) { + throw new IllegalArgumentException("Invalid scan mode param value"); + } try { mServiceLock.readLock().lock(); if (mService != null) { |