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

Commit 9f1085a4 authored by Jon Evans's avatar Jon Evans Committed by Luca Stefani
Browse files

Port: Wake on plug (1/2)

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

@@ -870,6 +873,9 @@ public final class PowerManagerService extends SystemService
        resolver.registerContentObserver(LineageSettings.Secure.getUriFor(
                LineageSettings.Secure.BUTTON_BACKLIGHT_TIMEOUT),
                false, mSettingsObserver, UserHandle.USER_ALL);
        resolver.registerContentObserver(LineageSettings.Global.getUriFor(
                LineageSettings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED),
                false, mSettingsObserver, UserHandle.USER_ALL);
        IVrManager vrManager = (IVrManager) getBinderService(Context.VR_SERVICE);
        if (vrManager != null) {
            try {
@@ -975,6 +981,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) {
@@ -1832,7 +1841,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;
        }