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

Commit fcac9b6f authored by Ameer Armaly's avatar Ameer Armaly Committed by Android Build Coastguard Worker
Browse files

AccessibilityManagerService: remove uninstalled services from enabled list after service update.

Bug: 326485767
Test: atest AccessibilityEndToEndTest#testUpdateServiceWithoutIntent_disablesService
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:74ab528e54558b5a78a9b0f32a2e3f0a61714ae5)
Merged-In: I2d986dc8f09a3cf2f31713237e69e15dcef84514
Change-Id: I2d986dc8f09a3cf2f31713237e69e15dcef84514
parent db6705d5
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -2647,10 +2647,13 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
                userState.mComponentNameToServiceMap;
        boolean isUnlockingOrUnlocked = mUmi.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);

@@ -2710,6 +2713,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);
        }
        updateAccessibilityEnabledSettingLocked(userState);
    }