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

Commit 9db835b7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Cts Tests: Fix enable scan settings race condition" into main

parents 7931466f 70988556
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -75,6 +75,16 @@ object BlockingBluetoothAdapter {
        if (toggleScanSetting) {
            Log.d(TAG, "Allowing the scan to be perform while Bluetooth is OFF")
            Settings.Global.putInt(context.contentResolver, BLE_SCAN_ALWAYS_AVAILABLE, 1)
            for (i in 1..5) {
                if (adapter.isBleScanAlwaysAvailable()) {
                    break
                }
                Log.d(TAG, "Ble scan not yet available… Sleeping 20 ms $i/5")
                Thread.sleep(20)
            }
            if (!adapter.isBleScanAlwaysAvailable()) {
                throw IllegalStateException("Could not enable BLE scan")
            }
        }
        Log.d(TAG, "Call to enableBLE")
        if (!withPermissions(BLUETOOTH_CONNECT).use { adapter.enableBLE() }) {