diff options
author | Jeff Brown <jeffbrown@google.com> | 2014-04-09 00:31:55 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2014-04-10 20:46:14 -0700 |
commit | 037c33eae74bee2774897d969d48947f9abe254f (patch) | |
tree | 9f6a33f07f48b9a08088eb287c1bfdd1fd97bda5 /policy | |
parent | 7289f3ab8f05db6206d696d75f460fadc05dc731 (diff) | |
download | frameworks_base-037c33eae74bee2774897d969d48947f9abe254f.zip frameworks_base-037c33eae74bee2774897d969d48947f9abe254f.tar.gz frameworks_base-037c33eae74bee2774897d969d48947f9abe254f.tar.bz2 |
Plumb display power state through display manager.
Declare a new method, Display.getState() to retrieve the actual
power state of a display.
Improved documentation for Intent.ACTION_SCREEN_ON and
Intent.ACTION_SCREEN_OFF to clarify what they really mean in
terms of the interactive state of the device.
Deprecated PowerManager.isScreenOn() and replaced it with
PowerManager.isInteractive() with a more suggestive name and
better documentation.
Redirect display power state changes to go through the display
manager first and only then head over to the power manager for
legacy compatibility.
Eliminated the bright here and woke here policy flags since they
were unused. Simplified the input dispatch policy somewhat.
Ensure that screen wake locks are respected up until the point
when dozing really begins.
Fixed a regression in DreamService where onDreamingStarted
might be called before onWindowAttached.
Bug: 13133142
Bug: 13472578
Bug: 13929355
Bug: 13760290
Change-Id: Iabef96921dd554ce3768fb18619cefc3230b5fb0
Diffstat (limited to 'policy')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 235fa0e..7128cfa 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -2363,7 +2363,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } private boolean interceptFallback(WindowState win, KeyEvent fallbackEvent, int policyFlags) { - int actions = interceptKeyBeforeQueueing(fallbackEvent, policyFlags, true); + int actions = interceptKeyBeforeQueueing(fallbackEvent, policyFlags); if ((actions & ACTION_PASS_TO_USER) != 0) { long delayMillis = interceptKeyBeforeDispatching( win, fallbackEvent, policyFlags); @@ -3802,12 +3802,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { /** {@inheritDoc} */ @Override - public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn) { + public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) { if (!mSystemBooted) { // If we have not yet booted, don't let key events do anything. return 0; } + final boolean interactive = (policyFlags & FLAG_INTERACTIVE) != 0; final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; final boolean canceled = event.isCanceled(); final int keyCode = event.getKeyCode(); @@ -3819,7 +3820,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // This will prevent any keys other than the power button from waking the screen // when the keyguard is hidden by another activity. final boolean keyguardActive = (mKeyguardDelegate == null ? false : - (isScreenOn ? + (interactive ? mKeyguardDelegate.isShowingAndNotHidden() : mKeyguardDelegate.isShowing())); @@ -3831,7 +3832,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (DEBUG_INPUT) { Log.d(TAG, "interceptKeyTq keycode=" + keyCode - + " screenIsOn=" + isScreenOn + " keyguardActive=" + keyguardActive + + " interactive=" + interactive + " keyguardActive=" + keyguardActive + " policyFlags=" + Integer.toHexString(policyFlags)); } @@ -3840,18 +3841,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false); } - // Basic policy based on screen state and keyguard. - // FIXME: This policy isn't quite correct. We shouldn't care whether the screen - // is on or off, really. We should care about whether the device is in an - // interactive state or is in suspend pretending to be "off". - // The primary screen might be turned off due to proximity sensor or - // because we are presenting media on an auxiliary screen or remotely controlling - // the device some other way (which is why we have an exemption here for injected - // events). + // Basic policy based on interactive state. int result; boolean isWakeKey = (policyFlags & (WindowManagerPolicy.FLAG_WAKE | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0; - if (isScreenOn || (isInjected && !isWakeKey)) { + if (interactive || (isInjected && !isWakeKey)) { // When the screen is on or if the key is injected pass the key to the application. result = ACTION_PASS_TO_USER; } else { @@ -3876,7 +3870,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { case KeyEvent.KEYCODE_VOLUME_MUTE: { if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { if (down) { - if (isScreenOn && !mVolumeDownKeyTriggered + if (interactive && !mVolumeDownKeyTriggered && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { mVolumeDownKeyTriggered = true; mVolumeDownKeyTime = event.getDownTime(); @@ -3890,7 +3884,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { if (down) { - if (isScreenOn && !mVolumeUpKeyTriggered + if (interactive && !mVolumeUpKeyTriggered && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { mVolumeUpKeyTriggered = true; cancelPendingPowerKeyAction(); @@ -3958,7 +3952,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { Log.w(TAG, "ITelephony threw RemoteException", ex); } } - interceptPowerKeyDown(!isScreenOn || hungUp); + interceptPowerKeyDown(!interactive || hungUp); } else { if (interceptPowerKeyUp(canceled)) { if ((mEndcallBehavior @@ -3980,9 +3974,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { case KeyEvent.KEYCODE_POWER: { result &= ~ACTION_PASS_TO_USER; if (down) { - mImmersiveModeConfirmation.onPowerKeyDown(isScreenOn, event.getDownTime(), + mImmersiveModeConfirmation.onPowerKeyDown(interactive, event.getDownTime(), isImmersiveMode(mLastSystemUiFlags)); - if (isScreenOn && !mPowerKeyTriggered + if (interactive && !mPowerKeyTriggered && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { mPowerKeyTriggered = true; mPowerKeyTime = event.getDownTime(); @@ -4008,7 +4002,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { Log.w(TAG, "ITelephony threw RemoteException", ex); } } - interceptPowerKeyDown(!isScreenOn || hungUp + interceptPowerKeyDown(!interactive || hungUp || mVolumeDownKeyTriggered || mVolumeUpKeyTriggered); } else { mPowerKeyTriggered = false; @@ -4141,15 +4135,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { /** {@inheritDoc} */ @Override - public int interceptMotionBeforeQueueingWhenScreenOff(long whenNanos, int policyFlags) { - int result = 0; - - final boolean isWakeMotion = (policyFlags - & (WindowManagerPolicy.FLAG_WAKE | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0; - if (isWakeMotion) { - mPowerManager.wakeUp(whenNanos / 1000000); - } - return result; + public int interceptWakeMotionBeforeQueueing(long whenNanos, int policyFlags) { + // We already know this is a wake motion so just wake up. + // Note that we would observe policyFlags containing + // FLAG_WAKE and FLAG_INTERACTIVE here. + mPowerManager.wakeUp(whenNanos / 1000000); + return 0; } void dispatchMediaKeyWithWakeLock(KeyEvent event) { |