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

Commit 4bec7098 authored by Patrick Baumann's avatar Patrick Baumann
Browse files

Inclusive naming of app enumeration changes from R

This change renames arguments and fields added for the purpose of app
enumeration in R to be more inclusive.

Test: atest AppsFilterTest AppEnumerationTests
Change-Id: I97ff73291d328b0ce1bf713c726371932c067c10
parent 6b4cca5a
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -457,7 +457,7 @@ public abstract class ActivityManagerInternal {
    public abstract int broadcastIntent(Intent intent,
    public abstract int broadcastIntent(Intent intent,
            IIntentReceiver resultTo,
            IIntentReceiver resultTo,
            String[] requiredPermissions, boolean serialized,
            String[] requiredPermissions, boolean serialized,
            int userId, int[] appIdWhitelist);
            int userId, int[] appIdAllowList);


    /**
    /**
     * Add uid to the ActivityManagerService PendingStartActivityUids list.
     * Add uid to the ActivityManagerService PendingStartActivityUids list.
+12 −12
Original line number Original line Diff line number Diff line
@@ -14286,7 +14286,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    }
    }
    private List<ResolveInfo> collectReceiverComponents(Intent intent, String resolvedType,
    private List<ResolveInfo> collectReceiverComponents(Intent intent, String resolvedType,
            int callingUid, int[] users, int[] broadcastWhitelist) {
            int callingUid, int[] users, int[] broadcastAllowList) {
        // TODO: come back and remove this assumption to triage all broadcasts
        // TODO: come back and remove this assumption to triage all broadcasts
        int pmFlags = STOCK_PM_FLAGS | MATCH_DEBUG_TRIAGED_MISSING;
        int pmFlags = STOCK_PM_FLAGS | MATCH_DEBUG_TRIAGED_MISSING;
@@ -14362,12 +14362,12 @@ public class ActivityManagerService extends IActivityManager.Stub
        } catch (RemoteException ex) {
        } catch (RemoteException ex) {
            // pm is in same process, this will never happen.
            // pm is in same process, this will never happen.
        }
        }
        if (receivers != null && broadcastWhitelist != null) {
        if (receivers != null && broadcastAllowList != null) {
            for (int i = receivers.size() - 1; i >= 0; i--) {
            for (int i = receivers.size() - 1; i >= 0; i--) {
                final int receiverAppId = UserHandle.getAppId(
                final int receiverAppId = UserHandle.getAppId(
                        receivers.get(i).activityInfo.applicationInfo.uid);
                        receivers.get(i).activityInfo.applicationInfo.uid);
                if (receiverAppId >= Process.FIRST_APPLICATION_UID
                if (receiverAppId >= Process.FIRST_APPLICATION_UID
                        && Arrays.binarySearch(broadcastWhitelist, receiverAppId) < 0) {
                        && Arrays.binarySearch(broadcastAllowList, receiverAppId) < 0) {
                    receivers.remove(i);
                    receivers.remove(i);
                }
                }
            }
            }
@@ -14477,7 +14477,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            boolean ordered, boolean sticky, int callingPid, int callingUid, int realCallingUid,
            boolean ordered, boolean sticky, int callingPid, int callingUid, int realCallingUid,
            int realCallingPid, int userId, boolean allowBackgroundActivityStarts,
            int realCallingPid, int userId, boolean allowBackgroundActivityStarts,
            @Nullable IBinder backgroundActivityStartsToken,
            @Nullable IBinder backgroundActivityStartsToken,
            @Nullable int[] broadcastWhitelist) {
            @Nullable int[] broadcastAllowList) {
        intent = new Intent(intent);
        intent = new Intent(intent);
        final boolean callerInstantApp = isInstantApp(callerApp, callerPackage, callingUid);
        final boolean callerInstantApp = isInstantApp(callerApp, callerPackage, callingUid);
@@ -14486,10 +14486,10 @@ public class ActivityManagerService extends IActivityManager.Stub
            intent.setFlags(intent.getFlags() & ~Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS);
            intent.setFlags(intent.getFlags() & ~Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS);
        }
        }
        if (userId == UserHandle.USER_ALL && broadcastWhitelist != null) {
        if (userId == UserHandle.USER_ALL && broadcastAllowList != null) {
                Slog.e(TAG, "broadcastWhitelist only applies when sending to individual users. "
                Slog.e(TAG, "broadcastAllowList only applies when sending to individual users. "
                        + "Assuming restrictive whitelist.");
                        + "Assuming restrictive whitelist.");
                broadcastWhitelist = new int[]{};
                broadcastAllowList = new int[]{};
        }
        }
        // By default broadcasts do not go to stopped apps.
        // By default broadcasts do not go to stopped apps.
@@ -14981,7 +14981,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        if ((intent.getFlags()&Intent.FLAG_RECEIVER_REGISTERED_ONLY)
        if ((intent.getFlags()&Intent.FLAG_RECEIVER_REGISTERED_ONLY)
                 == 0) {
                 == 0) {
            receivers = collectReceiverComponents(
            receivers = collectReceiverComponents(
                    intent, resolvedType, callingUid, users, broadcastWhitelist);
                    intent, resolvedType, callingUid, users, broadcastAllowList);
        }
        }
        if (intent.getComponent() == null) {
        if (intent.getComponent() == null) {
            if (userId == UserHandle.USER_ALL && callingUid == SHELL_UID) {
            if (userId == UserHandle.USER_ALL && callingUid == SHELL_UID) {
@@ -15011,13 +15011,13 @@ public class ActivityManagerService extends IActivityManager.Stub
        if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "Enqueueing broadcast: " + intent.getAction()
        if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "Enqueueing broadcast: " + intent.getAction()
                + " replacePending=" + replacePending);
                + " replacePending=" + replacePending);
        if (registeredReceivers != null && broadcastWhitelist != null) {
        if (registeredReceivers != null && broadcastAllowList != null) {
            // if a uid whitelist was provided, remove anything in the application space that wasn't
            // if a uid whitelist was provided, remove anything in the application space that wasn't
            // in it.
            // in it.
            for (int i = registeredReceivers.size() - 1; i >= 0; i--) {
            for (int i = registeredReceivers.size() - 1; i >= 0; i--) {
                final int owningAppId = UserHandle.getAppId(registeredReceivers.get(i).owningUid);
                final int owningAppId = UserHandle.getAppId(registeredReceivers.get(i).owningUid);
                if (owningAppId >= Process.FIRST_APPLICATION_UID
                if (owningAppId >= Process.FIRST_APPLICATION_UID
                        && Arrays.binarySearch(broadcastWhitelist, owningAppId) < 0) {
                        && Arrays.binarySearch(broadcastAllowList, owningAppId) < 0) {
                    registeredReceivers.remove(i);
                    registeredReceivers.remove(i);
                }
                }
            }
            }
@@ -17996,7 +17996,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        public int broadcastIntent(Intent intent,
        public int broadcastIntent(Intent intent,
                IIntentReceiver resultTo,
                IIntentReceiver resultTo,
                String[] requiredPermissions,
                String[] requiredPermissions,
                boolean serialized, int userId, int[] appIdWhitelist) {
                boolean serialized, int userId, int[] appIdAllowList) {
            synchronized (ActivityManagerService.this) {
            synchronized (ActivityManagerService.this) {
                intent = verifyBroadcastLocked(intent);
                intent = verifyBroadcastLocked(intent);
@@ -18011,7 +18011,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                            null /*options*/, serialized, false /*sticky*/, callingPid, callingUid,
                            null /*options*/, serialized, false /*sticky*/, callingPid, callingUid,
                            callingUid, callingPid, userId, false /*allowBackgroundStarts*/,
                            callingUid, callingPid, userId, false /*allowBackgroundStarts*/,
                            null /*tokenNeededForBackgroundActivityStarts*/,
                            null /*tokenNeededForBackgroundActivityStarts*/,
                            appIdWhitelist);
                            appIdAllowList);
                } finally {
                } finally {
                    Binder.restoreCallingIdentity(origId);
                    Binder.restoreCallingIdentity(origId);
                }
                }
+10 −10
Original line number Original line Diff line number Diff line
@@ -137,11 +137,11 @@ public class AppsFilter {
    @VisibleForTesting(visibility = PRIVATE)
    @VisibleForTesting(visibility = PRIVATE)
    AppsFilter(StateProvider stateProvider,
    AppsFilter(StateProvider stateProvider,
            FeatureConfig featureConfig,
            FeatureConfig featureConfig,
            String[] forceQueryableWhitelist,
            String[] forceQueryableList,
            boolean systemAppsQueryable,
            boolean systemAppsQueryable,
            @Nullable OverlayReferenceMapper.Provider overlayProvider) {
            @Nullable OverlayReferenceMapper.Provider overlayProvider) {
        mFeatureConfig = featureConfig;
        mFeatureConfig = featureConfig;
        mForceQueryableByDevicePackageNames = forceQueryableWhitelist;
        mForceQueryableByDevicePackageNames = forceQueryableList;
        mSystemAppsQueryable = systemAppsQueryable;
        mSystemAppsQueryable = systemAppsQueryable;
        mOverlayReferenceMapper = new OverlayReferenceMapper(true /*deferRebuild*/,
        mOverlayReferenceMapper = new OverlayReferenceMapper(true /*deferRebuild*/,
                overlayProvider);
                overlayProvider);
@@ -746,11 +746,11 @@ public class AppsFilter {
     * @param users            the set of users that should be evaluated for this calculation
     * @param users            the set of users that should be evaluated for this calculation
     * @param existingSettings the set of all package settings that currently exist on device
     * @param existingSettings the set of all package settings that currently exist on device
     * @return a SparseArray mapping userIds to a sorted int array of appIds that may view the
     * @return a SparseArray mapping userIds to a sorted int array of appIds that may view the
     * provided setting or null if the app is visible to all and no whitelist should be
     * provided setting or null if the app is visible to all and no allow list should be
     * applied.
     * applied.
     */
     */
    @Nullable
    @Nullable
    public SparseArray<int[]> getVisibilityWhitelist(PackageSetting setting, int[] users,
    public SparseArray<int[]> getVisibilityAllowList(PackageSetting setting, int[] users,
            ArrayMap<String, PackageSetting> existingSettings) {
            ArrayMap<String, PackageSetting> existingSettings) {
        if (mForceQueryable.contains(setting.appId)) {
        if (mForceQueryable.contains(setting.appId)) {
            return null;
            return null;
@@ -761,14 +761,14 @@ public class AppsFilter {
            final int userId = users[u];
            final int userId = users[u];
            int[] appIds = new int[existingSettings.size()];
            int[] appIds = new int[existingSettings.size()];
            int[] buffer = null;
            int[] buffer = null;
            int whitelistSize = 0;
            int allowListSize = 0;
            for (int i = existingSettings.size() - 1; i >= 0; i--) {
            for (int i = existingSettings.size() - 1; i >= 0; i--) {
                final PackageSetting existingSetting = existingSettings.valueAt(i);
                final PackageSetting existingSetting = existingSettings.valueAt(i);
                final int existingAppId = existingSetting.appId;
                final int existingAppId = existingSetting.appId;
                if (existingAppId < Process.FIRST_APPLICATION_UID) {
                if (existingAppId < Process.FIRST_APPLICATION_UID) {
                    continue;
                    continue;
                }
                }
                final int loc = Arrays.binarySearch(appIds, 0, whitelistSize, existingAppId);
                final int loc = Arrays.binarySearch(appIds, 0, allowListSize, existingAppId);
                if (loc >= 0) {
                if (loc >= 0) {
                    continue;
                    continue;
                }
                }
@@ -778,13 +778,13 @@ public class AppsFilter {
                        buffer = new int[appIds.length];
                        buffer = new int[appIds.length];
                    }
                    }
                    final int insert = ~loc;
                    final int insert = ~loc;
                    System.arraycopy(appIds, insert, buffer, 0, whitelistSize - insert);
                    System.arraycopy(appIds, insert, buffer, 0, allowListSize - insert);
                    appIds[insert] = existingAppId;
                    appIds[insert] = existingAppId;
                    System.arraycopy(buffer, 0, appIds, insert + 1, whitelistSize - insert);
                    System.arraycopy(buffer, 0, appIds, insert + 1, allowListSize - insert);
                    whitelistSize++;
                    allowListSize++;
                }
                }
            }
            }
            result.put(userId, Arrays.copyOf(appIds, whitelistSize));
            result.put(userId, Arrays.copyOf(appIds, allowListSize));
        }
        }
        return result;
        return result;
    }
    }
+19 −19
Original line number Original line Diff line number Diff line
@@ -2213,17 +2213,17 @@ public class PackageManagerService extends IPackageManager.Stub
                }
                }
                extras.putInt(PackageInstaller.EXTRA_DATA_LOADER_TYPE, dataLoaderType);
                extras.putInt(PackageInstaller.EXTRA_DATA_LOADER_TYPE, dataLoaderType);
                // Send to all running apps.
                // Send to all running apps.
                final SparseArray<int[]> newBroadcastWhitelist;
                final SparseArray<int[]> newBroadcastAllowList;
                synchronized (mLock) {
                synchronized (mLock) {
                    newBroadcastWhitelist = mAppsFilter.getVisibilityWhitelist(
                    newBroadcastAllowList = mAppsFilter.getVisibilityAllowList(
                            getPackageSettingInternal(res.name, Process.SYSTEM_UID),
                            getPackageSettingInternal(res.name, Process.SYSTEM_UID),
                            updateUserIds, mSettings.mPackages);
                            updateUserIds, mSettings.mPackages);
                }
                }
                sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, packageName,
                sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, packageName,
                        extras, 0 /*flags*/,
                        extras, 0 /*flags*/,
                        null /*targetPackage*/, null /*finishedReceiver*/,
                        null /*targetPackage*/, null /*finishedReceiver*/,
                        updateUserIds, instantUserIds, newBroadcastWhitelist);
                        updateUserIds, instantUserIds, newBroadcastAllowList);
                if (installerPackageName != null) {
                if (installerPackageName != null) {
                    // Send to the installer, even if it's not running.
                    // Send to the installer, even if it's not running.
                    sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, packageName,
                    sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, packageName,
@@ -2255,7 +2255,7 @@ public class PackageManagerService extends IPackageManager.Stub
                    sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED,
                    sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED,
                            packageName, extras, 0 /*flags*/,
                            packageName, extras, 0 /*flags*/,
                            null /*targetPackage*/, null /*finishedReceiver*/,
                            null /*targetPackage*/, null /*finishedReceiver*/,
                            updateUserIds, instantUserIds, res.removedInfo.broadcastWhitelist);
                            updateUserIds, instantUserIds, res.removedInfo.broadcastAllowList);
                    if (installerPackageName != null) {
                    if (installerPackageName != null) {
                        sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED, packageName,
                        sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED, packageName,
                                extras, 0 /*flags*/,
                                extras, 0 /*flags*/,
@@ -12675,7 +12675,7 @@ public class PackageManagerService extends IPackageManager.Stub
    public void sendPackageBroadcast(final String action, final String pkg, final Bundle extras,
    public void sendPackageBroadcast(final String action, final String pkg, final Bundle extras,
            final int flags, final String targetPkg, final IIntentReceiver finishedReceiver,
            final int flags, final String targetPkg, final IIntentReceiver finishedReceiver,
            final int[] userIds, int[] instantUserIds,
            final int[] userIds, int[] instantUserIds,
            @Nullable SparseArray<int[]> broadcastWhitelist) {
            @Nullable SparseArray<int[]> broadcastAllowList) {
        mHandler.post(() -> {
        mHandler.post(() -> {
            try {
            try {
                final IActivityManager am = ActivityManager.getService();
                final IActivityManager am = ActivityManager.getService();
@@ -12687,7 +12687,7 @@ public class PackageManagerService extends IPackageManager.Stub
                    resolvedUserIds = userIds;
                    resolvedUserIds = userIds;
                }
                }
                doSendBroadcast(am, action, pkg, extras, flags, targetPkg, finishedReceiver,
                doSendBroadcast(am, action, pkg, extras, flags, targetPkg, finishedReceiver,
                        resolvedUserIds, false, broadcastWhitelist);
                        resolvedUserIds, false, broadcastAllowList);
                if (instantUserIds != null && instantUserIds != EMPTY_INT_ARRAY) {
                if (instantUserIds != null && instantUserIds != EMPTY_INT_ARRAY) {
                    doSendBroadcast(am, action, pkg, extras, flags, targetPkg, finishedReceiver,
                    doSendBroadcast(am, action, pkg, extras, flags, targetPkg, finishedReceiver,
                            instantUserIds, true, null);
                            instantUserIds, true, null);
@@ -12760,7 +12760,7 @@ public class PackageManagerService extends IPackageManager.Stub
     */
     */
    private void doSendBroadcast(IActivityManager am, String action, String pkg, Bundle extras,
    private void doSendBroadcast(IActivityManager am, String action, String pkg, Bundle extras,
            int flags, String targetPkg, IIntentReceiver finishedReceiver,
            int flags, String targetPkg, IIntentReceiver finishedReceiver,
            int[] userIds, boolean isInstantApp, @Nullable SparseArray<int[]> broadcastWhitelist) {
            int[] userIds, boolean isInstantApp, @Nullable SparseArray<int[]> broadcastAllowList) {
        for (int id : userIds) {
        for (int id : userIds) {
            final Intent intent = new Intent(action,
            final Intent intent = new Intent(action,
                    pkg != null ? Uri.fromParts(PACKAGE_SCHEME, pkg, null) : null);
                    pkg != null ? Uri.fromParts(PACKAGE_SCHEME, pkg, null) : null);
@@ -12790,7 +12790,7 @@ public class PackageManagerService extends IPackageManager.Stub
            mInjector.getActivityManagerInternal().broadcastIntent(
            mInjector.getActivityManagerInternal().broadcastIntent(
                    intent, finishedReceiver, requiredPermissions,
                    intent, finishedReceiver, requiredPermissions,
                    finishedReceiver != null, id,
                    finishedReceiver != null, id,
                    broadcastWhitelist == null ? null : broadcastWhitelist.get(id));
                    broadcastAllowList == null ? null : broadcastAllowList.get(id));
        }
        }
    }
    }
@@ -12930,7 +12930,7 @@ public class PackageManagerService extends IPackageManager.Stub
        sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED,
        sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED,
                packageName, extras, 0, null, null, userIds, instantUserIds,
                packageName, extras, 0, null, null, userIds, instantUserIds,
                mAppsFilter.getVisibilityWhitelist(
                mAppsFilter.getVisibilityAllowList(
                        getPackageSettingInternal(packageName, Process.SYSTEM_UID),
                        getPackageSettingInternal(packageName, Process.SYSTEM_UID),
                        userIds, mSettings.mPackages));
                        userIds, mSettings.mPackages));
        if (sendBootCompleted && !ArrayUtils.isEmpty(userIds)) {
        if (sendBootCompleted && !ArrayUtils.isEmpty(userIds)) {
@@ -16763,7 +16763,7 @@ public class PackageManagerService extends IPackageManager.Stub
                reconciledPkg.pkgSetting.firstInstallTime = deletedPkgSetting.firstInstallTime;
                reconciledPkg.pkgSetting.firstInstallTime = deletedPkgSetting.firstInstallTime;
                reconciledPkg.pkgSetting.lastUpdateTime = System.currentTimeMillis();
                reconciledPkg.pkgSetting.lastUpdateTime = System.currentTimeMillis();
                res.removedInfo.broadcastWhitelist = mAppsFilter.getVisibilityWhitelist(
                res.removedInfo.broadcastAllowList = mAppsFilter.getVisibilityAllowList(
                                reconciledPkg.pkgSetting, request.mAllUsers, mSettings.mPackages);
                                reconciledPkg.pkgSetting, request.mAllUsers, mSettings.mPackages);
                if (reconciledPkg.prepareResult.system) {
                if (reconciledPkg.prepareResult.system) {
                    // Remove existing system package
                    // Remove existing system package
@@ -18693,7 +18693,7 @@ public class PackageManagerService extends IPackageManager.Stub
        boolean isStaticSharedLib;
        boolean isStaticSharedLib;
        // a two dimensional array mapping userId to the set of appIds that can receive notice
        // a two dimensional array mapping userId to the set of appIds that can receive notice
        // of package changes
        // of package changes
        SparseArray<int[]> broadcastWhitelist;
        SparseArray<int[]> broadcastAllowList;
        // Clean up resources deleted packages.
        // Clean up resources deleted packages.
        InstallArgs args = null;
        InstallArgs args = null;
@@ -18716,9 +18716,9 @@ public class PackageManagerService extends IPackageManager.Stub
            extras.putInt(Intent.EXTRA_UID, removedAppId >= 0 ? removedAppId : uid);
            extras.putInt(Intent.EXTRA_UID, removedAppId >= 0 ? removedAppId : uid);
            extras.putBoolean(Intent.EXTRA_REPLACING, true);
            extras.putBoolean(Intent.EXTRA_REPLACING, true);
            packageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, removedPackage, extras,
            packageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, removedPackage, extras,
                    0, null /*targetPackage*/, null, null, null, broadcastWhitelist);
                    0, null /*targetPackage*/, null, null, null, broadcastAllowList);
            packageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED, removedPackage,
            packageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED, removedPackage,
                    extras, 0, null /*targetPackage*/, null, null, null, broadcastWhitelist);
                    extras, 0, null /*targetPackage*/, null, null, null, broadcastAllowList);
            packageSender.sendPackageBroadcast(Intent.ACTION_MY_PACKAGE_REPLACED, null, null, 0,
            packageSender.sendPackageBroadcast(Intent.ACTION_MY_PACKAGE_REPLACED, null, null, 0,
                    removedPackage, null, null, null, null /* broadcastWhitelist */);
                    removedPackage, null, null, null, null /* broadcastWhitelist */);
            if (installerPackageName != null) {
            if (installerPackageName != null) {
@@ -18750,7 +18750,7 @@ public class PackageManagerService extends IPackageManager.Stub
            if (removedPackage != null) {
            if (removedPackage != null) {
                packageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED,
                packageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED,
                    removedPackage, extras, 0, null /*targetPackage*/, null,
                    removedPackage, extras, 0, null /*targetPackage*/, null,
                    broadcastUsers, instantUserIds, broadcastWhitelist);
                    broadcastUsers, instantUserIds, broadcastAllowList);
                if (installerPackageName != null) {
                if (installerPackageName != null) {
                    packageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED,
                    packageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED,
                            removedPackage, extras, 0 /*flags*/,
                            removedPackage, extras, 0 /*flags*/,
@@ -18759,7 +18759,7 @@ public class PackageManagerService extends IPackageManager.Stub
                if (dataRemoved && !isRemovedPackageSystemUpdate) {
                if (dataRemoved && !isRemovedPackageSystemUpdate) {
                    packageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_FULLY_REMOVED,
                    packageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_FULLY_REMOVED,
                            removedPackage, extras, Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND, null,
                            removedPackage, extras, Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND, null,
                            null, broadcastUsers, instantUserIds, broadcastWhitelist);
                            null, broadcastUsers, instantUserIds, broadcastAllowList);
                    packageSender.notifyPackageRemoved(removedPackage, removedUid);
                    packageSender.notifyPackageRemoved(removedPackage, removedUid);
                }
                }
            }
            }
@@ -18772,7 +18772,7 @@ public class PackageManagerService extends IPackageManager.Stub
                packageSender.sendPackageBroadcast(Intent.ACTION_UID_REMOVED,
                packageSender.sendPackageBroadcast(Intent.ACTION_UID_REMOVED,
                        null, extras, Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND,
                        null, extras, Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND,
                        null, null, broadcastUsers, instantUserIds, broadcastWhitelist);
                        null, null, broadcastUsers, instantUserIds, broadcastAllowList);
            }
            }
        }
        }
@@ -21264,17 +21264,17 @@ public class PackageManagerService extends IPackageManager.Stub
        final boolean isInstantApp = isInstantApp(packageName, userId);
        final boolean isInstantApp = isInstantApp(packageName, userId);
        final int[] userIds = isInstantApp ? EMPTY_INT_ARRAY : new int[] { userId };
        final int[] userIds = isInstantApp ? EMPTY_INT_ARRAY : new int[] { userId };
        final int[] instantUserIds = isInstantApp ? new int[] { userId } : EMPTY_INT_ARRAY;
        final int[] instantUserIds = isInstantApp ? new int[] { userId } : EMPTY_INT_ARRAY;
        final SparseArray<int[]> broadcastWhitelist;
        final SparseArray<int[]> broadcastAllowList;
        synchronized (mLock) {
        synchronized (mLock) {
            PackageSetting setting = getPackageSettingInternal(packageName, Process.SYSTEM_UID);
            PackageSetting setting = getPackageSettingInternal(packageName, Process.SYSTEM_UID);
            if (setting == null) {
            if (setting == null) {
                return;
                return;
            }
            }
            broadcastWhitelist = isInstantApp ? null : mAppsFilter.getVisibilityWhitelist(setting,
            broadcastAllowList = isInstantApp ? null : mAppsFilter.getVisibilityAllowList(setting,
                    userIds, mSettings.mPackages);
                    userIds, mSettings.mPackages);
        }
        }
        sendPackageBroadcast(Intent.ACTION_PACKAGE_CHANGED,  packageName, extras, flags, null, null,
        sendPackageBroadcast(Intent.ACTION_PACKAGE_CHANGED,  packageName, extras, flags, null, null,
                userIds, instantUserIds, broadcastWhitelist);
                userIds, instantUserIds, broadcastAllowList);
    }
    }
    @Override
    @Override
+5 −8
Original line number Original line Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.server.pm;


import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.any;
@@ -70,8 +69,6 @@ import java.util.Collections;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
import java.util.Set;
import java.util.Set;
import java.util.function.IntFunction;
import java.util.stream.Collectors;


@Presubmit
@Presubmit
@RunWith(JUnit4.class)
@RunWith(JUnit4.class)
@@ -805,24 +802,24 @@ public class AppsFilterTest {
                queriesProviderAppId);
                queriesProviderAppId);


        final SparseArray<int[]> systemFilter =
        final SparseArray<int[]> systemFilter =
                appsFilter.getVisibilityWhitelist(system, USER_ARRAY, mExisting);
                appsFilter.getVisibilityAllowList(system, USER_ARRAY, mExisting);
        assertThat(toList(systemFilter.get(SYSTEM_USER)),
        assertThat(toList(systemFilter.get(SYSTEM_USER)),
                contains(seesNothingAppId, hasProviderAppId, queriesProviderAppId));
                contains(seesNothingAppId, hasProviderAppId, queriesProviderAppId));


        final SparseArray<int[]> seesNothingFilter =
        final SparseArray<int[]> seesNothingFilter =
                appsFilter.getVisibilityWhitelist(seesNothing, USER_ARRAY, mExisting);
                appsFilter.getVisibilityAllowList(seesNothing, USER_ARRAY, mExisting);
        assertThat(toList(seesNothingFilter.get(SYSTEM_USER)),
        assertThat(toList(seesNothingFilter.get(SYSTEM_USER)),
                contains(seesNothingAppId));
                contains(seesNothingAppId));
        assertThat(toList(seesNothingFilter.get(SECONDARY_USER)),
        assertThat(toList(seesNothingFilter.get(SECONDARY_USER)),
                contains(seesNothingAppId));
                contains(seesNothingAppId));


        final SparseArray<int[]> hasProviderFilter =
        final SparseArray<int[]> hasProviderFilter =
                appsFilter.getVisibilityWhitelist(hasProvider, USER_ARRAY, mExisting);
                appsFilter.getVisibilityAllowList(hasProvider, USER_ARRAY, mExisting);
        assertThat(toList(hasProviderFilter.get(SYSTEM_USER)),
        assertThat(toList(hasProviderFilter.get(SYSTEM_USER)),
                contains(hasProviderAppId, queriesProviderAppId));
                contains(hasProviderAppId, queriesProviderAppId));


        SparseArray<int[]> queriesProviderFilter =
        SparseArray<int[]> queriesProviderFilter =
                appsFilter.getVisibilityWhitelist(queriesProvider, USER_ARRAY, mExisting);
                appsFilter.getVisibilityAllowList(queriesProvider, USER_ARRAY, mExisting);
        assertThat(toList(queriesProviderFilter.get(SYSTEM_USER)),
        assertThat(toList(queriesProviderFilter.get(SYSTEM_USER)),
                contains(queriesProviderAppId));
                contains(queriesProviderAppId));


@@ -831,7 +828,7 @@ public class AppsFilterTest {


        // ensure implicit access is included in the filter
        // ensure implicit access is included in the filter
        queriesProviderFilter =
        queriesProviderFilter =
                appsFilter.getVisibilityWhitelist(queriesProvider, USER_ARRAY, mExisting);
                appsFilter.getVisibilityAllowList(queriesProvider, USER_ARRAY, mExisting);
        assertThat(toList(queriesProviderFilter.get(SYSTEM_USER)),
        assertThat(toList(queriesProviderFilter.get(SYSTEM_USER)),
                contains(hasProviderAppId, queriesProviderAppId));
                contains(hasProviderAppId, queriesProviderAppId));
    }
    }