diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java index dda5569a26b31..4f94209466804 100644 --- a/core/java/android/app/Instrumentation.java +++ b/core/java/android/app/Instrumentation.java @@ -52,6 +52,7 @@ import android.view.KeyEvent; import android.view.MotionEvent; import android.view.ViewConfiguration; import android.view.Window; +import android.view.WindowManagerGlobal; import com.android.internal.content.ReferrerIntent; @@ -1102,8 +1103,11 @@ public class Instrumentation { if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == 0) { event.setSource(InputDevice.SOURCE_TOUCHSCREEN); } - InputManager.getInstance().injectInputEvent(event, - InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH); + try { + WindowManagerGlobal.getWindowManagerService().injectInputAfterTransactionsApplied(event, + InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH); + } catch (RemoteException e) { + } } /** diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 474a9dabf9c4a..0f01ee1426e92 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -145,6 +145,7 @@ import android.hardware.configstore.V1_0.OptionalBool; import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManagerInternal; import android.hardware.input.InputManager; +import android.hardware.input.InputManagerInternal; import android.net.Uri; import android.os.Binder; import android.os.Build; @@ -7434,7 +7435,7 @@ public class WindowManagerService extends IWindowManager.Stub new SurfaceControl.Transaction().syncInputWindows().apply(true); - return mInputManager.injectInputEvent(ev, mode); + return LocalServices.getService(InputManagerInternal.class).injectInputEvent(ev, mode); } private void waitForAnimationsToComplete() {