Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a4717679 authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Wait for input windows to be set before proceeding with inject for tests"

parents 0b90bd77 504715c5
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -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);
        }
+9 −0
Original line number Diff line number Diff line
@@ -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);
}
+13 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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);
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -85,6 +85,12 @@ class WindowSurfacePlacer {
        return mDeferDepth > 0;
    }

    void performSurfacePlacementIfScheduled() {
        if (mTraversalScheduled) {
            performSurfacePlacement();
        }
    }

    final void performSurfacePlacement() {
        performSurfacePlacement(false /* force */);
    }