diff options
| author | 2018-11-30 16:04:01 -0800 | |
|---|---|---|
| committer | 2018-11-30 16:04:01 -0800 | |
| commit | 1afc65d2fd8c74536aca5b64d67116c855932b42 (patch) | |
| tree | 5852d219091de29f1f7af61e47ff8d4572707e3a | |
| parent | ff2e7d8f41d75c5437f1fac199a280e650eb79ae (diff) | |
Fix ActivityView input forwarding.
The current behavior for input expects the input to be in screen space.
However, ActivityView was forwarding input in View space so it was
causing the touch to be in the wrong place.
This fix updates the touch event so it's translated into screen space
before forwarding to the InputManager.
Test: ActivityView touches
Change-Id: I8b86a17adb166fdd95f24610f2ba9ae55c39f7c5
Fixes: 111440225
| -rw-r--r-- | core/java/android/app/ActivityView.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/core/java/android/app/ActivityView.java b/core/java/android/app/ActivityView.java index 446d98e97936..2c435a27cbce 100644 --- a/core/java/android/app/ActivityView.java +++ b/core/java/android/app/ActivityView.java @@ -31,7 +31,6 @@ import android.util.DisplayMetrics; import android.util.Log; import android.view.IWindowManager; import android.view.InputDevice; -import android.view.InputEvent; import android.view.MotionEvent; import android.view.Surface; import android.view.SurfaceControl; @@ -291,9 +290,14 @@ public class ActivityView extends ViewGroup { return super.onGenericMotionEvent(event); } - private boolean injectInputEvent(InputEvent event) { + private boolean injectInputEvent(MotionEvent event) { if (mInputForwarder != null) { try { + // The touch event that the ActivityView gets is in View space, but the event needs + // to get forwarded in screen space. This offsets the touch event by the location + // the ActivityView is on screen and sends it to the input forwarder. + getLocationOnScreen(mLocationOnScreen); + event.offsetLocation(mLocationOnScreen[0], mLocationOnScreen[1]); return mInputForwarder.forwardEvent(event); } catch (RemoteException e) { e.rethrowAsRuntimeException(); |