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

Commit dbdd2123 authored by Jackal Guo's avatar Jackal Guo Committed by Automerger Merge Worker
Browse files

Merge "Apply package visibility to cached ServiceRecord" into sc-dev am: fdb069d3

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: If019ff860df13899e704ef3873cb000ed19fd970
parents 17896e43 fdb069d3
Loading
Loading
Loading
Loading
+18 −6
Original line number Original line Diff line number Diff line
@@ -2815,12 +2815,24 @@ public final class ActiveServices {
            r = smap.mServicesByIntent.get(filter);
            r = smap.mServicesByIntent.get(filter);
            if (DEBUG_SERVICE && r != null) Slog.v(TAG_SERVICE, "Retrieved by intent: " + r);
            if (DEBUG_SERVICE && r != null) Slog.v(TAG_SERVICE, "Retrieved by intent: " + r);
        }
        }
        if (r != null && (r.serviceInfo.flags & ServiceInfo.FLAG_EXTERNAL_SERVICE) != 0
        if (r != null) {
            // Compared to resolveService below, the ServiceRecord here is retrieved from
            // ServiceMap so the package visibility doesn't apply to it. We need to filter it.
            if (mAm.getPackageManagerInternal().filterAppAccess(r.packageName, callingUid,
                    userId)) {
                Slog.w(TAG_SERVICE, "Unable to start service " + service + " U=" + userId
                        + ": not found");
                return null;
            }
            if ((r.serviceInfo.flags & ServiceInfo.FLAG_EXTERNAL_SERVICE) != 0
                    && !callingPackage.equals(r.packageName)) {
                    && !callingPackage.equals(r.packageName)) {
                // If an external service is running within its own package, other packages
                // If an external service is running within its own package, other packages
                // should not bind to that instance.
                // should not bind to that instance.
                r = null;
                r = null;
            if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "Whoops, can't use existing external service");
                if (DEBUG_SERVICE) {
                    Slog.v(TAG_SERVICE, "Whoops, can't use existing external service");
                }
            }
        }
        }
        if (r == null) {
        if (r == null) {
            try {
            try {