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

Commit 2e82e39c authored by Patrick Baumann's avatar Patrick Baumann Committed by Android (Google) Code Review
Browse files

Merge "Honor shared users in visibility calculations"

parents 1008aa55 a72e674e
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -445,8 +445,31 @@ public class AppsFilter {

    private boolean shouldFilterApplicationInternal(
            PackageSetting callingPkgSetting, PackageSetting targetPkgSetting, int userId) {
        return shouldFilterApplicationInternal(callingPkgSetting, targetPkgSetting, userId,
                true /*expandSharedUser*/);
    }

    /**
     * @param expandSharedUser true if all members of the shared user a target may belong to should
     *                         be considered
     */
    private boolean shouldFilterApplicationInternal(
            PackageSetting callingPkgSetting, PackageSetting targetPkgSetting, int userId,
            boolean expandSharedUser) {
        Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "shouldFilterApplicationInternal");
        try {
            // special case shared user targets
            if (expandSharedUser && targetPkgSetting.sharedUser != null) {
                for (PackageSetting sharedMemberSetting : targetPkgSetting.sharedUser.packages) {
                    if (!shouldFilterApplicationInternal(
                            callingPkgSetting, sharedMemberSetting, userId,
                            false /*expandSharedUser*/)) {
                        return false;
                    }
                }
                return true;
            }

            final String callingName = callingPkgSetting.pkg.packageName;
            final PackageParser.Package targetPkg = targetPkgSetting.pkg;

@@ -471,6 +494,12 @@ public class AppsFilter {
                }
                return false;
            }
            if (callingPkgSetting.appId == targetPkgSetting.appId) {
                if (DEBUG_LOGGING) {
                    log(callingPkgSetting, targetPkgSetting, "same app id");
                }
                return false;
            }
            if (isImplicitlyQueryableSystemApp(targetPkgSetting)) {
                if (DEBUG_LOGGING) {
                    log(callingPkgSetting, targetPkgSetting, "implicitly queryable sys");