1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.server.pm;
18 
19 import android.util.SparseArray;
20 import android.util.SparseIntArray;
21 
22 import com.android.internal.util.ArrayUtils;
23 
24 final class PackageRemovedInfo {
25     String mRemovedPackage;
26     String mInstallerPackageName;
27     int mUid = -1;
28     boolean mIsAppIdRemoved = false;
29     int[] mOrigUsers;
30     int[] mRemovedUsers = null;
31     int[] mBroadcastUsers = null;
32     int[] mInstantUserIds = null;
33     SparseIntArray mInstallReasons;
34     SparseIntArray mUninstallReasons;
35     boolean mIsRemovedPackageSystemUpdate = false;
36     boolean mIsUpdate;
37     boolean mDataRemoved;
38     boolean mRemovedForAllUsers;
39     boolean mIsStaticSharedLib;
40     boolean mIsExternal;
41     long mRemovedPackageVersionCode;
42     // a two dimensional array mapping userId to the set of appIds that can receive notice
43     // of package changes
44     SparseArray<int[]> mBroadcastAllowList;
45     // Clean up resources deleted packages.
46     CleanUpArgs mArgs = null;
47     private static final int[] EMPTY_INT_ARRAY = new int[0];
48 
populateBroadcastUsers(PackageSetting deletedPackageSetting)49     public void populateBroadcastUsers(PackageSetting deletedPackageSetting) {
50         if (mRemovedUsers == null) {
51             mBroadcastUsers = null;
52             return;
53         }
54 
55         mBroadcastUsers = EMPTY_INT_ARRAY;
56         mInstantUserIds = EMPTY_INT_ARRAY;
57         for (int i = mRemovedUsers.length - 1; i >= 0; --i) {
58             final int userId = mRemovedUsers[i];
59             if (deletedPackageSetting.getInstantApp(userId)) {
60                 mInstantUserIds = ArrayUtils.appendInt(mInstantUserIds, userId);
61             } else {
62                 mBroadcastUsers = ArrayUtils.appendInt(mBroadcastUsers, userId);
63             }
64         }
65     }
66 }
67