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

Commit 94a336e6 authored by Ryan Lin's avatar Ryan Lin Committed by Automerger Merge Worker
Browse files

Merge "fix package visibility for installed accessibility services" into...

Merge "fix package visibility for installed accessibility services" into sc-dev am: d616f1ed am: 40580bb2

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14972858

Change-Id: I957957b60820dfeb5a4d213681fc6c5131231a41
parents bd32f3c4 40580bb2
Loading
Loading
Loading
Loading
+18 −4
Original line number Original line Diff line number Diff line
@@ -882,18 +882,32 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
                    FLAGS_ACCESSIBILITY_MANAGER, "userId=" + userId);
                    FLAGS_ACCESSIBILITY_MANAGER, "userId=" + userId);
        }
        }


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


        if (Binder.getCallingPid() == OWN_PROCESS_ID) {
        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
    @Override