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

Commit 5170c58c authored by ryanlwlin's avatar ryanlwlin
Browse files

fix package visibility for installed accessibility services

If the app targets API level 30, the returned installed
AccessibilityServiceInfo would based on its own package visiblity.
Using packageManagerInternal#filterAppAccess to determine whether
we need to fitler the service or not.

Bug: 179699353
Test: manual - use the test apk and check the log
      atest AppEnumerationTests
Change-Id: Ieea089e10410a9d9feeb4a741c871c43547b1861
parent 96d2926f
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -872,18 +872,32 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
                    "userId=" + userId);
        }

        final int resolvedUserId;
        final List<AccessibilityServiceInfo> serviceInfos;
        synchronized (mLock) {
            // We treat calls from a profile as if made by its parent as profiles
            // share the accessibility state of the parent. The call below
            // performs the current profile parent resolution.
            final int resolvedUserId = mSecurityPolicy
            resolvedUserId = mSecurityPolicy
                    .resolveCallingUserIdEnforcingPermissionsLocked(userId);
            serviceInfos = new ArrayList<>(
                    getUserStateLocked(resolvedUserId).mInstalledServices);
        }

        if (Binder.getCallingPid() == OWN_PROCESS_ID) {
                return new ArrayList<>(getUserStateLocked(resolvedUserId).mInstalledServices);
            return serviceInfos;
        }
        final PackageManagerInternal pm = LocalServices.getService(
                PackageManagerInternal.class);
        final int callingUid = Binder.getCallingUid();
        for (int i = serviceInfos.size() - 1; i >= 0; i--) {
            final AccessibilityServiceInfo serviceInfo = serviceInfos.get(i);
            if (pm.filterAppAccess(serviceInfo.getComponentName().getPackageName(), callingUid,
                    resolvedUserId)) {
                serviceInfos.remove(i);
            }
            return getUserStateLocked(resolvedUserId).mInstalledServices;
        }
        return serviceInfos;
    }

    @Override