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

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

PowerManagerService: Wake on plug (1/2)

Change-Id: I5e50a7fd351857d76c1c2fd13c6e737d8902a2f3
parent 74d18ed1
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -528,6 +528,9 @@ public final class PowerManagerService extends SystemService
    // True if the device should wake up when plugged or unplugged.
    private boolean mWakeUpWhenPluggedOrUnpluggedConfig;

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

    // True if the device should wake up when plugged or unplugged in theater mode.
    private boolean mWakeUpWhenPluggedOrUnpluggedInTheaterModeConfig;

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

        // Register for broadcasts from other components of the system.
        IntentFilter filter = new IntentFilter();
@@ -1667,6 +1673,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 = LineageSettings.Global.getInt(resolver,
                LineageSettings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED,
                (mWakeUpWhenPluggedOrUnpluggedConfig ? 1 : 0)) == 1;
        mAlwaysOnEnabled = mAmbientDisplayConfiguration.alwaysOnEnabled(UserHandle.USER_CURRENT);

        if (mSupportsDoubleTapWakeConfig) {
@@ -2795,7 +2804,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) {
            return false;
        }