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

Commit c52b2ecc authored by Wei Wang's avatar Wei Wang
Browse files

Enforce permission check in BLE scan only mode.

Bug:21494402
Change-Id: I3d5d6e87bb8aef8760aa4087559abfeebabb42b1
parent e80c5aea
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -2087,14 +2087,16 @@ public class GattService extends ProfileService {
    }

    private boolean needsPrivilegedPermissionForScan(ScanSettings settings) {
        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
        // BLE scan only mode needs special permission.
        if (adapter.getState() != BluetoothAdapter.STATE_ON) return true;

        // Regular scan, no special permission.
        if (settings == null) {
            return false;
        }
        if (settings == null) return false;

        // Regular scan, no special permission.
        if (settings.getReportDelayMillis() == 0) {
            return false;
        }
        if (settings.getReportDelayMillis() == 0) return false;

        // Batch scan, truncated mode needs permission.
        return settings.getScanResultType() == ScanSettings.SCAN_RESULT_TYPE_ABBREVIATED;
    }