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