OSDN Git Service

Exposing MotionEvent.addBatch method to be used in Launcher
authorSunny Goyal <sunnygoyal@google.com>
Wed, 20 Feb 2019 18:44:51 +0000 (10:44 -0800)
committerSunny Goyal <sunnygoyal@google.com>
Wed, 20 Feb 2019 19:47:54 +0000 (11:47 -0800)
Test: Verified library in Launcher
Change-Id: Idd58082d75310a15ed2196917f1a9e9e42f82d45

packages/SystemUI/shared/src/com/android/systemui/shared/system/InputChannelCompat.java

index 804f4f1..6567b6a 100644 (file)
@@ -24,6 +24,7 @@ import android.view.Choreographer;
 import android.view.InputChannel;
 import android.view.InputEvent;
 import android.view.InputEventSender;
+import android.view.MotionEvent;
 
 /**
  * @see android.view.InputChannel
@@ -64,6 +65,19 @@ public class InputChannelCompat {
     }
 
     /**
+     * Version of addBatch method which preserves time accuracy in nanoseconds instead of
+     * converting the time to milliseconds.
+     * @param src old MotionEvent where the target should be appended
+     * @param target new MotionEvent which should be added to the src
+     * @return true if the merge was successful
+     *
+     * @see MotionEvent#addBatch(MotionEvent)
+     */
+    public static boolean mergeMotionEvent(MotionEvent src, MotionEvent target) {
+        return target.addBatch(src);
+    }
+
+    /**
      * @see BatchedInputEventReceiver
      */
     public static class InputEventReceiver {