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

Commit a3e0c532 authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Automerger Merge Worker
Browse files

Merge "Remove injectInputAfterTransactionsApplied from WMS" into tm-dev am:...

Merge "Remove injectInputAfterTransactionsApplied from WMS" into tm-dev am: baf0f207 am: 77693b6c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17506923



Change-Id: I35f0db89e49c79f122d2211f0dec140ca2e3bd5c
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 4a5272e3 77693b6c
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -1154,11 +1154,30 @@ public class Instrumentation {
        if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == 0) {
            event.setSource(InputDevice.SOURCE_TOUCHSCREEN);
        }

        syncInputTransactionsAndInjectEvent(event);
    }

    private void syncInputTransactionsAndInjectEvent(MotionEvent event) {
        final boolean syncBefore = event.getAction() == MotionEvent.ACTION_DOWN
                || event.isFromSource(InputDevice.SOURCE_MOUSE);
        final boolean syncAfter = event.getAction() == MotionEvent.ACTION_UP;

        try {
            WindowManagerGlobal.getWindowManagerService().injectInputAfterTransactionsApplied(event,
                    InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH,
                    true /* waitForAnimations */);
            if (syncBefore) {
                WindowManagerGlobal.getWindowManagerService()
                        .syncInputTransactions(true /*waitForAnimations*/);
            }

            InputManager.getInstance().injectInputEvent(
                    event, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT);

            if (syncAfter) {
                WindowManagerGlobal.getWindowManagerService()
                        .syncInputTransactions(true /*waitForAnimations*/);
            }
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }

+30 −4
Original line number Diff line number Diff line
@@ -36,7 +36,10 @@ import android.os.UserHandle;
import android.permission.IPermissionManager;
import android.util.Log;
import android.view.IWindowManager;
import android.view.InputDevice;
import android.view.InputEvent;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.SurfaceControl;
import android.view.WindowAnimationFrameStats;
import android.view.WindowContentFrameStats;
@@ -132,13 +135,36 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
            throwIfShutdownLocked();
            throwIfNotConnectedLocked();
        }
        final int mode = (sync) ? InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH
                : InputManager.INJECT_INPUT_EVENT_MODE_ASYNC;

        final boolean syncTransactionsBefore;
        final boolean syncTransactionsAfter;
        if (event instanceof KeyEvent) {
            KeyEvent keyEvent = (KeyEvent) event;
            syncTransactionsBefore = keyEvent.getAction() == KeyEvent.ACTION_DOWN;
            syncTransactionsAfter = keyEvent.getAction() == KeyEvent.ACTION_UP;
        } else {
            MotionEvent motionEvent = (MotionEvent) event;
            syncTransactionsBefore = motionEvent.getAction() == MotionEvent.ACTION_DOWN
                    || motionEvent.isFromSource(InputDevice.SOURCE_MOUSE);
            syncTransactionsAfter = motionEvent.getAction() == MotionEvent.ACTION_UP;
        }

        final long identity = Binder.clearCallingIdentity();
        try {
            return mWindowManager.injectInputAfterTransactionsApplied(event, mode,
                    waitForAnimations);
            if (syncTransactionsBefore) {
                mWindowManager.syncInputTransactions(waitForAnimations);
            }

            final boolean result = InputManager.getInstance().injectInputEvent(event,
                    sync ? InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH
                            : InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);

            if (syncTransactionsAfter) {
                mWindowManager.syncInputTransactions(waitForAnimations);
            }
            return result;
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
+0 −9
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.graphics.PointF;
import android.hardware.display.DisplayViewport;
import android.os.IBinder;
import android.view.InputChannel;
import android.view.InputEvent;

import java.util.List;

@@ -31,14 +30,6 @@ import java.util.List;
 * @hide Only for use within the system server.
 */
public abstract class InputManagerInternal {
    /**
     * Inject an input event.
     *
     * @param event The InputEvent to inject
     * @param mode Synchronous or asynchronous mode
     * @return True if injection has succeeded
     */
    public abstract boolean injectInputEvent(InputEvent event, int mode);

    /**
     * Called by the display manager to set information about the displays as needed
+0 −11
Original line number Diff line number Diff line
@@ -676,17 +676,6 @@ interface IWindowManager
     */
    void setDisplayImePolicy(int displayId, int imePolicy);

    /**
     * Waits for transactions to get applied before injecting input, optionally waiting for
     * animations to complete. 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,
            boolean waitForAnimations);

    /**
     * Waits until input information has been sent from WindowManager to native InputManager,
     * optionally waiting for animations to complete.
+0 −9
Original line number Diff line number Diff line
@@ -898,10 +898,6 @@ public class InputManagerService extends IInputManager.Stub

    @Override // Binder call
    public boolean injectInputEvent(InputEvent event, int mode) {
        return injectInputEventInternal(event, mode);
    }

    private boolean injectInputEventInternal(InputEvent event, int mode) {
        Objects.requireNonNull(event, "event must not be null");
        if (mode != InputEventInjectionSync.NONE
                && mode != InputEventInjectionSync.WAIT_FOR_FINISHED
@@ -3663,11 +3659,6 @@ public class InputManagerService extends IInputManager.Stub
            setDisplayViewportsInternal(viewports);
        }

        @Override
        public boolean injectInputEvent(InputEvent event, int mode) {
            return injectInputEventInternal(event, mode);
        }

        @Override
        public void setInteractive(boolean interactive) {
            nativeSetInteractive(mPtr, interactive);
Loading