Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d8e063f2 authored by Rahul Sabnis's avatar Rahul Sabnis
Browse files

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
parent a6b3fac3
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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) {