diff options
author | Jeff Brown <jeffbrown@google.com> | 2015-06-10 16:36:03 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2015-06-10 16:36:03 -0700 |
commit | 48d1b14b7b54ae1491e7d9d5fdd9be8906c19a3c (patch) | |
tree | 46c18b6ba39f4a15a7c669d75a584d22e7ae5ac3 | |
parent | 8e5d33ef985ebeaa68bf2a7847ed865536ff0623 (diff) | |
download | frameworks_base-48d1b14b7b54ae1491e7d9d5fdd9be8906c19a3c.zip frameworks_base-48d1b14b7b54ae1491e7d9d5fdd9be8906c19a3c.tar.gz frameworks_base-48d1b14b7b54ae1491e7d9d5fdd9be8906c19a3c.tar.bz2 |
Pause activities when the screen is off.
Bug: 19948628
Change-Id: I90923605d50f4ee381da4e05117879554e0a1dee
-rw-r--r-- | services/core/java/com/android/server/policy/PhoneWindowManager.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 6e52358..25ca167 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -514,6 +514,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean mDreamingLockscreen; boolean mDreamingSleepTokenNeeded; SleepToken mDreamingSleepToken; + SleepToken mScreenOffSleepToken; boolean mKeyguardSecure; boolean mKeyguardSecureIncludingHidden; volatile boolean mKeyguardOccluded; @@ -5385,6 +5386,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { public void screenTurnedOff() { if (DEBUG_WAKEUP) Slog.i(TAG, "Screen turned off..."); + updateScreenOffSleepToken(true); synchronized (mLock) { mScreenOnEarly = false; mScreenOnFully = false; @@ -5399,6 +5401,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { public void screenTurningOn(final ScreenOnListener screenOnListener) { if (DEBUG_WAKEUP) Slog.i(TAG, "Screen turning on..."); + updateScreenOffSleepToken(false); synchronized (mLock) { mScreenOnEarly = true; mScreenOnFully = false; @@ -6021,6 +6024,20 @@ public class PhoneWindowManager implements WindowManagerPolicy { } else { if (mDreamingSleepToken != null) { mDreamingSleepToken.release(); + mDreamingSleepToken = null; + } + } + } + + private void updateScreenOffSleepToken(boolean acquire) { + if (acquire) { + if (mScreenOffSleepToken == null) { + mScreenOffSleepToken = mActivityManagerInternal.acquireSleepToken("ScreenOff"); + } + } else { + if (mScreenOffSleepToken != null) { + mScreenOffSleepToken.release(); + mScreenOffSleepToken = null; } } } |