Merge "Sync input transactions after ACTION_UP" into qt-dev-plus-aosp

This commit is contained in:
TreeHugger Robot
2019-06-18 21:44:32 +00:00
committed by Android (Google) Code Review

View File

@@ -7626,22 +7626,30 @@ public class WindowManagerService extends IWindowManager.Stub
@Override @Override
public boolean injectInputAfterTransactionsApplied(InputEvent ev, int mode) { public boolean injectInputAfterTransactionsApplied(InputEvent ev, int mode) {
boolean shouldWaitForAnimToComplete = false; boolean isDown;
boolean isUp;
if (ev instanceof KeyEvent) { if (ev instanceof KeyEvent) {
KeyEvent keyEvent = (KeyEvent) ev; KeyEvent keyEvent = (KeyEvent) ev;
shouldWaitForAnimToComplete = keyEvent.getSource() == InputDevice.SOURCE_MOUSE isDown = keyEvent.getAction() == KeyEvent.ACTION_DOWN;
|| keyEvent.getAction() == KeyEvent.ACTION_DOWN; isUp = keyEvent.getAction() == KeyEvent.ACTION_UP;
} else if (ev instanceof MotionEvent) { } else {
MotionEvent motionEvent = (MotionEvent) ev; MotionEvent motionEvent = (MotionEvent) ev;
shouldWaitForAnimToComplete = motionEvent.getSource() == InputDevice.SOURCE_MOUSE isDown = motionEvent.getAction() == MotionEvent.ACTION_DOWN;
|| motionEvent.getAction() == MotionEvent.ACTION_DOWN; isUp = motionEvent.getAction() == MotionEvent.ACTION_UP;
} }
if (shouldWaitForAnimToComplete) { // For ACTION_DOWN, syncInputTransactions before injecting input.
// For ACTION_UP, sync after injecting.
if (isDown) {
syncInputTransactions(); syncInputTransactions();
} }
final boolean result =
return LocalServices.getService(InputManagerInternal.class).injectInputEvent(ev, mode); LocalServices.getService(InputManagerInternal.class).injectInputEvent(ev, mode);
if (isUp) {
syncInputTransactions();
}
return result;
} }
@Override @Override