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

Commit 12b1c383 authored by Robert Horvath's avatar Robert Horvath Committed by Android (Google) Code Review
Browse files

Merge "Set the Low Power Standby enabled setting when unassigned"

parents f6cd035c 6dbc4a14
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -201,6 +201,7 @@ public class LowPowerStandbyController {
            mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.LOW_POWER_STANDBY_ACTIVE_DURING_MAINTENANCE),
                    false, mSettingsObserver, UserHandle.USER_ALL);
            initSettingsLocked();
            updateSettingsLocked();

            if (mIsEnabled) {
@@ -211,6 +212,23 @@ public class LowPowerStandbyController {
        LocalServices.addService(LowPowerStandbyControllerInternal.class, mLocalService);
    }

    @GuardedBy("mLock")
    private void initSettingsLocked() {
        final ContentResolver resolver = mContext.getContentResolver();
        if (mSupportedConfig) {
            final int enabledSetting = Settings.Global.getInt(resolver,
                    Settings.Global.LOW_POWER_STANDBY_ENABLED, /* def= */ -1);

            // If the ENABLED setting hasn't been assigned yet, set it to its default value.
            // This ensures reading the setting reflects the enabled state, without having to know
            // the default value for this device.
            if (enabledSetting == -1) {
                Settings.Global.putInt(resolver, Settings.Global.LOW_POWER_STANDBY_ENABLED,
                        /* value= */ mEnabledByDefaultConfig ? 1 : 0);
            }
        }
    }

    @GuardedBy("mLock")
    private void updateSettingsLocked() {
        final ContentResolver resolver = mContext.getContentResolver();