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

Commit a43ef3d1 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Gestures don't work when turning on Explore by Touch pragmatically.

1. There was a misspelled duplicate member in the accessibility service
   class which was causing inconsistent behavior because one field was
   updated and another checked.

2. When the set of services that can put the device in explore by touch
   mode changes we were disconnecting and reconnecting all services
   and this is not correct. Now only the state of explore by touch is
   updated appropriately.

bug:6798860

Change-Id: Ib3c119cef8e71c3458d56e4ce6fbde2c2f750dcd
parent d59bf649
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -358,8 +358,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
                        // We will update when the automation service dies.
                        if (mUiAutomationService == null) {
                            populateTouchExplorationGrantedAccessibilityServicesLocked();
                            unbindAllServicesLocked();
                            manageServicesLocked();
                            handleTouchExplorationGrantedAccessibilityServicesChangedLocked();
                        }
                    }
                }
@@ -624,7 +623,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
        //       enabled accessibility services.
        for (int i = mServices.size() - 1; i >= 0; i--) {
            Service service = mServices.get(i);
            if (service.mReqeustTouchExplorationMode && service.mIsDefault == isDefault) {
            if (service.mRequestTouchExplorationMode && service.mIsDefault == isDefault) {
                service.notifyGesture(gestureId);
                return true;
            }
@@ -1000,6 +999,22 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
                Settings.Secure.TOUCH_EXPLORATION_ENABLED, 0) == 1;
    }

    private void handleTouchExplorationGrantedAccessibilityServicesChangedLocked() {
        final int serviceCount = mServices.size();
        for (int i = 0; i < serviceCount; i++) {
            Service service = mServices.get(i);
            if (service.mRequestTouchExplorationMode
                    && mTouchExplorationGrantedServices.contains(service.mComponentName)) {
                tryEnableTouchExplorationLocked(service);
                return;
            }
        }
        if (mIsTouchExplorationEnabled) {
            mMainHandler.obtainMessage(MSG_TOGGLE_TOUCH_EXPLORATION, 0,
                    0).sendToTarget();
        }
    }

    private void tryEnableTouchExplorationLocked(final Service service) {
        if (!mIsTouchExplorationEnabled && service.mRequestTouchExplorationMode) {
            final boolean canToggleTouchExploration = mTouchExplorationGrantedServices.contains(
@@ -1163,8 +1178,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {

        boolean mCanRetrieveScreenContent;

        boolean mReqeustTouchExplorationMode;

        boolean mIsAutomation;

        final Rect mTempBounds = new Rect();
@@ -1204,7 +1217,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
            mIsAutomation = isAutomation;
            if (!isAutomation) {
                mCanRetrieveScreenContent = accessibilityServiceInfo.getCanRetrieveWindowContent();
                mReqeustTouchExplorationMode =
                mRequestTouchExplorationMode =
                    (accessibilityServiceInfo.flags
                            & AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE) != 0;
                mIntent = new Intent().setComponent(mComponentName);