summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/com/android/internal/app/AccessibilityButtonChooserActivity.java32
1 files changed, 30 insertions, 2 deletions
diff --git a/core/java/com/android/internal/app/AccessibilityButtonChooserActivity.java b/core/java/com/android/internal/app/AccessibilityButtonChooserActivity.java
index c40864131a2e..51b13345a6c3 100644
--- a/core/java/com/android/internal/app/AccessibilityButtonChooserActivity.java
+++ b/core/java/com/android/internal/app/AccessibilityButtonChooserActivity.java
@@ -169,13 +169,41 @@ public class AccessibilityButtonChooserActivity extends Activity {
private static List<AccessibilityButtonTarget> getInstalledServiceTargets(
@NonNull Context context) {
final List<AccessibilityButtonTarget> targets = new ArrayList<>();
- targets.addAll(getAccessibilityServiceTargets(context));
- targets.addAll(getAccessibilityActivityTargets(context));
+ targets.addAll(getAccessibilityFilteredTargets(context));
targets.addAll(getWhiteListingServiceTargets(context));
return targets;
}
+ private static List<AccessibilityButtonTarget> getAccessibilityFilteredTargets(
+ @NonNull Context context) {
+ final List<AccessibilityButtonTarget> serviceTargets =
+ getAccessibilityServiceTargets(context);
+ final List<AccessibilityButtonTarget> activityTargets =
+ getAccessibilityActivityTargets(context);
+
+ for (AccessibilityButtonTarget activityTarget : activityTargets) {
+ serviceTargets.removeIf(serviceTarget -> {
+ final ComponentName serviceComponentName =
+ ComponentName.unflattenFromString(serviceTarget.getId());
+ final ComponentName activityComponentName =
+ ComponentName.unflattenFromString(activityTarget.getId());
+ final boolean isSamePackageName = activityComponentName.getPackageName().equals(
+ serviceComponentName.getPackageName());
+ final boolean isSameLabel = activityTarget.getLabel().equals(
+ serviceTarget.getLabel());
+
+ return isSamePackageName && isSameLabel;
+ });
+ }
+
+ final List<AccessibilityButtonTarget> targets = new ArrayList<>();
+ targets.addAll(serviceTargets);
+ targets.addAll(activityTargets);
+
+ return targets;
+ }
+
private static List<AccessibilityButtonTarget> getAccessibilityServiceTargets(
@NonNull Context context) {
final AccessibilityManager ams = context.getSystemService(AccessibilityManager.class);