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

Commit 9f4bc55f authored by chaviw's avatar chaviw
Browse files

Change Instrumentation to call injectInputAfterTransactionApplied

Instrumentation.sendPointerSync currently calls direclty into
InputManager to inject input. Instead have it call
injectInputAfterTransactionApplied to ensure it waits for animations
to complete and input windows to get set.

Additionally, changed injectInputAfterTransactionApplied to call
InputManagerInternal instead of InputManager to prevent the calling pid
from changing. This ensures the permission check remains tied to the client
that injected the input.

Bug: 123616343
Bug: 120920331
Test: atest HoverTest
Change-Id: I8c893e47fea9bd38e92da0ffa668ebca066f1080
parent 5f9cad60
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.view.Window;
import android.view.WindowManagerGlobal;

import com.android.internal.content.ReferrerIntent;

@@ -1102,8 +1103,11 @@ public class Instrumentation {
        if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == 0) {
            event.setSource(InputDevice.SOURCE_TOUCHSCREEN);
        }
        InputManager.getInstance().injectInputEvent(event,
        try {
            WindowManagerGlobal.getWindowManagerService().injectInputAfterTransactionsApplied(event,
                    InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH);
        } catch (RemoteException e) {
        }
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -145,6 +145,7 @@ import android.hardware.configstore.V1_0.OptionalBool;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManagerInternal;
import android.hardware.input.InputManager;
import android.hardware.input.InputManagerInternal;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
@@ -7434,7 +7435,7 @@ public class WindowManagerService extends IWindowManager.Stub

        new SurfaceControl.Transaction().syncInputWindows().apply(true);

        return mInputManager.injectInputEvent(ev, mode);
        return LocalServices.getService(InputManagerInternal.class).injectInputEvent(ev, mode);
    }

    private void waitForAnimationsToComplete() {