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