Ensure the ShortcutManager uses the correct key character map.

The ShortcutManager used to only receive the key code of the key event
that triggered the shortcut.  This change now provides the shortcut
manager with the whole key event so it can look up the associated
character using the correct key character map.

To make this more efficient, added a mechanism for recycling
key events.  At the moment it is only used by key events owned by the
system process, since clients of the existing API (such as Views)
might continue to hold on to key events after dispatch has finished so
they would break if the key event were recycled by the framework.

Deprecated KeyCharacterMap.BUILT_IN_KEYBOARD.

Change-Id: I4313725dd63f2be01c350c005a41c7fde9bc67e8
diff --git a/services/java/com/android/server/InputManager.java b/services/java/com/android/server/InputManager.java
index 30b49d3..9078811 100644
--- a/services/java/com/android/server/InputManager.java
+++ b/services/java/com/android/server/InputManager.java
@@ -30,6 +30,7 @@
 import android.view.InputChannel;
 import android.view.InputDevice;
 import android.view.InputEvent;
+import android.view.KeyEvent;
 import android.view.Surface;
 
 import java.io.BufferedReader;
@@ -398,26 +399,23 @@
         }
         
         @SuppressWarnings("unused")
-        public int interceptKeyBeforeQueueing(long whenNanos, int action, int flags,
-                int keyCode, int scanCode, int policyFlags, boolean isScreenOn) {
+        public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn) {
             return mWindowManagerService.mInputMonitor.interceptKeyBeforeQueueing(
-                    whenNanos, action, flags, keyCode, scanCode, policyFlags, isScreenOn);
+                    event, policyFlags, isScreenOn);
         }
         
         @SuppressWarnings("unused")
-        public boolean interceptKeyBeforeDispatching(InputChannel focus, int action,
-                int flags, int keyCode, int scanCode, int metaState, int repeatCount,
-                int policyFlags) {
-            return mWindowManagerService.mInputMonitor.interceptKeyBeforeDispatching(focus,
-                    action, flags, keyCode, scanCode, metaState, repeatCount, policyFlags);
+        public boolean interceptKeyBeforeDispatching(InputChannel focus,
+                KeyEvent event, int policyFlags) {
+            return mWindowManagerService.mInputMonitor.interceptKeyBeforeDispatching(
+                    focus, event, policyFlags);
         }
         
         @SuppressWarnings("unused")
-        public boolean dispatchUnhandledKey(InputChannel focus, int action,
-                int flags, int keyCode, int scanCode, int metaState, int repeatCount,
-                int policyFlags) {
-            return mWindowManagerService.mInputMonitor.dispatchUnhandledKey(focus,
-                    action, flags, keyCode, scanCode, metaState, repeatCount, policyFlags);
+        public boolean dispatchUnhandledKey(InputChannel focus,
+                KeyEvent event, int policyFlags) {
+            return mWindowManagerService.mInputMonitor.dispatchUnhandledKey(
+                    focus, event, policyFlags);
         }
         
         @SuppressWarnings("unused")