blob: 5a91e94781d7ec0120408306f3295b68b4f63749 [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
Adam Lesinskiab56b9d2017-11-14 00:50:18 -080019import android.annotation.IntDef;
Alan Viveretteb6a25732017-11-21 14:49:24 -050020import android.annotation.Nullable;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.os.Parcel;
22import android.os.Parcelable;
23
Adam Lesinskiab56b9d2017-11-14 00:50:18 -080024import java.lang.annotation.Retention;
25import java.lang.annotation.RetentionPolicy;
26
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027/**
28 * Overall information about the contents of a package. This corresponds
29 * to all of the information collected from AndroidManifest.xml.
30 */
31public class PackageInfo implements Parcelable {
32 /**
33 * The name of this package. From the <manifest> tag's "name"
34 * attribute.
35 */
36 public String packageName;
37
38 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -070039 * The names of any installed split APKs for this package.
40 */
41 public String[] splitNames;
42
43 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -070044 * @deprecated Use {@link #getLongVersionCode()} instead, which includes both
45 * this and the additional
46 * {@link android.R.styleable#AndroidManifest_versionCodeMajor versionCodeMajor} attribute.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080047 * The version number of this package, as specified by the <manifest>
48 * tag's {@link android.R.styleable#AndroidManifest_versionCode versionCode}
49 * attribute.
Dianne Hackborn3accca02013-09-20 09:32:11 -070050 * @see #getLongVersionCode()
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080051 */
Dianne Hackborn3accca02013-09-20 09:32:11 -070052 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080053 public int versionCode;
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -080054
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -070056 * @hide
57 * The major version number of this package, as specified by the <manifest>
58 * tag's {@link android.R.styleable#AndroidManifest_versionCode versionCodeMajor}
59 * attribute.
60 * @see #getLongVersionCode()
61 */
62 public int versionCodeMajor;
63
64 /**
65 * Return {@link android.R.styleable#AndroidManifest_versionCode versionCode} and
66 * {@link android.R.styleable#AndroidManifest_versionCodeMajor versionCodeMajor} combined
67 * together as a single long value. The
68 * {@link android.R.styleable#AndroidManifest_versionCodeMajor versionCodeMajor} is placed in
69 * the upper 32 bits.
70 */
71 public long getLongVersionCode() {
72 return composeLongVersionCode(versionCodeMajor, versionCode);
73 }
74
75 /**
76 * Set the full version code in this PackageInfo, updating {@link #versionCode}
77 * with the lower bits.
78 * @see #getLongVersionCode()
79 */
80 public void setLongVersionCode(long longVersionCode) {
81 versionCodeMajor = (int) (longVersionCode>>32);
82 versionCode = (int) longVersionCode;
83 }
84
85 /**
86 * @hide Internal implementation for composing a minor and major version code in to
87 * a single long version code.
88 */
89 public static long composeLongVersionCode(int major, int minor) {
90 return (((long) major) << 32) | (((long) minor) & 0xffffffffL);
91 }
92
93 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080094 * The version name of this package, as specified by the &lt;manifest&gt;
95 * tag's {@link android.R.styleable#AndroidManifest_versionName versionName}
96 * attribute.
97 */
98 public String versionName;
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -080099
100 /**
101 * The revision number of the base APK for this package, as specified by the
102 * &lt;manifest&gt; tag's
103 * {@link android.R.styleable#AndroidManifest_revisionCode revisionCode}
104 * attribute.
105 */
106 public int baseRevisionCode;
107
108 /**
109 * The revision number of any split APKs for this package, as specified by
110 * the &lt;manifest&gt; tag's
111 * {@link android.R.styleable#AndroidManifest_revisionCode revisionCode}
112 * attribute. Indexes are a 1:1 mapping against {@link #splitNames}.
113 */
114 public int[] splitRevisionCodes;
115
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800116 /**
117 * The shared user ID name of this package, as specified by the &lt;manifest&gt;
118 * tag's {@link android.R.styleable#AndroidManifest_sharedUserId sharedUserId}
119 * attribute.
120 */
121 public String sharedUserId;
122
123 /**
124 * The shared user ID label of this package, as specified by the &lt;manifest&gt;
125 * tag's {@link android.R.styleable#AndroidManifest_sharedUserLabel sharedUserLabel}
126 * attribute.
127 */
128 public int sharedUserLabel;
129
130 /**
131 * Information collected from the &lt;application&gt; tag, or null if
132 * there was none.
133 */
134 public ApplicationInfo applicationInfo;
135
136 /**
Dianne Hackborn78d6883692010-10-07 01:12:46 -0700137 * The time at which the app was first installed. Units are as
138 * per {@link System#currentTimeMillis()}.
139 */
140 public long firstInstallTime;
141
142 /**
143 * The time at which the app was last updated. Units are as
144 * per {@link System#currentTimeMillis()}.
145 */
146 public long lastUpdateTime;
147
148 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800149 * All kernel group-IDs that have been assigned to this package.
150 * This is only filled in if the flag {@link PackageManager#GET_GIDS} was set.
151 */
152 public int[] gids;
153
154 /**
155 * Array of all {@link android.R.styleable#AndroidManifestActivity
156 * &lt;activity&gt;} tags included under &lt;application&gt;,
157 * or null if there were none. This is only filled in if the flag
158 * {@link PackageManager#GET_ACTIVITIES} was set.
159 */
160 public ActivityInfo[] activities;
161
162 /**
163 * Array of all {@link android.R.styleable#AndroidManifestReceiver
164 * &lt;receiver&gt;} tags included under &lt;application&gt;,
165 * or null if there were none. This is only filled in if the flag
166 * {@link PackageManager#GET_RECEIVERS} was set.
167 */
168 public ActivityInfo[] receivers;
169
170 /**
171 * Array of all {@link android.R.styleable#AndroidManifestService
172 * &lt;service&gt;} tags included under &lt;application&gt;,
173 * or null if there were none. This is only filled in if the flag
174 * {@link PackageManager#GET_SERVICES} was set.
175 */
176 public ServiceInfo[] services;
177
178 /**
179 * Array of all {@link android.R.styleable#AndroidManifestProvider
180 * &lt;provider&gt;} tags included under &lt;application&gt;,
181 * or null if there were none. This is only filled in if the flag
182 * {@link PackageManager#GET_PROVIDERS} was set.
183 */
184 public ProviderInfo[] providers;
185
186 /**
187 * Array of all {@link android.R.styleable#AndroidManifestInstrumentation
188 * &lt;instrumentation&gt;} tags included under &lt;manifest&gt;,
189 * or null if there were none. This is only filled in if the flag
190 * {@link PackageManager#GET_INSTRUMENTATION} was set.
191 */
192 public InstrumentationInfo[] instrumentation;
Svet Ganov67882122016-12-11 16:36:34 -0800193
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800194 /**
195 * Array of all {@link android.R.styleable#AndroidManifestPermission
196 * &lt;permission&gt;} tags included under &lt;manifest&gt;,
197 * or null if there were none. This is only filled in if the flag
198 * {@link PackageManager#GET_PERMISSIONS} was set.
199 */
200 public PermissionInfo[] permissions;
Svet Ganov67882122016-12-11 16:36:34 -0800201
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800202 /**
203 * Array of all {@link android.R.styleable#AndroidManifestUsesPermission
204 * &lt;uses-permission&gt;} tags included under &lt;manifest&gt;,
205 * or null if there were none. This is only filled in if the flag
206 * {@link PackageManager#GET_PERMISSIONS} was set. This list includes
207 * all permissions requested, even those that were not granted or known
208 * by the system at install time.
209 */
210 public String[] requestedPermissions;
Svet Ganov67882122016-12-11 16:36:34 -0800211
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800212 /**
Dianne Hackborne639da72012-02-21 15:11:13 -0800213 * Array of flags of all {@link android.R.styleable#AndroidManifestUsesPermission
214 * &lt;uses-permission&gt;} tags included under &lt;manifest&gt;,
215 * or null if there were none. This is only filled in if the flag
216 * {@link PackageManager#GET_PERMISSIONS} was set. Each value matches
217 * the corresponding entry in {@link #requestedPermissions}, and will have
Svetoslavc6d1c342015-02-26 14:44:43 -0800218 * the flag {@link #REQUESTED_PERMISSION_GRANTED} set as appropriate.
Dianne Hackborne639da72012-02-21 15:11:13 -0800219 */
220 public int[] requestedPermissionsFlags;
221
222 /**
223 * Flag for {@link #requestedPermissionsFlags}: the requested permission
224 * is required for the application to run; the user can not optionally
Nick Kralevich32eb5b182013-04-11 10:20:09 -0700225 * disable it. Currently all permissions are required.
Svetoslavc6d1c342015-02-26 14:44:43 -0800226 *
227 * @removed We do not support required permissions.
Dianne Hackborne639da72012-02-21 15:11:13 -0800228 */
229 public static final int REQUESTED_PERMISSION_REQUIRED = 1<<0;
230
231 /**
232 * Flag for {@link #requestedPermissionsFlags}: the requested permission
233 * is currently granted to the application.
234 */
235 public static final int REQUESTED_PERMISSION_GRANTED = 1<<1;
236
237 /**
Svetoslav Ganovcdd685c2017-08-22 14:35:04 -0700238 * Array of all signatures read from the package file. This is only filled
239 * in if the flag {@link PackageManager#GET_SIGNATURES} was set. A package
240 * must be singed with at least one certificate which is at position zero.
241 * The package can be signed with additional certificates which appear as
242 * subsequent entries.
243 *
244 * <strong>Note:</strong> Signature ordering is not guaranteed to be
245 * stable which means that a package signed with certificates A and B is
246 * equivalent to being signed with certificates B and A. This means that
247 * in case multiple signatures are reported you cannot assume the one at
248 * the first position to be the same across updates.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800249 */
250 public Signature[] signatures;
251
252 /**
253 * Application specified preferred configuration
254 * {@link android.R.styleable#AndroidManifestUsesConfiguration
255 * &lt;uses-configuration&gt;} tags included under &lt;manifest&gt;,
256 * or null if there were none. This is only filled in if the flag
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700257 * {@link PackageManager#GET_CONFIGURATIONS} was set.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800258 */
259 public ConfigurationInfo[] configPreferences;
260
Dianne Hackborn49237342009-08-27 20:08:01 -0700261 /**
Jeff Sharkeyda96e132014-07-15 14:54:09 -0700262 * Features that this application has requested.
263 *
264 * @see FeatureInfo#FLAG_REQUIRED
Dianne Hackborn49237342009-08-27 20:08:01 -0700265 */
266 public FeatureInfo[] reqFeatures;
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800267
268 /**
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700269 * Groups of features that this application has requested.
270 * Each group contains a set of features that are required.
271 * A device must match the features listed in {@link #reqFeatures} and one
272 * or more FeatureGroups in order to have satisfied the feature requirement.
273 *
274 * @see FeatureInfo#FLAG_REQUIRED
275 */
276 public FeatureGroupInfo[] featureGroups;
277
278 /**
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800279 * Constant corresponding to <code>auto</code> in
280 * the {@link android.R.attr#installLocation} attribute.
281 * @hide
282 */
Suchi Amalapurapu90d8ee62010-03-18 11:38:35 -0700283 public static final int INSTALL_LOCATION_UNSPECIFIED = -1;
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700284
Suchi Amalapurapu90d8ee62010-03-18 11:38:35 -0700285 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700286 * Constant corresponding to <code>auto</code> in the
287 * {@link android.R.attr#installLocation} attribute.
Suchi Amalapurapu90d8ee62010-03-18 11:38:35 -0700288 */
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800289 public static final int INSTALL_LOCATION_AUTO = 0;
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700290
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800291 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700292 * Constant corresponding to <code>internalOnly</code> in the
293 * {@link android.R.attr#installLocation} attribute.
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800294 */
295 public static final int INSTALL_LOCATION_INTERNAL_ONLY = 1;
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700296
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800297 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700298 * Constant corresponding to <code>preferExternal</code> in the
299 * {@link android.R.attr#installLocation} attribute.
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800300 */
301 public static final int INSTALL_LOCATION_PREFER_EXTERNAL = 2;
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700302
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800303 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700304 * The install location requested by the package. From the
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800305 * {@link android.R.attr#installLocation} attribute, one of
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700306 * {@link #INSTALL_LOCATION_AUTO}, {@link #INSTALL_LOCATION_INTERNAL_ONLY},
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800307 * {@link #INSTALL_LOCATION_PREFER_EXTERNAL}
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800308 */
309 public int installLocation = INSTALL_LOCATION_INTERNAL_ONLY;
Amith Yamasanidf2e92a2013-03-01 17:04:38 -0800310
311 /** @hide */
Todd Kennedy7c8addf2017-06-27 14:13:55 -0700312 public boolean isStub;
313
314 /** @hide */
Jeff Hao272bf3a2014-10-08 13:34:43 -0700315 public boolean coreApp;
316
317 /** @hide */
Amith Yamasanidf2e92a2013-03-01 17:04:38 -0800318 public boolean requiredForAllUsers;
319
Amith Yamasani0ac1fc92013-03-27 18:56:08 -0700320 /** @hide */
321 public String restrictedAccountType;
322
Amith Yamasaniccbe3892013-04-12 17:52:42 -0700323 /** @hide */
324 public String requiredAccountType;
325
Mårten Kongstad48d22322014-01-31 14:43:27 +0100326 /**
327 * What package, if any, this package will overlay.
328 *
329 * Package name of target package, or null.
330 * @hide
331 */
332 public String overlayTarget;
333
Jaekyun Seok04342892017-03-02 15:24:19 +0900334 /** @hide */
Jaekyun Seok42d53f62017-04-10 13:48:58 +0900335 public int overlayPriority;
336
Adam Lesinskiab56b9d2017-11-14 00:50:18 -0800337 /**
338 * Flag for use with {@link #mOverlayFlags}. Marks the overlay as static, meaning it cannot
339 * be enabled/disabled at runtime.
340 */
341 static final int FLAG_OVERLAY_STATIC = 1 << 1;
342
343 /**
344 * Flag for use with {@link #mOverlayFlags}. Marks the overlay as trusted (not 3rd party).
345 */
346 static final int FLAG_OVERLAY_TRUSTED = 1 << 2;
347
348 @IntDef(flag = true, prefix = "FLAG_OVERLAY_", value = {
349 FLAG_OVERLAY_STATIC,
350 FLAG_OVERLAY_TRUSTED
351 })
352 @Retention(RetentionPolicy.SOURCE)
353 @interface OverlayFlags {}
354
355 /**
356 * Modifiers that affect the state of this overlay. See {@link #FLAG_OVERLAY_STATIC},
357 * {@link #FLAG_OVERLAY_TRUSTED}.
358 */
359 @OverlayFlags int mOverlayFlags;
Jaekyun Seok04342892017-03-02 15:24:19 +0900360
Alan Viveretteb6a25732017-11-21 14:49:24 -0500361 /**
362 * The user-visible SDK version (ex. 26) of the framework against which the application claims
363 * to have been compiled, or {@code 0} if not specified.
364 * <p>
365 * This property is the compile-time equivalent of
366 * {@link android.os.Build.VERSION#SDK_INT Build.VERSION.SDK_INT}.
367 *
368 * @hide For platform use only; we don't expect developers to need to read this value.
369 */
370 public int compileSdkVersion;
371
372 /**
373 * The development codename (ex. "O", "REL") of the framework against which the application
374 * claims to have been compiled, or {@code null} if not specified.
375 * <p>
376 * This property is the compile-time equivalent of
377 * {@link android.os.Build.VERSION#CODENAME Build.VERSION.CODENAME}.
378 *
379 * @hide For platform use only; we don't expect developers to need to read this value.
380 */
381 @Nullable
382 public String compileSdkVersionCodename;
383
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800384 public PackageInfo() {
385 }
386
Adam Lesinskiab56b9d2017-11-14 00:50:18 -0800387 /**
388 * Returns true if the package is a valid Runtime Overlay package.
389 * @hide
390 */
391 public boolean isOverlayPackage() {
392 return overlayTarget != null && (mOverlayFlags & FLAG_OVERLAY_TRUSTED) != 0;
393 }
394
395 /**
396 * Returns true if the package is a valid static Runtime Overlay package. Static overlays
397 * are not updatable outside of a system update and are safe to load in the system process.
398 * @hide
399 */
400 public boolean isStaticOverlayPackage() {
401 return overlayTarget != null && (mOverlayFlags & FLAG_OVERLAY_STATIC) != 0;
402 }
403
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800404 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800405 public String toString() {
406 return "PackageInfo{"
407 + Integer.toHexString(System.identityHashCode(this))
408 + " " + packageName + "}";
409 }
410
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800411 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800412 public int describeContents() {
413 return 0;
414 }
415
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800416 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800417 public void writeToParcel(Parcel dest, int parcelableFlags) {
418 dest.writeString(packageName);
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700419 dest.writeStringArray(splitNames);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800420 dest.writeInt(versionCode);
Dianne Hackborn3accca02013-09-20 09:32:11 -0700421 dest.writeInt(versionCodeMajor);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800422 dest.writeString(versionName);
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800423 dest.writeInt(baseRevisionCode);
424 dest.writeIntArray(splitRevisionCodes);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800425 dest.writeString(sharedUserId);
426 dest.writeInt(sharedUserLabel);
427 if (applicationInfo != null) {
428 dest.writeInt(1);
429 applicationInfo.writeToParcel(dest, parcelableFlags);
430 } else {
431 dest.writeInt(0);
432 }
Dianne Hackborn78d6883692010-10-07 01:12:46 -0700433 dest.writeLong(firstInstallTime);
434 dest.writeLong(lastUpdateTime);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800435 dest.writeIntArray(gids);
Christopher Tateb9116762015-09-09 18:46:31 -0700436 dest.writeTypedArray(activities, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
437 dest.writeTypedArray(receivers, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
438 dest.writeTypedArray(services, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
439 dest.writeTypedArray(providers, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800440 dest.writeTypedArray(instrumentation, parcelableFlags);
441 dest.writeTypedArray(permissions, parcelableFlags);
442 dest.writeStringArray(requestedPermissions);
Dianne Hackborne639da72012-02-21 15:11:13 -0800443 dest.writeIntArray(requestedPermissionsFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800444 dest.writeTypedArray(signatures, parcelableFlags);
445 dest.writeTypedArray(configPreferences, parcelableFlags);
Dianne Hackborn49237342009-08-27 20:08:01 -0700446 dest.writeTypedArray(reqFeatures, parcelableFlags);
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700447 dest.writeTypedArray(featureGroups, parcelableFlags);
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800448 dest.writeInt(installLocation);
Todd Kennedy7c8addf2017-06-27 14:13:55 -0700449 dest.writeInt(isStub ? 1 : 0);
Jeff Hao272bf3a2014-10-08 13:34:43 -0700450 dest.writeInt(coreApp ? 1 : 0);
Amith Yamasanidf2e92a2013-03-01 17:04:38 -0800451 dest.writeInt(requiredForAllUsers ? 1 : 0);
Amith Yamasani0ac1fc92013-03-27 18:56:08 -0700452 dest.writeString(restrictedAccountType);
Amith Yamasaniccbe3892013-04-12 17:52:42 -0700453 dest.writeString(requiredAccountType);
Mårten Kongstad48d22322014-01-31 14:43:27 +0100454 dest.writeString(overlayTarget);
Jaekyun Seok42d53f62017-04-10 13:48:58 +0900455 dest.writeInt(overlayPriority);
Adam Lesinskiab56b9d2017-11-14 00:50:18 -0800456 dest.writeInt(mOverlayFlags);
Alan Viveretteb6a25732017-11-21 14:49:24 -0500457 dest.writeInt(compileSdkVersion);
458 dest.writeString(compileSdkVersionCodename);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800459 }
460
461 public static final Parcelable.Creator<PackageInfo> CREATOR
462 = new Parcelable.Creator<PackageInfo>() {
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800463 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800464 public PackageInfo createFromParcel(Parcel source) {
465 return new PackageInfo(source);
466 }
467
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800468 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800469 public PackageInfo[] newArray(int size) {
470 return new PackageInfo[size];
471 }
472 };
473
474 private PackageInfo(Parcel source) {
475 packageName = source.readString();
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800476 splitNames = source.createStringArray();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800477 versionCode = source.readInt();
Dianne Hackborn3accca02013-09-20 09:32:11 -0700478 versionCodeMajor = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800479 versionName = source.readString();
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800480 baseRevisionCode = source.readInt();
481 splitRevisionCodes = source.createIntArray();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800482 sharedUserId = source.readString();
483 sharedUserLabel = source.readInt();
484 int hasApp = source.readInt();
485 if (hasApp != 0) {
486 applicationInfo = ApplicationInfo.CREATOR.createFromParcel(source);
487 }
Dianne Hackborn78d6883692010-10-07 01:12:46 -0700488 firstInstallTime = source.readLong();
489 lastUpdateTime = source.readLong();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800490 gids = source.createIntArray();
491 activities = source.createTypedArray(ActivityInfo.CREATOR);
492 receivers = source.createTypedArray(ActivityInfo.CREATOR);
493 services = source.createTypedArray(ServiceInfo.CREATOR);
494 providers = source.createTypedArray(ProviderInfo.CREATOR);
495 instrumentation = source.createTypedArray(InstrumentationInfo.CREATOR);
496 permissions = source.createTypedArray(PermissionInfo.CREATOR);
497 requestedPermissions = source.createStringArray();
Dianne Hackborne639da72012-02-21 15:11:13 -0800498 requestedPermissionsFlags = source.createIntArray();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800499 signatures = source.createTypedArray(Signature.CREATOR);
500 configPreferences = source.createTypedArray(ConfigurationInfo.CREATOR);
Dianne Hackborn49237342009-08-27 20:08:01 -0700501 reqFeatures = source.createTypedArray(FeatureInfo.CREATOR);
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700502 featureGroups = source.createTypedArray(FeatureGroupInfo.CREATOR);
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800503 installLocation = source.readInt();
Todd Kennedy7c8addf2017-06-27 14:13:55 -0700504 isStub = source.readInt() != 0;
Jeff Hao272bf3a2014-10-08 13:34:43 -0700505 coreApp = source.readInt() != 0;
Amith Yamasanidf2e92a2013-03-01 17:04:38 -0800506 requiredForAllUsers = source.readInt() != 0;
Amith Yamasani0ac1fc92013-03-27 18:56:08 -0700507 restrictedAccountType = source.readString();
Amith Yamasaniccbe3892013-04-12 17:52:42 -0700508 requiredAccountType = source.readString();
Mårten Kongstad48d22322014-01-31 14:43:27 +0100509 overlayTarget = source.readString();
Jaekyun Seok42d53f62017-04-10 13:48:58 +0900510 overlayPriority = source.readInt();
Adam Lesinskiab56b9d2017-11-14 00:50:18 -0800511 mOverlayFlags = source.readInt();
Alan Viveretteb6a25732017-11-21 14:49:24 -0500512 compileSdkVersion = source.readInt();
513 compileSdkVersionCodename = source.readString();
Christopher Tateb9116762015-09-09 18:46:31 -0700514
515 // The component lists were flattened with the redundant ApplicationInfo
516 // instances omitted. Distribute the canonical one here as appropriate.
517 if (applicationInfo != null) {
518 propagateApplicationInfo(applicationInfo, activities);
519 propagateApplicationInfo(applicationInfo, receivers);
520 propagateApplicationInfo(applicationInfo, services);
521 propagateApplicationInfo(applicationInfo, providers);
522 }
523 }
524
525 private void propagateApplicationInfo(ApplicationInfo appInfo, ComponentInfo[] components) {
526 if (components != null) {
527 for (ComponentInfo ci : components) {
528 ci.applicationInfo = appInfo;
529 }
530 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800531 }
532}