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

Commit 2289e408 authored by Anna Herrera's avatar Anna Herrera
Browse files

Use user settings for BT permissions

If the BluetoothAdapter is unavailable, use the user settings to
determine CHRE's BT permissions.

Bug: 302590029
Test: Verify if Bluetooth Scanning is enabled and BT is disabled,
Bluetooth Scanning will be propagated to CHRE as enabled after rebooting

Change-Id: I0f15ae080e045c2205bae9f270727742593d004e
parent 73c8acd4
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -1431,13 +1431,17 @@ public class ContextHubService extends IContextHubService.Stub {
                mContextHubWrapper.onBtMainSettingChanged(btEnabled);
            }
        } else {
            Log.d(TAG, "BT adapter not available. Defaulting to disabled");
            if (forceUpdate || mIsBtMainEnabled) {
                mIsBtMainEnabled = false;
            Log.d(TAG, "BT adapter not available. Getting permissions from user settings");
            boolean btEnabled = Settings.Global.getInt(mContext.getContentResolver(),
                    Settings.Global.BLUETOOTH_ON, 0) == 1;
            boolean btScanEnabled = Settings.Global.getInt(mContext.getContentResolver(),
                    Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0) == 1;
            if (forceUpdate || mIsBtMainEnabled != btEnabled) {
                mIsBtMainEnabled = btEnabled;
                mContextHubWrapper.onBtMainSettingChanged(mIsBtMainEnabled);
            }
            if (forceUpdate || mIsBtScanningEnabled) {
                mIsBtScanningEnabled = false;
            if (forceUpdate || mIsBtScanningEnabled != btScanEnabled) {
                mIsBtScanningEnabled = btScanEnabled;
                mContextHubWrapper.onBtScanningSettingChanged(mIsBtScanningEnabled);
            }
        }