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

Commit 62b8a498 authored by Ruchi Kandoi's avatar Ruchi Kandoi
Browse files

Adds Content Observer for the Low power mode in developer options.



Change-Id: Ibed319e734340dfd5348dbeb8fe20c01b1adaac5
Signed-off-by: default avatarRuchi Kandoi <kandoiruchi@google.com>
parent c3be4506
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -5969,6 +5969,12 @@ public final class Settings {
         */
        public static final String SHOW_PROCESSES = "show_processes";

        /**
         * If 1 low power mode is enabled.
         * @hide
         */
        public static final String LOW_POWER_MODE = "low_power";

         /**
         * If 1, the activity manager will aggressively finish activities and
         * processes as soon as they are no longer needed.  If 0, the normal
+15 −1
Original line number Diff line number Diff line
@@ -168,6 +168,10 @@ public final class PowerManagerService extends com.android.server.SystemService
    // Poll interval in milliseconds for watching boot animation finished.
    private static final int BOOT_ANIMATION_POLL_INTERVAL = 200;

    //powerHint
    private static final int POWER_HINT_LOW_POWER_MODE = 5;
    private static boolean mLowPowerModeEnabled;

    private final Context mContext;
    private LightsManager mLightsManager;
    private BatteryService mBatteryService;
@@ -530,7 +534,9 @@ public final class PowerManagerService extends com.android.server.SystemService
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.SCREEN_BRIGHTNESS_MODE),
                    false, mSettingsObserver, UserHandle.USER_ALL);

            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.LOW_POWER_MODE),
                    false, mSettingsObserver, UserHandle.USER_ALL);
            // Go.
            readConfigurationLocked();
            updateSettingsLocked();
@@ -610,6 +616,14 @@ public final class PowerManagerService extends com.android.server.SystemService
                Settings.System.SCREEN_BRIGHTNESS_MODE,
                Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, UserHandle.USER_CURRENT);

        boolean mIsEnabled = Settings.Global.getInt(resolver,
            Settings.Global.LOW_POWER_MODE, 0) != 0;
        if (mIsEnabled != mLowPowerModeEnabled) {
            BinderService bs = new BinderService();
            bs.powerHint(POWER_HINT_LOW_POWER_MODE, mIsEnabled ? 1 : 0);
            mLowPowerModeEnabled = mIsEnabled;
        }

        mDirty |= DIRTY_SETTINGS;
    }