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

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

Merge "Traverse all users to look up the names of the appId" into sc-dev am: c4cf0d49

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

Change-Id: I62343568415cb674c7c1e0080c5842a9f29b6006
parents d43af4a4 c4cf0d49
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.content.pm.parsing.component.ParsedInstrumentation;
import android.content.pm.parsing.component.ParsedIntentInfo;
import android.content.pm.parsing.component.ParsedMainComponent;
import android.content.pm.parsing.component.ParsedProvider;
import android.os.Binder;
import android.os.Process;
import android.os.Trace;
import android.os.UserHandle;
@@ -51,6 +52,7 @@ import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.function.QuadFunction;
import com.android.server.FgThread;
import com.android.server.compat.CompatChange;
import com.android.server.om.OverlayReferenceMapper;
@@ -69,7 +71,6 @@ import java.util.Objects;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.concurrent.Executor;
import java.util.function.Function;

/**
 * The entity responsible for filtering visibility between apps based on declarations in their
@@ -1447,14 +1448,20 @@ public class AppsFilter implements Watchable, Snappable {

    public void dumpQueries(
            PrintWriter pw, @Nullable Integer filteringAppId, DumpState dumpState, int[] users,
            Function<Integer, String[]> getPackagesForUid) {
            QuadFunction<Integer, Integer, Integer, Boolean, String[]> getPackagesForUid) {
        final SparseArray<String> cache = new SparseArray<>();
        ToString<Integer> expandPackages = input -> {
            String cachedValue = cache.get(input);
            if (cachedValue == null) {
                final String[] packagesForUid = getPackagesForUid.apply(input);
                final int callingUid = Binder.getCallingUid();
                final int appId = UserHandle.getAppId(input);
                String[] packagesForUid = null;
                for (int i = 0, size = users.length; packagesForUid == null && i < size; i++) {
                    packagesForUid = getPackagesForUid.apply(callingUid, users[i], appId,
                            false /*isCallerInstantApp*/);
                }
                if (packagesForUid == null) {
                    cachedValue = "[unknown app id " + input + "]";
                    cachedValue = "[app id " + input + " not installed]";
                } else {
                    cachedValue = packagesForUid.length == 1 ? packagesForUid[0]
                            : "[" + TextUtils.join(",", packagesForUid) + "]";
+1 −1
Original line number Diff line number Diff line
@@ -4621,7 +4621,7 @@ public class PackageManagerService extends IPackageManager.Stub
                    Integer filteringAppId = setting == null ? null : setting.appId;
                    mAppsFilter.dumpQueries(
                            pw, filteringAppId, dumpState, mUserManager.getUserIds(),
                            this::getPackagesForUid);
                            this::getPackagesForUidInternalBody);
                    break;
                }