Use META_LEFT to launch the ASSIST behavior.
Also, claim any key combo'd with META_LEFT for the system.
Change-Id: I29892e31ed40f04d1dd3cf173551237ffb3702ca
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index b883c5f6..03d29c0 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -446,6 +446,7 @@
boolean mSearchKeyShortcutPending;
boolean mConsumeSearchKeyUp;
boolean mAssistKeyLongPressed;
+ boolean mPendingMetaAction;
// support for activating the lock screen while the screen is on
boolean mAllowLockscreenWhenOn;
@@ -2088,6 +2089,12 @@
}
}
+ // Cancel any pending meta actions if we see any other keys being pressed between the down
+ // of the meta key and its corresponding up.
+ if (mPendingMetaAction && keyCode != KeyEvent.KEYCODE_META_LEFT) {
+ mPendingMetaAction = false;
+ }
+
// First we always handle the home key here, so applications
// can never break it, although if keyguard is on, we do let
// it handle it, because that gives us the correct 5 second
@@ -2282,6 +2289,14 @@
mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT_OR_SELF);
}
return -1;
+ } else if (keyCode == KeyEvent.KEYCODE_META_LEFT) {
+ if (down) {
+ mPendingMetaAction = true;
+ } else if (mPendingMetaAction) {
+ mPendingMetaAction = false;
+ launchAssistAction();
+ }
+ return -1;
}
// Shortcuts are invoked through Search+key, so intercept those here
@@ -2391,6 +2406,11 @@
return -1;
}
+ // Reserve all the META modifier combos for system behavior
+ if ((metaState & KeyEvent.META_META_LEFT_ON) != 0) {
+ return -1;
+ }
+
// Let the application handle the key.
return 0;
}