IME support for trackball and generic motion events

Trackball and generic motion events now pass through the IME in case
it would like to handle them before passing them on to the view
hierarchy.

While I was at it, I also...
...fixed the documentation on InputMethodService.onKeyUp()
...added documentation to InputMethodService.onTrackballEvent()
...added trackball and generic motion events to the "input" command
...fixed input consistency verification involving ACTION_OUTSIDE

Bug: 7050005
Change-Id: I40ab68df4a9542af6df25de6ec2ec500e4c02902
diff --git a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
index ce797d1..5324f81 100644
--- a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
+++ b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
@@ -43,6 +43,7 @@
     private static final int DO_UPDATE_EXTRACTED_TEXT = 67;
     private static final int DO_DISPATCH_KEY_EVENT = 70;
     private static final int DO_DISPATCH_TRACKBALL_EVENT = 80;
+    private static final int DO_DISPATCH_GENERIC_MOTION_EVENT = 85;
     private static final int DO_UPDATE_SELECTION = 90;
     private static final int DO_UPDATE_CURSOR = 95;
     private static final int DO_APP_PRIVATE_COMMAND = 100;
@@ -109,6 +110,15 @@
                 args.recycle();
                 return;
             }
+            case DO_DISPATCH_GENERIC_MOTION_EVENT: {
+                SomeArgs args = (SomeArgs)msg.obj;
+                mInputMethodSession.dispatchGenericMotionEvent(msg.arg1,
+                        (MotionEvent)args.arg1,
+                        new InputMethodEventCallbackWrapper(
+                                (IInputMethodCallback)args.arg2));
+                args.recycle();
+                return;
+            }
             case DO_UPDATE_SELECTION: {
                 SomeArgs args = (SomeArgs)msg.obj;
                 mInputMethodSession.updateSelection(args.argi1, args.argi2,
@@ -167,6 +177,12 @@
                 event, callback));
     }
 
+    public void dispatchGenericMotionEvent(int seq, MotionEvent event,
+            IInputMethodCallback callback) {
+        mCaller.executeOrSendMessage(mCaller.obtainMessageIOO(DO_DISPATCH_GENERIC_MOTION_EVENT, seq,
+                event, callback));
+    }
+
     public void updateSelection(int oldSelStart, int oldSelEnd,
             int newSelStart, int newSelEnd, int candidatesStart, int candidatesEnd) {
         mCaller.executeOrSendMessage(mCaller.obtainMessageIIIIII(DO_UPDATE_SELECTION,