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