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
This commit is contained in:
chaviw
2019-02-27 15:22:47 -08:00
parent 5f9cad60c8
commit 9f4bc55faf
2 changed files with 8 additions and 3 deletions

View File

@@ -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,
InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH);
try {
WindowManagerGlobal.getWindowManagerService().injectInputAfterTransactionsApplied(event,
InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH);
} catch (RemoteException e) {
}
}
/**

View File

@@ -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() {