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

Commit e8592c1b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Dispatch accessibility gesture if device supports touch" into sc-dev am: e418222e

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I2e3f0a4fcec13d144da0e9e66a7f827661164aa4
parents d59c4d54 e418222e
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -372,12 +372,11 @@ class AccessibilityServiceConnection extends AbstractAccessibilityServiceConnect


    @Override
    @Override
    public void dispatchGesture(int sequence, ParceledListSlice gestureSteps, int displayId) {
    public void dispatchGesture(int sequence, ParceledListSlice gestureSteps, int displayId) {
        final boolean isTouchableDisplay = mWindowManagerService.isTouchableDisplay(displayId);
        synchronized (mLock) {
        synchronized (mLock) {
            if (mSecurityPolicy.canPerformGestures(this)) {
            if (mSecurityPolicy.canPerformGestures(this)) {
                MotionEventInjector motionEventInjector =
                MotionEventInjector motionEventInjector =
                        mSystemSupport.getMotionEventInjectorForDisplayLocked(displayId);
                        mSystemSupport.getMotionEventInjectorForDisplayLocked(displayId);
                if (motionEventInjector != null && isTouchableDisplay) {
                if (mWindowManagerService.isTouchOrFaketouchDevice()) {
                    motionEventInjector.injectEvents(
                    motionEventInjector.injectEvents(
                            gestureSteps.getList(), mServiceInterface, sequence, displayId);
                            gestureSteps.getList(), mServiceInterface, sequence, displayId);
                } else {
                } else {
+2 −2
Original line number Original line Diff line number Diff line
@@ -611,9 +611,9 @@ public abstract class WindowManagerInternal {
    public abstract void removeNonHighRefreshRatePackage(@NonNull String packageName);
    public abstract void removeNonHighRefreshRatePackage(@NonNull String packageName);


    /**
    /**
     * Checks if this display is touchable.
     * Checks if the device supports touch or faketouch.
     */
     */
    public abstract boolean isTouchableDisplay(int displayId);
    public abstract boolean isTouchOrFaketouchDevice();


    /**
    /**
     * Returns the info associated with the input token used to determine if a key should be
     * Returns the info associated with the input token used to determine if a key should be
+6 −6
Original line number Original line Diff line number Diff line
@@ -750,6 +750,7 @@ public class WindowManagerService extends IWindowManager.Stub
    final TaskSnapshotController mTaskSnapshotController;
    final TaskSnapshotController mTaskSnapshotController;


    boolean mIsTouchDevice;
    boolean mIsTouchDevice;
    boolean mIsFakeTouchDevice;


    final H mH = new H();
    final H mH = new H();


@@ -4960,6 +4961,8 @@ public class WindowManagerService extends IWindowManager.Stub
            mRoot.forAllDisplays(DisplayContent::reconfigureDisplayLocked);
            mRoot.forAllDisplays(DisplayContent::reconfigureDisplayLocked);
            mIsTouchDevice = mContext.getPackageManager().hasSystemFeature(
            mIsTouchDevice = mContext.getPackageManager().hasSystemFeature(
                    PackageManager.FEATURE_TOUCHSCREEN);
                    PackageManager.FEATURE_TOUCHSCREEN);
            mIsFakeTouchDevice = mContext.getPackageManager().hasSystemFeature(
                    PackageManager.FEATURE_FAKETOUCH);
        }
        }


        try {
        try {
@@ -7956,13 +7959,10 @@ public class WindowManagerService extends IWindowManager.Stub
        }
        }


        @Override
        @Override
        public boolean isTouchableDisplay(int displayId) {
        public boolean isTouchOrFaketouchDevice() {
            synchronized (mGlobalLock) {
            synchronized (mGlobalLock) {
                final DisplayContent displayContent = mRoot.getDisplayContent(displayId);
                // All touchable devices are also faketouchable.
                final Configuration configuration =
                return mIsFakeTouchDevice;
                        displayContent != null ? displayContent.getConfiguration() : null;
                return configuration != null
                        && configuration.touchscreen == Configuration.TOUCHSCREEN_FINGER;
            }
            }
        }
        }


+4 −6
Original line number Original line Diff line number Diff line
@@ -110,8 +110,6 @@ public class AccessibilityServiceConnectionTest {
        mMockResolveInfo.serviceInfo.applicationInfo = mock(ApplicationInfo.class);
        mMockResolveInfo.serviceInfo.applicationInfo = mock(ApplicationInfo.class);


        when(mMockIBinder.queryLocalInterface(any())).thenReturn(mMockServiceClient);
        when(mMockIBinder.queryLocalInterface(any())).thenReturn(mMockServiceClient);
        when(mMockWindowManagerInternal.isTouchableDisplay(Display.DEFAULT_DISPLAY)).thenReturn(
                true);


        mConnection = new AccessibilityServiceConnection(mMockUserState, mMockContext,
        mConnection = new AccessibilityServiceConnection(mMockUserState, mMockContext,
                COMPONENT_NAME, mMockServiceInfo, SERVICE_ID, mHandler, new Object(),
                COMPONENT_NAME, mMockServiceInfo, SERVICE_ID, mHandler, new Object(),
@@ -197,8 +195,9 @@ public class AccessibilityServiceConnectionTest {
    }
    }


    @Test
    @Test
    public void sendGesture_touchableDisplay_injectEvents()
    public void sendGesture_touchableDevice_injectEvents()
            throws RemoteException {
            throws RemoteException {
        when(mMockWindowManagerInternal.isTouchOrFaketouchDevice()).thenReturn(true);
        setServiceBinding(COMPONENT_NAME);
        setServiceBinding(COMPONENT_NAME);
        mConnection.bindLocked();
        mConnection.bindLocked();
        mConnection.onServiceConnected(COMPONENT_NAME, mMockIBinder);
        mConnection.onServiceConnected(COMPONENT_NAME, mMockIBinder);
@@ -213,10 +212,9 @@ public class AccessibilityServiceConnectionTest {
    }
    }


    @Test
    @Test
    public void sendGesture_untouchableDisplay_performGestureResultFailed()
    public void sendGesture_untouchableDevice_performGestureResultFailed()
            throws RemoteException {
            throws RemoteException {
        when(mMockWindowManagerInternal.isTouchableDisplay(Display.DEFAULT_DISPLAY)).thenReturn(
        when(mMockWindowManagerInternal.isTouchOrFaketouchDevice()).thenReturn(false);
                false);
        setServiceBinding(COMPONENT_NAME);
        setServiceBinding(COMPONENT_NAME);
        mConnection.bindLocked();
        mConnection.bindLocked();
        mConnection.onServiceConnected(COMPONENT_NAME, mMockIBinder);
        mConnection.onServiceConnected(COMPONENT_NAME, mMockIBinder);