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

Commit fe57d721 authored by Jon Evans's avatar Jon Evans Committed by Steve Kondik
Browse files

Port: Wake on plug (1/2)

Change-Id: I5e50a7fd351857d76c1c2fd13c6e737d8902a2f3
parent 8910c77f
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -6646,6 +6646,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.
         */
@@ -8223,6 +8230,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,
            AUTO_TIME,
            AUTO_TIME_ZONE,
            POWER_SOUNDS_ENABLED,
+10 −1
Original line number Diff line number Diff line
@@ -390,6 +390,9 @@ public final class PowerManagerService extends SystemService
    // 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;

@@ -667,6 +670,9 @@ public final class PowerManagerService extends SystemService
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.PROXIMITY_ON_WAKE),
                    false, mSettingsObserver, UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED),
                    false, mSettingsObserver, UserHandle.USER_ALL);

            // Go.
            readConfigurationLocked();
@@ -753,6 +759,9 @@ public final class PowerManagerService extends SystemService
                Settings.Global.STAY_ON_WHILE_PLUGGED_IN, BatteryManager.BATTERY_PLUGGED_AC);
        mTheaterModeEnabled = Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.THEATER_MODE_ON, 0) == 1;
        mWakeUpWhenPluggedOrUnpluggedSetting = Settings.Global.getInt(resolver,
                Settings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED,
                (mWakeUpWhenPluggedOrUnpluggedConfig ? 1 : 0));
        mProximityWakeEnabled = Settings.System.getInt(resolver,
                Settings.System.PROXIMITY_ON_WAKE, mProximityWakeEnabledByDefaultConfig ? 1 : 0) == 1;

@@ -1473,7 +1482,7 @@ public final class PowerManagerService extends SystemService
    private boolean shouldWakeUpWhenPluggedOrUnpluggedLocked(
            boolean wasPowered, int oldPlugType, boolean dockedOnWirelessCharger) {
        // Don't wake when powered unless configured to do so.
        if (!mWakeUpWhenPluggedOrUnpluggedConfig) {
        if (mWakeUpWhenPluggedOrUnpluggedSetting == 0) {
            return false;
        }