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

Commit 814a8ff2 authored by David van Tonder's avatar David van Tonder Committed by Gerrit Code Review
Browse files

Merge "Display options: allow configuration of wake on plug behavior (2/2)" into cm-10.2

parents 5e556b3f b15776db
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -5518,6 +5518,13 @@ public final class Settings {
         */
        public static final String BUGREPORT_IN_POWER_MENU = "bugreport_in_power_menu";

        /**
         * Whether to wake the display when plugging or unplugging the charger
         *
         * @hide
         */
        public static final String WAKE_WHEN_PLUGGED_OR_UNPLUGGED = "wake_when_plugged_or_unplugged";

        /**
         * Whether ADB is enabled.
         */
@@ -6611,6 +6618,7 @@ public final class Settings {
        public static final String[] SETTINGS_TO_BACKUP = {
            BUGREPORT_IN_POWER_MENU,
            STAY_ON_WHILE_PLUGGED_IN,
            WAKE_WHEN_PLUGGED_OR_UNPLUGGED,
            MODE_RINGER,
            AUTO_TIME,
            AUTO_TIME_ZONE,
+13 −3
Original line number Diff line number Diff line
@@ -290,7 +290,7 @@ public final class PowerManagerService extends IPowerManager.Stub
    // The current dock state.
    private int mDockState = Intent.EXTRA_DOCK_STATE_UNDOCKED;

    // True if the device should wake up when plugged or unplugged.
    // True if the device should wake up when plugged or unplugged (default from config.xml)
    private boolean mWakeUpWhenPluggedOrUnpluggedConfig;

    // True if dreams are supported on this device.
@@ -325,6 +325,9 @@ public final class PowerManagerService extends IPowerManager.Stub
    // A bitfield of battery conditions under which to make the screen stay on.
    private int mStayOnWhilePluggedInSetting;

    // True if the device should wake up when plugged or unplugged
    private int mWakeUpWhenPluggedOrUnpluggedSetting;

    // True if the device should stay on.
    private boolean mStayOn;

@@ -517,6 +520,9 @@ public final class PowerManagerService extends IPowerManager.Stub
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.STAY_ON_WHILE_PLUGGED_IN),
                    false, mSettingsObserver, UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED),
                    false, mSettingsObserver, UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.SCREEN_BRIGHTNESS),
                    false, mSettingsObserver, UserHandle.USER_ALL);
@@ -570,6 +576,9 @@ public final class PowerManagerService extends IPowerManager.Stub
                UserHandle.USER_CURRENT);
        mStayOnWhilePluggedInSetting = Settings.Global.getInt(resolver,
                Settings.Global.STAY_ON_WHILE_PLUGGED_IN, BatteryManager.BATTERY_PLUGGED_AC);
        mWakeUpWhenPluggedOrUnpluggedSetting = Settings.Global.getInt(resolver,
                Settings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED,
                (mWakeUpWhenPluggedOrUnpluggedConfig ? 1 : 0));

        final int oldScreenBrightnessSetting = mScreenBrightnessSetting;
        mScreenBrightnessSetting = Settings.System.getIntForUser(resolver,
@@ -1271,8 +1280,9 @@ public final class PowerManagerService extends IPowerManager.Stub

    private boolean shouldWakeUpWhenPluggedOrUnpluggedLocked(
            boolean wasPowered, int oldPlugType, boolean dockedOnWirelessCharger) {
        // Don't wake when powered unless configured to do so.
        if (!mWakeUpWhenPluggedOrUnpluggedConfig) {

        // Don't wake when powered if disabled in settings.
        if (mWakeUpWhenPluggedOrUnpluggedSetting == 0) {
            return false;
        }