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

Commit 584bc650 authored by Wei Wang's avatar Wei Wang Committed by Android Git Automerger
Browse files

am 5d84367a: Merge "Enforce permission check in BLE scan only mode." into mnc-dev

* commit '5d84367a':
  Enforce permission check in BLE scan only mode.
parents 19bb26b3 5d84367a
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;
    }