Merge "Removes shortcut target when an a11y service is unbound" into rvc-dev
This commit is contained in:
@@ -1544,6 +1544,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
} else {
|
||||
if (service != null) {
|
||||
service.unbindLocked();
|
||||
removeShortcutTargetForUnboundServiceLocked(userState, service);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user