diff options
author | Jeff Brown <jeffbrown@google.com> | 2014-04-11 03:49:37 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-04-11 03:49:37 +0000 |
commit | 337e764debde56b1462fb5f2794b3e917d8a42e2 (patch) | |
tree | 5a2b4e77654a0897408f04e429045e49359a0e4b /policy | |
parent | cd5e3f85fc9228b943ee8dfda0951e068953596c (diff) | |
parent | f24687e2731811fd0e3803b691fd47a659f89329 (diff) | |
download | frameworks_base-337e764debde56b1462fb5f2794b3e917d8a42e2.zip frameworks_base-337e764debde56b1462fb5f2794b3e917d8a42e2.tar.gz frameworks_base-337e764debde56b1462fb5f2794b3e917d8a42e2.tar.bz2 |
am f24687e2: Merge "Plumb display power state through display manager." into klp-modular-dev
* commit 'f24687e2731811fd0e3803b691fd47a659f89329':
Plumb display power state through display manager.
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 f3fce11..2a4e059 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) { |