Loading core/java/android/app/UiAutomationConnection.java +7 −1 Original line number Diff line number Diff line Loading @@ -128,7 +128,13 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub { : InputManager.INJECT_INPUT_EVENT_MODE_ASYNC; final long identity = Binder.clearCallingIdentity(); try { return InputManager.getInstance().injectInputEvent(event, mode); IWindowManager manager = IWindowManager.Stub.asInterface( ServiceManager.getService(Context.WINDOW_SERVICE)); try { return manager.injectInputAfterTransactionsApplied(event, mode); } catch (RemoteException e) { } return false; } finally { Binder.restoreCallingIdentity(identity); } Loading core/java/android/view/IWindowManager.aidl +9 −0 Original line number Diff line number Diff line Loading @@ -582,4 +582,13 @@ interface IWindowManager * display should be re-parented to. */ void reparentDisplayContent(int displayId, in SurfaceControl sc); /** * Waits for transactions to get applied before injecting input. * This includes waiting for the input windows to get sent to InputManager. * * This is needed for testing since the system add windows and injects input * quick enough that the windows don't have time to get sent to InputManager. */ boolean injectInputAfterTransactionsApplied(in InputEvent ev, int mode); } services/core/java/com/android/server/wm/WindowManagerService.java +13 −0 Original line number Diff line number Diff line Loading @@ -209,6 +209,7 @@ import android.view.IWindowSession; import android.view.IWindowSessionCallback; import android.view.InputChannel; import android.view.InputDevice; import android.view.InputEvent; import android.view.InputEventReceiver; import android.view.InsetsState; import android.view.KeyEvent; Loading Loading @@ -7419,4 +7420,16 @@ public class WindowManagerService extends IWindowManager.Stub } } } @Override public boolean injectInputAfterTransactionsApplied(InputEvent ev, int mode) { synchronized (mGlobalLock) { mWindowPlacerLocked.performSurfacePlacementIfScheduled(); new SurfaceControl.Transaction() .syncInputWindows() .apply(true); } return mInputManager.injectInputEvent(ev, mode); } } services/core/java/com/android/server/wm/WindowSurfacePlacer.java +6 −0 Original line number Diff line number Diff line Loading @@ -85,6 +85,12 @@ class WindowSurfacePlacer { return mDeferDepth > 0; } void performSurfacePlacementIfScheduled() { if (mTraversalScheduled) { performSurfacePlacement(); } } final void performSurfacePlacement() { performSurfacePlacement(false /* force */); } Loading Loading
core/java/android/app/UiAutomationConnection.java +7 −1 Original line number Diff line number Diff line Loading @@ -128,7 +128,13 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub { : InputManager.INJECT_INPUT_EVENT_MODE_ASYNC; final long identity = Binder.clearCallingIdentity(); try { return InputManager.getInstance().injectInputEvent(event, mode); IWindowManager manager = IWindowManager.Stub.asInterface( ServiceManager.getService(Context.WINDOW_SERVICE)); try { return manager.injectInputAfterTransactionsApplied(event, mode); } catch (RemoteException e) { } return false; } finally { Binder.restoreCallingIdentity(identity); } Loading
core/java/android/view/IWindowManager.aidl +9 −0 Original line number Diff line number Diff line Loading @@ -582,4 +582,13 @@ interface IWindowManager * display should be re-parented to. */ void reparentDisplayContent(int displayId, in SurfaceControl sc); /** * Waits for transactions to get applied before injecting input. * This includes waiting for the input windows to get sent to InputManager. * * This is needed for testing since the system add windows and injects input * quick enough that the windows don't have time to get sent to InputManager. */ boolean injectInputAfterTransactionsApplied(in InputEvent ev, int mode); }
services/core/java/com/android/server/wm/WindowManagerService.java +13 −0 Original line number Diff line number Diff line Loading @@ -209,6 +209,7 @@ import android.view.IWindowSession; import android.view.IWindowSessionCallback; import android.view.InputChannel; import android.view.InputDevice; import android.view.InputEvent; import android.view.InputEventReceiver; import android.view.InsetsState; import android.view.KeyEvent; Loading Loading @@ -7419,4 +7420,16 @@ public class WindowManagerService extends IWindowManager.Stub } } } @Override public boolean injectInputAfterTransactionsApplied(InputEvent ev, int mode) { synchronized (mGlobalLock) { mWindowPlacerLocked.performSurfacePlacementIfScheduled(); new SurfaceControl.Transaction() .syncInputWindows() .apply(true); } return mInputManager.injectInputEvent(ev, mode); } }
services/core/java/com/android/server/wm/WindowSurfacePlacer.java +6 −0 Original line number Diff line number Diff line Loading @@ -85,6 +85,12 @@ class WindowSurfacePlacer { return mDeferDepth > 0; } void performSurfacePlacementIfScheduled() { if (mTraversalScheduled) { performSurfacePlacement(); } } final void performSurfacePlacement() { performSurfacePlacement(false /* force */); } Loading