Loading services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java +31 −0 Original line number Diff line number Diff line Loading @@ -1544,6 +1544,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub } else { if (service != null) { service.unbindLocked(); removeShortcutTargetForUnboundServiceLocked(userState, service); } } } Loading Loading @@ -2318,6 +2319,36 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub scheduleNotifyClientsOfServicesStateChangeLocked(userState); } /** * Remove the shortcut target for the unbound service which is requesting accessibility button * and targeting sdk > Q from the accessibility button and shortcut. * * @param userState The accessibility user state. * @param service The unbound service. */ private void removeShortcutTargetForUnboundServiceLocked(AccessibilityUserState userState, AccessibilityServiceConnection service) { if (!service.mRequestAccessibilityButton || service.getServiceInfo().getResolveInfo().serviceInfo.applicationInfo .targetSdkVersion <= Build.VERSION_CODES.Q) { return; } final ComponentName serviceName = service.getComponentName(); if (userState.removeShortcutTargetLocked(ACCESSIBILITY_SHORTCUT_KEY, serviceName)) { final Set<String> currentTargets = userState.getShortcutTargetsLocked( ACCESSIBILITY_SHORTCUT_KEY); persistColonDelimitedSetToSettingLocked( Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE, userState.mUserId, currentTargets, str -> str); } if (userState.removeShortcutTargetLocked(ACCESSIBILITY_BUTTON, serviceName)) { final Set<String> currentTargets = userState.getShortcutTargetsLocked( ACCESSIBILITY_BUTTON); persistColonDelimitedSetToSettingLocked(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS, userState.mUserId, currentTargets, str -> str); } } private void updateRecommendedUiTimeoutLocked(AccessibilityUserState userState) { int newNonInteractiveUiTimeout = userState.getUserNonInteractiveUiTimeoutLocked(); int newInteractiveUiTimeout = userState.getUserInteractiveUiTimeoutLocked(); Loading services/accessibility/java/com/android/server/accessibility/AccessibilityUserState.java +19 −0 Original line number Diff line number Diff line Loading @@ -630,6 +630,25 @@ class AccessibilityUserState { return false; } /** * Removes given shortcut target in the list. * * @param shortcutType The shortcut type. * @param target The component name of the shortcut target. * @return true if the shortcut target is removed. */ public boolean removeShortcutTargetLocked(@ShortcutType int shortcutType, ComponentName target) { return getShortcutTargetsLocked(shortcutType).removeIf(name -> { ComponentName componentName; if (name == null || (componentName = ComponentName.unflattenFromString(name)) == null) { return false; } return componentName.equals(target); }); } /** * Returns installed accessibility service info by the given service component name. */ Loading Loading
services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java +31 −0 Original line number Diff line number Diff line Loading @@ -1544,6 +1544,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub } else { if (service != null) { service.unbindLocked(); removeShortcutTargetForUnboundServiceLocked(userState, service); } } } Loading Loading @@ -2318,6 +2319,36 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub scheduleNotifyClientsOfServicesStateChangeLocked(userState); } /** * Remove the shortcut target for the unbound service which is requesting accessibility button * and targeting sdk > Q from the accessibility button and shortcut. * * @param userState The accessibility user state. * @param service The unbound service. */ private void removeShortcutTargetForUnboundServiceLocked(AccessibilityUserState userState, AccessibilityServiceConnection service) { if (!service.mRequestAccessibilityButton || service.getServiceInfo().getResolveInfo().serviceInfo.applicationInfo .targetSdkVersion <= Build.VERSION_CODES.Q) { return; } final ComponentName serviceName = service.getComponentName(); if (userState.removeShortcutTargetLocked(ACCESSIBILITY_SHORTCUT_KEY, serviceName)) { final Set<String> currentTargets = userState.getShortcutTargetsLocked( ACCESSIBILITY_SHORTCUT_KEY); persistColonDelimitedSetToSettingLocked( Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE, userState.mUserId, currentTargets, str -> str); } if (userState.removeShortcutTargetLocked(ACCESSIBILITY_BUTTON, serviceName)) { final Set<String> currentTargets = userState.getShortcutTargetsLocked( ACCESSIBILITY_BUTTON); persistColonDelimitedSetToSettingLocked(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS, userState.mUserId, currentTargets, str -> str); } } private void updateRecommendedUiTimeoutLocked(AccessibilityUserState userState) { int newNonInteractiveUiTimeout = userState.getUserNonInteractiveUiTimeoutLocked(); int newInteractiveUiTimeout = userState.getUserInteractiveUiTimeoutLocked(); Loading
services/accessibility/java/com/android/server/accessibility/AccessibilityUserState.java +19 −0 Original line number Diff line number Diff line Loading @@ -630,6 +630,25 @@ class AccessibilityUserState { return false; } /** * Removes given shortcut target in the list. * * @param shortcutType The shortcut type. * @param target The component name of the shortcut target. * @return true if the shortcut target is removed. */ public boolean removeShortcutTargetLocked(@ShortcutType int shortcutType, ComponentName target) { return getShortcutTargetsLocked(shortcutType).removeIf(name -> { ComponentName componentName; if (name == null || (componentName = ComponentName.unflattenFromString(name)) == null) { return false; } return componentName.equals(target); }); } /** * Returns installed accessibility service info by the given service component name. */ Loading