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

Commit 5d84367a authored by Wei Wang's avatar Wei Wang Committed by Android (Google) Code Review
Browse files

Merge "Enforce permission check in BLE scan only mode." into mnc-dev

parents e07ee532 c52b2ecc
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;
    }