diff options
| author | 2019-03-12 14:06:35 -0700 | |
|---|---|---|
| committer | 2019-03-14 11:01:54 -0700 | |
| commit | 9d29030c0704f423f868aa6690243c7b60894555 (patch) | |
| tree | db678e4410b4247348ba4519c9f126de644286f3 | |
| parent | c7f498fe0bceca283c384ac303422fd8e9d0eccf (diff) | |
Only wait for animations to complete when injecting a DOWN event.
When running quick step launcher tests, the tests attempt to inject
input to start the recents animation. However, because the launcher is
animating, the inject input will wait until the animation is complete.
This causes very slow input injection when attempting to go to recents
with quick step.
Since most cases will inject DOWN before any other event, it's mostly
safe to only wait for animations to complete before the first injection.
This is because the windows will most likely be correctly set up by then
and all other injections can proceed normally.
The code makes an exception for events that are from SOURCE_MOUSE since
we do want to wait for an animation to complete when dragging around a
mouse pointer since focus change could affect behavior.
Fixes: 128333900
Bug: 128446223
Test: TaplTestsQuickstep#testBackground,testSwitchToOverview
Change-Id: I153130282a7cc824d260541b98b57c04e5f90f4f
| -rw-r--r-- | services/core/java/com/android/server/wm/WindowManagerService.java | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index e3a8be5d52d4..f9f734fd9b6e 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -7447,13 +7447,26 @@ public class WindowManagerService extends IWindowManager.Stub @Override public boolean injectInputAfterTransactionsApplied(InputEvent ev, int mode) { - waitForAnimationsToComplete(); - - synchronized (mGlobalLock) { - mWindowPlacerLocked.performSurfacePlacementIfScheduled(); + boolean shouldWaitForAnimComplete = false; + if (ev instanceof KeyEvent) { + KeyEvent keyEvent = (KeyEvent) ev; + shouldWaitForAnimComplete = keyEvent.getSource() == InputDevice.SOURCE_MOUSE + || keyEvent.getAction() == KeyEvent.ACTION_DOWN; + } else if (ev instanceof MotionEvent) { + MotionEvent motionEvent = (MotionEvent) ev; + shouldWaitForAnimComplete = motionEvent.getSource() == InputDevice.SOURCE_MOUSE + || motionEvent.getAction() == MotionEvent.ACTION_DOWN; } - new SurfaceControl.Transaction().syncInputWindows().apply(true); + if (shouldWaitForAnimComplete) { + waitForAnimationsToComplete(); + + synchronized (mGlobalLock) { + mWindowPlacerLocked.performSurfacePlacementIfScheduled(); + } + + new SurfaceControl.Transaction().syncInputWindows().apply(true); + } return LocalServices.getService(InputManagerInternal.class).injectInputEvent(ev, mode); } |