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

Commit 2b76abd7 authored by mincheli's avatar mincheli
Browse files

Removes the a11y service from the cached service list when onPackageRemoved

The disabled a11y service is not removed from the cached service list
when the a11y service package is uninstalled.
To fix it, we have to remove the service from the service list.

Bug: 153507990
Test: manual test & adb shell dumpsys accessibility
Change-Id: Ic1d2ebe3a46faf7237123bcdfca96c79b2c35705
parent 15ab8e10
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -130,6 +130,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
@@ -389,7 +390,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.
@@ -438,15 +439,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,
@@ -474,11 +478,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) {