summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRahul Sabnis <rahulsabnis@google.com>2022-03-30 17:45:02 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2022-03-30 17:45:02 +0000
commit1bad855b89729564dda00fce7f59d0d015fbce4b (patch)
tree75bb7d8eb3a16687ca5a684bfcad89fa2d875790
parent65b8a67060b9ac8a423f1b35c6edef5ce76d35fe (diff)
parentd8e063f200a7ebfbcdd9bd2ab77c3126bd5fd3bb (diff)
Merge "Update BluetoothAdapter#setScanMode to throw an IllegalArgumentException when the the input is invalid" into tm-dev
-rw-r--r--framework/java/android/bluetooth/BluetoothAdapter.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java
index 4e950e31f8..04232f6cf0 100644
--- a/framework/java/android/bluetooth/BluetoothAdapter.java
+++ b/framework/java/android/bluetooth/BluetoothAdapter.java
@@ -1941,6 +1941,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
@@ -1954,6 +1955,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) {