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