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

Commit 412427d7 authored by Ameer Armaly's avatar Ameer Armaly
Browse files

[RESTRICT AUTOMERGE] AccessibilityManagerService: remove uninstalled services...

[RESTRICT AUTOMERGE] AccessibilityManagerService: remove uninstalled services from enabled list after service update.

Bug: 326485767
Test: atest AccessibilityEndToEndTest#testUpdateServiceWithoutIntent_disablesService
Change-Id: I3b778e8f41ace30e09b93a39580993ef5ac52ace
parent f84dc1ff
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -1919,10 +1919,13 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
        boolean isUnlockingOrUnlocked = LocalServices.getService(UserManagerInternal.class)
                    .isUserUnlockingOrUnlocked(userState.mUserId);

        // Store the list of installed services.
        mTempComponentNameSet.clear();
        for (int i = 0, count = userState.mInstalledServices.size(); i < count; i++) {
            AccessibilityServiceInfo installedService = userState.mInstalledServices.get(i);
            ComponentName componentName = ComponentName.unflattenFromString(
                    installedService.getId());
            mTempComponentNameSet.add(componentName);

            AccessibilityServiceConnection service = componentNameToServiceMap.get(componentName);

@@ -1973,6 +1976,25 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
            audioManager.setAccessibilityServiceUids(mTempIntArray);
        }
        mActivityTaskManagerService.setAccessibilityServiceUids(mTempIntArray);
        // If any services have been removed, remove them from the enabled list and the touch
        // exploration granted list.
        boolean anyServiceRemoved =
                userState.mEnabledServices.removeIf((comp) -> !mTempComponentNameSet.contains(comp))
                        || userState.mTouchExplorationGrantedServices.removeIf(
                                (comp) -> !mTempComponentNameSet.contains(comp));
        if (anyServiceRemoved) {
            // Update the enabled services setting.
            persistComponentNamesToSettingLocked(
                    Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
                    userState.mEnabledServices,
                    userState.mUserId);
            // Update the touch exploration granted services setting.
            persistComponentNamesToSettingLocked(
                    Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
                    userState.mTouchExplorationGrantedServices,
                    userState.mUserId);
        }
        mTempComponentNameSet.clear();
        updateAccessibilityEnabledSettingLocked(userState);
    }