blob: cf0edcad7e2b213c714b8445bf48bd1085c12821 [file] [log] [blame]
Kenny Root15a4d2f2010-03-11 18:20:12 -08001/*
2 * Copyright (C) 2007 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
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080017package android.content.pm;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21
22/**
23 * Overall information about the contents of a package. This corresponds
24 * to all of the information collected from AndroidManifest.xml.
25 */
26public class PackageInfo implements Parcelable {
27 /**
28 * The name of this package. From the <manifest> tag's "name"
29 * attribute.
30 */
31 public String packageName;
32
33 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -070034 * The names of any installed split APKs for this package.
35 */
36 public String[] splitNames;
37
38 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039 * The version number of this package, as specified by the <manifest>
40 * tag's {@link android.R.styleable#AndroidManifest_versionCode versionCode}
41 * attribute.
42 */
43 public int versionCode;
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -080044
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045 /**
46 * The version name of this package, as specified by the <manifest>
47 * tag's {@link android.R.styleable#AndroidManifest_versionName versionName}
48 * attribute.
49 */
50 public String versionName;
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -080051
52 /**
53 * The revision number of the base APK for this package, as specified by the
54 * <manifest> tag's
55 * {@link android.R.styleable#AndroidManifest_revisionCode revisionCode}
56 * attribute.
57 */
58 public int baseRevisionCode;
59
60 /**
61 * The revision number of any split APKs for this package, as specified by
62 * the <manifest> tag's
63 * {@link android.R.styleable#AndroidManifest_revisionCode revisionCode}
64 * attribute. Indexes are a 1:1 mapping against {@link #splitNames}.
65 */
66 public int[] splitRevisionCodes;
67
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080068 /**
69 * The shared user ID name of this package, as specified by the <manifest>
70 * tag's {@link android.R.styleable#AndroidManifest_sharedUserId sharedUserId}
71 * attribute.
72 */
73 public String sharedUserId;
74
75 /**
76 * The shared user ID label of this package, as specified by the <manifest>
77 * tag's {@link android.R.styleable#AndroidManifest_sharedUserLabel sharedUserLabel}
78 * attribute.
79 */
80 public int sharedUserLabel;
81
82 /**
83 * Information collected from the <application> tag, or null if
84 * there was none.
85 */
86 public ApplicationInfo applicationInfo;
87
88 /**
Dianne Hackborn78d6883692010-10-07 01:12:46 -070089 * The time at which the app was first installed. Units are as
90 * per {@link System#currentTimeMillis()}.
91 */
92 public long firstInstallTime;
93
94 /**
95 * The time at which the app was last updated. Units are as
96 * per {@link System#currentTimeMillis()}.
97 */
98 public long lastUpdateTime;
99
100 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800101 * All kernel group-IDs that have been assigned to this package.
102 * This is only filled in if the flag {@link PackageManager#GET_GIDS} was set.
103 */
104 public int[] gids;
105
106 /**
107 * Array of all {@link android.R.styleable#AndroidManifestActivity
108 * <activity>} tags included under <application>,
109 * or null if there were none. This is only filled in if the flag
110 * {@link PackageManager#GET_ACTIVITIES} was set.
111 */
112 public ActivityInfo[] activities;
113
114 /**
115 * Array of all {@link android.R.styleable#AndroidManifestReceiver
116 * <receiver>} tags included under <application>,
117 * or null if there were none. This is only filled in if the flag
118 * {@link PackageManager#GET_RECEIVERS} was set.
119 */
120 public ActivityInfo[] receivers;
121
122 /**
123 * Array of all {@link android.R.styleable#AndroidManifestService
124 * <service>} tags included under <application>,
125 * or null if there were none. This is only filled in if the flag
126 * {@link PackageManager#GET_SERVICES} was set.
127 */
128 public ServiceInfo[] services;
129
130 /**
131 * Array of all {@link android.R.styleable#AndroidManifestProvider
132 * <provider>} tags included under <application>,
133 * or null if there were none. This is only filled in if the flag
134 * {@link PackageManager#GET_PROVIDERS} was set.
135 */
136 public ProviderInfo[] providers;
137
138 /**
139 * Array of all {@link android.R.styleable#AndroidManifestInstrumentation
140 * <instrumentation>} tags included under <manifest>,
141 * or null if there were none. This is only filled in if the flag
142 * {@link PackageManager#GET_INSTRUMENTATION} was set.
143 */
144 public InstrumentationInfo[] instrumentation;
Svet Ganov67882122016-12-11 16:36:34 -0800145
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800146 /**
147 * Array of all {@link android.R.styleable#AndroidManifestPermission
148 * <permission>} tags included under <manifest>,
149 * or null if there were none. This is only filled in if the flag
150 * {@link PackageManager#GET_PERMISSIONS} was set.
151 */
152 public PermissionInfo[] permissions;
Svet Ganov67882122016-12-11 16:36:34 -0800153
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800154 /**
155 * Array of all {@link android.R.styleable#AndroidManifestUsesPermission
156 * <uses-permission>} tags included under <manifest>,
157 * or null if there were none. This is only filled in if the flag
158 * {@link PackageManager#GET_PERMISSIONS} was set. This list includes
159 * all permissions requested, even those that were not granted or known
160 * by the system at install time.
161 */
162 public String[] requestedPermissions;
Svet Ganov67882122016-12-11 16:36:34 -0800163
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800164 /**
Dianne Hackborne639da72012-02-21 15:11:13 -0800165 * Array of flags of all {@link android.R.styleable#AndroidManifestUsesPermission
166 * <uses-permission>} tags included under <manifest>,
167 * or null if there were none. This is only filled in if the flag
168 * {@link PackageManager#GET_PERMISSIONS} was set. Each value matches
169 * the corresponding entry in {@link #requestedPermissions}, and will have
Svetoslavc6d1c342015-02-26 14:44:43 -0800170 * the flag {@link #REQUESTED_PERMISSION_GRANTED} set as appropriate.
Dianne Hackborne639da72012-02-21 15:11:13 -0800171 */
172 public int[] requestedPermissionsFlags;
173
174 /**
175 * Flag for {@link #requestedPermissionsFlags}: the requested permission
176 * is required for the application to run; the user can not optionally
Nick Kralevich32eb5b182013-04-11 10:20:09 -0700177 * disable it. Currently all permissions are required.
Svetoslavc6d1c342015-02-26 14:44:43 -0800178 *
179 * @removed We do not support required permissions.
Dianne Hackborne639da72012-02-21 15:11:13 -0800180 */
181 public static final int REQUESTED_PERMISSION_REQUIRED = 1<<0;
182
183 /**
184 * Flag for {@link #requestedPermissionsFlags}: the requested permission
185 * is currently granted to the application.
186 */
187 public static final int REQUESTED_PERMISSION_GRANTED = 1<<1;
188
189 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800190 * Array of all signatures read from the package file. This is only filled
191 * in if the flag {@link PackageManager#GET_SIGNATURES} was set.
192 */
193 public Signature[] signatures;
194
195 /**
196 * Application specified preferred configuration
197 * {@link android.R.styleable#AndroidManifestUsesConfiguration
198 * &lt;uses-configuration&gt;} tags included under &lt;manifest&gt;,
199 * or null if there were none. This is only filled in if the flag
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700200 * {@link PackageManager#GET_CONFIGURATIONS} was set.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800201 */
202 public ConfigurationInfo[] configPreferences;
203
Dianne Hackborn49237342009-08-27 20:08:01 -0700204 /**
Jeff Sharkeyda96e132014-07-15 14:54:09 -0700205 * Features that this application has requested.
206 *
207 * @see FeatureInfo#FLAG_REQUIRED
Dianne Hackborn49237342009-08-27 20:08:01 -0700208 */
209 public FeatureInfo[] reqFeatures;
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800210
211 /**
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700212 * Groups of features that this application has requested.
213 * Each group contains a set of features that are required.
214 * A device must match the features listed in {@link #reqFeatures} and one
215 * or more FeatureGroups in order to have satisfied the feature requirement.
216 *
217 * @see FeatureInfo#FLAG_REQUIRED
218 */
219 public FeatureGroupInfo[] featureGroups;
220
221 /**
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800222 * Constant corresponding to <code>auto</code> in
223 * the {@link android.R.attr#installLocation} attribute.
224 * @hide
225 */
Suchi Amalapurapu90d8ee62010-03-18 11:38:35 -0700226 public static final int INSTALL_LOCATION_UNSPECIFIED = -1;
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700227
Suchi Amalapurapu90d8ee62010-03-18 11:38:35 -0700228 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700229 * Constant corresponding to <code>auto</code> in the
230 * {@link android.R.attr#installLocation} attribute.
Suchi Amalapurapu90d8ee62010-03-18 11:38:35 -0700231 */
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800232 public static final int INSTALL_LOCATION_AUTO = 0;
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700233
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800234 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700235 * Constant corresponding to <code>internalOnly</code> in the
236 * {@link android.R.attr#installLocation} attribute.
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800237 */
238 public static final int INSTALL_LOCATION_INTERNAL_ONLY = 1;
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700239
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800240 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700241 * Constant corresponding to <code>preferExternal</code> in the
242 * {@link android.R.attr#installLocation} attribute.
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800243 */
244 public static final int INSTALL_LOCATION_PREFER_EXTERNAL = 2;
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700245
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800246 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700247 * The install location requested by the package. From the
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800248 * {@link android.R.attr#installLocation} attribute, one of
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700249 * {@link #INSTALL_LOCATION_AUTO}, {@link #INSTALL_LOCATION_INTERNAL_ONLY},
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800250 * {@link #INSTALL_LOCATION_PREFER_EXTERNAL}
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800251 */
252 public int installLocation = INSTALL_LOCATION_INTERNAL_ONLY;
Amith Yamasanidf2e92a2013-03-01 17:04:38 -0800253
254 /** @hide */
Todd Kennedy7c8addf2017-06-27 14:13:55 -0700255 public boolean isStub;
256
257 /** @hide */
Jeff Hao272bf3a2014-10-08 13:34:43 -0700258 public boolean coreApp;
259
260 /** @hide */
Amith Yamasanidf2e92a2013-03-01 17:04:38 -0800261 public boolean requiredForAllUsers;
262
Amith Yamasani0ac1fc92013-03-27 18:56:08 -0700263 /** @hide */
264 public String restrictedAccountType;
265
Amith Yamasaniccbe3892013-04-12 17:52:42 -0700266 /** @hide */
267 public String requiredAccountType;
268
Mårten Kongstad48d22322014-01-31 14:43:27 +0100269 /**
270 * What package, if any, this package will overlay.
271 *
272 * Package name of target package, or null.
273 * @hide
274 */
275 public String overlayTarget;
276
Jaekyun Seok04342892017-03-02 15:24:19 +0900277 /** @hide */
Jaekyun Seok42d53f62017-04-10 13:48:58 +0900278 public int overlayPriority;
279
280 /** @hide */
Jaekyun Seok04342892017-03-02 15:24:19 +0900281 public boolean isStaticOverlay;
282
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800283 public PackageInfo() {
284 }
285
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800286 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800287 public String toString() {
288 return "PackageInfo{"
289 + Integer.toHexString(System.identityHashCode(this))
290 + " " + packageName + "}";
291 }
292
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800293 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800294 public int describeContents() {
295 return 0;
296 }
297
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800298 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800299 public void writeToParcel(Parcel dest, int parcelableFlags) {
300 dest.writeString(packageName);
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700301 dest.writeStringArray(splitNames);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800302 dest.writeInt(versionCode);
303 dest.writeString(versionName);
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800304 dest.writeInt(baseRevisionCode);
305 dest.writeIntArray(splitRevisionCodes);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800306 dest.writeString(sharedUserId);
307 dest.writeInt(sharedUserLabel);
308 if (applicationInfo != null) {
309 dest.writeInt(1);
310 applicationInfo.writeToParcel(dest, parcelableFlags);
311 } else {
312 dest.writeInt(0);
313 }
Dianne Hackborn78d6883692010-10-07 01:12:46 -0700314 dest.writeLong(firstInstallTime);
315 dest.writeLong(lastUpdateTime);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800316 dest.writeIntArray(gids);
Christopher Tateb9116762015-09-09 18:46:31 -0700317 dest.writeTypedArray(activities, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
318 dest.writeTypedArray(receivers, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
319 dest.writeTypedArray(services, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
320 dest.writeTypedArray(providers, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800321 dest.writeTypedArray(instrumentation, parcelableFlags);
322 dest.writeTypedArray(permissions, parcelableFlags);
323 dest.writeStringArray(requestedPermissions);
Dianne Hackborne639da72012-02-21 15:11:13 -0800324 dest.writeIntArray(requestedPermissionsFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800325 dest.writeTypedArray(signatures, parcelableFlags);
326 dest.writeTypedArray(configPreferences, parcelableFlags);
Dianne Hackborn49237342009-08-27 20:08:01 -0700327 dest.writeTypedArray(reqFeatures, parcelableFlags);
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700328 dest.writeTypedArray(featureGroups, parcelableFlags);
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800329 dest.writeInt(installLocation);
Todd Kennedy7c8addf2017-06-27 14:13:55 -0700330 dest.writeInt(isStub ? 1 : 0);
Jeff Hao272bf3a2014-10-08 13:34:43 -0700331 dest.writeInt(coreApp ? 1 : 0);
Amith Yamasanidf2e92a2013-03-01 17:04:38 -0800332 dest.writeInt(requiredForAllUsers ? 1 : 0);
Amith Yamasani0ac1fc92013-03-27 18:56:08 -0700333 dest.writeString(restrictedAccountType);
Amith Yamasaniccbe3892013-04-12 17:52:42 -0700334 dest.writeString(requiredAccountType);
Mårten Kongstad48d22322014-01-31 14:43:27 +0100335 dest.writeString(overlayTarget);
Jaekyun Seok04342892017-03-02 15:24:19 +0900336 dest.writeInt(isStaticOverlay ? 1 : 0);
Jaekyun Seok42d53f62017-04-10 13:48:58 +0900337 dest.writeInt(overlayPriority);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800338 }
339
340 public static final Parcelable.Creator<PackageInfo> CREATOR
341 = new Parcelable.Creator<PackageInfo>() {
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800342 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800343 public PackageInfo createFromParcel(Parcel source) {
344 return new PackageInfo(source);
345 }
346
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800347 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800348 public PackageInfo[] newArray(int size) {
349 return new PackageInfo[size];
350 }
351 };
352
353 private PackageInfo(Parcel source) {
354 packageName = source.readString();
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800355 splitNames = source.createStringArray();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800356 versionCode = source.readInt();
357 versionName = source.readString();
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800358 baseRevisionCode = source.readInt();
359 splitRevisionCodes = source.createIntArray();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800360 sharedUserId = source.readString();
361 sharedUserLabel = source.readInt();
362 int hasApp = source.readInt();
363 if (hasApp != 0) {
364 applicationInfo = ApplicationInfo.CREATOR.createFromParcel(source);
365 }
Dianne Hackborn78d6883692010-10-07 01:12:46 -0700366 firstInstallTime = source.readLong();
367 lastUpdateTime = source.readLong();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800368 gids = source.createIntArray();
369 activities = source.createTypedArray(ActivityInfo.CREATOR);
370 receivers = source.createTypedArray(ActivityInfo.CREATOR);
371 services = source.createTypedArray(ServiceInfo.CREATOR);
372 providers = source.createTypedArray(ProviderInfo.CREATOR);
373 instrumentation = source.createTypedArray(InstrumentationInfo.CREATOR);
374 permissions = source.createTypedArray(PermissionInfo.CREATOR);
375 requestedPermissions = source.createStringArray();
Dianne Hackborne639da72012-02-21 15:11:13 -0800376 requestedPermissionsFlags = source.createIntArray();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800377 signatures = source.createTypedArray(Signature.CREATOR);
378 configPreferences = source.createTypedArray(ConfigurationInfo.CREATOR);
Dianne Hackborn49237342009-08-27 20:08:01 -0700379 reqFeatures = source.createTypedArray(FeatureInfo.CREATOR);
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700380 featureGroups = source.createTypedArray(FeatureGroupInfo.CREATOR);
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800381 installLocation = source.readInt();
Todd Kennedy7c8addf2017-06-27 14:13:55 -0700382 isStub = source.readInt() != 0;
Jeff Hao272bf3a2014-10-08 13:34:43 -0700383 coreApp = source.readInt() != 0;
Amith Yamasanidf2e92a2013-03-01 17:04:38 -0800384 requiredForAllUsers = source.readInt() != 0;
Amith Yamasani0ac1fc92013-03-27 18:56:08 -0700385 restrictedAccountType = source.readString();
Amith Yamasaniccbe3892013-04-12 17:52:42 -0700386 requiredAccountType = source.readString();
Mårten Kongstad48d22322014-01-31 14:43:27 +0100387 overlayTarget = source.readString();
Jaekyun Seok04342892017-03-02 15:24:19 +0900388 isStaticOverlay = source.readInt() != 0;
Jaekyun Seok42d53f62017-04-10 13:48:58 +0900389 overlayPriority = source.readInt();
Christopher Tateb9116762015-09-09 18:46:31 -0700390
391 // The component lists were flattened with the redundant ApplicationInfo
392 // instances omitted. Distribute the canonical one here as appropriate.
393 if (applicationInfo != null) {
394 propagateApplicationInfo(applicationInfo, activities);
395 propagateApplicationInfo(applicationInfo, receivers);
396 propagateApplicationInfo(applicationInfo, services);
397 propagateApplicationInfo(applicationInfo, providers);
398 }
399 }
400
401 private void propagateApplicationInfo(ApplicationInfo appInfo, ComponentInfo[] components) {
402 if (components != null) {
403 for (ComponentInfo ci : components) {
404 ci.applicationInfo = appInfo;
405 }
406 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800407 }
408}