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

Commit 37fedf8b authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Disable accessibility if all accessibility serivces are disbaled.

Accessibility was kept enabled even if all accessibility services
are disabled (explicitly by the user or removed) which was causing
the system to fire accessibility events that will never be consumed.

Change-Id: Ifb03e786ac0106687252bd1979725ffd724ad1c5
parent cb18db8e
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -697,6 +697,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
    private void manageServicesLocked() {
        populateEnabledServicesLocked(mEnabledServices);
        updateServicesStateLocked(mInstalledServices, mEnabledServices);
        disableAccessibilityIfNoEnabledServices(mEnabledServices);
    }

    /**
@@ -780,6 +781,19 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
        }
    }

    /**
     * Disables accessibility if there are no enabled accessibility services which
     * to consume the generated accessibility events.
     *
     * @param enabledServices The set of enabled services.
     */
    private void disableAccessibilityIfNoEnabledServices(Set<ComponentName> enabledServices) {
        if (enabledServices.isEmpty()) {
            Settings.Secure.putInt(mContext.getContentResolver(),
                    Settings.Secure.ACCESSIBILITY_ENABLED, 0);
        }
    }

    /**
     * Sends the state to the clients.
     */