blob: b8d7889c86ff4792d6803141481c0364e911e867 [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 Inwood5c0d3542018-08-14 13:54:31 +010020import android.annotation.UnsupportedAppUsage;
Dario Frenicb7a68d2018-10-18 11:49:50 +010021import android.apex.ApexInfo;
Mathew Inwood31755f92018-12-20 13:53:36 +000022import android.os.Build;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080023import android.os.Parcel;
24import android.os.Parcelable;
25
Chad Brubakera58ce392018-10-29 14:14:22 -070026import java.util.ArrayList;
27import java.util.List;
28
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029/**
30 * Overall information about the contents of a package. This corresponds
31 * to all of the information collected from AndroidManifest.xml.
32 */
33public class PackageInfo implements Parcelable {
34 /**
35 * The name of this package. From the <manifest> tag's "name"
36 * attribute.
37 */
38 public String packageName;
39
40 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -070041 * The names of any installed split APKs for this package.
42 */
43 public String[] splitNames;
44
45 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -070046 * @deprecated Use {@link #getLongVersionCode()} instead, which includes both
47 * this and the additional
48 * {@link android.R.styleable#AndroidManifest_versionCodeMajor versionCodeMajor} attribute.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080049 * The version number of this package, as specified by the <manifest>
50 * tag's {@link android.R.styleable#AndroidManifest_versionCode versionCode}
51 * attribute.
Dianne Hackborn3accca02013-09-20 09:32:11 -070052 * @see #getLongVersionCode()
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080053 */
Dianne Hackborn3accca02013-09-20 09:32:11 -070054 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055 public int versionCode;
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -080056
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080057 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -070058 * @hide
59 * The major version number of this package, as specified by the <manifest>
60 * tag's {@link android.R.styleable#AndroidManifest_versionCode versionCodeMajor}
61 * attribute.
62 * @see #getLongVersionCode()
63 */
64 public int versionCodeMajor;
65
66 /**
67 * Return {@link android.R.styleable#AndroidManifest_versionCode versionCode} and
68 * {@link android.R.styleable#AndroidManifest_versionCodeMajor versionCodeMajor} combined
69 * together as a single long value. The
70 * {@link android.R.styleable#AndroidManifest_versionCodeMajor versionCodeMajor} is placed in
71 * the upper 32 bits.
72 */
73 public long getLongVersionCode() {
74 return composeLongVersionCode(versionCodeMajor, versionCode);
75 }
76
77 /**
78 * Set the full version code in this PackageInfo, updating {@link #versionCode}
79 * with the lower bits.
80 * @see #getLongVersionCode()
81 */
82 public void setLongVersionCode(long longVersionCode) {
83 versionCodeMajor = (int) (longVersionCode>>32);
84 versionCode = (int) longVersionCode;
85 }
86
87 /**
88 * @hide Internal implementation for composing a minor and major version code in to
89 * a single long version code.
90 */
91 public static long composeLongVersionCode(int major, int minor) {
92 return (((long) major) << 32) | (((long) minor) & 0xffffffffL);
93 }
94
95 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080096 * The version name of this package, as specified by the &lt;manifest&gt;
97 * tag's {@link android.R.styleable#AndroidManifest_versionName versionName}
98 * attribute.
99 */
100 public String versionName;
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800101
102 /**
103 * The revision number of the base APK for this package, as specified by the
104 * &lt;manifest&gt; tag's
105 * {@link android.R.styleable#AndroidManifest_revisionCode revisionCode}
106 * attribute.
107 */
108 public int baseRevisionCode;
109
110 /**
111 * The revision number of any split APKs for this package, as specified by
112 * the &lt;manifest&gt; tag's
113 * {@link android.R.styleable#AndroidManifest_revisionCode revisionCode}
114 * attribute. Indexes are a 1:1 mapping against {@link #splitNames}.
115 */
116 public int[] splitRevisionCodes;
117
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800118 /**
119 * The shared user ID name of this package, as specified by the &lt;manifest&gt;
120 * tag's {@link android.R.styleable#AndroidManifest_sharedUserId sharedUserId}
121 * attribute.
122 */
123 public String sharedUserId;
124
125 /**
126 * The shared user ID label of this package, as specified by the &lt;manifest&gt;
127 * tag's {@link android.R.styleable#AndroidManifest_sharedUserLabel sharedUserLabel}
128 * attribute.
129 */
130 public int sharedUserLabel;
131
132 /**
133 * Information collected from the &lt;application&gt; tag, or null if
134 * there was none.
135 */
136 public ApplicationInfo applicationInfo;
137
138 /**
Dianne Hackborn78d6883692010-10-07 01:12:46 -0700139 * The time at which the app was first installed. Units are as
140 * per {@link System#currentTimeMillis()}.
141 */
142 public long firstInstallTime;
143
144 /**
145 * The time at which the app was last updated. Units are as
146 * per {@link System#currentTimeMillis()}.
147 */
148 public long lastUpdateTime;
149
150 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800151 * All kernel group-IDs that have been assigned to this package.
152 * This is only filled in if the flag {@link PackageManager#GET_GIDS} was set.
153 */
154 public int[] gids;
155
156 /**
157 * Array of all {@link android.R.styleable#AndroidManifestActivity
158 * &lt;activity&gt;} tags included under &lt;application&gt;,
159 * or null if there were none. This is only filled in if the flag
160 * {@link PackageManager#GET_ACTIVITIES} was set.
161 */
162 public ActivityInfo[] activities;
163
164 /**
165 * Array of all {@link android.R.styleable#AndroidManifestReceiver
166 * &lt;receiver&gt;} tags included under &lt;application&gt;,
167 * or null if there were none. This is only filled in if the flag
168 * {@link PackageManager#GET_RECEIVERS} was set.
169 */
170 public ActivityInfo[] receivers;
171
172 /**
173 * Array of all {@link android.R.styleable#AndroidManifestService
174 * &lt;service&gt;} tags included under &lt;application&gt;,
175 * or null if there were none. This is only filled in if the flag
176 * {@link PackageManager#GET_SERVICES} was set.
177 */
178 public ServiceInfo[] services;
179
180 /**
181 * Array of all {@link android.R.styleable#AndroidManifestProvider
182 * &lt;provider&gt;} tags included under &lt;application&gt;,
183 * or null if there were none. This is only filled in if the flag
184 * {@link PackageManager#GET_PROVIDERS} was set.
185 */
186 public ProviderInfo[] providers;
187
188 /**
189 * Array of all {@link android.R.styleable#AndroidManifestInstrumentation
190 * &lt;instrumentation&gt;} tags included under &lt;manifest&gt;,
191 * or null if there were none. This is only filled in if the flag
192 * {@link PackageManager#GET_INSTRUMENTATION} was set.
193 */
194 public InstrumentationInfo[] instrumentation;
Svet Ganov67882122016-12-11 16:36:34 -0800195
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800196 /**
197 * Array of all {@link android.R.styleable#AndroidManifestPermission
198 * &lt;permission&gt;} tags included under &lt;manifest&gt;,
199 * or null if there were none. This is only filled in if the flag
200 * {@link PackageManager#GET_PERMISSIONS} was set.
201 */
202 public PermissionInfo[] permissions;
Svet Ganov67882122016-12-11 16:36:34 -0800203
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800204 /**
205 * Array of all {@link android.R.styleable#AndroidManifestUsesPermission
206 * &lt;uses-permission&gt;} tags included under &lt;manifest&gt;,
207 * or null if there were none. This is only filled in if the flag
208 * {@link PackageManager#GET_PERMISSIONS} was set. This list includes
209 * all permissions requested, even those that were not granted or known
210 * by the system at install time.
Chad Brubakera58ce392018-10-29 14:14:22 -0700211 *
212 * @deprecated Use {@link #usesPermissions}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800213 */
Chad Brubakera58ce392018-10-29 14:14:22 -0700214 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800215 public String[] requestedPermissions;
Svet Ganov67882122016-12-11 16:36:34 -0800216
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800217 /**
Dianne Hackborne639da72012-02-21 15:11:13 -0800218 * Array of flags of all {@link android.R.styleable#AndroidManifestUsesPermission
219 * &lt;uses-permission&gt;} tags included under &lt;manifest&gt;,
220 * or null if there were none. This is only filled in if the flag
221 * {@link PackageManager#GET_PERMISSIONS} was set. Each value matches
222 * the corresponding entry in {@link #requestedPermissions}, and will have
Svetoslavc6d1c342015-02-26 14:44:43 -0800223 * the flag {@link #REQUESTED_PERMISSION_GRANTED} set as appropriate.
Chad Brubakera58ce392018-10-29 14:14:22 -0700224 *
225 * @deprecated Use {@link #usesPermissions}
Dianne Hackborne639da72012-02-21 15:11:13 -0800226 */
Chad Brubakera58ce392018-10-29 14:14:22 -0700227 @Deprecated
Dianne Hackborne639da72012-02-21 15:11:13 -0800228 public int[] requestedPermissionsFlags;
229
230 /**
Chad Brubakera58ce392018-10-29 14:14:22 -0700231 * Array of all {@link android.R.styleable#AndroidManifestUsesPermission
232 * &lt;uses-permission&gt;} tags included under &lt;manifest&gt;,
233 * or null if there were none. This is only filled in if the flag
234 * {@link PackageManager#GET_PERMISSIONS} was set. This list includes
235 * all permissions requested, even those that were not granted or known
236 * by the system at install time.
237 */
238 public UsesPermissionInfo[] usesPermissions;
239
240 /**
Dianne Hackborne639da72012-02-21 15:11:13 -0800241 * Flag for {@link #requestedPermissionsFlags}: the requested permission
242 * is required for the application to run; the user can not optionally
Nick Kralevich32eb5b182013-04-11 10:20:09 -0700243 * disable it. Currently all permissions are required.
Svetoslavc6d1c342015-02-26 14:44:43 -0800244 *
245 * @removed We do not support required permissions.
Dianne Hackborne639da72012-02-21 15:11:13 -0800246 */
247 public static final int REQUESTED_PERMISSION_REQUIRED = 1<<0;
248
249 /**
250 * Flag for {@link #requestedPermissionsFlags}: the requested permission
251 * is currently granted to the application.
252 */
253 public static final int REQUESTED_PERMISSION_GRANTED = 1<<1;
254
255 /**
Svetoslav Ganovcdd685c2017-08-22 14:35:04 -0700256 * Array of all signatures read from the package file. This is only filled
257 * in if the flag {@link PackageManager#GET_SIGNATURES} was set. A package
Xin Wei Chow6ab8afb2018-09-01 09:12:58 +1000258 * must be signed with at least one certificate which is at position zero.
Svetoslav Ganovcdd685c2017-08-22 14:35:04 -0700259 * The package can be signed with additional certificates which appear as
260 * subsequent entries.
261 *
262 * <strong>Note:</strong> Signature ordering is not guaranteed to be
263 * stable which means that a package signed with certificates A and B is
264 * equivalent to being signed with certificates B and A. This means that
265 * in case multiple signatures are reported you cannot assume the one at
266 * the first position to be the same across updates.
Daniel Cashman5cdda342018-01-19 07:22:52 -0800267 *
268 * <strong>Deprecated</strong> This has been replaced by the
Dan Cashman5c9f527e2018-04-03 16:42:23 -0700269 * {@link PackageInfo#signingInfo} field, which takes into
Daniel Cashman5cdda342018-01-19 07:22:52 -0800270 * account signing certificate rotation. For backwards compatibility in
271 * the event of signing certificate rotation, this will return the oldest
272 * reported signing certificate, so that an application will appear to
273 * callers as though no rotation occurred.
274 *
Dan Cashmane942b912018-04-16 14:41:24 -0700275 * @deprecated use {@code signingInfo} instead
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800276 */
Daniel Cashman5cdda342018-01-19 07:22:52 -0800277 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800278 public Signature[] signatures;
Daniel Cashman5cdda342018-01-19 07:22:52 -0800279
280 /**
Dan Cashman5c9f527e2018-04-03 16:42:23 -0700281 * Signing information read from the package file, potentially
Daniel Cashman5cdda342018-01-19 07:22:52 -0800282 * including past signing certificates no longer used after signing
Dan Cashman5c9f527e2018-04-03 16:42:23 -0700283 * certificate rotation. This is only filled in if
Daniel Cashman5cdda342018-01-19 07:22:52 -0800284 * the flag {@link PackageManager#GET_SIGNING_CERTIFICATES} was set.
285 *
Dan Cashman5c9f527e2018-04-03 16:42:23 -0700286 * Use this field instead of the deprecated {@code signatures} field.
287 * See {@link SigningInfo} for more information on its contents.
Daniel Cashman5cdda342018-01-19 07:22:52 -0800288 */
Dan Cashman5c9f527e2018-04-03 16:42:23 -0700289 public SigningInfo signingInfo;
Daniel Cashman5cdda342018-01-19 07:22:52 -0800290
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800291 /**
292 * Application specified preferred configuration
293 * {@link android.R.styleable#AndroidManifestUsesConfiguration
294 * &lt;uses-configuration&gt;} tags included under &lt;manifest&gt;,
295 * or null if there were none. This is only filled in if the flag
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700296 * {@link PackageManager#GET_CONFIGURATIONS} was set.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800297 */
298 public ConfigurationInfo[] configPreferences;
299
Dianne Hackborn49237342009-08-27 20:08:01 -0700300 /**
Jeff Sharkeyda96e132014-07-15 14:54:09 -0700301 * Features that this application has requested.
302 *
303 * @see FeatureInfo#FLAG_REQUIRED
Dianne Hackborn49237342009-08-27 20:08:01 -0700304 */
305 public FeatureInfo[] reqFeatures;
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800306
307 /**
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700308 * Groups of features that this application has requested.
309 * Each group contains a set of features that are required.
310 * A device must match the features listed in {@link #reqFeatures} and one
311 * or more FeatureGroups in order to have satisfied the feature requirement.
312 *
313 * @see FeatureInfo#FLAG_REQUIRED
314 */
315 public FeatureGroupInfo[] featureGroups;
316
317 /**
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800318 * Constant corresponding to <code>auto</code> in
319 * the {@link android.R.attr#installLocation} attribute.
320 * @hide
321 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +0100322 @UnsupportedAppUsage
Suchi Amalapurapu90d8ee62010-03-18 11:38:35 -0700323 public static final int INSTALL_LOCATION_UNSPECIFIED = -1;
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700324
Suchi Amalapurapu90d8ee62010-03-18 11:38:35 -0700325 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700326 * Constant corresponding to <code>auto</code> in the
327 * {@link android.R.attr#installLocation} attribute.
Suchi Amalapurapu90d8ee62010-03-18 11:38:35 -0700328 */
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800329 public static final int INSTALL_LOCATION_AUTO = 0;
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700330
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800331 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700332 * Constant corresponding to <code>internalOnly</code> in the
333 * {@link android.R.attr#installLocation} attribute.
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800334 */
335 public static final int INSTALL_LOCATION_INTERNAL_ONLY = 1;
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700336
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800337 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700338 * Constant corresponding to <code>preferExternal</code> in the
339 * {@link android.R.attr#installLocation} attribute.
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800340 */
341 public static final int INSTALL_LOCATION_PREFER_EXTERNAL = 2;
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700342
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800343 /**
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700344 * The install location requested by the package. From the
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800345 * {@link android.R.attr#installLocation} attribute, one of
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700346 * {@link #INSTALL_LOCATION_AUTO}, {@link #INSTALL_LOCATION_INTERNAL_ONLY},
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800347 * {@link #INSTALL_LOCATION_PREFER_EXTERNAL}
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800348 */
349 public int installLocation = INSTALL_LOCATION_INTERNAL_ONLY;
Amith Yamasanidf2e92a2013-03-01 17:04:38 -0800350
351 /** @hide */
Todd Kennedy7c8addf2017-06-27 14:13:55 -0700352 public boolean isStub;
353
354 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +0100355 @UnsupportedAppUsage
Jeff Hao272bf3a2014-10-08 13:34:43 -0700356 public boolean coreApp;
357
358 /** @hide */
Amith Yamasanidf2e92a2013-03-01 17:04:38 -0800359 public boolean requiredForAllUsers;
360
Amith Yamasani0ac1fc92013-03-27 18:56:08 -0700361 /** @hide */
362 public String restrictedAccountType;
363
Amith Yamasaniccbe3892013-04-12 17:52:42 -0700364 /** @hide */
365 public String requiredAccountType;
366
MÃ¥rten Kongstad48d22322014-01-31 14:43:27 +0100367 /**
368 * What package, if any, this package will overlay.
369 *
370 * Package name of target package, or null.
371 * @hide
372 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +0100373 @UnsupportedAppUsage
MÃ¥rten Kongstad48d22322014-01-31 14:43:27 +0100374 public String overlayTarget;
375
Adrian Roosc84df772018-01-19 21:20:22 +0100376 /**
377 * The overlay category, if any, of this package
378 *
379 * @hide
380 */
381 public String overlayCategory;
382
Jaekyun Seok04342892017-03-02 15:24:19 +0900383 /** @hide */
Jaekyun Seok42d53f62017-04-10 13:48:58 +0900384 public int overlayPriority;
385
Adam Lesinskiab56b9d2017-11-14 00:50:18 -0800386 /**
Adam Lesinskie7334972018-01-17 16:13:52 -0800387 * Whether the overlay is static, meaning it cannot be enabled/disabled at runtime.
Adam Lesinskiab56b9d2017-11-14 00:50:18 -0800388 */
Adam Lesinskie7334972018-01-17 16:13:52 -0800389 boolean mOverlayIsStatic;
Jaekyun Seok04342892017-03-02 15:24:19 +0900390
Alan Viveretteb6a25732017-11-21 14:49:24 -0500391 /**
392 * The user-visible SDK version (ex. 26) of the framework against which the application claims
393 * to have been compiled, or {@code 0} if not specified.
394 * <p>
395 * This property is the compile-time equivalent of
396 * {@link android.os.Build.VERSION#SDK_INT Build.VERSION.SDK_INT}.
397 *
398 * @hide For platform use only; we don't expect developers to need to read this value.
399 */
400 public int compileSdkVersion;
401
402 /**
403 * The development codename (ex. "O", "REL") of the framework against which the application
404 * claims to have been compiled, or {@code null} if not specified.
405 * <p>
406 * This property is the compile-time equivalent of
407 * {@link android.os.Build.VERSION#CODENAME Build.VERSION.CODENAME}.
408 *
409 * @hide For platform use only; we don't expect developers to need to read this value.
410 */
411 @Nullable
412 public String compileSdkVersionCodename;
413
Dario Frenicb7a68d2018-10-18 11:49:50 +0100414 /**
415 * Whether the package is an APEX package.
416 */
417 public boolean isApex;
418
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800419 public PackageInfo() {
420 }
421
Adam Lesinskiab56b9d2017-11-14 00:50:18 -0800422 /**
423 * Returns true if the package is a valid Runtime Overlay package.
424 * @hide
425 */
426 public boolean isOverlayPackage() {
Adam Lesinskie7334972018-01-17 16:13:52 -0800427 return overlayTarget != null;
Adam Lesinskiab56b9d2017-11-14 00:50:18 -0800428 }
429
430 /**
431 * Returns true if the package is a valid static Runtime Overlay package. Static overlays
432 * are not updatable outside of a system update and are safe to load in the system process.
433 * @hide
434 */
435 public boolean isStaticOverlayPackage() {
Adam Lesinskie7334972018-01-17 16:13:52 -0800436 return overlayTarget != null && mOverlayIsStatic;
Adam Lesinskiab56b9d2017-11-14 00:50:18 -0800437 }
438
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800439 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800440 public String toString() {
441 return "PackageInfo{"
442 + Integer.toHexString(System.identityHashCode(this))
443 + " " + packageName + "}";
444 }
445
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800446 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800447 public int describeContents() {
448 return 0;
449 }
450
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800451 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800452 public void writeToParcel(Parcel dest, int parcelableFlags) {
453 dest.writeString(packageName);
Jeff Sharkey6c833e02014-07-14 22:44:30 -0700454 dest.writeStringArray(splitNames);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800455 dest.writeInt(versionCode);
Dianne Hackborn3accca02013-09-20 09:32:11 -0700456 dest.writeInt(versionCodeMajor);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800457 dest.writeString(versionName);
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800458 dest.writeInt(baseRevisionCode);
459 dest.writeIntArray(splitRevisionCodes);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800460 dest.writeString(sharedUserId);
461 dest.writeInt(sharedUserLabel);
462 if (applicationInfo != null) {
463 dest.writeInt(1);
464 applicationInfo.writeToParcel(dest, parcelableFlags);
465 } else {
466 dest.writeInt(0);
467 }
Dianne Hackborn78d6883692010-10-07 01:12:46 -0700468 dest.writeLong(firstInstallTime);
469 dest.writeLong(lastUpdateTime);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800470 dest.writeIntArray(gids);
Christopher Tateb9116762015-09-09 18:46:31 -0700471 dest.writeTypedArray(activities, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
472 dest.writeTypedArray(receivers, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
473 dest.writeTypedArray(services, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
474 dest.writeTypedArray(providers, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800475 dest.writeTypedArray(instrumentation, parcelableFlags);
476 dest.writeTypedArray(permissions, parcelableFlags);
477 dest.writeStringArray(requestedPermissions);
Dianne Hackborne639da72012-02-21 15:11:13 -0800478 dest.writeIntArray(requestedPermissionsFlags);
Chad Brubakera58ce392018-10-29 14:14:22 -0700479 dest.writeTypedArray(usesPermissions, parcelableFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800480 dest.writeTypedArray(signatures, parcelableFlags);
481 dest.writeTypedArray(configPreferences, parcelableFlags);
Dianne Hackborn49237342009-08-27 20:08:01 -0700482 dest.writeTypedArray(reqFeatures, parcelableFlags);
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700483 dest.writeTypedArray(featureGroups, parcelableFlags);
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800484 dest.writeInt(installLocation);
Todd Kennedy7c8addf2017-06-27 14:13:55 -0700485 dest.writeInt(isStub ? 1 : 0);
Jeff Hao272bf3a2014-10-08 13:34:43 -0700486 dest.writeInt(coreApp ? 1 : 0);
Amith Yamasanidf2e92a2013-03-01 17:04:38 -0800487 dest.writeInt(requiredForAllUsers ? 1 : 0);
Amith Yamasani0ac1fc92013-03-27 18:56:08 -0700488 dest.writeString(restrictedAccountType);
Amith Yamasaniccbe3892013-04-12 17:52:42 -0700489 dest.writeString(requiredAccountType);
MÃ¥rten Kongstad48d22322014-01-31 14:43:27 +0100490 dest.writeString(overlayTarget);
Adrian Roosc84df772018-01-19 21:20:22 +0100491 dest.writeString(overlayCategory);
Jaekyun Seok42d53f62017-04-10 13:48:58 +0900492 dest.writeInt(overlayPriority);
Adam Lesinskie7334972018-01-17 16:13:52 -0800493 dest.writeBoolean(mOverlayIsStatic);
Alan Viveretteb6a25732017-11-21 14:49:24 -0500494 dest.writeInt(compileSdkVersion);
495 dest.writeString(compileSdkVersionCodename);
Dan Cashman5c9f527e2018-04-03 16:42:23 -0700496 if (signingInfo != null) {
497 dest.writeInt(1);
498 signingInfo.writeToParcel(dest, parcelableFlags);
Dan Cashman050b7992018-02-06 17:08:58 -0800499 } else {
Dan Cashman5c9f527e2018-04-03 16:42:23 -0700500 dest.writeInt(0);
Dan Cashman050b7992018-02-06 17:08:58 -0800501 }
Dario Frenicb7a68d2018-10-18 11:49:50 +0100502 dest.writeBoolean(isApex);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800503 }
504
505 public static final Parcelable.Creator<PackageInfo> CREATOR
506 = new Parcelable.Creator<PackageInfo>() {
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800507 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800508 public PackageInfo createFromParcel(Parcel source) {
509 return new PackageInfo(source);
510 }
511
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800512 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800513 public PackageInfo[] newArray(int size) {
514 return new PackageInfo[size];
515 }
516 };
517
Mathew Inwood31755f92018-12-20 13:53:36 +0000518 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800519 private PackageInfo(Parcel source) {
520 packageName = source.readString();
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800521 splitNames = source.createStringArray();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800522 versionCode = source.readInt();
Dianne Hackborn3accca02013-09-20 09:32:11 -0700523 versionCodeMajor = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800524 versionName = source.readString();
Jeff Sharkey88d2a3c2014-11-22 16:49:34 -0800525 baseRevisionCode = source.readInt();
526 splitRevisionCodes = source.createIntArray();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800527 sharedUserId = source.readString();
528 sharedUserLabel = source.readInt();
529 int hasApp = source.readInt();
530 if (hasApp != 0) {
531 applicationInfo = ApplicationInfo.CREATOR.createFromParcel(source);
532 }
Dianne Hackborn78d6883692010-10-07 01:12:46 -0700533 firstInstallTime = source.readLong();
534 lastUpdateTime = source.readLong();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800535 gids = source.createIntArray();
536 activities = source.createTypedArray(ActivityInfo.CREATOR);
537 receivers = source.createTypedArray(ActivityInfo.CREATOR);
538 services = source.createTypedArray(ServiceInfo.CREATOR);
539 providers = source.createTypedArray(ProviderInfo.CREATOR);
540 instrumentation = source.createTypedArray(InstrumentationInfo.CREATOR);
541 permissions = source.createTypedArray(PermissionInfo.CREATOR);
542 requestedPermissions = source.createStringArray();
Dianne Hackborne639da72012-02-21 15:11:13 -0800543 requestedPermissionsFlags = source.createIntArray();
Chad Brubakera58ce392018-10-29 14:14:22 -0700544 usesPermissions = source.createTypedArray(UsesPermissionInfo.CREATOR);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800545 signatures = source.createTypedArray(Signature.CREATOR);
546 configPreferences = source.createTypedArray(ConfigurationInfo.CREATOR);
Dianne Hackborn49237342009-08-27 20:08:01 -0700547 reqFeatures = source.createTypedArray(FeatureInfo.CREATOR);
Adam Lesinskid3edfde2014-08-08 17:32:44 -0700548 featureGroups = source.createTypedArray(FeatureGroupInfo.CREATOR);
Suchi Amalapurapu117818e2010-02-09 03:45:40 -0800549 installLocation = source.readInt();
Todd Kennedy7c8addf2017-06-27 14:13:55 -0700550 isStub = source.readInt() != 0;
Jeff Hao272bf3a2014-10-08 13:34:43 -0700551 coreApp = source.readInt() != 0;
Amith Yamasanidf2e92a2013-03-01 17:04:38 -0800552 requiredForAllUsers = source.readInt() != 0;
Amith Yamasani0ac1fc92013-03-27 18:56:08 -0700553 restrictedAccountType = source.readString();
Amith Yamasaniccbe3892013-04-12 17:52:42 -0700554 requiredAccountType = source.readString();
MÃ¥rten Kongstad48d22322014-01-31 14:43:27 +0100555 overlayTarget = source.readString();
Adrian Roosc84df772018-01-19 21:20:22 +0100556 overlayCategory = source.readString();
Jaekyun Seok42d53f62017-04-10 13:48:58 +0900557 overlayPriority = source.readInt();
Adam Lesinskie7334972018-01-17 16:13:52 -0800558 mOverlayIsStatic = source.readBoolean();
Alan Viveretteb6a25732017-11-21 14:49:24 -0500559 compileSdkVersion = source.readInt();
560 compileSdkVersionCodename = source.readString();
Dan Cashman5c9f527e2018-04-03 16:42:23 -0700561 int hasSigningInfo = source.readInt();
562 if (hasSigningInfo != 0) {
563 signingInfo = SigningInfo.CREATOR.createFromParcel(source);
564 }
Dario Frenicb7a68d2018-10-18 11:49:50 +0100565 isApex = source.readBoolean();
Christopher Tateb9116762015-09-09 18:46:31 -0700566 // The component lists were flattened with the redundant ApplicationInfo
567 // instances omitted. Distribute the canonical one here as appropriate.
568 if (applicationInfo != null) {
569 propagateApplicationInfo(applicationInfo, activities);
570 propagateApplicationInfo(applicationInfo, receivers);
571 propagateApplicationInfo(applicationInfo, services);
572 propagateApplicationInfo(applicationInfo, providers);
573 }
574 }
575
Dario Frenicb7a68d2018-10-18 11:49:50 +0100576 /**
577 * @hide
578 */
579 public PackageInfo(ApexInfo apexInfo) {
580 packageName = apexInfo.packageName;
581 setLongVersionCode(apexInfo.versionCode);
582 isApex = true;
583 }
584
Christopher Tateb9116762015-09-09 18:46:31 -0700585 private void propagateApplicationInfo(ApplicationInfo appInfo, ComponentInfo[] components) {
586 if (components != null) {
587 for (ComponentInfo ci : components) {
588 ci.applicationInfo = appInfo;
589 }
590 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800591 }
592}