RESTRICT AUTOMERGE Disable all A11yServices from an uninstalled package.

Previous logic would exit the loop after removing the first service
matching the uninstalled package.

Bug: 243378132
Test: atest AccessibilityEndToEndTest
Test: m sts;
      sts-tradefed run sts-dynamic-develop -m \
        CtsAccessibilityServiceTestCases
Change-Id: I4ba30345d8600674ee8a9ea3ff411aecbf3655a3
This commit is contained in:
Daniel Norman
2022-10-05 16:28:20 -07:00
parent 459808b2c0
commit 3796629985

View File

@@ -427,25 +427,27 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
} }
UserState userState = getUserStateLocked(userId); UserState userState = getUserStateLocked(userId);
Iterator<ComponentName> it = userState.mEnabledServices.iterator(); Iterator<ComponentName> it = userState.mEnabledServices.iterator();
boolean anyServiceRemoved = false;
while (it.hasNext()) { while (it.hasNext()) {
ComponentName comp = it.next(); ComponentName comp = it.next();
String compPkg = comp.getPackageName(); String compPkg = comp.getPackageName();
if (compPkg.equals(packageName)) { if (compPkg.equals(packageName)) {
it.remove(); it.remove();
userState.mBindingServices.remove(comp); userState.mBindingServices.remove(comp);
userState.mTouchExplorationGrantedServices.remove(comp);
anyServiceRemoved = true;
}
}
if (anyServiceRemoved) {
// Update the enabled services setting. // Update the enabled services setting.
persistComponentNamesToSettingLocked( persistComponentNamesToSettingLocked(
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
userState.mEnabledServices, userId); userState.mEnabledServices, userId);
// Update the touch exploration granted services setting. // Update the touch exploration granted services setting.
userState.mTouchExplorationGrantedServices.remove(comp);
persistComponentNamesToSettingLocked( persistComponentNamesToSettingLocked(
Settings.Secure. Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
userState.mTouchExplorationGrantedServices, userId); userState.mTouchExplorationGrantedServices, userId);
onUserStateChangedLocked(userState); onUserStateChangedLocked(userState);
return;
}
} }
} }
} }