Kenny Root | 15a4d2f | 2010-03-11 18:20:12 -0800 | [diff] [blame] | 1 | /* |
| 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 17 | package android.content.pm; |
| 18 | |
Alan Viverette | b6a2573 | 2017-11-21 14:49:24 -0500 | [diff] [blame] | 19 | import android.annotation.Nullable; |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 20 | import android.annotation.UnsupportedAppUsage; |
Mathew Inwood | 31755f9 | 2018-12-20 13:53:36 +0000 | [diff] [blame] | 21 | import android.os.Build; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | import android.os.Parcel; |
| 23 | import android.os.Parcelable; |
| 24 | |
| 25 | /** |
| 26 | * Overall information about the contents of a package. This corresponds |
| 27 | * to all of the information collected from AndroidManifest.xml. |
| 28 | */ |
| 29 | public class PackageInfo implements Parcelable { |
| 30 | /** |
| 31 | * The name of this package. From the <manifest> tag's "name" |
| 32 | * attribute. |
| 33 | */ |
| 34 | public String packageName; |
| 35 | |
| 36 | /** |
Jeff Sharkey | 6c833e0 | 2014-07-14 22:44:30 -0700 | [diff] [blame] | 37 | * The names of any installed split APKs for this package. |
| 38 | */ |
| 39 | public String[] splitNames; |
| 40 | |
| 41 | /** |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 42 | * @deprecated Use {@link #getLongVersionCode()} instead, which includes both |
| 43 | * this and the additional |
| 44 | * {@link android.R.styleable#AndroidManifest_versionCodeMajor versionCodeMajor} attribute. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | * The version number of this package, as specified by the <manifest> |
| 46 | * tag's {@link android.R.styleable#AndroidManifest_versionCode versionCode} |
| 47 | * attribute. |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 48 | * @see #getLongVersionCode() |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | */ |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 50 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | public int versionCode; |
Jeff Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 52 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | /** |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 54 | * @hide |
| 55 | * The major version number of this package, as specified by the <manifest> |
| 56 | * tag's {@link android.R.styleable#AndroidManifest_versionCode versionCodeMajor} |
| 57 | * attribute. |
| 58 | * @see #getLongVersionCode() |
| 59 | */ |
| 60 | public int versionCodeMajor; |
| 61 | |
| 62 | /** |
| 63 | * Return {@link android.R.styleable#AndroidManifest_versionCode versionCode} and |
| 64 | * {@link android.R.styleable#AndroidManifest_versionCodeMajor versionCodeMajor} combined |
| 65 | * together as a single long value. The |
| 66 | * {@link android.R.styleable#AndroidManifest_versionCodeMajor versionCodeMajor} is placed in |
| 67 | * the upper 32 bits. |
| 68 | */ |
| 69 | public long getLongVersionCode() { |
| 70 | return composeLongVersionCode(versionCodeMajor, versionCode); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Set the full version code in this PackageInfo, updating {@link #versionCode} |
| 75 | * with the lower bits. |
| 76 | * @see #getLongVersionCode() |
| 77 | */ |
| 78 | public void setLongVersionCode(long longVersionCode) { |
| 79 | versionCodeMajor = (int) (longVersionCode>>32); |
| 80 | versionCode = (int) longVersionCode; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * @hide Internal implementation for composing a minor and major version code in to |
| 85 | * a single long version code. |
| 86 | */ |
| 87 | public static long composeLongVersionCode(int major, int minor) { |
| 88 | return (((long) major) << 32) | (((long) minor) & 0xffffffffL); |
| 89 | } |
| 90 | |
| 91 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 92 | * The version name of this package, as specified by the <manifest> |
| 93 | * tag's {@link android.R.styleable#AndroidManifest_versionName versionName} |
| 94 | * attribute. |
| 95 | */ |
| 96 | public String versionName; |
Jeff Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 97 | |
| 98 | /** |
| 99 | * The revision number of the base APK for this package, as specified by the |
| 100 | * <manifest> tag's |
| 101 | * {@link android.R.styleable#AndroidManifest_revisionCode revisionCode} |
| 102 | * attribute. |
| 103 | */ |
| 104 | public int baseRevisionCode; |
| 105 | |
| 106 | /** |
| 107 | * The revision number of any split APKs for this package, as specified by |
| 108 | * the <manifest> tag's |
| 109 | * {@link android.R.styleable#AndroidManifest_revisionCode revisionCode} |
| 110 | * attribute. Indexes are a 1:1 mapping against {@link #splitNames}. |
| 111 | */ |
| 112 | public int[] splitRevisionCodes; |
| 113 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 114 | /** |
| 115 | * The shared user ID name of this package, as specified by the <manifest> |
| 116 | * tag's {@link android.R.styleable#AndroidManifest_sharedUserId sharedUserId} |
| 117 | * attribute. |
| 118 | */ |
| 119 | public String sharedUserId; |
| 120 | |
| 121 | /** |
| 122 | * The shared user ID label of this package, as specified by the <manifest> |
| 123 | * tag's {@link android.R.styleable#AndroidManifest_sharedUserLabel sharedUserLabel} |
| 124 | * attribute. |
| 125 | */ |
| 126 | public int sharedUserLabel; |
| 127 | |
| 128 | /** |
| 129 | * Information collected from the <application> tag, or null if |
| 130 | * there was none. |
| 131 | */ |
| 132 | public ApplicationInfo applicationInfo; |
| 133 | |
| 134 | /** |
Dianne Hackborn | 78d688369 | 2010-10-07 01:12:46 -0700 | [diff] [blame] | 135 | * The time at which the app was first installed. Units are as |
| 136 | * per {@link System#currentTimeMillis()}. |
| 137 | */ |
| 138 | public long firstInstallTime; |
| 139 | |
| 140 | /** |
| 141 | * The time at which the app was last updated. Units are as |
| 142 | * per {@link System#currentTimeMillis()}. |
| 143 | */ |
| 144 | public long lastUpdateTime; |
| 145 | |
| 146 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 147 | * All kernel group-IDs that have been assigned to this package. |
| 148 | * This is only filled in if the flag {@link PackageManager#GET_GIDS} was set. |
| 149 | */ |
| 150 | public int[] gids; |
| 151 | |
| 152 | /** |
| 153 | * Array of all {@link android.R.styleable#AndroidManifestActivity |
| 154 | * <activity>} tags included under <application>, |
| 155 | * or null if there were none. This is only filled in if the flag |
| 156 | * {@link PackageManager#GET_ACTIVITIES} was set. |
| 157 | */ |
| 158 | public ActivityInfo[] activities; |
| 159 | |
| 160 | /** |
| 161 | * Array of all {@link android.R.styleable#AndroidManifestReceiver |
| 162 | * <receiver>} tags included under <application>, |
| 163 | * or null if there were none. This is only filled in if the flag |
| 164 | * {@link PackageManager#GET_RECEIVERS} was set. |
| 165 | */ |
| 166 | public ActivityInfo[] receivers; |
| 167 | |
| 168 | /** |
| 169 | * Array of all {@link android.R.styleable#AndroidManifestService |
| 170 | * <service>} tags included under <application>, |
| 171 | * or null if there were none. This is only filled in if the flag |
| 172 | * {@link PackageManager#GET_SERVICES} was set. |
| 173 | */ |
| 174 | public ServiceInfo[] services; |
| 175 | |
| 176 | /** |
| 177 | * Array of all {@link android.R.styleable#AndroidManifestProvider |
| 178 | * <provider>} tags included under <application>, |
| 179 | * or null if there were none. This is only filled in if the flag |
| 180 | * {@link PackageManager#GET_PROVIDERS} was set. |
| 181 | */ |
| 182 | public ProviderInfo[] providers; |
| 183 | |
| 184 | /** |
| 185 | * Array of all {@link android.R.styleable#AndroidManifestInstrumentation |
| 186 | * <instrumentation>} tags included under <manifest>, |
| 187 | * or null if there were none. This is only filled in if the flag |
| 188 | * {@link PackageManager#GET_INSTRUMENTATION} was set. |
| 189 | */ |
| 190 | public InstrumentationInfo[] instrumentation; |
Svet Ganov | 6788212 | 2016-12-11 16:36:34 -0800 | [diff] [blame] | 191 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 192 | /** |
| 193 | * Array of all {@link android.R.styleable#AndroidManifestPermission |
| 194 | * <permission>} tags included under <manifest>, |
| 195 | * or null if there were none. This is only filled in if the flag |
| 196 | * {@link PackageManager#GET_PERMISSIONS} was set. |
| 197 | */ |
| 198 | public PermissionInfo[] permissions; |
Svet Ganov | 6788212 | 2016-12-11 16:36:34 -0800 | [diff] [blame] | 199 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 200 | /** |
| 201 | * Array of all {@link android.R.styleable#AndroidManifestUsesPermission |
| 202 | * <uses-permission>} tags included under <manifest>, |
| 203 | * or null if there were none. This is only filled in if the flag |
| 204 | * {@link PackageManager#GET_PERMISSIONS} was set. This list includes |
| 205 | * all permissions requested, even those that were not granted or known |
| 206 | * by the system at install time. |
| 207 | */ |
| 208 | public String[] requestedPermissions; |
Svet Ganov | 6788212 | 2016-12-11 16:36:34 -0800 | [diff] [blame] | 209 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 210 | /** |
Dianne Hackborn | e639da7 | 2012-02-21 15:11:13 -0800 | [diff] [blame] | 211 | * Array of flags of all {@link android.R.styleable#AndroidManifestUsesPermission |
| 212 | * <uses-permission>} tags included under <manifest>, |
| 213 | * or null if there were none. This is only filled in if the flag |
| 214 | * {@link PackageManager#GET_PERMISSIONS} was set. Each value matches |
| 215 | * the corresponding entry in {@link #requestedPermissions}, and will have |
Svetoslav | c6d1c34 | 2015-02-26 14:44:43 -0800 | [diff] [blame] | 216 | * the flag {@link #REQUESTED_PERMISSION_GRANTED} set as appropriate. |
Dianne Hackborn | e639da7 | 2012-02-21 15:11:13 -0800 | [diff] [blame] | 217 | */ |
| 218 | public int[] requestedPermissionsFlags; |
| 219 | |
| 220 | /** |
| 221 | * Flag for {@link #requestedPermissionsFlags}: the requested permission |
| 222 | * is required for the application to run; the user can not optionally |
Nick Kralevich | 32eb5b18 | 2013-04-11 10:20:09 -0700 | [diff] [blame] | 223 | * disable it. Currently all permissions are required. |
Svetoslav | c6d1c34 | 2015-02-26 14:44:43 -0800 | [diff] [blame] | 224 | * |
| 225 | * @removed We do not support required permissions. |
Dianne Hackborn | e639da7 | 2012-02-21 15:11:13 -0800 | [diff] [blame] | 226 | */ |
| 227 | public static final int REQUESTED_PERMISSION_REQUIRED = 1<<0; |
| 228 | |
| 229 | /** |
| 230 | * Flag for {@link #requestedPermissionsFlags}: the requested permission |
| 231 | * is currently granted to the application. |
| 232 | */ |
| 233 | public static final int REQUESTED_PERMISSION_GRANTED = 1<<1; |
| 234 | |
| 235 | /** |
Svetoslav Ganov | cdd685c | 2017-08-22 14:35:04 -0700 | [diff] [blame] | 236 | * Array of all signatures read from the package file. This is only filled |
| 237 | * in if the flag {@link PackageManager#GET_SIGNATURES} was set. A package |
Xin Wei Chow | 6ab8afb | 2018-09-01 09:12:58 +1000 | [diff] [blame] | 238 | * must be signed with at least one certificate which is at position zero. |
Svetoslav Ganov | cdd685c | 2017-08-22 14:35:04 -0700 | [diff] [blame] | 239 | * The package can be signed with additional certificates which appear as |
| 240 | * subsequent entries. |
| 241 | * |
| 242 | * <strong>Note:</strong> Signature ordering is not guaranteed to be |
| 243 | * stable which means that a package signed with certificates A and B is |
| 244 | * equivalent to being signed with certificates B and A. This means that |
| 245 | * in case multiple signatures are reported you cannot assume the one at |
| 246 | * the first position to be the same across updates. |
Daniel Cashman | 5cdda34 | 2018-01-19 07:22:52 -0800 | [diff] [blame] | 247 | * |
| 248 | * <strong>Deprecated</strong> This has been replaced by the |
Dan Cashman | 5c9f527e | 2018-04-03 16:42:23 -0700 | [diff] [blame] | 249 | * {@link PackageInfo#signingInfo} field, which takes into |
Daniel Cashman | 5cdda34 | 2018-01-19 07:22:52 -0800 | [diff] [blame] | 250 | * account signing certificate rotation. For backwards compatibility in |
| 251 | * the event of signing certificate rotation, this will return the oldest |
| 252 | * reported signing certificate, so that an application will appear to |
| 253 | * callers as though no rotation occurred. |
| 254 | * |
Dan Cashman | e942b91 | 2018-04-16 14:41:24 -0700 | [diff] [blame] | 255 | * @deprecated use {@code signingInfo} instead |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 256 | */ |
Daniel Cashman | 5cdda34 | 2018-01-19 07:22:52 -0800 | [diff] [blame] | 257 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 258 | public Signature[] signatures; |
Daniel Cashman | 5cdda34 | 2018-01-19 07:22:52 -0800 | [diff] [blame] | 259 | |
| 260 | /** |
Dan Cashman | 5c9f527e | 2018-04-03 16:42:23 -0700 | [diff] [blame] | 261 | * Signing information read from the package file, potentially |
Daniel Cashman | 5cdda34 | 2018-01-19 07:22:52 -0800 | [diff] [blame] | 262 | * including past signing certificates no longer used after signing |
Dan Cashman | 5c9f527e | 2018-04-03 16:42:23 -0700 | [diff] [blame] | 263 | * certificate rotation. This is only filled in if |
Daniel Cashman | 5cdda34 | 2018-01-19 07:22:52 -0800 | [diff] [blame] | 264 | * the flag {@link PackageManager#GET_SIGNING_CERTIFICATES} was set. |
| 265 | * |
Dan Cashman | 5c9f527e | 2018-04-03 16:42:23 -0700 | [diff] [blame] | 266 | * Use this field instead of the deprecated {@code signatures} field. |
| 267 | * See {@link SigningInfo} for more information on its contents. |
Daniel Cashman | 5cdda34 | 2018-01-19 07:22:52 -0800 | [diff] [blame] | 268 | */ |
Dan Cashman | 5c9f527e | 2018-04-03 16:42:23 -0700 | [diff] [blame] | 269 | public SigningInfo signingInfo; |
Daniel Cashman | 5cdda34 | 2018-01-19 07:22:52 -0800 | [diff] [blame] | 270 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 271 | /** |
| 272 | * Application specified preferred configuration |
| 273 | * {@link android.R.styleable#AndroidManifestUsesConfiguration |
| 274 | * <uses-configuration>} tags included under <manifest>, |
| 275 | * or null if there were none. This is only filled in if the flag |
Adam Lesinski | d3edfde | 2014-08-08 17:32:44 -0700 | [diff] [blame] | 276 | * {@link PackageManager#GET_CONFIGURATIONS} was set. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 277 | */ |
| 278 | public ConfigurationInfo[] configPreferences; |
| 279 | |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 280 | /** |
Jeff Sharkey | da96e13 | 2014-07-15 14:54:09 -0700 | [diff] [blame] | 281 | * Features that this application has requested. |
| 282 | * |
| 283 | * @see FeatureInfo#FLAG_REQUIRED |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 284 | */ |
| 285 | public FeatureInfo[] reqFeatures; |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 286 | |
| 287 | /** |
Adam Lesinski | d3edfde | 2014-08-08 17:32:44 -0700 | [diff] [blame] | 288 | * Groups of features that this application has requested. |
| 289 | * Each group contains a set of features that are required. |
| 290 | * A device must match the features listed in {@link #reqFeatures} and one |
| 291 | * or more FeatureGroups in order to have satisfied the feature requirement. |
| 292 | * |
| 293 | * @see FeatureInfo#FLAG_REQUIRED |
| 294 | */ |
| 295 | public FeatureGroupInfo[] featureGroups; |
| 296 | |
| 297 | /** |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 298 | * Constant corresponding to <code>auto</code> in |
| 299 | * the {@link android.R.attr#installLocation} attribute. |
| 300 | * @hide |
| 301 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 302 | @UnsupportedAppUsage |
Suchi Amalapurapu | 90d8ee6 | 2010-03-18 11:38:35 -0700 | [diff] [blame] | 303 | public static final int INSTALL_LOCATION_UNSPECIFIED = -1; |
Jeff Sharkey | 6c833e0 | 2014-07-14 22:44:30 -0700 | [diff] [blame] | 304 | |
Suchi Amalapurapu | 90d8ee6 | 2010-03-18 11:38:35 -0700 | [diff] [blame] | 305 | /** |
Jeff Sharkey | 6c833e0 | 2014-07-14 22:44:30 -0700 | [diff] [blame] | 306 | * Constant corresponding to <code>auto</code> in the |
| 307 | * {@link android.R.attr#installLocation} attribute. |
Suchi Amalapurapu | 90d8ee6 | 2010-03-18 11:38:35 -0700 | [diff] [blame] | 308 | */ |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 309 | public static final int INSTALL_LOCATION_AUTO = 0; |
Jeff Sharkey | 6c833e0 | 2014-07-14 22:44:30 -0700 | [diff] [blame] | 310 | |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 311 | /** |
Jeff Sharkey | 6c833e0 | 2014-07-14 22:44:30 -0700 | [diff] [blame] | 312 | * Constant corresponding to <code>internalOnly</code> in the |
| 313 | * {@link android.R.attr#installLocation} attribute. |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 314 | */ |
| 315 | public static final int INSTALL_LOCATION_INTERNAL_ONLY = 1; |
Jeff Sharkey | 6c833e0 | 2014-07-14 22:44:30 -0700 | [diff] [blame] | 316 | |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 317 | /** |
Jeff Sharkey | 6c833e0 | 2014-07-14 22:44:30 -0700 | [diff] [blame] | 318 | * Constant corresponding to <code>preferExternal</code> in the |
| 319 | * {@link android.R.attr#installLocation} attribute. |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 320 | */ |
| 321 | public static final int INSTALL_LOCATION_PREFER_EXTERNAL = 2; |
Jeff Sharkey | 6c833e0 | 2014-07-14 22:44:30 -0700 | [diff] [blame] | 322 | |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 323 | /** |
Jeff Sharkey | 6c833e0 | 2014-07-14 22:44:30 -0700 | [diff] [blame] | 324 | * The install location requested by the package. From the |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 325 | * {@link android.R.attr#installLocation} attribute, one of |
Jeff Sharkey | 6c833e0 | 2014-07-14 22:44:30 -0700 | [diff] [blame] | 326 | * {@link #INSTALL_LOCATION_AUTO}, {@link #INSTALL_LOCATION_INTERNAL_ONLY}, |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 327 | * {@link #INSTALL_LOCATION_PREFER_EXTERNAL} |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 328 | */ |
| 329 | public int installLocation = INSTALL_LOCATION_INTERNAL_ONLY; |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 330 | |
| 331 | /** @hide */ |
Todd Kennedy | 7c8addf | 2017-06-27 14:13:55 -0700 | [diff] [blame] | 332 | public boolean isStub; |
| 333 | |
| 334 | /** @hide */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 335 | @UnsupportedAppUsage |
Jeff Hao | 272bf3a | 2014-10-08 13:34:43 -0700 | [diff] [blame] | 336 | public boolean coreApp; |
| 337 | |
| 338 | /** @hide */ |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 339 | public boolean requiredForAllUsers; |
| 340 | |
Amith Yamasani | 0ac1fc9 | 2013-03-27 18:56:08 -0700 | [diff] [blame] | 341 | /** @hide */ |
| 342 | public String restrictedAccountType; |
| 343 | |
Amith Yamasani | ccbe389 | 2013-04-12 17:52:42 -0700 | [diff] [blame] | 344 | /** @hide */ |
| 345 | public String requiredAccountType; |
| 346 | |
MÃ¥rten Kongstad | 48d2232 | 2014-01-31 14:43:27 +0100 | [diff] [blame] | 347 | /** |
| 348 | * What package, if any, this package will overlay. |
| 349 | * |
| 350 | * Package name of target package, or null. |
| 351 | * @hide |
| 352 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 353 | @UnsupportedAppUsage |
MÃ¥rten Kongstad | 48d2232 | 2014-01-31 14:43:27 +0100 | [diff] [blame] | 354 | public String overlayTarget; |
| 355 | |
Adrian Roos | c84df77 | 2018-01-19 21:20:22 +0100 | [diff] [blame] | 356 | /** |
Ryan Mitchell | a362846 | 2019-01-14 12:19:40 -0800 | [diff] [blame] | 357 | * What overlayable set of elements package, if any, this package will overlay. |
| 358 | * |
| 359 | * Overlayable name defined within the target package, or null. |
| 360 | * @hide |
| 361 | */ |
| 362 | public String overlayTargetName; |
| 363 | |
| 364 | /** |
Adrian Roos | c84df77 | 2018-01-19 21:20:22 +0100 | [diff] [blame] | 365 | * The overlay category, if any, of this package |
| 366 | * |
| 367 | * @hide |
| 368 | */ |
| 369 | public String overlayCategory; |
| 370 | |
Jaekyun Seok | 0434289 | 2017-03-02 15:24:19 +0900 | [diff] [blame] | 371 | /** @hide */ |
Jaekyun Seok | 42d53f6 | 2017-04-10 13:48:58 +0900 | [diff] [blame] | 372 | public int overlayPriority; |
| 373 | |
Adam Lesinski | ab56b9d | 2017-11-14 00:50:18 -0800 | [diff] [blame] | 374 | /** |
Adam Lesinski | e733497 | 2018-01-17 16:13:52 -0800 | [diff] [blame] | 375 | * Whether the overlay is static, meaning it cannot be enabled/disabled at runtime. |
Adam Lesinski | ab56b9d | 2017-11-14 00:50:18 -0800 | [diff] [blame] | 376 | */ |
Adam Lesinski | e733497 | 2018-01-17 16:13:52 -0800 | [diff] [blame] | 377 | boolean mOverlayIsStatic; |
Jaekyun Seok | 0434289 | 2017-03-02 15:24:19 +0900 | [diff] [blame] | 378 | |
Alan Viverette | b6a2573 | 2017-11-21 14:49:24 -0500 | [diff] [blame] | 379 | /** |
| 380 | * The user-visible SDK version (ex. 26) of the framework against which the application claims |
| 381 | * to have been compiled, or {@code 0} if not specified. |
| 382 | * <p> |
| 383 | * This property is the compile-time equivalent of |
| 384 | * {@link android.os.Build.VERSION#SDK_INT Build.VERSION.SDK_INT}. |
| 385 | * |
| 386 | * @hide For platform use only; we don't expect developers to need to read this value. |
| 387 | */ |
| 388 | public int compileSdkVersion; |
| 389 | |
| 390 | /** |
| 391 | * The development codename (ex. "O", "REL") of the framework against which the application |
| 392 | * claims to have been compiled, or {@code null} if not specified. |
| 393 | * <p> |
| 394 | * This property is the compile-time equivalent of |
| 395 | * {@link android.os.Build.VERSION#CODENAME Build.VERSION.CODENAME}. |
| 396 | * |
| 397 | * @hide For platform use only; we don't expect developers to need to read this value. |
| 398 | */ |
| 399 | @Nullable |
| 400 | public String compileSdkVersionCodename; |
| 401 | |
Dario Freni | cb7a68d | 2018-10-18 11:49:50 +0100 | [diff] [blame] | 402 | /** |
| 403 | * Whether the package is an APEX package. |
| 404 | */ |
| 405 | public boolean isApex; |
| 406 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 407 | public PackageInfo() { |
| 408 | } |
| 409 | |
Adam Lesinski | ab56b9d | 2017-11-14 00:50:18 -0800 | [diff] [blame] | 410 | /** |
| 411 | * Returns true if the package is a valid Runtime Overlay package. |
| 412 | * @hide |
| 413 | */ |
| 414 | public boolean isOverlayPackage() { |
Adam Lesinski | e733497 | 2018-01-17 16:13:52 -0800 | [diff] [blame] | 415 | return overlayTarget != null; |
Adam Lesinski | ab56b9d | 2017-11-14 00:50:18 -0800 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | /** |
| 419 | * Returns true if the package is a valid static Runtime Overlay package. Static overlays |
| 420 | * are not updatable outside of a system update and are safe to load in the system process. |
| 421 | * @hide |
| 422 | */ |
| 423 | public boolean isStaticOverlayPackage() { |
Adam Lesinski | e733497 | 2018-01-17 16:13:52 -0800 | [diff] [blame] | 424 | return overlayTarget != null && mOverlayIsStatic; |
Adam Lesinski | ab56b9d | 2017-11-14 00:50:18 -0800 | [diff] [blame] | 425 | } |
| 426 | |
Jeff Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 427 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 428 | public String toString() { |
| 429 | return "PackageInfo{" |
| 430 | + Integer.toHexString(System.identityHashCode(this)) |
| 431 | + " " + packageName + "}"; |
| 432 | } |
| 433 | |
Jeff Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 434 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 435 | public int describeContents() { |
| 436 | return 0; |
| 437 | } |
| 438 | |
Jeff Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 439 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 440 | public void writeToParcel(Parcel dest, int parcelableFlags) { |
| 441 | dest.writeString(packageName); |
Jeff Sharkey | 6c833e0 | 2014-07-14 22:44:30 -0700 | [diff] [blame] | 442 | dest.writeStringArray(splitNames); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 443 | dest.writeInt(versionCode); |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 444 | dest.writeInt(versionCodeMajor); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 445 | dest.writeString(versionName); |
Jeff Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 446 | dest.writeInt(baseRevisionCode); |
| 447 | dest.writeIntArray(splitRevisionCodes); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 448 | dest.writeString(sharedUserId); |
| 449 | dest.writeInt(sharedUserLabel); |
| 450 | if (applicationInfo != null) { |
| 451 | dest.writeInt(1); |
| 452 | applicationInfo.writeToParcel(dest, parcelableFlags); |
| 453 | } else { |
| 454 | dest.writeInt(0); |
| 455 | } |
Dianne Hackborn | 78d688369 | 2010-10-07 01:12:46 -0700 | [diff] [blame] | 456 | dest.writeLong(firstInstallTime); |
| 457 | dest.writeLong(lastUpdateTime); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 458 | dest.writeIntArray(gids); |
Christopher Tate | b911676 | 2015-09-09 18:46:31 -0700 | [diff] [blame] | 459 | dest.writeTypedArray(activities, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES); |
| 460 | dest.writeTypedArray(receivers, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES); |
| 461 | dest.writeTypedArray(services, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES); |
| 462 | dest.writeTypedArray(providers, parcelableFlags | Parcelable.PARCELABLE_ELIDE_DUPLICATES); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 463 | dest.writeTypedArray(instrumentation, parcelableFlags); |
| 464 | dest.writeTypedArray(permissions, parcelableFlags); |
| 465 | dest.writeStringArray(requestedPermissions); |
Dianne Hackborn | e639da7 | 2012-02-21 15:11:13 -0800 | [diff] [blame] | 466 | dest.writeIntArray(requestedPermissionsFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 467 | dest.writeTypedArray(signatures, parcelableFlags); |
| 468 | dest.writeTypedArray(configPreferences, parcelableFlags); |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 469 | dest.writeTypedArray(reqFeatures, parcelableFlags); |
Adam Lesinski | d3edfde | 2014-08-08 17:32:44 -0700 | [diff] [blame] | 470 | dest.writeTypedArray(featureGroups, parcelableFlags); |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 471 | dest.writeInt(installLocation); |
Todd Kennedy | 7c8addf | 2017-06-27 14:13:55 -0700 | [diff] [blame] | 472 | dest.writeInt(isStub ? 1 : 0); |
Jeff Hao | 272bf3a | 2014-10-08 13:34:43 -0700 | [diff] [blame] | 473 | dest.writeInt(coreApp ? 1 : 0); |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 474 | dest.writeInt(requiredForAllUsers ? 1 : 0); |
Amith Yamasani | 0ac1fc9 | 2013-03-27 18:56:08 -0700 | [diff] [blame] | 475 | dest.writeString(restrictedAccountType); |
Amith Yamasani | ccbe389 | 2013-04-12 17:52:42 -0700 | [diff] [blame] | 476 | dest.writeString(requiredAccountType); |
MÃ¥rten Kongstad | 48d2232 | 2014-01-31 14:43:27 +0100 | [diff] [blame] | 477 | dest.writeString(overlayTarget); |
Adrian Roos | c84df77 | 2018-01-19 21:20:22 +0100 | [diff] [blame] | 478 | dest.writeString(overlayCategory); |
Jaekyun Seok | 42d53f6 | 2017-04-10 13:48:58 +0900 | [diff] [blame] | 479 | dest.writeInt(overlayPriority); |
Adam Lesinski | e733497 | 2018-01-17 16:13:52 -0800 | [diff] [blame] | 480 | dest.writeBoolean(mOverlayIsStatic); |
Alan Viverette | b6a2573 | 2017-11-21 14:49:24 -0500 | [diff] [blame] | 481 | dest.writeInt(compileSdkVersion); |
| 482 | dest.writeString(compileSdkVersionCodename); |
Dan Cashman | 5c9f527e | 2018-04-03 16:42:23 -0700 | [diff] [blame] | 483 | if (signingInfo != null) { |
| 484 | dest.writeInt(1); |
| 485 | signingInfo.writeToParcel(dest, parcelableFlags); |
Dan Cashman | 050b799 | 2018-02-06 17:08:58 -0800 | [diff] [blame] | 486 | } else { |
Dan Cashman | 5c9f527e | 2018-04-03 16:42:23 -0700 | [diff] [blame] | 487 | dest.writeInt(0); |
Dan Cashman | 050b799 | 2018-02-06 17:08:58 -0800 | [diff] [blame] | 488 | } |
Dario Freni | cb7a68d | 2018-10-18 11:49:50 +0100 | [diff] [blame] | 489 | dest.writeBoolean(isApex); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | public static final Parcelable.Creator<PackageInfo> CREATOR |
| 493 | = new Parcelable.Creator<PackageInfo>() { |
Jeff Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 494 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 495 | public PackageInfo createFromParcel(Parcel source) { |
| 496 | return new PackageInfo(source); |
| 497 | } |
| 498 | |
Jeff Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 499 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 500 | public PackageInfo[] newArray(int size) { |
| 501 | return new PackageInfo[size]; |
| 502 | } |
| 503 | }; |
| 504 | |
Mathew Inwood | 31755f9 | 2018-12-20 13:53:36 +0000 | [diff] [blame] | 505 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 506 | private PackageInfo(Parcel source) { |
| 507 | packageName = source.readString(); |
Jeff Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 508 | splitNames = source.createStringArray(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 509 | versionCode = source.readInt(); |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 510 | versionCodeMajor = source.readInt(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 511 | versionName = source.readString(); |
Jeff Sharkey | 88d2a3c | 2014-11-22 16:49:34 -0800 | [diff] [blame] | 512 | baseRevisionCode = source.readInt(); |
| 513 | splitRevisionCodes = source.createIntArray(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 514 | sharedUserId = source.readString(); |
| 515 | sharedUserLabel = source.readInt(); |
| 516 | int hasApp = source.readInt(); |
| 517 | if (hasApp != 0) { |
| 518 | applicationInfo = ApplicationInfo.CREATOR.createFromParcel(source); |
| 519 | } |
Dianne Hackborn | 78d688369 | 2010-10-07 01:12:46 -0700 | [diff] [blame] | 520 | firstInstallTime = source.readLong(); |
| 521 | lastUpdateTime = source.readLong(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 522 | gids = source.createIntArray(); |
| 523 | activities = source.createTypedArray(ActivityInfo.CREATOR); |
| 524 | receivers = source.createTypedArray(ActivityInfo.CREATOR); |
| 525 | services = source.createTypedArray(ServiceInfo.CREATOR); |
| 526 | providers = source.createTypedArray(ProviderInfo.CREATOR); |
| 527 | instrumentation = source.createTypedArray(InstrumentationInfo.CREATOR); |
| 528 | permissions = source.createTypedArray(PermissionInfo.CREATOR); |
| 529 | requestedPermissions = source.createStringArray(); |
Dianne Hackborn | e639da7 | 2012-02-21 15:11:13 -0800 | [diff] [blame] | 530 | requestedPermissionsFlags = source.createIntArray(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 531 | signatures = source.createTypedArray(Signature.CREATOR); |
| 532 | configPreferences = source.createTypedArray(ConfigurationInfo.CREATOR); |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 533 | reqFeatures = source.createTypedArray(FeatureInfo.CREATOR); |
Adam Lesinski | d3edfde | 2014-08-08 17:32:44 -0700 | [diff] [blame] | 534 | featureGroups = source.createTypedArray(FeatureGroupInfo.CREATOR); |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 535 | installLocation = source.readInt(); |
Todd Kennedy | 7c8addf | 2017-06-27 14:13:55 -0700 | [diff] [blame] | 536 | isStub = source.readInt() != 0; |
Jeff Hao | 272bf3a | 2014-10-08 13:34:43 -0700 | [diff] [blame] | 537 | coreApp = source.readInt() != 0; |
Amith Yamasani | df2e92a | 2013-03-01 17:04:38 -0800 | [diff] [blame] | 538 | requiredForAllUsers = source.readInt() != 0; |
Amith Yamasani | 0ac1fc9 | 2013-03-27 18:56:08 -0700 | [diff] [blame] | 539 | restrictedAccountType = source.readString(); |
Amith Yamasani | ccbe389 | 2013-04-12 17:52:42 -0700 | [diff] [blame] | 540 | requiredAccountType = source.readString(); |
MÃ¥rten Kongstad | 48d2232 | 2014-01-31 14:43:27 +0100 | [diff] [blame] | 541 | overlayTarget = source.readString(); |
Adrian Roos | c84df77 | 2018-01-19 21:20:22 +0100 | [diff] [blame] | 542 | overlayCategory = source.readString(); |
Jaekyun Seok | 42d53f6 | 2017-04-10 13:48:58 +0900 | [diff] [blame] | 543 | overlayPriority = source.readInt(); |
Adam Lesinski | e733497 | 2018-01-17 16:13:52 -0800 | [diff] [blame] | 544 | mOverlayIsStatic = source.readBoolean(); |
Alan Viverette | b6a2573 | 2017-11-21 14:49:24 -0500 | [diff] [blame] | 545 | compileSdkVersion = source.readInt(); |
| 546 | compileSdkVersionCodename = source.readString(); |
Dan Cashman | 5c9f527e | 2018-04-03 16:42:23 -0700 | [diff] [blame] | 547 | int hasSigningInfo = source.readInt(); |
| 548 | if (hasSigningInfo != 0) { |
| 549 | signingInfo = SigningInfo.CREATOR.createFromParcel(source); |
| 550 | } |
Dario Freni | cb7a68d | 2018-10-18 11:49:50 +0100 | [diff] [blame] | 551 | isApex = source.readBoolean(); |
Christopher Tate | b911676 | 2015-09-09 18:46:31 -0700 | [diff] [blame] | 552 | // The component lists were flattened with the redundant ApplicationInfo |
| 553 | // instances omitted. Distribute the canonical one here as appropriate. |
| 554 | if (applicationInfo != null) { |
| 555 | propagateApplicationInfo(applicationInfo, activities); |
| 556 | propagateApplicationInfo(applicationInfo, receivers); |
| 557 | propagateApplicationInfo(applicationInfo, services); |
| 558 | propagateApplicationInfo(applicationInfo, providers); |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | private void propagateApplicationInfo(ApplicationInfo appInfo, ComponentInfo[] components) { |
| 563 | if (components != null) { |
| 564 | for (ComponentInfo ci : components) { |
| 565 | ci.applicationInfo = appInfo; |
| 566 | } |
| 567 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 568 | } |
| 569 | } |