summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author David Stevens <stevensd@google.com> 2017-09-14 16:27:56 -0700
committer David Stevens <stevensd@google.com> 2017-09-18 16:39:19 -0700
commita3d263c1c3605b0f71a01ecdeeefb3a033f6e6ce (patch)
tree6434ff2df125da6bf6c404df5adca093a134269e
parentcdf80ad738408b75d9f047e23393672bc27e3628 (diff)
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
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java19
1 files changed, 6 insertions, 13 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 85fa7a1b4c3e..edeaa50c7189 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -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;
- // 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;
+ if (wasAwake != isAwake) {
+ // Also update state in a special way for running foreground services UI.
+ 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();
}
}