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