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

Commit aa8b0f1d authored by Arthur Hsu's avatar Arthur Hsu
Browse files

Add config_supportBluetoothPersistedState.

Add a config to indicate whether a device supports Bluetooth persisted
state and defaulted to true. In ARC++, Bluetooth adapter state can be
out-of-sync from its container if the user changes it before the
container being available.

When set to false, this config prevents Android to auto start the
Bluetooth. ARC++ will set this to false and sync Bluetooth state later
with Android.

Related CL is ag/931281

Bug: 62413625, 69965109
Test: On sailfish, Bluetooth on/off correctly and state persisted across reboot
Change-Id: Ie298929eb6b882108a12e8b95f61e3c9f8eb63ea
parent d4b90a87
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -439,10 +439,17 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
                Settings.Global.AIRPLANE_MODE_ON, 0) == 1;
    }

    private boolean supportBluetoothPersistedState() {
        return mContext.getResources().getBoolean(R.bool.config_supportBluetoothPersistedState);
    }

    /**
     *  Returns true if the Bluetooth saved state is "on"
     */
    private boolean isBluetoothPersistedStateOn() {
        if (!supportBluetoothPersistedState()) {
            return false;
        }
        int state = Settings.Global.getInt(mContentResolver, Settings.Global.BLUETOOTH_ON, -1);
        if (DBG) {
            Slog.d(TAG, "Bluetooth persisted state: " + state);
@@ -454,6 +461,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
     *  Returns true if the Bluetooth saved state is BLUETOOTH_ON_BLUETOOTH
     */
    private boolean isBluetoothPersistedStateOnBluetooth() {
        if (!supportBluetoothPersistedState()) {
            return false;
        }
        return Settings.Global.getInt(mContentResolver, Settings.Global.BLUETOOTH_ON,
                BLUETOOTH_ON_BLUETOOTH) == BLUETOOTH_ON_BLUETOOTH;
    }