blob: cd8dc6338612c805b5764f933d15583bc0e3dadd [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
Alan Viveretteb6a25732017-11-21 14:49:24 -050019import android.annotation.Nullable;
Mathew Inwood1c77a112018-08-14 14:06:26 +010020import android.annotation.UnsupportedAppUsage;
Dario Frenie8129a32018-10-18 11:49:50 +010021import android.apex.ApexInfo;
Mathew Inwood55418ea2018-12-20 15:30:45 +000022import android.os.Build;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080023import android.os.Parcel;
24import android.os.Parcelable;
25
26/**
27 * Overall information about the contents of a package. This corresponds
28 * to all of the information collected from AndroidManifest.xml.
29 */
30public class PackageInfo implements Parcelable {
31 /**
32 * The name of this package. From the <manifest> tag's "name"
33 * attribute.
34 */
35 public String packageName;
36
37 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -070038 * The names of any installed split APKs for this package.
39 */
40 public String[] splitNames;
41
42 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -070043 * @deprecated Use {@link #getLongVersionCode()} instead, which includes both
44 * this and the additional
45 * {@link android.R.styleable#AndroidManifest_versionCodeMajor versionCodeMajor} attribute.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046 * The version number of this package, as specified by the <manifest>
47 * tag's {@link android.R.styleable#AndroidManifest_versionCode versionCode}
48 * attribute.
Dianne Hackborn3accca02013-09-20 09:32:11 -070049 * @see #getLongVersionCode()
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080050 */
Dianne Hackborn3accca02013-09-20 09:32:11 -070051 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052 public int versionCode;
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -080053
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080054 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -070055 * @hide
56 * The major version number of this package, as specified by the <manifest>
57 * tag's {@link android.R.styleable#AndroidManifest_versionCode versionCodeMajor}
58 * attribute.
59 * @see #getLongVersionCode()
60 */
61 public int versionCodeMajor;
62
63 /**
64 * Return {@link android.R.styleable#AndroidManifest_versionCode versionCode} and
65 * {@link android.R.styleable#AndroidManifest_versionCodeMajor versionCodeMajor} combined
66 * together as a single long value. The
67 * {@link android.R.styleable#AndroidManifest_versionCodeMajor versionCodeMajor} is placed in
68 * the upper 32 bits.
69 */
70 public long getLongVersionCode() {
71 return composeLongVersionCode(versionCodeMajor, versionCode);
72 }
73
74 /**
75 * Set the full version code in this PackageInfo, updating {@link #versionCode}
76 * with the lower bits.
77 * @see #getLongVersionCode()
78 */
79 public void setLongVersionCode(long longVersionCode) {
80 versionCodeMajor = (int) (longVersionCode>>32);
81 versionCode = (int) longVersionCode;
82 }
83
84 /**
85 * @hide Internal implementation for composing a minor and major version code in to
86 * a single long version code.
87 */
88 public static long composeLongVersionCode(int major, int minor) {
89 return (((long) major) << 32) | (((long) minor) & 0xffffffffL);
90 }
91
92 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080093 * The version name of this package, as specified by the &lt;manifest&gt;
94 * tag's {@link android.R.styleable#AndroidManifest_versionName versionName}
95 * attribute.
96 */
97 public String versionName;
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -080098
99 /**
100 * The revision number of the base APK for this package, as specified by the
101 * &lt;manifest&gt; tag's
102 * {@link android.R.styleable#AndroidManifest_revisionCode revisionCode}
103 * attribute.
104 */
105 public int baseRevisionCode;
106
107 /**
108 * The revision number of any split APKs for this package, as specified by
109 * the &lt;manifest&gt; tag's
110 * {@link android.R.styleable#AndroidManifest_revisionCode revisionCode}
111 * attribute. Indexes are a 1:1 mapping against {@link #splitNames}.
112 */
113 public int[] splitRevisionCodes;
114
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800115 /**
116 * The shared user ID name of this package, as specified by the &lt;manifest&gt;
117 * tag's {@link android.R.styleable#AndroidManifest_sharedUserId sharedUserId}
118 * attribute.
119 */
120 public String sharedUserId;
121
122 /**
123 * The shared user ID label of this package, as specified by the &lt;manifest&gt;
124 * tag's {@link android.R.styleable#AndroidManifest_sharedUserLabel sharedUserLabel}
125 * attribute.
126 */
127 public int sharedUserLabel;
128
129 /**
130 * Information collected from the &lt;application&gt; tag, or null if
131 * there was none.
132 */
133 public ApplicationInfo applicationInfo;
134
135 /**
Dianne Hackborn78d6883692010-10-07 01:12:46 -0700136 * The time at which the app was first installed. Units are as
137 * per {@link System#currentTimeMillis()}.
138 */
139 public long firstInstallTime;
140
141 /**
142 * The time at which the app was last updated. Units are as
143 * per {@link System#currentTimeMillis()}.
144 */
145 public long lastUpdateTime;
146
147 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800148 * All kernel group-IDs that have been assigned to this package.
149 * This is only filled in if the flag {@link PackageManager#GET_GIDS} was set.
150 */
151 public int[] gids;
152
153 /**
154 * Array of all {@link android.R.styleable#AndroidManifestActivity
155 * &lt;activity&gt;} tags included under &lt;application&gt;,
156 * or null if there were none. This is only filled in if the flag
157 * {@link PackageManager#GET_ACTIVITIES} was set.
158 */
159 public ActivityInfo[] activities;
160
161 /**
162 * Array of all {@link android.R.styleable#AndroidManifestReceiver
163 * &lt;receiver&gt;} tags included under &lt;application&gt;,
164 * or null if there were none. This is only filled in if the flag
165 * {@link PackageManager#GET_RECEIVERS} was set.
166 */
167 public ActivityInfo[] receivers;
168
169 /**
170 * Array of all {@link android.R.styleable#AndroidManifestService
171 * &lt;service&gt;} tags included under &lt;application&gt;,
172 * or null if there were none. This is only filled in if the flag
173 * {@link PackageManager#GET_SERVICES} was set.
174 */
175 public ServiceInfo[] services;
176
177 /**
178 * Array of all {@link android.R.styleable#AndroidManifestProvider
179 * &lt;provider&gt;} tags included under &lt;application&gt;,
180 * or null if there were none. This is only filled in if the flag
181 * {@link PackageManager#GET_PROVIDERS} was set.
182 */
183 public ProviderInfo[] providers;
184
185 /**
186 * Array of all {@link android.R.styleable#AndroidManifestInstrumentation
187 * &lt;instrumentation&gt;} tags included under &lt;manifest&gt;,
188 * or null if there were none. This is only filled in if the flag
189 * {@link PackageManager#GET_INSTRUMENTATION} was set.
190 */
191 public InstrumentationInfo[] instrumentation;
Svet Ganov67882122016-12-11 16:36:34 -0800192
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800193 /**
194 * Array of all {@link android.R.styleable#AndroidManifestPermission
195 * &lt;permission&gt;} tags included under &lt;manifest&gt;,
196 * or null if there were none. This is only filled in if the flag
197 * {@link PackageManager#GET_PERMISSIONS} was set.
198 */
199 public PermissionInfo[] permissions;
Svet Ganov67882122016-12-11 16:36:34 -0800200
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800201 /**
202 * Array of all {@link android.R.styleable#AndroidManifestUsesPermission
203 * &lt;uses-permission&gt;} tags included under &lt;manifest&gt;,
204 * or null if there were none. This is only filled in if the flag
205 * {@link PackageManager#GET_PERMISSIONS} was set. This list includes
206 * all permissions requested, even those that were not granted or known
207 * by the system at install time.
208 */
209 public String[] requestedPermissions;
Svet Ganov67882122016-12-11 16:36:34 -0800210
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800211 /**
Dianne Hackborne639da72012-02-21 15:11:13 -0800212 * Array of flags of all {@link android.R.styleable#AndroidManifestUsesPermission
213 * &lt;uses-permission&gt;} tags included under &lt;manifest&gt;,
214 * or null if there were none. This is only filled in if the flag
215 * {@link PackageManager#GET_PERMISSIONS} was set. Each value matches
216 * the corresponding entry in {@link #requestedPermissions}, and will have
Svetoslavc6d1c342015-02-26 14:44:43 -0800217 * the flag {@link #REQUESTED_PERMISSION_GRANTED} set as appropriate.
Dianne Hackborne639da72012-02-21 15:11:13 -0800218 */
219 public int[] requestedPermissionsFlags;
220
221 /**
222 * Flag for {@link #requestedPermissionsFlags}: the requested permission
223 * is required for the application to run; the user can not optionally
Nick Kralevich32eb5b182013-04-11 10:20:09 -0700224 * disable it. Currently all permissions are required.
Svetoslavc6d1c342015-02-26 14:44:43 -0800225 *
226 * @removed We do not support required permissions.
Dianne Hackborne639da72012-02-21 15:11:13 -0800227 */
228 public static final int REQUESTED_PERMISSION_REQUIRED = 1<<0;
229
230 /**
231 * Flag for {@link #requestedPermissionsFlags}: the requested permission
232 * is currently granted to the application.
233 */
234 public static final int REQUESTED_PERMISSION_GRANTED = 1<<1;
235
236 /**
Svetoslav Ganovcdd685c2017-08-22 14:35:04 -0700237 * Array of all signatures read from the package file. This is only filled
238 * in if the flag {@link PackageManager#GET_SIGNATURES} was set. A package
kopriva219f7dc2018-10-09 13:42:28 -0700239 * must be signed with at least one certificate which is at position zero.
Svetoslav Ganovcdd685c2017-08-22 14:35:04 -0700240 * The package can be signed with additional certificates which appear as
241 * subsequent entries.
242 *
243 * <strong>Note:</strong> Signature ordering is not guaranteed to be
244 * stable which means that a package signed with certificates A and B is
245 * equivalent to being signed with certificates B and A. This means that
246 * in case multiple signatures are reported you cannot assume the one at
247 * the first position to be the same across updates.
Daniel Cashman5cdda342018-01-19 07:22:52 -0800248 *
249 * <strong>Deprecated</strong> This has been replaced by the
Dan Cashman5c9f527e2018-04-03 16:42:23 -0700250 * {@link PackageInfo#signingInfo} field, which takes into
Daniel Cashman5cdda342018-01-19 07:22:52 -0800251 * account signing certificate rotation. For backwards compatibility in
252 * the event of signing certificate rotation, this will return the oldest
253 * reported signing certificate, so that an application will appear to
254 * callers as though no rotation occurred.
255 *
Dan Cashmane942b912018-04-16 14:41:24 -0700256 * @deprecated use {@code signingInfo} instead
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800257 */
Daniel Cashman5cdda342018-01-19 07:22:52 -0800258 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800259 public Signature[] signatures;
Daniel Cashman5cdda342018-01-19 07:22:52 -0800260
261 /**
Dan Cashman5c9f527e2018-04-03 16:42:23 -0700262 * Signing information read from the package file, potentially
Daniel Cashman5cdda342018-01-19 07:22:52 -0800263 * including past signing certificates no longer used after signing
Dan Cashman5c9f527e2018-04-03 16:42:23 -0700264 * certificate rotation. This is only filled in if
Daniel Cashman5cdda342018-01-19 07:22:52 -0800265 * the flag {@link PackageManager#GET_SIGNING_CERTIFICATES} was set.
266 *
Dan Cashman5c9f527e2018-04-03 16:42:23 -0700267 * Use this field instead of the deprecated {@code signatures} field.
268 * See {@link SigningInfo} for more information on its contents.
Daniel Cashman5cdda342018-01-19 07:22:52 -0800269 */
Dan Cashman5c9f527e2018-04-03 16:42:23 -0700270 public SigningInfo signingInfo;
Daniel Cashman5cdda342018-01-19 07:22:52 -0800271
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800272 /**
273 * Application specified preferred configuration
274 * {@link android.R.styleable#AndroidManifestUsesConfiguration
275 * &lt;uses-configuration&gt;} tags included under &lt;manifest&gt;,
276 * or null if there were none. This is only filled in if the flag
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700277 * {@link PackageManager#GET_CONFIGURATIONS} was set.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800278 */
279 public ConfigurationInfo[] configPreferences;
280
Dianne Hackborn49237342009-08-27 20:08:01 -0700281 /**
Jeff Sharkeyda96e132014-07-15 14:54:09 -0700282 * Features that this application has requested.
283 *
284 * @see FeatureInfo#FLAG_REQUIRED
Dianne Hackborn49237342009-08-27 20:08:01 -0700285 */
286 public FeatureInfo[] reqFeatures;
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800287
288 /**
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700289 * Groups of features that this application has requested.
290 * Each group contains a set of features that are required.
291 * A device must match the features listed in {@link #reqFeatures} and one
292 * or more FeatureGroups in order to have satisfied the feature requirement.
293 *
294 * @see FeatureInfo#FLAG_REQUIRED
295 */
296 public FeatureGroupInfo[] featureGroups;
297
298 /**
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800299 * Constant corresponding to <code>auto</code> in
300 * the {@link android.R.attr#installLocation} attribute.
301 * @hide
302 */
Mathew Inwood1c77a112018-08-14 14:06:26 +0100303 @UnsupportedAppUsage
Suchi Amalapurapu90d8ee62010-03-18 11:38:35 -0700304 public static final int INSTALL_LOCATION_UNSPECIFIED = -1;
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700305
Suchi Amalapurapu90d8ee62010-03-18 11:38:35 -0700306 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700307 * Constant corresponding to <code>auto</code> in the
308 * {@link android.R.attr#installLocation} attribute.
Suchi Amalapurapu90d8ee62010-03-18 11:38:35 -0700309 */
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800310 public static final int INSTALL_LOCATION_AUTO = 0;
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700311
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800312 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700313 * Constant corresponding to <code>internalOnly</code> in the
314 * {@link android.R.attr#installLocation} attribute.
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800315 */
316 public static final int INSTALL_LOCATION_INTERNAL_ONLY = 1;
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700317
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800318 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700319 * Constant corresponding to <code>preferExternal</code> in the
320 * {@link android.R.attr#installLocation} attribute.
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800321 */
322 public static final int INSTALL_LOCATION_PREFER_EXTERNAL = 2;
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700323
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800324 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700325 * The install location requested by the package. From the
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800326 * {@link android.R.attr#installLocation} attribute, one of
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700327 * {@link #INSTALL_LOCATION_AUTO}, {@link #INSTALL_LOCATION_INTERNAL_ONLY},
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800328 * {@link #INSTALL_LOCATION_PREFER_EXTERNAL}
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800329 */
330 public int installLocation = INSTALL_LOCATION_INTERNAL_ONLY;
Amith Yamasanidf2e92a2013-03-01 17:04:38 -0800331
332 /** @hide */
Todd Kennedy7c8addf2017-06-27 14:13:55 -0700333 public boolean isStub;
334
335 /** @hide */
Mathew Inwood1c77a112018-08-14 14:06:26 +0100336 @UnsupportedAppUsage
Jeff Hao272bf3a2014-10-08 13:34:43 -0700337 public boolean coreApp;
338
339 /** @hide */
Amith Yamasanidf2e92a2013-03-01 17:04:38 -0800340 public boolean requiredForAllUsers;
341
Amith Yamasani0ac1fc92013-03-27 18:56:08 -0700342 /** @hide */
343 public String restrictedAccountType;
344
Amith Yamasaniccbe3892013-04-12 17:52:42 -0700345 /** @hide */
346 public String requiredAccountType;
347
MÃ¥rten Kongstad48d22322014-01-31 14:43:27 +0100348 /**
349 * What package, if any, this package will overlay.
350 *
351 * Package name of target package, or null.
352 * @hide
353 */
Mathew Inwood1c77a112018-08-14 14:06:26 +0100354 @UnsupportedAppUsage
MÃ¥rten Kongstad48d22322014-01-31 14:43:27 +0100355 public String overlayTarget;
356
Adrian Roosc84df772018-01-19 21:20:22 +0100357 /**
358 * The overlay category, if any, of this package
359 *
360 * @hide
361 */
362 public String overlayCategory;
363
Jaekyun Seok04342892017-03-02 15:24:19 +0900364 /** @hide */
Jaekyun Seok42d53f62017-04-10 13:48:58 +0900365 public int overlayPriority;
366
Adam Lesinskiab56b9d2017-11-14 00:50:18 -0800367 /**
Adam Lesinskie7334972018-01-17 16:13:52 -0800368 * Whether the overlay is static, meaning it cannot be enabled/disabled at runtime.
Adam Lesinskiab56b9d2017-11-14 00:50:18 -0800369 */
Adam Lesinskie7334972018-01-17 16:13:52 -0800370 boolean mOverlayIsStatic;
Jaekyun Seok04342892017-03-02 15:24:19 +0900371
Alan Viveretteb6a25732017-11-21 14:49:24 -0500372 /**
373 * The user-visible SDK version (ex. 26) of the framework against which the application claims
374 * to have been compiled, or {@code 0} if not specified.
375 * <p>
376 * This property is the compile-time equivalent of
377 * {@link android.os.Build.VERSION#SDK_INT Build.VERSION.SDK_INT}.
378 *
379 * @hide For platform use only; we don't expect developers to need to read this value.
380 */
381 public int compileSdkVersion;
382
383 /**
384 * The development codename (ex. "O", "REL") of the framework against which the application
385 * claims to have been compiled, or {@code null} if not specified.
386 * <p>
387 * This property is the compile-time equivalent of
388 * {@link android.os.Build.VERSION#CODENAME Build.VERSION.CODENAME}.
389 *
390 * @hide For platform use only; we don't expect developers to need to read this value.
391 */
392 @Nullable
393 public String compileSdkVersionCodename;
394
Dario Frenie8129a32018-10-18 11:49:50 +0100395 /**
396 * Whether the package is an APEX package.
397 */
398 public boolean isApex;
399
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800400 public PackageInfo() {
401 }
402
Adam Lesinskiab56b9d2017-11-14 00:50:18 -0800403 /**
404 * Returns true if the package is a valid Runtime Overlay package.
405 * @hide
406 */
407 public boolean isOverlayPackage() {
Adam Lesinskie7334972018-01-17 16:13:52 -0800408 return overlayTarget != null;
Adam Lesinskiab56b9d2017-11-14 00:50:18 -0800409 }
410
411 /**
412 * Returns true if the package is a valid static Runtime Overlay package. Static overlays
413 * are not updatable outside of a system update and are safe to load in the system process.
414 * @hide
415 */
416 public boolean isStaticOverlayPackage() {
Adam Lesinskie7334972018-01-17 16:13:52 -0800417 return overlayTarget != null && mOverlayIsStatic;
Adam Lesinskiab56b9d2017-11-14 00:50:18 -0800418 }
419
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800420 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800421 public String toString() {
422 return "PackageInfo{"
423 + Integer.toHexString(System.identityHashCode(this))
424 + " " + packageName + "}";
425 }
426
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800427 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800428 public int describeContents() {
429 return 0;
430 }
431
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800432 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800433 public void writeToParcel(Parcel dest, int parcelableFlags) {
434 dest.writeString(packageName);
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700435 dest.writeStringArray(splitNames);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800436 dest.writeInt(versionCode);
Dianne Hackborn3accca02013-09-20 09:32:11 -0700437 dest.writeInt(versionCodeMajor);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800438 dest.writeString(versionName);
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800439 dest.writeInt(baseRevisionCode);
440 dest.writeIntArray(splitRevisionCodes);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800441 dest.writeString(sharedUserId);
442 dest.writeInt(sharedUserLabel);
443 if (applicationInfo != null) {
444 dest.writeInt(1);
445 applicationInfo.writeToParcel(dest, parcelableFlags);
446 } else {
447 dest.writeInt(0);
448 }
Dianne Hackborn78d6883692010-10-07 01:12:46 -0700449 dest.writeLong(firstInstallTime);
450 dest.writeLong(lastUpdateTime);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800451 dest.writeIntArray(gids);
Christopher Tateb9116762015-09-09 18:46:31 -0700452 dest.writeTypedArray(activities, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
453 dest.writeTypedArray(receivers, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
454 dest.writeTypedArray(services, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
455 dest.writeTypedArray(providers, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800456 dest.writeTypedArray(instrumentation, parcelableFlags);
457 dest.writeTypedArray(permissions, parcelableFlags);
458 dest.writeStringArray(requestedPermissions);
Dianne Hackborne639da72012-02-21 15:11:13 -0800459 dest.writeIntArray(requestedPermissionsFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800460 dest.writeTypedArray(signatures, parcelableFlags);
461 dest.writeTypedArray(configPreferences, parcelableFlags);
Dianne Hackborn49237342009-08-27 20:08:01 -0700462 dest.writeTypedArray(reqFeatures, parcelableFlags);
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700463 dest.writeTypedArray(featureGroups, parcelableFlags);
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800464 dest.writeInt(installLocation);
Todd Kennedy7c8addf2017-06-27 14:13:55 -0700465 dest.writeInt(isStub ? 1 : 0);
Jeff Hao272bf3a2014-10-08 13:34:43 -0700466 dest.writeInt(coreApp ? 1 : 0);
Amith Yamasanidf2e92a2013-03-01 17:04:38 -0800467 dest.writeInt(requiredForAllUsers ? 1 : 0);
Amith Yamasani0ac1fc92013-03-27 18:56:08 -0700468 dest.writeString(restrictedAccountType);
Amith Yamasaniccbe3892013-04-12 17:52:42 -0700469 dest.writeString(requiredAccountType);
MÃ¥rten Kongstad48d22322014-01-31 14:43:27 +0100470 dest.writeString(overlayTarget);
Adrian Roosc84df772018-01-19 21:20:22 +0100471 dest.writeString(overlayCategory);
Jaekyun Seok42d53f62017-04-10 13:48:58 +0900472 dest.writeInt(overlayPriority);
Adam Lesinskie7334972018-01-17 16:13:52 -0800473 dest.writeBoolean(mOverlayIsStatic);
Alan Viveretteb6a25732017-11-21 14:49:24 -0500474 dest.writeInt(compileSdkVersion);
475 dest.writeString(compileSdkVersionCodename);
Dan Cashman5c9f527e2018-04-03 16:42:23 -0700476 if (signingInfo != null) {
477 dest.writeInt(1);
478 signingInfo.writeToParcel(dest, parcelableFlags);
Dan Cashman050b7992018-02-06 17:08:58 -0800479 } else {
Dan Cashman5c9f527e2018-04-03 16:42:23 -0700480 dest.writeInt(0);
Dan Cashman050b7992018-02-06 17:08:58 -0800481 }
Dario Frenie8129a32018-10-18 11:49:50 +0100482 dest.writeBoolean(isApex);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800483 }
484
485 public static final Parcelable.Creator<PackageInfo> CREATOR
486 = new Parcelable.Creator<PackageInfo>() {
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800487 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800488 public PackageInfo createFromParcel(Parcel source) {
489 return new PackageInfo(source);
490 }
491
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800492 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800493 public PackageInfo[] newArray(int size) {
494 return new PackageInfo[size];
495 }
496 };
497
Mathew Inwood55418ea2018-12-20 15:30:45 +0000498 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800499 private PackageInfo(Parcel source) {
500 packageName = source.readString();
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800501 splitNames = source.createStringArray();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800502 versionCode = source.readInt();
Dianne Hackborn3accca02013-09-20 09:32:11 -0700503 versionCodeMajor = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800504 versionName = source.readString();
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800505 baseRevisionCode = source.readInt();
506 splitRevisionCodes = source.createIntArray();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800507 sharedUserId = source.readString();
508 sharedUserLabel = source.readInt();
509 int hasApp = source.readInt();
510 if (hasApp != 0) {
511 applicationInfo = ApplicationInfo.CREATOR.createFromParcel(source);
512 }
Dianne Hackborn78d6883692010-10-07 01:12:46 -0700513 firstInstallTime = source.readLong();
514 lastUpdateTime = source.readLong();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800515 gids = source.createIntArray();
516 activities = source.createTypedArray(ActivityInfo.CREATOR);
517 receivers = source.createTypedArray(ActivityInfo.CREATOR);
518 services = source.createTypedArray(ServiceInfo.CREATOR);
519 providers = source.createTypedArray(ProviderInfo.CREATOR);
520 instrumentation = source.createTypedArray(InstrumentationInfo.CREATOR);
521 permissions = source.createTypedArray(PermissionInfo.CREATOR);
522 requestedPermissions = source.createStringArray();
Dianne Hackborne639da72012-02-21 15:11:13 -0800523 requestedPermissionsFlags = source.createIntArray();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800524 signatures = source.createTypedArray(Signature.CREATOR);
525 configPreferences = source.createTypedArray(ConfigurationInfo.CREATOR);
Dianne Hackborn49237342009-08-27 20:08:01 -0700526 reqFeatures = source.createTypedArray(FeatureInfo.CREATOR);
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700527 featureGroups = source.createTypedArray(FeatureGroupInfo.CREATOR);
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800528 installLocation = source.readInt();
Todd Kennedy7c8addf2017-06-27 14:13:55 -0700529 isStub = source.readInt() != 0;
Jeff Hao272bf3a2014-10-08 13:34:43 -0700530 coreApp = source.readInt() != 0;
Amith Yamasanidf2e92a2013-03-01 17:04:38 -0800531 requiredForAllUsers = source.readInt() != 0;
Amith Yamasani0ac1fc92013-03-27 18:56:08 -0700532 restrictedAccountType = source.readString();
Amith Yamasaniccbe3892013-04-12 17:52:42 -0700533 requiredAccountType = source.readString();
MÃ¥rten Kongstad48d22322014-01-31 14:43:27 +0100534 overlayTarget = source.readString();
Adrian Roosc84df772018-01-19 21:20:22 +0100535 overlayCategory = source.readString();
Jaekyun Seok42d53f62017-04-10 13:48:58 +0900536 overlayPriority = source.readInt();
Adam Lesinskie7334972018-01-17 16:13:52 -0800537 mOverlayIsStatic = source.readBoolean();
Alan Viveretteb6a25732017-11-21 14:49:24 -0500538 compileSdkVersion = source.readInt();
539 compileSdkVersionCodename = source.readString();
Dan Cashman5c9f527e2018-04-03 16:42:23 -0700540 int hasSigningInfo = source.readInt();
541 if (hasSigningInfo != 0) {
542 signingInfo = SigningInfo.CREATOR.createFromParcel(source);
543 }
Dario Frenie8129a32018-10-18 11:49:50 +0100544 isApex = source.readBoolean();
Christopher Tateb9116762015-09-09 18:46:31 -0700545 // The component lists were flattened with the redundant ApplicationInfo
546 // instances omitted. Distribute the canonical one here as appropriate.
547 if (applicationInfo != null) {
548 propagateApplicationInfo(applicationInfo, activities);
549 propagateApplicationInfo(applicationInfo, receivers);
550 propagateApplicationInfo(applicationInfo, services);
551 propagateApplicationInfo(applicationInfo, providers);
552 }
553 }
554
Dario Frenie8129a32018-10-18 11:49:50 +0100555 /**
556 * @hide
557 */
558 public PackageInfo(ApexInfo apexInfo) {
559 packageName = apexInfo.packageName;
560 setLongVersionCode(apexInfo.versionCode);
561 isApex = true;
562 }
563
Christopher Tateb9116762015-09-09 18:46:31 -0700564 private void propagateApplicationInfo(ApplicationInfo appInfo, ComponentInfo[] components) {
565 if (components != null) {
566 for (ComponentInfo ci : components) {
567 ci.applicationInfo = appInfo;
568 }
569 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800570 }
571}