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

Commit 385ac3fa authored by Daniel Norman's avatar Daniel Norman Committed by Automerger Merge Worker
Browse files

RESTRICT AUTOMERGE Stops hiding a11y services with the same package+label as...

RESTRICT AUTOMERGE Stops hiding a11y services with the same package+label as an activity. am: 25ecee05 am: ab7fcdc9

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/28807176



Change-Id: I5a5d5af46a986e3d8ce1ae437124a56b7f52ca67
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 20002f05 ab7fcdc9
Loading
Loading
Loading
Loading
+0 −25
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.app.settings.SettingsEnums;
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;
@@ -416,17 +415,11 @@ public class AccessibilitySettings extends DashboardFragment {
        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);

@@ -437,24 +430,6 @@ public class AccessibilitySettings extends DashboardFragment {
        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);