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

Commit a3d263c1 authored by David Stevens's avatar David Stevens
Browse files

Listen for device power state for VrMode

ActivityManagerService's sleep state is now dependent on whether or not
there are any awake displays, instead of the device power state. Make
VrManagerService listen to the device power state instead of the
ActtivityManagerService sleep state, since its VirtualDisplay for 2D
activities will keep ActtivityManagerService awake.

Bug: 65605913
Test: manual
Change-Id: Ia620d24977d896e6688020d59850046dd0cb7187
parent cdf80ad7
Loading
Loading
Loading
Loading
+6 −13
Original line number Diff line number Diff line
@@ -12463,19 +12463,14 @@ public class ActivityManagerService extends IActivityManager.Stub
    void onWakefulnessChanged(int wakefulness) {
        synchronized(this) {
            boolean wasAwake = mWakefulness == PowerManagerInternal.WAKEFULNESS_AWAKE;
            boolean isAwake = wakefulness == PowerManagerInternal.WAKEFULNESS_AWAKE;
            mWakefulness = wakefulness;
            if (wasAwake != isAwake) {
                // Also update state in a special way for running foreground services UI.
            switch (mWakefulness) {
                case PowerManagerInternal.WAKEFULNESS_ASLEEP:
                case PowerManagerInternal.WAKEFULNESS_DREAMING:
                case PowerManagerInternal.WAKEFULNESS_DOZING:
                    mServices.updateScreenStateLocked(false /* screenOn */);
                    break;
                case PowerManagerInternal.WAKEFULNESS_AWAKE:
                default:
                    mServices.updateScreenStateLocked(true /* screenOn */);
                    break;
                mServices.updateScreenStateLocked(isAwake);
                sendNotifyVrManagerOfSleepState(!isAwake);
            }
        }
    }
@@ -12511,7 +12506,6 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
            mStackSupervisor.applySleepTokensLocked(true /* applyToStacks */);
            if (wasSleeping) {
                sendNotifyVrManagerOfSleepState(false);
                updateOomAdjLocked();
            }
        } else if (!mSleeping && shouldSleep) {
@@ -12521,7 +12515,6 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
            mTopProcessState = ActivityManager.PROCESS_STATE_TOP_SLEEPING;
            mStackSupervisor.goingToSleepLocked();
            sendNotifyVrManagerOfSleepState(true);
            updateOomAdjLocked();
        }
    }