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

Commit 3daefb4b authored by Todd Kennedy's avatar Todd Kennedy
Browse files

Don't broadcast PACKAGE_REMOVED for InstantApps

Change-Id: I7f054bbf844ad6c1b9a8aa20c5ba91cbf9a5db04
Fixes: 36444594
Test: Manual; uninstall AIA and see that the broadcast isn't sent
parent 46f847fb
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -17643,6 +17643,7 @@ public class PackageManagerService extends IPackageManager.Stub {
        int removedAppId = -1;
        int[] origUsers;
        int[] removedUsers = null;
        int[] broadcastUsers = null;
        SparseArray<Integer> installReasons;
        boolean isRemovedPackageSystemUpdate = false;
        boolean isUpdate;
@@ -17716,16 +17717,16 @@ public class PackageManagerService extends IPackageManager.Stub {
            extras.putBoolean(Intent.EXTRA_REMOVED_FOR_ALL_USERS, removedForAllUsers);
            if (removedPackage != null) {
                sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED, removedPackage,
                        extras, 0, null, null, removedUsers);
                        extras, 0, null, null, broadcastUsers);
                if (dataRemoved && !isRemovedPackageSystemUpdate) {
                    sendPackageBroadcast(Intent.ACTION_PACKAGE_FULLY_REMOVED,
                            removedPackage, extras, Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND,
                            null, null, removedUsers);
                            null, null, broadcastUsers);
                }
            }
            if (removedAppId >= 0) {
                sendPackageBroadcast(Intent.ACTION_UID_REMOVED, null, extras, 0, null, null,
                        removedUsers);
                        broadcastUsers);
            }
        }
    }
@@ -17754,6 +17755,20 @@ public class PackageManagerService extends IPackageManager.Stub {
                outInfo.removedUsers = deletedPs != null
                        ? deletedPs.queryInstalledUsers(sUserManager.getUserIds(), true)
                        : null;
                if (outInfo.removedUsers == null) {
                    outInfo.broadcastUsers = null;
                } else {
                    outInfo.broadcastUsers = EMPTY_INT_ARRAY;
                    int[] allUsers = outInfo.removedUsers;
                    for (int i = allUsers.length - 1; i >= 0; --i) {
                        final int userId = allUsers[i];
                        if (deletedPs.getInstantApp(userId)) {
                            continue;
                        }
                        outInfo.broadcastUsers =
                                ArrayUtils.appendInt(outInfo.broadcastUsers, userId);
                    }
                }
            }
        }