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

Commit 3db65d45 authored by Jackal Guo's avatar Jackal Guo
Browse files

Rename the API and remove boolean isInstantApp

getBroadcastAllowListlink takes a boolean isInstantApp for all users.
It's possible that an app is instant in one user, but not in another.
This may cause mis-use.

Bug: 228902006
Test: atest PackageManagerTest
Change-Id: I7eaf0a972cc54d210bd220b3e6a54296598f67b6
parent 9a52759e
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -439,10 +439,6 @@ public interface Computer extends PackageDataSnapshot {

    boolean getBlockUninstallForUser(@NonNull String packageName, @UserIdInt int userId);

    @Nullable
    SparseArray<int[]> getBroadcastAllowList(@NonNull String packageName, @UserIdInt int[] userIds,
            boolean isInstantApp);

    @Nullable
    String getInstallerPackageName(@NonNull String packageName);

@@ -479,6 +475,16 @@ public interface Computer extends PackageDataSnapshot {

    boolean isPackageSignedByKeySetExactly(@NonNull String packageName, @NonNull KeySet ks);

    /**
     * See {@link AppsFilterSnapshot#getVisibilityAllowList(PackageStateInternal, int[], ArrayMap)}
     */
    @Nullable
    SparseArray<int[]> getVisibilityAllowLists(@NonNull String packageName,
            @UserIdInt int[] userIds);

    /**
     * See {@link AppsFilterSnapshot#getVisibilityAllowList(PackageStateInternal, int[], ArrayMap)}
     */
    @Nullable
    int[] getVisibilityAllowList(@NonNull String packageName, @UserIdInt int userId);

+10 −17
Original line number Diff line number Diff line
@@ -5024,20 +5024,6 @@ public class ComputerEngine implements Computer {
            return mSettings.getBlockUninstall(userId, packageName);
    }

    @Nullable
    @Override
    public SparseArray<int[]> getBroadcastAllowList(@NonNull String packageName,
            @UserIdInt int[] userIds, boolean isInstantApp) {
        if (isInstantApp) {
            return null;
        }
        PackageStateInternal setting = getPackageStateInternal(packageName, Process.SYSTEM_UID);
        if (setting == null) {
            return null;
        }
        return mAppsFilter.getVisibilityAllowList(setting, userIds, getPackageStates());
    }

    @Nullable
    @Override
    public String getInstallerPackageName(@NonNull String packageName) {
@@ -5316,14 +5302,21 @@ public class ComputerEngine implements Computer {

    @Nullable
    @Override
    public int[] getVisibilityAllowList(@NonNull String packageName, @UserIdInt int userId) {
    public SparseArray<int[]> getVisibilityAllowLists(@NonNull String packageName,
            @UserIdInt int[] userIds) {
        final PackageStateInternal ps =
                getPackageStateInternal(packageName, Process.SYSTEM_UID);
        if (ps == null) {
            return null;
        }
        final SparseArray<int[]> visibilityAllowList = mAppsFilter.getVisibilityAllowList(ps,
                new int[]{userId}, getPackageStates());
        return mAppsFilter.getVisibilityAllowList(ps, userIds, getPackageStates());
    }

    @Nullable
    @Override
    public int[] getVisibilityAllowList(@NonNull String packageName, @UserIdInt int userId) {
        final SparseArray<int[]> visibilityAllowList = getVisibilityAllowLists(packageName,
                new int[]{userId});
        return visibilityAllowList != null ? visibilityAllowList.get(userId) : null;
    }

+2 −2
Original line number Diff line number Diff line
@@ -3937,8 +3937,8 @@ public class PackageManagerService implements PackageSender, TestUtilityService
                snapshot.isInstantAppInternal(packageName, userId, Process.SYSTEM_UID);
        final int[] userIds = isInstantApp ? EMPTY_INT_ARRAY : new int[] { userId };
        final int[] instantUserIds = isInstantApp ? new int[] { userId } : EMPTY_INT_ARRAY;
        final SparseArray<int[]> broadcastAllowList = snapshot.getBroadcastAllowList(
                packageName, userIds, isInstantApp);
        final SparseArray<int[]> broadcastAllowList =
                isInstantApp ? null : snapshot.getVisibilityAllowLists(packageName, userIds);
        mHandler.post(() -> mBroadcastHelper.sendPackageChangedBroadcast(
                packageName, dontKillApp, componentNames, packageUid, reason, userIds,
                instantUserIds, broadcastAllowList));