Merge "Removes the a11y service from the cached service list when onPackageRemoved" into rvc-dev

This commit is contained in:
Minche Li
2020-05-13 02:31:50 +00:00
committed by Android (Google) Code Review

View File

@@ -132,6 +132,7 @@ import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
/**
* This class is instantiated by the system as a system level service and can be
@@ -391,7 +392,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
return;
}
// We will update when the automation service dies.
AccessibilityUserState userState = getCurrentUserStateLocked();
final AccessibilityUserState userState = getCurrentUserStateLocked();
// We have to reload the installed services since some services may
// have different attributes, resolve info (does not support equals),
// etc. Remove them then to force reload.
@@ -440,15 +441,18 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
if (userId != mCurrentUserId) {
return;
}
AccessibilityUserState userState = getUserStateLocked(userId);
Iterator<ComponentName> it = userState.mEnabledServices.iterator();
final AccessibilityUserState userState = getUserStateLocked(userId);
final Predicate<ComponentName> filter =
component -> component != null && component.getPackageName().equals(
packageName);
userState.mBindingServices.removeIf(filter);
userState.mCrashedServices.removeIf(filter);
final Iterator<ComponentName> it = userState.mEnabledServices.iterator();
while (it.hasNext()) {
ComponentName comp = it.next();
String compPkg = comp.getPackageName();
final ComponentName comp = it.next();
final String compPkg = comp.getPackageName();
if (compPkg.equals(packageName)) {
it.remove();
userState.getBindingServicesLocked().remove(comp);
userState.getCrashedServicesLocked().remove(comp);
// Update the enabled services setting.
persistComponentNamesToSettingLocked(
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
@@ -476,11 +480,11 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
if (userId != mCurrentUserId) {
return false;
}
AccessibilityUserState userState = getUserStateLocked(userId);
Iterator<ComponentName> it = userState.mEnabledServices.iterator();
final AccessibilityUserState userState = getUserStateLocked(userId);
final Iterator<ComponentName> it = userState.mEnabledServices.iterator();
while (it.hasNext()) {
ComponentName comp = it.next();
String compPkg = comp.getPackageName();
final ComponentName comp = it.next();
final String compPkg = comp.getPackageName();
for (String pkg : packages) {
if (compPkg.equals(pkg)) {
if (!doit) {