• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 static com.android.server.pm.PackageManagerService.TAG;
20 
21 import android.util.ExceptionUtils;
22 import android.util.Slog;
23 
24 import com.android.server.pm.parsing.pkg.AndroidPackage;
25 
26 import java.util.ArrayList;
27 
28 final class PackageInstalledInfo {
29     String mName;
30     int mUid;
31     // The set of users that originally had this package installed.
32     int[] mOrigUsers;
33     // The set of users that now have this package installed.
34     int[] mNewUsers;
35     AndroidPackage mPkg;
36     int mReturnCode;
37     String mReturnMsg;
38     String mInstallerPackageName;
39     PackageRemovedInfo mRemovedInfo;
40     // The set of packages consuming this shared library or null if no consumers exist.
41     ArrayList<AndroidPackage> mLibraryConsumers;
42     PackageFreezer mFreezer;
43 
44     // In some error cases we want to convey more info back to the observer
45     String mOrigPackage;
46     String mOrigPermission;
47 
PackageInstalledInfo(int currentStatus)48     PackageInstalledInfo(int currentStatus) {
49         mReturnCode = currentStatus;
50         mUid = -1;
51         mPkg = null;
52         mRemovedInfo = null;
53     }
54 
setError(int code, String msg)55     public void setError(int code, String msg) {
56         setReturnCode(code);
57         setReturnMessage(msg);
58         Slog.w(TAG, msg);
59     }
60 
setError(String msg, PackageManagerException e)61     public void setError(String msg, PackageManagerException e) {
62         mReturnCode = e.error;
63         setReturnMessage(ExceptionUtils.getCompleteMessage(msg, e));
64         Slog.w(TAG, msg, e);
65     }
66 
setReturnCode(int returnCode)67     public void setReturnCode(int returnCode) {
68         mReturnCode = returnCode;
69     }
70 
setReturnMessage(String returnMsg)71     private void setReturnMessage(String returnMsg) {
72         mReturnMsg = returnMsg;
73     }
74 }
75