Skip to content

Commit

Permalink
RESTRICT AUTOMERGE Stops hiding a11y services with the same package+l…
Browse files Browse the repository at this point in the history
…abel as an activity.

Bug: 353700779
Test: Install poc APKs from the bug, observe issue not reproducible
Test: (automated tests on 'main' branch)
Flag: NONE security fix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:b5ec3e0cd212ca20b28b48284f030a9e45053cc2)
Merged-In: Ia8d43229d277dd4442173166ae0402f05096da4b
Change-Id: Ia8d43229d277dd4442173166ae0402f05096da4b
  • Loading branch information
Daniel-Norman authored and aoleary committed Nov 18, 2024
1 parent 9201010 commit abbdc04
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions src/com/android/settings/accessibility/AccessibilitySettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.ServiceInfo;
import android.os.Bundle;
import android.os.Handler;
import android.os.UserHandle;
Expand Down Expand Up @@ -389,17 +388,11 @@ private List<RestrictedPreference> getInstalledAccessibilityList(Context context
final List<AccessibilityShortcutInfo> installedShortcutList =
a11yManager.getInstalledAccessibilityShortcutListAsUser(context,
UserHandle.myUserId());

// Remove duplicate item here, new a ArrayList to copy unmodifiable list result
// (getInstalledAccessibilityServiceList).
final List<AccessibilityServiceInfo> installedServiceList = new ArrayList<>(
a11yManager.getInstalledAccessibilityServiceList());
installedServiceList.removeIf(
target -> containsTargetNameInList(installedShortcutList, target));

final List<RestrictedPreference> activityList =
preferenceHelper.createAccessibilityActivityPreferenceList(installedShortcutList);

final List<RestrictedPreference> serviceList =
preferenceHelper.createAccessibilityServicePreferenceList(installedServiceList);

Expand All @@ -410,24 +403,6 @@ private List<RestrictedPreference> getInstalledAccessibilityList(Context context
return preferenceList;
}

private boolean containsTargetNameInList(List<AccessibilityShortcutInfo> shortcutInfos,
AccessibilityServiceInfo targetServiceInfo) {
final ServiceInfo serviceInfo = targetServiceInfo.getResolveInfo().serviceInfo;
final String servicePackageName = serviceInfo.packageName;
final CharSequence serviceLabel = serviceInfo.loadLabel(getPackageManager());

for (int i = 0, count = shortcutInfos.size(); i < count; ++i) {
final ActivityInfo activityInfo = shortcutInfos.get(i).getActivityInfo();
final String activityPackageName = activityInfo.packageName;
final CharSequence activityLabel = activityInfo.loadLabel(getPackageManager());
if (servicePackageName.equals(activityPackageName)
&& serviceLabel.equals(activityLabel)) {
return true;
}
}
return false;
}

private void initializePreBundledServicesMapFromArray(String categoryKey, int key) {
String[] services = getResources().getStringArray(key);
PreferenceCategory category = mCategoryToPrefCategoryMap.get(categoryKey);
Expand Down

0 comments on commit abbdc04

Please sign in to comment.