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

Unverified Commit 404ebaa8 authored by Jon Evans's avatar Jon Evans Committed by Michael Bestas
Browse files

Port: Wake on plug (1/2)

Change-Id: I5e50a7fd351857d76c1c2fd13c6e737d8902a2f3
parent 62306ce0
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -418,6 +418,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;

@@ -722,6 +725,9 @@ public final class PowerManagerService extends SystemService
            resolver.registerContentObserver(CMSettings.Secure.getUriFor(
                    CMSettings.Secure.BUTTON_BACKLIGHT_TIMEOUT),
                    false, mSettingsObserver, UserHandle.USER_ALL);
            resolver.registerContentObserver(CMSettings.Global.getUriFor(
                    CMSettings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED),
                    false, mSettingsObserver, UserHandle.USER_ALL);

            // Go.
            readConfigurationLocked();
@@ -797,6 +803,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 = CMSettings.Global.getInt(resolver,
                CMSettings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED,
                (mWakeUpWhenPluggedOrUnpluggedConfig ? 1 : 0));

        if (mSupportsDoubleTapWakeConfig) {
            boolean doubleTapWakeEnabled = Settings.Secure.getIntForUser(resolver,
@@ -1587,7 +1596,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;
        }