Merge "Always wake device on power key from non interactive immediately." into lmp-sprout-dev

This commit is contained in:
Bryce Lee
2014-11-18 19:09:08 +00:00
committed by Android (Google) Code Review

View File

@@ -316,6 +316,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// handler thread. We'll need to resolve this someday by teaching the input dispatcher // handler thread. We'll need to resolve this someday by teaching the input dispatcher
// to hold wakelocks during dispatch and eliminating the critical path. // to hold wakelocks during dispatch and eliminating the critical path.
volatile boolean mPowerKeyHandled; volatile boolean mPowerKeyHandled;
volatile boolean mBeganFromNonInteractive;
volatile int mPowerKeyPressCounter; volatile int mPowerKeyPressCounter;
volatile boolean mEndCallKeyHandled; volatile boolean mEndCallKeyHandled;
@@ -877,15 +878,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout()); ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout());
} }
} else { } else {
// When non-interactive, we ordinarily wake up immediately and
// consume the key. However on some devices we need to support multi-press
// without waking so we will delay handling for later in that case
// (at the cost of increased latency).
final int maxCount = getMaxMultiPressPowerCount();
if (maxCount <= 1) {
// No other actions. We can wake immediately.
wakeUpFromPowerKey(event.getDownTime()); wakeUpFromPowerKey(event.getDownTime());
final int maxCount = getMaxMultiPressPowerCount();
if (maxCount <= 1) {
mPowerKeyHandled = true; mPowerKeyHandled = true;
} else {
mBeganFromNonInteractive = true;
} }
} }
} }
@@ -922,6 +921,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
private void finishPowerKeyPress() { private void finishPowerKeyPress() {
mBeganFromNonInteractive = false;
mPowerKeyPressCounter = 0; mPowerKeyPressCounter = 0;
if (mPowerKeyWakeLock.isHeld()) { if (mPowerKeyWakeLock.isHeld()) {
mPowerKeyWakeLock.release(); mPowerKeyWakeLock.release();
@@ -946,9 +946,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
powerMultiPressAction(eventTime, interactive, mDoublePressOnPowerBehavior); powerMultiPressAction(eventTime, interactive, mDoublePressOnPowerBehavior);
} else if (count == 3) { } else if (count == 3) {
powerMultiPressAction(eventTime, interactive, mTriplePressOnPowerBehavior); powerMultiPressAction(eventTime, interactive, mTriplePressOnPowerBehavior);
} else if (!interactive) { } else if (interactive && !mBeganFromNonInteractive) {
wakeUpFromPowerKey(eventTime);
} else {
switch (mShortPressOnPowerBehavior) { switch (mShortPressOnPowerBehavior) {
case SHORT_PRESS_POWER_NOTHING: case SHORT_PRESS_POWER_NOTHING:
break; break;