Merge "Use a consistent policy for filtering wake keys." into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
872965bb22
@@ -3168,8 +3168,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
|
|
||||||
if (lidOpen) {
|
if (lidOpen) {
|
||||||
if (keyguardIsShowingTq()) {
|
if (keyguardIsShowingTq()) {
|
||||||
mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(
|
mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(KeyEvent.KEYCODE_POWER);
|
||||||
KeyEvent.KEYCODE_POWER, mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED);
|
|
||||||
} else {
|
} else {
|
||||||
mPowerManager.wakeUp(SystemClock.uptimeMillis());
|
mPowerManager.wakeUp(SystemClock.uptimeMillis());
|
||||||
}
|
}
|
||||||
@@ -3388,11 +3387,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
// When the screen is off and the key is not injected, determine whether
|
// When the screen is off and the key is not injected, determine whether
|
||||||
// to wake the device but don't pass the key to the application.
|
// to wake the device but don't pass the key to the application.
|
||||||
result = 0;
|
result = 0;
|
||||||
if (down && isWakeKey) {
|
if (down && isWakeKey && isWakeKeyWhenScreenOff(keyCode)) {
|
||||||
if (keyguardActive) {
|
if (keyguardActive) {
|
||||||
// If the keyguard is showing, let it decide what to do with the wake key.
|
// If the keyguard is showing, let it wake the device when ready.
|
||||||
mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode,
|
mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode);
|
||||||
mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED);
|
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, wake the device ourselves.
|
// Otherwise, wake the device ourselves.
|
||||||
result |= ACTION_WAKE_UP;
|
result |= ACTION_WAKE_UP;
|
||||||
@@ -3614,6 +3612,40 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the screen is off we ignore some keys that might otherwise typically
|
||||||
|
* be considered wake keys. We filter them out here.
|
||||||
|
*
|
||||||
|
* {@link KeyEvent#KEYCODE_POWER} is notably absent from this list because it
|
||||||
|
* is always considered a wake key.
|
||||||
|
*/
|
||||||
|
private boolean isWakeKeyWhenScreenOff(int keyCode) {
|
||||||
|
switch (keyCode) {
|
||||||
|
// ignore volume keys unless docked
|
||||||
|
case KeyEvent.KEYCODE_VOLUME_UP:
|
||||||
|
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
||||||
|
case KeyEvent.KEYCODE_VOLUME_MUTE:
|
||||||
|
return mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED;
|
||||||
|
|
||||||
|
// ignore media and camera keys
|
||||||
|
case KeyEvent.KEYCODE_MUTE:
|
||||||
|
case KeyEvent.KEYCODE_HEADSETHOOK:
|
||||||
|
case KeyEvent.KEYCODE_MEDIA_PLAY:
|
||||||
|
case KeyEvent.KEYCODE_MEDIA_PAUSE:
|
||||||
|
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
|
||||||
|
case KeyEvent.KEYCODE_MEDIA_STOP:
|
||||||
|
case KeyEvent.KEYCODE_MEDIA_NEXT:
|
||||||
|
case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
|
||||||
|
case KeyEvent.KEYCODE_MEDIA_REWIND:
|
||||||
|
case KeyEvent.KEYCODE_MEDIA_RECORD:
|
||||||
|
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
|
||||||
|
case KeyEvent.KEYCODE_CAMERA:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags) {
|
public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags) {
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public class KeyguardViewMediator {
|
|||||||
* Does not turn on screen, held while a call to {@link KeyguardViewManager#wakeWhenReadyTq(int)}
|
* Does not turn on screen, held while a call to {@link KeyguardViewManager#wakeWhenReadyTq(int)}
|
||||||
* is called to make sure the device doesn't sleep before it has a chance to poke
|
* is called to make sure the device doesn't sleep before it has a chance to poke
|
||||||
* the wake lock.
|
* the wake lock.
|
||||||
* @see #wakeWhenReadyLocked(int)
|
* @see #wakeWhenReady(int)
|
||||||
*/
|
*/
|
||||||
private PowerManager.WakeLock mWakeAndHandOff;
|
private PowerManager.WakeLock mWakeAndHandOff;
|
||||||
|
|
||||||
@@ -935,8 +935,8 @@ public class KeyguardViewMediator {
|
|||||||
* @see #handleWakeWhenReady
|
* @see #handleWakeWhenReady
|
||||||
* @see #onWakeKeyWhenKeyguardShowingTq(int)
|
* @see #onWakeKeyWhenKeyguardShowingTq(int)
|
||||||
*/
|
*/
|
||||||
private void wakeWhenReadyLocked(int keyCode) {
|
private void wakeWhenReady(int keyCode) {
|
||||||
if (DBG_WAKE) Log.d(TAG, "wakeWhenReadyLocked(" + keyCode + ")");
|
if (DBG_WAKE) Log.d(TAG, "wakeWhenReady(" + keyCode + ")");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* acquire the handoff lock that will keep the cpu running. this will
|
* acquire the handoff lock that will keep the cpu running. this will
|
||||||
@@ -1014,54 +1014,14 @@ public class KeyguardViewMediator {
|
|||||||
* action should be posted to a handler.
|
* action should be posted to a handler.
|
||||||
*
|
*
|
||||||
* @param keyCode The keycode of the key that woke the device
|
* @param keyCode The keycode of the key that woke the device
|
||||||
* @param isDocked True if the device is in the dock
|
|
||||||
* @return Whether we poked the wake lock (and turned the screen on)
|
|
||||||
*/
|
*/
|
||||||
public boolean onWakeKeyWhenKeyguardShowingTq(int keyCode, boolean isDocked) {
|
public void onWakeKeyWhenKeyguardShowingTq(int keyCode) {
|
||||||
if (DEBUG) Log.d(TAG, "onWakeKeyWhenKeyguardShowing(" + keyCode + ")");
|
if (DEBUG) Log.d(TAG, "onWakeKeyWhenKeyguardShowing(" + keyCode + ")");
|
||||||
|
|
||||||
if (isWakeKeyWhenKeyguardShowing(keyCode, isDocked)) {
|
// give the keyguard view manager a chance to adjust the state of the
|
||||||
// give the keyguard view manager a chance to adjust the state of the
|
// keyguard based on the key that woke the device before poking
|
||||||
// keyguard based on the key that woke the device before poking
|
// the wake lock
|
||||||
// the wake lock
|
wakeWhenReady(keyCode);
|
||||||
wakeWhenReadyLocked(keyCode);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* When the keyguard is showing we ignore some keys that might otherwise typically
|
|
||||||
* be considered wake keys. We filter them out here.
|
|
||||||
*
|
|
||||||
* {@link KeyEvent#KEYCODE_POWER} is notably absent from this list because it
|
|
||||||
* is always considered a wake key.
|
|
||||||
*/
|
|
||||||
private boolean isWakeKeyWhenKeyguardShowing(int keyCode, boolean isDocked) {
|
|
||||||
switch (keyCode) {
|
|
||||||
// ignore volume keys unless docked
|
|
||||||
case KeyEvent.KEYCODE_VOLUME_UP:
|
|
||||||
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
|
||||||
case KeyEvent.KEYCODE_VOLUME_MUTE:
|
|
||||||
return isDocked;
|
|
||||||
|
|
||||||
// ignore media and camera keys
|
|
||||||
case KeyEvent.KEYCODE_MUTE:
|
|
||||||
case KeyEvent.KEYCODE_HEADSETHOOK:
|
|
||||||
case KeyEvent.KEYCODE_MEDIA_PLAY:
|
|
||||||
case KeyEvent.KEYCODE_MEDIA_PAUSE:
|
|
||||||
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
|
|
||||||
case KeyEvent.KEYCODE_MEDIA_STOP:
|
|
||||||
case KeyEvent.KEYCODE_MEDIA_NEXT:
|
|
||||||
case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
|
|
||||||
case KeyEvent.KEYCODE_MEDIA_REWIND:
|
|
||||||
case KeyEvent.KEYCODE_MEDIA_RECORD:
|
|
||||||
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
|
|
||||||
case KeyEvent.KEYCODE_CAMERA:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1073,17 +1033,14 @@ public class KeyguardViewMediator {
|
|||||||
* The 'Tq' suffix is per the documentation in {@link WindowManagerPolicy}.
|
* The 'Tq' suffix is per the documentation in {@link WindowManagerPolicy}.
|
||||||
* Be sure not to take any action that takes a long time; any significant
|
* Be sure not to take any action that takes a long time; any significant
|
||||||
* action should be posted to a handler.
|
* action should be posted to a handler.
|
||||||
*
|
|
||||||
* @return Whether we poked the wake lock (and turned the screen on)
|
|
||||||
*/
|
*/
|
||||||
public boolean onWakeMotionWhenKeyguardShowingTq() {
|
public void onWakeMotionWhenKeyguardShowingTq() {
|
||||||
if (DEBUG) Log.d(TAG, "onWakeMotionWhenKeyguardShowing()");
|
if (DEBUG) Log.d(TAG, "onWakeMotionWhenKeyguardShowing()");
|
||||||
|
|
||||||
// give the keyguard view manager a chance to adjust the state of the
|
// give the keyguard view manager a chance to adjust the state of the
|
||||||
// keyguard based on the key that woke the device before poking
|
// keyguard based on the key that woke the device before poking
|
||||||
// the wake lock
|
// the wake lock
|
||||||
wakeWhenReadyLocked(KeyEvent.KEYCODE_UNKNOWN);
|
wakeWhenReady(KeyEvent.KEYCODE_UNKNOWN);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void keyguardDone(boolean authenticated, boolean wakeup) {
|
public void keyguardDone(boolean authenticated, boolean wakeup) {
|
||||||
@@ -1350,7 +1307,7 @@ public class KeyguardViewMediator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle message sent by {@link #wakeWhenReadyLocked(int)}
|
* Handle message sent by {@link #wakeWhenReady(int)}
|
||||||
* @param keyCode The key that woke the device.
|
* @param keyCode The key that woke the device.
|
||||||
* @see #WAKE_WHEN_READY
|
* @see #WAKE_WHEN_READY
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user