diff options
author | Gabriele M <moto.falcon.git@gmail.com> | 2016-09-26 00:43:08 +0200 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-10-08 14:15:39 -0700 |
commit | 19139443a777843efe4e0f02a77e939629bd249b (patch) | |
tree | 22a28459db22d5b04470bf8a44b3bb9bc0504ceb | |
parent | b3616bc68be22bdb5f72c190c6e09e87314e9786 (diff) | |
download | frameworks_base-19139443a777843efe4e0f02a77e939629bd249b.zip frameworks_base-19139443a777843efe4e0f02a77e939629bd249b.tar.gz frameworks_base-19139443a777843efe4e0f02a77e939629bd249b.tar.bz2 |
Fix volume keys wakeup status handling
The same status flag is used for the three different volume keys,
however nothing prevents users from pressing multiple keys at the
same time. This allows to set the status flag with one volume key
and clear it with the other volume key.
Use one flag per key so that we never end up in an inconsistent
state. This fixes the seldom power button issues that happen when
the "volume wake" feature is enabled.
Change-Id: I08f5f9ff696bef3dd840cff97d570e44ebe03e4e
-rw-r--r-- | services/core/java/com/android/server/policy/PhoneWindowManager.java | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 83eb424..6339007 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -495,7 +495,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { // During wakeup by volume keys, we still need to capture subsequent events // until the key is released. This is required since the beep sound is produced // post keypressed. - boolean mVolumeWakeTriggered; + boolean mVolumeDownWakeTriggered; + boolean mVolumeUpWakeTriggered; + boolean mVolumeMuteWakeTriggered; int mPointerLocationMode = 0; // guarded by mLock @@ -5572,6 +5574,36 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } + private void setVolumeWakeTriggered(final int keyCode, boolean triggered) { + switch (keyCode) { + case KeyEvent.KEYCODE_VOLUME_DOWN: + mVolumeDownWakeTriggered = triggered; + break; + case KeyEvent.KEYCODE_VOLUME_UP: + mVolumeUpWakeTriggered = triggered; + break; + case KeyEvent.KEYCODE_VOLUME_MUTE: + mVolumeMuteWakeTriggered = triggered; + break; + default: + Log.w(TAG, "setVolumeWakeTriggered: unexpected keyCode=" + keyCode); + } + } + + private boolean getVolumeWakeTriggered(final int keyCode) { + switch (keyCode) { + case KeyEvent.KEYCODE_VOLUME_DOWN: + return mVolumeDownWakeTriggered; + case KeyEvent.KEYCODE_VOLUME_UP: + return mVolumeUpWakeTriggered; + case KeyEvent.KEYCODE_VOLUME_MUTE: + return mVolumeMuteWakeTriggered; + default: + Log.w(TAG, "getVolumeWakeTriggered: unexpected keyCode=" + keyCode); + return false; + } + } + /** {@inheritDoc} */ @Override public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) { @@ -5667,11 +5699,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Eat all down & up keys when using volume wake. // This disables volume control, music control, and "beep" on key up. if (isWakeKey && mVolumeWakeScreen) { - mVolumeWakeTriggered = true; + setVolumeWakeTriggered(keyCode, true); break; - } else if (mVolumeWakeTriggered && !down) { + } else if (getVolumeWakeTriggered(keyCode) && !down) { result &= ~ACTION_PASS_TO_USER; - mVolumeWakeTriggered = false; + setVolumeWakeTriggered(keyCode, false); break; } |