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

Commit 4c344591 authored by Stephanie Bak's avatar Stephanie Bak
Browse files

Update APM Device Configs

Update Settings.Global flags with Device Config flag values on
initialization

Bug: 239983569
Test: manual
Ignore-AOSP-First: merge conflicts in AOSP
Change-Id: I777582ae8b21c3dc93142c7681a2e9b21e19cd8a
parent cd30ea3e
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -52,19 +52,28 @@ public class BluetoothDeviceConfigListener {
        mService = service;
        mLogDebug = logDebug;
        mContext = context;
        mPrevApmEnhancement = Settings.Global.getInt(mContext.getContentResolver(),
                APM_ENHANCEMENT, DEFAULT_APM_ENHANCEMENT) == 1;
        mPrevBtApmState = Settings.Global.getInt(mContext.getContentResolver(),
                BT_DEFAULT_APM_STATE, DEFAULT_BT_APM_STATE) == 1;
        mConfigChangeTracker =
                new BluetoothDeviceConfigChangeTracker(
                        DeviceConfig.getProperties(DeviceConfig.NAMESPACE_BLUETOOTH));
        updateApmConfigs();
        DeviceConfig.addOnPropertiesChangedListener(
                DeviceConfig.NAMESPACE_BLUETOOTH,
                (Runnable r) -> r.run(),
                mDeviceConfigChangedListener);
    }

    private void updateApmConfigs() {
        mPrevApmEnhancement = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_BLUETOOTH,
                APM_ENHANCEMENT, false);
        mPrevBtApmState = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_BLUETOOTH,
                BT_DEFAULT_APM_STATE, false);

        Settings.Global.putInt(mContext.getContentResolver(),
                APM_ENHANCEMENT, mPrevApmEnhancement ? 1 : 0);
        Settings.Global.putInt(mContext.getContentResolver(),
                BT_DEFAULT_APM_STATE, mPrevBtApmState ? 1 : 0);
    }

    private final DeviceConfig.OnPropertiesChangedListener mDeviceConfigChangedListener =
            new DeviceConfig.OnPropertiesChangedListener() {
                @Override