1 /* 2 * Copyright (C) 2020 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 17 package com.android.internal.pm.parsing.pkg; 18 19 import static java.util.Collections.emptyList; 20 import static java.util.Collections.emptyMap; 21 import static java.util.Collections.emptySet; 22 23 import android.annotation.LongDef; 24 import android.annotation.NonNull; 25 import android.annotation.Nullable; 26 import android.content.Intent; 27 import android.content.IntentFilter; 28 import android.content.pm.ActivityInfo; 29 import android.content.pm.ApplicationInfo; 30 import android.content.pm.ConfigurationInfo; 31 import android.content.pm.FeatureGroupInfo; 32 import android.content.pm.FeatureInfo; 33 import android.content.pm.PackageInfo; 34 import android.content.pm.PackageManager; 35 import android.content.pm.SigningDetails; 36 import android.content.res.TypedArray; 37 import android.os.Build; 38 import android.os.Bundle; 39 import android.os.Environment; 40 import android.os.Parcel; 41 import android.os.Parcelable; 42 import android.os.UserHandle; 43 import android.os.storage.StorageManager; 44 import android.text.TextUtils; 45 import android.util.ArrayMap; 46 import android.util.ArraySet; 47 import android.util.Pair; 48 import android.util.SparseArray; 49 import android.util.SparseIntArray; 50 51 import com.android.internal.R; 52 import com.android.internal.annotations.VisibleForTesting; 53 import com.android.internal.pm.parsing.AppInfoUtils; 54 import com.android.internal.pm.pkg.AndroidPackageSplitImpl; 55 import com.android.internal.pm.pkg.SEInfoUtil; 56 import com.android.internal.pm.pkg.component.ComponentMutateUtils; 57 import com.android.internal.pm.pkg.component.ParsedActivity; 58 import com.android.internal.pm.pkg.component.ParsedActivityImpl; 59 import com.android.internal.pm.pkg.component.ParsedApexSystemService; 60 import com.android.internal.pm.pkg.component.ParsedApexSystemServiceImpl; 61 import com.android.internal.pm.pkg.component.ParsedAttribution; 62 import com.android.internal.pm.pkg.component.ParsedAttributionImpl; 63 import com.android.internal.pm.pkg.component.ParsedComponent; 64 import com.android.internal.pm.pkg.component.ParsedInstrumentation; 65 import com.android.internal.pm.pkg.component.ParsedInstrumentationImpl; 66 import com.android.internal.pm.pkg.component.ParsedIntentInfo; 67 import com.android.internal.pm.pkg.component.ParsedMainComponent; 68 import com.android.internal.pm.pkg.component.ParsedPermission; 69 import com.android.internal.pm.pkg.component.ParsedPermissionGroup; 70 import com.android.internal.pm.pkg.component.ParsedPermissionGroupImpl; 71 import com.android.internal.pm.pkg.component.ParsedPermissionImpl; 72 import com.android.internal.pm.pkg.component.ParsedProcess; 73 import com.android.internal.pm.pkg.component.ParsedProcessImpl; 74 import com.android.internal.pm.pkg.component.ParsedProvider; 75 import com.android.internal.pm.pkg.component.ParsedProviderImpl; 76 import com.android.internal.pm.pkg.component.ParsedService; 77 import com.android.internal.pm.pkg.component.ParsedServiceImpl; 78 import com.android.internal.pm.pkg.component.ParsedUsesPermission; 79 import com.android.internal.pm.pkg.component.ParsedUsesPermissionImpl; 80 import com.android.internal.pm.pkg.parsing.ParsingPackage; 81 import com.android.internal.pm.pkg.parsing.ParsingPackageHidden; 82 import com.android.internal.pm.pkg.parsing.ParsingPackageUtils; 83 import com.android.internal.pm.pkg.parsing.ParsingUtils; 84 import com.android.internal.util.ArrayUtils; 85 import com.android.internal.util.CollectionUtils; 86 import com.android.internal.util.DataClass; 87 import com.android.internal.util.Parcelling; 88 import com.android.internal.util.Parcelling.BuiltIn.ForInternedString; 89 import com.android.server.pm.pkg.AndroidPackage; 90 import com.android.server.pm.pkg.AndroidPackageSplit; 91 92 import libcore.util.EmptyArray; 93 94 import java.io.File; 95 import java.security.PublicKey; 96 import java.util.ArrayList; 97 import java.util.Arrays; 98 import java.util.Collections; 99 import java.util.Comparator; 100 import java.util.List; 101 import java.util.Map; 102 import java.util.Set; 103 import java.util.UUID; 104 105 /** 106 * Extensions to {@link PackageImpl} including fields/state contained in the system server 107 * and not exposed to the core SDK. 108 * 109 * @hide 110 */ 111 public class PackageImpl implements ParsedPackage, AndroidPackageInternal, 112 AndroidPackageHidden, ParsingPackage, ParsingPackageHidden, Parcelable { 113 114 private static final SparseArray<int[]> EMPTY_INT_ARRAY_SPARSE_ARRAY = new SparseArray<>(); 115 private static final Comparator<ParsedMainComponent> ORDER_COMPARATOR = 116 (first, second) -> Integer.compare(second.getOrder(), first.getOrder()); 117 public static final Parcelling.BuiltIn.ForBoolean sForBoolean = Parcelling.Cache.getOrCreate( 118 Parcelling.BuiltIn.ForBoolean.class); 119 public static final ForInternedString sForInternedString = Parcelling.Cache.getOrCreate( 120 ForInternedString.class); 121 public static final Parcelling.BuiltIn.ForInternedStringArray sForInternedStringArray = 122 Parcelling.Cache.getOrCreate(Parcelling.BuiltIn.ForInternedStringArray.class); 123 public static final Parcelling.BuiltIn.ForInternedStringList sForInternedStringList = 124 Parcelling.Cache.getOrCreate(Parcelling.BuiltIn.ForInternedStringList.class); 125 public static final Parcelling.BuiltIn.ForInternedStringValueMap sForInternedStringValueMap = 126 Parcelling.Cache.getOrCreate(Parcelling.BuiltIn.ForInternedStringValueMap.class); 127 public static final Parcelling.BuiltIn.ForStringSet sForStringSet = 128 Parcelling.Cache.getOrCreate(Parcelling.BuiltIn.ForStringSet.class); 129 public static final Parcelling.BuiltIn.ForInternedStringSet sForInternedStringSet = 130 Parcelling.Cache.getOrCreate(Parcelling.BuiltIn.ForInternedStringSet.class); 131 protected static final ParsingUtils.StringPairListParceler sForIntentInfoPairs = 132 new ParsingUtils.StringPairListParceler(); 133 protected int versionCode; 134 protected int versionCodeMajor; 135 @NonNull 136 @DataClass.ParcelWith(ForInternedString.class) 137 protected String packageName; 138 @NonNull 139 protected String mBaseApkPath; 140 @NonNull 141 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringList.class) 142 protected List<String> usesLibraries = emptyList(); 143 @NonNull 144 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringList.class) 145 protected List<String> usesOptionalLibraries = emptyList(); 146 @NonNull 147 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringList.class) 148 protected List<String> usesNativeLibraries = emptyList(); 149 @NonNull 150 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringList.class) 151 protected List<String> usesOptionalNativeLibraries = emptyList(); 152 @NonNull 153 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringList.class) 154 protected List<String> originalPackages = emptyList(); 155 @NonNull 156 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringList.class) 157 protected List<String> adoptPermissions = emptyList(); 158 /** 159 * @deprecated consider migrating to {@link #getUsesPermissions} which has 160 * more parsed details, such as flags 161 */ 162 @NonNull 163 @Deprecated 164 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringSet.class) 165 protected Set<String> requestedPermissions = emptySet(); 166 @NonNull 167 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringList.class) 168 protected List<String> protectedBroadcasts = emptyList(); 169 @NonNull 170 protected List<ParsedActivity> activities = emptyList(); 171 @NonNull 172 protected List<ParsedApexSystemService> apexSystemServices = emptyList(); 173 @NonNull 174 protected List<ParsedActivity> receivers = emptyList(); 175 @NonNull 176 protected List<ParsedService> services = emptyList(); 177 @NonNull 178 protected List<ParsedProvider> providers = emptyList(); 179 @NonNull 180 protected List<ParsedPermission> permissions = emptyList(); 181 @NonNull 182 protected List<ParsedPermissionGroup> permissionGroups = emptyList(); 183 @NonNull 184 protected List<ParsedInstrumentation> instrumentations = emptyList(); 185 @Nullable 186 @DataClass.ParcelWith(ForInternedString.class) 187 protected String volumeUuid; 188 @NonNull 189 @DataClass.ParcelWith(ForInternedString.class) 190 protected String mPath; 191 @Nullable 192 protected String[] splitCodePaths; 193 @NonNull 194 protected UUID mStorageUuid; 195 // These are objects because null represents not explicitly set 196 @Nullable 197 @DataClass.ParcelWith(Parcelling.BuiltIn.ForBoolean.class) 198 private Boolean supportsSmallScreens; 199 @Nullable 200 @DataClass.ParcelWith(Parcelling.BuiltIn.ForBoolean.class) 201 private Boolean supportsNormalScreens; 202 @Nullable 203 @DataClass.ParcelWith(Parcelling.BuiltIn.ForBoolean.class) 204 private Boolean supportsLargeScreens; 205 @Nullable 206 @DataClass.ParcelWith(Parcelling.BuiltIn.ForBoolean.class) 207 private Boolean supportsExtraLargeScreens; 208 @Nullable 209 @DataClass.ParcelWith(Parcelling.BuiltIn.ForBoolean.class) 210 private Boolean resizeable; 211 @Nullable 212 @DataClass.ParcelWith(Parcelling.BuiltIn.ForBoolean.class) 213 private Boolean anyDensity; 214 private int baseRevisionCode; 215 @Nullable 216 @DataClass.ParcelWith(ForInternedString.class) 217 private String versionName; 218 private int compileSdkVersion; 219 @Nullable 220 @DataClass.ParcelWith(ForInternedString.class) 221 private String compileSdkVersionCodeName; 222 @Nullable 223 @DataClass.ParcelWith(ForInternedString.class) 224 private String restrictedAccountType; 225 @Nullable 226 @DataClass.ParcelWith(ForInternedString.class) 227 private String requiredAccountType; 228 @Nullable 229 @DataClass.ParcelWith(ForInternedString.class) 230 private String mEmergencyInstaller; 231 @Nullable 232 @DataClass.ParcelWith(ForInternedString.class) 233 private String overlayTarget; 234 @Nullable 235 @DataClass.ParcelWith(ForInternedString.class) 236 private String overlayTargetOverlayableName; 237 @Nullable 238 @DataClass.ParcelWith(ForInternedString.class) 239 private String overlayCategory; 240 private int overlayPriority; 241 @NonNull 242 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringValueMap.class) 243 private Map<String, String> overlayables = emptyMap(); 244 @Nullable 245 @DataClass.ParcelWith(ForInternedString.class) 246 private String sdkLibraryName; 247 private int sdkLibVersionMajor; 248 @Nullable 249 @DataClass.ParcelWith(ForInternedString.class) 250 private String staticSharedLibraryName; 251 private long staticSharedLibVersion; 252 @NonNull 253 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringList.class) 254 private List<String> libraryNames = emptyList(); 255 @NonNull 256 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringList.class) 257 private List<String> usesStaticLibraries = emptyList(); 258 @Nullable 259 private long[] usesStaticLibrariesVersions; 260 @Nullable 261 private String[][] usesStaticLibrariesCertDigests; 262 @NonNull 263 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringList.class) 264 private List<String> usesSdkLibraries = emptyList(); 265 @Nullable 266 private long[] usesSdkLibrariesVersionsMajor; 267 @Nullable 268 private String[][] usesSdkLibrariesCertDigests; 269 @Nullable 270 private boolean[] usesSdkLibrariesOptional; 271 @Nullable 272 @DataClass.ParcelWith(ForInternedString.class) 273 private String sharedUserId; 274 private int sharedUserLabel; 275 @NonNull 276 private List<ConfigurationInfo> configPreferences = emptyList(); 277 @NonNull 278 private List<FeatureInfo> reqFeatures = emptyList(); 279 @NonNull 280 private List<FeatureGroupInfo> featureGroups = emptyList(); 281 @Nullable 282 private byte[] restrictUpdateHash; 283 @NonNull 284 private List<ParsedUsesPermission> usesPermissions = emptyList(); 285 @NonNull 286 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringSet.class) 287 private Set<String> implicitPermissions = emptySet(); 288 @NonNull 289 private Set<String> upgradeKeySets = emptySet(); 290 @NonNull 291 private Map<String, ArraySet<PublicKey>> keySetMapping = emptyMap(); 292 @NonNull 293 private List<ParsedAttribution> attributions = emptyList(); 294 @NonNull 295 // @DataClass.ParcelWith(ParsingUtils.StringPairListParceler.class) 296 private List<Pair<String, ParsedIntentInfo>> preferredActivityFilters = emptyList(); 297 /** 298 * Map from a process name to a {@link ParsedProcess}. 299 */ 300 @NonNull 301 private Map<String, ParsedProcess> processes = emptyMap(); 302 @Nullable 303 private Bundle metaData; 304 @NonNull 305 private Map<String, PackageManager.Property> mProperties = emptyMap(); 306 @NonNull 307 private SigningDetails signingDetails = SigningDetails.UNKNOWN; 308 @NonNull 309 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringList.class) 310 private List<Intent> queriesIntents = emptyList(); 311 @NonNull 312 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringList.class) 313 private List<String> queriesPackages = emptyList(); 314 @NonNull 315 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringSet.class) 316 private Set<String> queriesProviders = emptySet(); 317 @Nullable 318 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringArray.class) 319 private String[] splitClassLoaderNames; 320 @Nullable 321 private SparseArray<int[]> splitDependencies; 322 @Nullable 323 private int[] splitFlags; 324 @Nullable 325 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringArray.class) 326 private String[] splitNames; 327 @Nullable 328 private int[] splitRevisionCodes; 329 @Nullable 330 @DataClass.ParcelWith(ForInternedString.class) 331 private String appComponentFactory; 332 @Nullable 333 @DataClass.ParcelWith(ForInternedString.class) 334 private String backupAgentName; 335 private int banner; 336 private int category = ApplicationInfo.CATEGORY_UNDEFINED; 337 @Nullable 338 @DataClass.ParcelWith(ForInternedString.class) 339 private String classLoaderName; 340 @Nullable 341 @DataClass.ParcelWith(ForInternedString.class) 342 private String className; 343 private int compatibleWidthLimitDp; 344 private int descriptionRes; 345 private int fullBackupContent; 346 private int dataExtractionRules; 347 private int iconRes; 348 private int installLocation = ParsingPackageUtils.PARSE_DEFAULT_INSTALL_LOCATION; 349 private int labelRes; 350 private int largestWidthLimitDp; 351 private int logo; 352 @Nullable 353 @DataClass.ParcelWith(ForInternedString.class) 354 private String manageSpaceActivityName; 355 private float maxAspectRatio; 356 private float minAspectRatio; 357 @Nullable 358 private SparseIntArray minExtensionVersions; 359 private int minSdkVersion = ParsingUtils.DEFAULT_MIN_SDK_VERSION; 360 private int maxSdkVersion = ParsingUtils.DEFAULT_MAX_SDK_VERSION; 361 private int networkSecurityConfigRes; 362 @Nullable 363 private CharSequence nonLocalizedLabel; 364 @Nullable 365 @DataClass.ParcelWith(ForInternedString.class) 366 private String permission; 367 @Nullable 368 @DataClass.ParcelWith(ForInternedString.class) 369 private String processName; 370 private int requiresSmallestWidthDp; 371 private int roundIconRes; 372 private int targetSandboxVersion; 373 private int targetSdkVersion = ParsingUtils.DEFAULT_TARGET_SDK_VERSION; 374 @Nullable 375 @DataClass.ParcelWith(ForInternedString.class) 376 private String taskAffinity; 377 private int theme; 378 private int uiOptions; 379 @Nullable 380 @DataClass.ParcelWith(ForInternedString.class) 381 private String zygotePreloadName; 382 /** 383 * @see AndroidPackage#getResizeableActivity() 384 */ 385 @Nullable 386 @DataClass.ParcelWith(Parcelling.BuiltIn.ForBoolean.class) 387 private Boolean resizeableActivity; 388 private int autoRevokePermissions; 389 @ApplicationInfo.GwpAsanMode 390 private int gwpAsanMode; 391 @ApplicationInfo.MemtagMode 392 private int memtagMode; 393 @ApplicationInfo.NativeHeapZeroInitialized 394 private int nativeHeapZeroInitialized; 395 @Nullable 396 @DataClass.ParcelWith(Parcelling.BuiltIn.ForBoolean.class) 397 private Boolean requestRawExternalStorageAccess; 398 @NonNull 399 @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringSet.class) 400 private Set<String> mimeGroups = emptySet(); 401 // Usually there's code to set enabled to true during parsing, but it's possible to install 402 // an APK targeting <R that doesn't contain an <application> tag. That code would be skipped 403 // and never assign this, so initialize this to true for those cases. 404 private long mBooleans = Booleans.ENABLED; 405 private long mBooleans2 = Booleans2.UPDATABLE_SYSTEM; 406 @NonNull 407 private Set<String> mKnownActivityEmbeddingCerts = emptySet(); 408 // Derived fields 409 private long mLongVersionCode; 410 private int mLocaleConfigRes; 411 private boolean mAllowCrossUidActivitySwitchFromBelow; 412 413 private List<AndroidPackageSplit> mSplits; 414 415 @NonNull 416 private String[] mUsesLibrariesSorted; 417 @NonNull 418 private String[] mUsesOptionalLibrariesSorted; 419 @NonNull 420 private String[] mUsesSdkLibrariesSorted; 421 @NonNull 422 private String[] mUsesStaticLibrariesSorted; 423 424 @NonNull forParsing(@onNull String packageName, @NonNull String baseCodePath, @NonNull String codePath, @NonNull TypedArray manifestArray, boolean isCoreApp, @Nullable ParsingPackageUtils.Callback callback)425 public static PackageImpl forParsing(@NonNull String packageName, @NonNull String baseCodePath, 426 @NonNull String codePath, @NonNull TypedArray manifestArray, boolean isCoreApp, 427 @Nullable ParsingPackageUtils.Callback callback) { 428 return new PackageImpl( 429 packageName, baseCodePath, codePath, manifestArray, isCoreApp, callback); 430 } 431 432 /** 433 * Mock an unavailable {@link AndroidPackage} to use when 434 * removing 435 * a package from the system. 436 * This can occur if the package was installed on a storage device that has since been removed. 437 * Since the infrastructure uses {@link AndroidPackage}, but 438 * for 439 * this case only cares about 440 * volumeUuid, just fake it rather than having separate method paths. 441 */ 442 @NonNull buildFakeForDeletion(String packageName, String volumeUuid)443 public static AndroidPackage buildFakeForDeletion(String packageName, String volumeUuid) { 444 return PackageImpl.forTesting(packageName) 445 .setVolumeUuid(volumeUuid) 446 .hideAsParsed() 447 .hideAsFinal(); 448 } 449 450 @NonNull 451 @VisibleForTesting forTesting(String packageName)452 public static ParsingPackage forTesting(String packageName) { 453 return forTesting(packageName, ""); 454 } 455 456 @NonNull 457 @VisibleForTesting forTesting(String packageName, String baseCodePath)458 public static ParsingPackage forTesting(String packageName, String baseCodePath) { 459 return new PackageImpl(packageName, baseCodePath, baseCodePath, null, false, null); 460 } 461 462 @NonNull 463 @DataClass.ParcelWith(ForInternedString.class) 464 private final String manifestPackageName; 465 466 @Nullable 467 @DataClass.ParcelWith(ForInternedString.class) 468 protected String nativeLibraryDir; 469 470 @Nullable 471 @DataClass.ParcelWith(ForInternedString.class) 472 protected String nativeLibraryRootDir; 473 474 @Nullable 475 @DataClass.ParcelWith(ForInternedString.class) 476 protected String primaryCpuAbi; 477 @Nullable 478 @DataClass.ParcelWith(ForInternedString.class) 479 protected String secondaryCpuAbi; 480 @Nullable 481 @DataClass.ParcelWith(ForInternedString.class) 482 protected String secondaryNativeLibraryDir; 483 484 /** 485 * This is an appId, the uid if the userId is == USER_SYSTEM 486 */ 487 private int uid = -1; 488 489 // This is kept around as a boolean to avoid flag calculation 490 // during ApplicationInfo generation. 491 private boolean nativeLibraryRootRequiresIsa; 492 493 @Override addActivity(ParsedActivity parsedActivity)494 public PackageImpl addActivity(ParsedActivity parsedActivity) { 495 this.activities = CollectionUtils.add(this.activities, parsedActivity); 496 addMimeGroupsFromComponent(parsedActivity); 497 return this; 498 } 499 500 @Override addAdoptPermission(String adoptPermission)501 public PackageImpl addAdoptPermission(String adoptPermission) { 502 this.adoptPermissions = CollectionUtils.add(this.adoptPermissions, 503 TextUtils.safeIntern(adoptPermission)); 504 return this; 505 } 506 507 @Override addApexSystemService( ParsedApexSystemService parsedApexSystemService)508 public final PackageImpl addApexSystemService( 509 ParsedApexSystemService parsedApexSystemService) { 510 this.apexSystemServices = CollectionUtils.add( 511 this.apexSystemServices, parsedApexSystemService); 512 return this; 513 } 514 515 @Override addAttribution(ParsedAttribution attribution)516 public PackageImpl addAttribution(ParsedAttribution attribution) { 517 this.attributions = CollectionUtils.add(this.attributions, attribution); 518 return this; 519 } 520 521 @Override addConfigPreference(ConfigurationInfo configPreference)522 public PackageImpl addConfigPreference(ConfigurationInfo configPreference) { 523 this.configPreferences = CollectionUtils.add(this.configPreferences, configPreference); 524 return this; 525 } 526 527 @Override addFeatureGroup(FeatureGroupInfo featureGroup)528 public PackageImpl addFeatureGroup(FeatureGroupInfo featureGroup) { 529 this.featureGroups = CollectionUtils.add(this.featureGroups, featureGroup); 530 return this; 531 } 532 533 @Override addImplicitPermission(String permission)534 public PackageImpl addImplicitPermission(String permission) { 535 addUsesPermission(new ParsedUsesPermissionImpl(permission, 0 /*usesPermissionFlags*/)); 536 this.implicitPermissions = CollectionUtils.add(this.implicitPermissions, 537 TextUtils.safeIntern(permission)); 538 return this; 539 } 540 541 @Override addInstrumentation(ParsedInstrumentation instrumentation)542 public PackageImpl addInstrumentation(ParsedInstrumentation instrumentation) { 543 this.instrumentations = CollectionUtils.add(this.instrumentations, instrumentation); 544 return this; 545 } 546 547 @Override addKeySet(String keySetName, PublicKey publicKey)548 public PackageImpl addKeySet(String keySetName, PublicKey publicKey) { 549 ArraySet<PublicKey> publicKeys = keySetMapping.get(keySetName); 550 if (publicKeys == null) { 551 publicKeys = new ArraySet<>(); 552 } 553 publicKeys.add(publicKey); 554 keySetMapping = CollectionUtils.add(this.keySetMapping, keySetName, publicKeys); 555 return this; 556 } 557 558 @Override addLibraryName(String libraryName)559 public PackageImpl addLibraryName(String libraryName) { 560 this.libraryNames = CollectionUtils.add(this.libraryNames, 561 TextUtils.safeIntern(libraryName)); 562 return this; 563 } 564 addMimeGroupsFromComponent(ParsedComponent component)565 private void addMimeGroupsFromComponent(ParsedComponent component) { 566 for (int i = component.getIntents().size() - 1; i >= 0; i--) { 567 IntentFilter filter = component.getIntents().get(i).getIntentFilter(); 568 for (int groupIndex = filter.countMimeGroups() - 1; groupIndex >= 0; groupIndex--) { 569 if (mimeGroups != null && mimeGroups.size() > 500) { 570 throw new IllegalStateException("Max limit on number of MIME Groups reached"); 571 } 572 mimeGroups = CollectionUtils.add(mimeGroups, filter.getMimeGroup(groupIndex)); 573 } 574 } 575 } 576 577 @Override addOriginalPackage(String originalPackage)578 public PackageImpl addOriginalPackage(String originalPackage) { 579 this.originalPackages = CollectionUtils.add(this.originalPackages, originalPackage); 580 return this; 581 } 582 583 @Override addOverlayable(String overlayableName, String actorName)584 public ParsingPackage addOverlayable(String overlayableName, String actorName) { 585 this.overlayables = CollectionUtils.add(this.overlayables, overlayableName, 586 TextUtils.safeIntern(actorName)); 587 return this; 588 } 589 590 @Override addPermission(ParsedPermission permission)591 public PackageImpl addPermission(ParsedPermission permission) { 592 this.permissions = CollectionUtils.add(this.permissions, permission); 593 return this; 594 } 595 596 @Override addPermissionGroup(ParsedPermissionGroup permissionGroup)597 public PackageImpl addPermissionGroup(ParsedPermissionGroup permissionGroup) { 598 this.permissionGroups = CollectionUtils.add(this.permissionGroups, permissionGroup); 599 return this; 600 } 601 602 @Override addPreferredActivityFilter(String className, ParsedIntentInfo intentInfo)603 public PackageImpl addPreferredActivityFilter(String className, 604 ParsedIntentInfo intentInfo) { 605 this.preferredActivityFilters = CollectionUtils.add(this.preferredActivityFilters, 606 Pair.create(className, intentInfo)); 607 return this; 608 } 609 610 @Override addProperty(@ullable PackageManager.Property property)611 public PackageImpl addProperty(@Nullable PackageManager.Property property) { 612 if (property == null) { 613 return this; 614 } 615 this.mProperties = CollectionUtils.add(this.mProperties, property.getName(), property); 616 return this; 617 } 618 619 @Override addProtectedBroadcast(String protectedBroadcast)620 public PackageImpl addProtectedBroadcast(String protectedBroadcast) { 621 if (!this.protectedBroadcasts.contains(protectedBroadcast)) { 622 this.protectedBroadcasts = CollectionUtils.add(this.protectedBroadcasts, 623 TextUtils.safeIntern(protectedBroadcast)); 624 } 625 return this; 626 } 627 628 @Override addProvider(ParsedProvider parsedProvider)629 public PackageImpl addProvider(ParsedProvider parsedProvider) { 630 this.providers = CollectionUtils.add(this.providers, parsedProvider); 631 addMimeGroupsFromComponent(parsedProvider); 632 return this; 633 } 634 635 @Override addQueriesIntent(Intent intent)636 public PackageImpl addQueriesIntent(Intent intent) { 637 this.queriesIntents = CollectionUtils.add(this.queriesIntents, intent); 638 return this; 639 } 640 641 @Override addQueriesPackage(String packageName)642 public PackageImpl addQueriesPackage(String packageName) { 643 this.queriesPackages = CollectionUtils.add(this.queriesPackages, 644 TextUtils.safeIntern(packageName)); 645 return this; 646 } 647 648 @Override addQueriesProvider(String authority)649 public PackageImpl addQueriesProvider(String authority) { 650 this.queriesProviders = CollectionUtils.add(this.queriesProviders, authority); 651 return this; 652 } 653 654 @Override addReceiver(ParsedActivity parsedReceiver)655 public PackageImpl addReceiver(ParsedActivity parsedReceiver) { 656 this.receivers = CollectionUtils.add(this.receivers, parsedReceiver); 657 addMimeGroupsFromComponent(parsedReceiver); 658 return this; 659 } 660 661 @Override addReqFeature(FeatureInfo reqFeature)662 public PackageImpl addReqFeature(FeatureInfo reqFeature) { 663 this.reqFeatures = CollectionUtils.add(this.reqFeatures, reqFeature); 664 return this; 665 } 666 667 @Override addService(ParsedService parsedService)668 public PackageImpl addService(ParsedService parsedService) { 669 this.services = CollectionUtils.add(this.services, parsedService); 670 addMimeGroupsFromComponent(parsedService); 671 return this; 672 } 673 674 @Override addUsesLibrary(String libraryName)675 public PackageImpl addUsesLibrary(String libraryName) { 676 libraryName = TextUtils.safeIntern(libraryName); 677 if (!ArrayUtils.contains(this.usesLibraries, libraryName)) { 678 this.usesLibraries = CollectionUtils.add(this.usesLibraries, libraryName); 679 } 680 return this; 681 } 682 683 @Override addUsesNativeLibrary(String libraryName)684 public final PackageImpl addUsesNativeLibrary(String libraryName) { 685 libraryName = TextUtils.safeIntern(libraryName); 686 if (!ArrayUtils.contains(this.usesNativeLibraries, libraryName)) { 687 this.usesNativeLibraries = CollectionUtils.add(this.usesNativeLibraries, libraryName); 688 } 689 return this; 690 } 691 692 @Override addUsesOptionalLibrary(String libraryName)693 public PackageImpl addUsesOptionalLibrary(String libraryName) { 694 libraryName = TextUtils.safeIntern(libraryName); 695 if (!ArrayUtils.contains(this.usesOptionalLibraries, libraryName)) { 696 this.usesOptionalLibraries = CollectionUtils.add(this.usesOptionalLibraries, 697 libraryName); 698 } 699 return this; 700 } 701 702 @Override addUsesOptionalNativeLibrary(String libraryName)703 public final PackageImpl addUsesOptionalNativeLibrary(String libraryName) { 704 libraryName = TextUtils.safeIntern(libraryName); 705 if (!ArrayUtils.contains(this.usesOptionalNativeLibraries, libraryName)) { 706 this.usesOptionalNativeLibraries = CollectionUtils.add(this.usesOptionalNativeLibraries, 707 libraryName); 708 } 709 return this; 710 } 711 712 @Override addUsesPermission(ParsedUsesPermission permission)713 public PackageImpl addUsesPermission(ParsedUsesPermission permission) { 714 this.usesPermissions = CollectionUtils.add(this.usesPermissions, permission); 715 716 // Continue populating legacy data structures to avoid performance 717 // issues until all that code can be migrated 718 this.requestedPermissions = CollectionUtils.add(this.requestedPermissions, 719 permission.getName()); 720 721 return this; 722 } 723 724 @Override addUsesSdkLibrary(String libraryName, long versionMajor, String[] certSha256Digests, boolean usesSdkLibrariesOptional)725 public PackageImpl addUsesSdkLibrary(String libraryName, long versionMajor, 726 String[] certSha256Digests, boolean usesSdkLibrariesOptional) { 727 this.usesSdkLibraries = CollectionUtils.add(this.usesSdkLibraries, 728 TextUtils.safeIntern(libraryName)); 729 this.usesSdkLibrariesVersionsMajor = ArrayUtils.appendLong( 730 this.usesSdkLibrariesVersionsMajor, versionMajor, true); 731 this.usesSdkLibrariesCertDigests = ArrayUtils.appendElement(String[].class, 732 this.usesSdkLibrariesCertDigests, certSha256Digests, true); 733 this.usesSdkLibrariesOptional = ArrayUtils.appendBoolean(this.usesSdkLibrariesOptional, 734 usesSdkLibrariesOptional); 735 return this; 736 } 737 738 @Override addUsesStaticLibrary(String libraryName, long version, String[] certSha256Digests)739 public PackageImpl addUsesStaticLibrary(String libraryName, long version, 740 String[] certSha256Digests) { 741 this.usesStaticLibraries = CollectionUtils.add(this.usesStaticLibraries, 742 TextUtils.safeIntern(libraryName)); 743 this.usesStaticLibrariesVersions = ArrayUtils.appendLong(this.usesStaticLibrariesVersions, 744 version, true); 745 this.usesStaticLibrariesCertDigests = ArrayUtils.appendElement(String[].class, 746 this.usesStaticLibrariesCertDigests, certSha256Digests, true); 747 return this; 748 } 749 750 @Override isAttributionsUserVisible()751 public boolean isAttributionsUserVisible() { 752 return getBoolean(Booleans.ATTRIBUTIONS_ARE_USER_VISIBLE); 753 } 754 755 @Override asSplit(String[] splitNames, String[] splitCodePaths, int[] splitRevisionCodes, SparseArray<int[]> splitDependencies)756 public PackageImpl asSplit(String[] splitNames, String[] splitCodePaths, 757 int[] splitRevisionCodes, SparseArray<int[]> splitDependencies) { 758 this.splitNames = splitNames; 759 this.splitCodePaths = splitCodePaths; 760 this.splitRevisionCodes = splitRevisionCodes; 761 this.splitDependencies = splitDependencies; 762 763 int count = splitNames.length; 764 this.splitFlags = new int[count]; 765 this.splitClassLoaderNames = new String[count]; 766 return this; 767 } 768 assignDerivedFields()769 protected void assignDerivedFields() { 770 mStorageUuid = StorageManager.convert(volumeUuid); 771 mLongVersionCode = PackageInfo.composeLongVersionCode(versionCodeMajor, versionCode); 772 } 773 774 /** 775 * Create a map from a process name to the custom application class for this process, 776 * which comes from <processes><process android:name="xxx">. 777 * 778 * The original information is stored in {@link #processes}, but it's stored in 779 * a form of: [process name] -[1:N]-> [package name] -[1:N]-> [class name]. 780 * We scan it and collect the process names and their app class names, only for this package. 781 * 782 * The resulting map only contains processes with a custom application class set. 783 */ 784 @Nullable buildAppClassNamesByProcess()785 private ArrayMap<String, String> buildAppClassNamesByProcess() { 786 if (ArrayUtils.size(processes) == 0) { 787 return null; 788 } 789 final ArrayMap<String, String> ret = new ArrayMap<>(4); 790 for (String processName : processes.keySet()) { 791 final ParsedProcess process = processes.get(processName); 792 final ArrayMap<String, String> appClassesByPackage = 793 process.getAppClassNamesByPackage(); 794 795 for (int i = 0; i < appClassesByPackage.size(); i++) { 796 final String packageName = appClassesByPackage.keyAt(i); 797 798 if (this.packageName.equals(packageName)) { 799 final String appClassName = appClassesByPackage.valueAt(i); 800 if (!TextUtils.isEmpty(appClassName)) { 801 ret.put(processName, appClassName); 802 } 803 } 804 } 805 } 806 return ret; 807 } 808 809 @Override getSplits()810 public List<AndroidPackageSplit> getSplits() { 811 if (mSplits == null) { 812 var splits = new ArrayList<AndroidPackageSplit>(); 813 splits.add(new AndroidPackageSplitImpl( 814 null, 815 getBaseApkPath(), 816 getBaseRevisionCode(), 817 isDeclaredHavingCode() ? ApplicationInfo.FLAG_HAS_CODE : 0, 818 getClassLoaderName() 819 )); 820 821 if (splitNames != null) { 822 for (int index = 0; index < splitNames.length; index++) { 823 splits.add(new AndroidPackageSplitImpl( 824 splitNames[index], 825 splitCodePaths[index], 826 splitRevisionCodes[index], 827 splitFlags[index], 828 splitClassLoaderNames[index] 829 )); 830 } 831 } 832 833 if (splitDependencies != null) { 834 for (int index = 0; index < splitDependencies.size(); index++) { 835 var splitIndex = splitDependencies.keyAt(index); 836 var dependenciesByIndex = splitDependencies.valueAt(index); 837 var dependencies = new ArrayList<AndroidPackageSplit>(); 838 for (int dependencyIndex : dependenciesByIndex) { 839 // Legacy holdover, base dependencies are an array of -1 rather than empty 840 if (dependencyIndex >= 0) { 841 dependencies.add(splits.get(dependencyIndex)); 842 } 843 } 844 ((AndroidPackageSplitImpl) splits.get(splitIndex)) 845 .fillDependencies(Collections.unmodifiableList(dependencies)); 846 } 847 } 848 849 mSplits = Collections.unmodifiableList(splits); 850 } 851 return mSplits; 852 } 853 854 @Override toString()855 public String toString() { 856 return "Package{" 857 + Integer.toHexString(System.identityHashCode(this)) 858 + " " + packageName + "}"; 859 } 860 861 @NonNull 862 @Override getActivities()863 public List<ParsedActivity> getActivities() { 864 return activities; 865 } 866 867 @NonNull 868 @Override getAdoptPermissions()869 public List<String> getAdoptPermissions() { 870 return adoptPermissions; 871 } 872 873 @NonNull 874 @Override getApexSystemServices()875 public List<ParsedApexSystemService> getApexSystemServices() { 876 return apexSystemServices; 877 } 878 879 @Nullable 880 @Override getAppComponentFactory()881 public String getAppComponentFactory() { 882 return appComponentFactory; 883 } 884 885 @NonNull 886 @Override getAttributions()887 public List<ParsedAttribution> getAttributions() { 888 return attributions; 889 } 890 891 @Override getAutoRevokePermissions()892 public int getAutoRevokePermissions() { 893 return autoRevokePermissions; 894 } 895 896 @Nullable 897 @Override getBackupAgentName()898 public String getBackupAgentName() { 899 return backupAgentName; 900 } 901 902 @Override getBannerResourceId()903 public int getBannerResourceId() { 904 return banner; 905 } 906 907 @NonNull 908 @Override getBaseApkPath()909 public String getBaseApkPath() { 910 return mBaseApkPath; 911 } 912 913 @Override getBaseRevisionCode()914 public int getBaseRevisionCode() { 915 return baseRevisionCode; 916 } 917 918 @Override getCategory()919 public int getCategory() { 920 return category; 921 } 922 923 @Nullable 924 @Override getClassLoaderName()925 public String getClassLoaderName() { 926 return classLoaderName; 927 } 928 929 @Nullable 930 @Override getApplicationClassName()931 public String getApplicationClassName() { 932 return className; 933 } 934 935 @Override getCompatibleWidthLimitDp()936 public int getCompatibleWidthLimitDp() { 937 return compatibleWidthLimitDp; 938 } 939 940 @Override getCompileSdkVersion()941 public int getCompileSdkVersion() { 942 return compileSdkVersion; 943 } 944 945 @Nullable 946 @Override getCompileSdkVersionCodeName()947 public String getCompileSdkVersionCodeName() { 948 return compileSdkVersionCodeName; 949 } 950 951 @NonNull 952 @Override getConfigPreferences()953 public List<ConfigurationInfo> getConfigPreferences() { 954 return configPreferences; 955 } 956 957 @Override getDataExtractionRulesResourceId()958 public int getDataExtractionRulesResourceId() { 959 return dataExtractionRules; 960 } 961 962 @Override getDescriptionResourceId()963 public int getDescriptionResourceId() { 964 return descriptionRes; 965 } 966 967 @NonNull 968 @Override getFeatureGroups()969 public List<FeatureGroupInfo> getFeatureGroups() { 970 return featureGroups; 971 } 972 973 @Override getFullBackupContentResourceId()974 public int getFullBackupContentResourceId() { 975 return fullBackupContent; 976 } 977 978 @ApplicationInfo.GwpAsanMode 979 @Override getGwpAsanMode()980 public int getGwpAsanMode() { 981 return gwpAsanMode; 982 } 983 984 @Override getIconResourceId()985 public int getIconResourceId() { 986 return iconRes; 987 } 988 989 @NonNull 990 @Override getImplicitPermissions()991 public Set<String> getImplicitPermissions() { 992 return implicitPermissions; 993 } 994 995 @Override getInstallLocation()996 public int getInstallLocation() { 997 return installLocation; 998 } 999 1000 @NonNull 1001 @Override getInstrumentations()1002 public List<ParsedInstrumentation> getInstrumentations() { 1003 return instrumentations; 1004 } 1005 1006 @NonNull 1007 @Override getKeySetMapping()1008 public Map<String,ArraySet<PublicKey>> getKeySetMapping() { 1009 return keySetMapping; 1010 } 1011 1012 @NonNull 1013 @Override getKnownActivityEmbeddingCerts()1014 public Set<String> getKnownActivityEmbeddingCerts() { 1015 return mKnownActivityEmbeddingCerts; 1016 } 1017 1018 @Override getLabelResourceId()1019 public int getLabelResourceId() { 1020 return labelRes; 1021 } 1022 1023 @Override getLargestWidthLimitDp()1024 public int getLargestWidthLimitDp() { 1025 return largestWidthLimitDp; 1026 } 1027 1028 @NonNull 1029 @Override getLibraryNames()1030 public List<String> getLibraryNames() { 1031 return libraryNames; 1032 } 1033 1034 @Override getLocaleConfigResourceId()1035 public int getLocaleConfigResourceId() { 1036 return mLocaleConfigRes; 1037 } 1038 1039 @Override getLogoResourceId()1040 public int getLogoResourceId() { 1041 return logo; 1042 } 1043 1044 @Nullable 1045 @Override getManageSpaceActivityName()1046 public String getManageSpaceActivityName() { 1047 return manageSpaceActivityName; 1048 } 1049 1050 @Override getMaxAspectRatio()1051 public float getMaxAspectRatio() { 1052 return maxAspectRatio; 1053 } 1054 1055 @Override getMaxSdkVersion()1056 public int getMaxSdkVersion() { 1057 return maxSdkVersion; 1058 } 1059 1060 @ApplicationInfo.MemtagMode 1061 @Override getMemtagMode()1062 public int getMemtagMode() { 1063 return memtagMode; 1064 } 1065 1066 @Nullable 1067 @Override getMetaData()1068 public Bundle getMetaData() { 1069 return metaData; 1070 } 1071 1072 @Override 1073 @Nullable getMimeGroups()1074 public Set<String> getMimeGroups() { 1075 return mimeGroups; 1076 } 1077 1078 @Override getMinAspectRatio()1079 public float getMinAspectRatio() { 1080 return minAspectRatio; 1081 } 1082 1083 @Nullable 1084 @Override getMinExtensionVersions()1085 public SparseIntArray getMinExtensionVersions() { 1086 return minExtensionVersions; 1087 } 1088 1089 @Override getMinSdkVersion()1090 public int getMinSdkVersion() { 1091 return minSdkVersion; 1092 } 1093 1094 @ApplicationInfo.NativeHeapZeroInitialized 1095 @Override getNativeHeapZeroInitialized()1096 public int getNativeHeapZeroInitialized() { 1097 return nativeHeapZeroInitialized; 1098 } 1099 1100 @Override getNetworkSecurityConfigResourceId()1101 public int getNetworkSecurityConfigResourceId() { 1102 return networkSecurityConfigRes; 1103 } 1104 1105 @Nullable 1106 @Override getNonLocalizedLabel()1107 public CharSequence getNonLocalizedLabel() { 1108 return nonLocalizedLabel; 1109 } 1110 1111 @NonNull 1112 @Override getOriginalPackages()1113 public List<String> getOriginalPackages() { 1114 return originalPackages; 1115 } 1116 1117 @Nullable 1118 @Override getOverlayCategory()1119 public String getOverlayCategory() { 1120 return overlayCategory; 1121 } 1122 1123 @Override getOverlayPriority()1124 public int getOverlayPriority() { 1125 return overlayPriority; 1126 } 1127 1128 @Nullable 1129 @Override getOverlayTarget()1130 public String getOverlayTarget() { 1131 return overlayTarget; 1132 } 1133 1134 @Nullable 1135 @Override getOverlayTargetOverlayableName()1136 public String getOverlayTargetOverlayableName() { 1137 return overlayTargetOverlayableName; 1138 } 1139 1140 @NonNull 1141 @Override getOverlayables()1142 public Map<String,String> getOverlayables() { 1143 return overlayables; 1144 } 1145 1146 @NonNull 1147 @Override getPackageName()1148 public String getPackageName() { 1149 return packageName; 1150 } 1151 1152 @NonNull 1153 @Override getPath()1154 public String getPath() { 1155 return mPath; 1156 } 1157 1158 @Nullable 1159 @Override getPermission()1160 public String getPermission() { 1161 return permission; 1162 } 1163 1164 @NonNull 1165 @Override getPermissionGroups()1166 public List<ParsedPermissionGroup> getPermissionGroups() { 1167 return permissionGroups; 1168 } 1169 1170 @NonNull 1171 @Override getPermissions()1172 public List<ParsedPermission> getPermissions() { 1173 return permissions; 1174 } 1175 1176 @NonNull 1177 @Override getPreferredActivityFilters()1178 public List<Pair<String,ParsedIntentInfo>> getPreferredActivityFilters() { 1179 return preferredActivityFilters; 1180 } 1181 1182 @NonNull 1183 @Override getProcessName()1184 public String getProcessName() { 1185 return processName != null ? processName : packageName; 1186 } 1187 1188 @NonNull 1189 @Override getProcesses()1190 public Map<String,ParsedProcess> getProcesses() { 1191 return processes; 1192 } 1193 1194 @NonNull 1195 @Override getProperties()1196 public Map<String, PackageManager.Property> getProperties() { 1197 return mProperties; 1198 } 1199 1200 @NonNull 1201 @Override getProtectedBroadcasts()1202 public List<String> getProtectedBroadcasts() { 1203 return protectedBroadcasts; 1204 } 1205 1206 @NonNull 1207 @Override getProviders()1208 public List<ParsedProvider> getProviders() { 1209 return providers; 1210 } 1211 1212 @NonNull 1213 @Override getQueriesIntents()1214 public List<Intent> getQueriesIntents() { 1215 return queriesIntents; 1216 } 1217 1218 @NonNull 1219 @Override getQueriesPackages()1220 public List<String> getQueriesPackages() { 1221 return queriesPackages; 1222 } 1223 1224 @NonNull 1225 @Override getQueriesProviders()1226 public Set<String> getQueriesProviders() { 1227 return queriesProviders; 1228 } 1229 1230 @NonNull 1231 @Override getReceivers()1232 public List<ParsedActivity> getReceivers() { 1233 return receivers; 1234 } 1235 1236 @NonNull 1237 @Override getRequestedFeatures()1238 public List<FeatureInfo> getRequestedFeatures() { 1239 return reqFeatures; 1240 } 1241 1242 /** 1243 * @deprecated consider migrating to {@link #getUsesPermissions} which has 1244 * more parsed details, such as flags 1245 */ 1246 @NonNull 1247 @Override 1248 @Deprecated getRequestedPermissions()1249 public Set<String> getRequestedPermissions() { 1250 return requestedPermissions; 1251 } 1252 1253 @Nullable 1254 @Override getRequiredAccountType()1255 public String getRequiredAccountType() { 1256 return requiredAccountType; 1257 } 1258 1259 @Override getRequiresSmallestWidthDp()1260 public int getRequiresSmallestWidthDp() { 1261 return requiresSmallestWidthDp; 1262 } 1263 1264 @Nullable 1265 @Override getResizeableActivity()1266 public Boolean getResizeableActivity() { 1267 return resizeableActivity; 1268 } 1269 1270 @Nullable 1271 @Override getRestrictUpdateHash()1272 public byte[] getRestrictUpdateHash() { 1273 return restrictUpdateHash; 1274 } 1275 1276 @Nullable 1277 @Override getRestrictedAccountType()1278 public String getRestrictedAccountType() { 1279 return restrictedAccountType; 1280 } 1281 1282 @Nullable 1283 @Override getEmergencyInstaller()1284 public String getEmergencyInstaller() { 1285 return mEmergencyInstaller; 1286 } 1287 1288 @Override getRoundIconResourceId()1289 public int getRoundIconResourceId() { 1290 return roundIconRes; 1291 } 1292 1293 @Nullable 1294 @Override getSdkLibraryName()1295 public String getSdkLibraryName() { 1296 return sdkLibraryName; 1297 } 1298 1299 @Override getSdkLibVersionMajor()1300 public int getSdkLibVersionMajor() { 1301 return sdkLibVersionMajor; 1302 } 1303 1304 @NonNull 1305 @Override getServices()1306 public List<ParsedService> getServices() { 1307 return services; 1308 } 1309 1310 @Nullable 1311 @Override getSharedUserId()1312 public String getSharedUserId() { 1313 return sharedUserId; 1314 } 1315 1316 @Override getSharedUserLabelResourceId()1317 public int getSharedUserLabelResourceId() { 1318 return sharedUserLabel; 1319 } 1320 1321 @NonNull 1322 @Override getSigningDetails()1323 public SigningDetails getSigningDetails() { 1324 return signingDetails; 1325 } 1326 1327 @NonNull 1328 @Override getSplitClassLoaderNames()1329 public String[] getSplitClassLoaderNames() { 1330 return splitClassLoaderNames == null ? EmptyArray.STRING : splitClassLoaderNames; 1331 } 1332 1333 @NonNull 1334 @Override getSplitCodePaths()1335 public String[] getSplitCodePaths() { 1336 return splitCodePaths == null ? EmptyArray.STRING : splitCodePaths; 1337 } 1338 1339 @Nullable 1340 @Override getSplitDependencies()1341 public SparseArray<int[]> getSplitDependencies() { 1342 return splitDependencies == null ? EMPTY_INT_ARRAY_SPARSE_ARRAY : splitDependencies; 1343 } 1344 1345 @Nullable 1346 @Override getSplitFlags()1347 public int[] getSplitFlags() { 1348 return splitFlags; 1349 } 1350 1351 @NonNull 1352 @Override getSplitNames()1353 public String[] getSplitNames() { 1354 return splitNames == null ? EmptyArray.STRING : splitNames; 1355 } 1356 1357 @NonNull 1358 @Override getSplitRevisionCodes()1359 public int[] getSplitRevisionCodes() { 1360 return splitRevisionCodes == null ? EmptyArray.INT : splitRevisionCodes; 1361 } 1362 1363 @Nullable 1364 @Override getStaticSharedLibraryName()1365 public String getStaticSharedLibraryName() { 1366 return staticSharedLibraryName; 1367 } 1368 1369 @Override getStaticSharedLibraryVersion()1370 public long getStaticSharedLibraryVersion() { 1371 return staticSharedLibVersion; 1372 } 1373 1374 @Override getStorageUuid()1375 public UUID getStorageUuid() { 1376 return mStorageUuid; 1377 } 1378 1379 @Override getTargetSandboxVersion()1380 public int getTargetSandboxVersion() { 1381 return targetSandboxVersion; 1382 } 1383 1384 @Override getTargetSdkVersion()1385 public int getTargetSdkVersion() { 1386 return targetSdkVersion; 1387 } 1388 1389 @Nullable 1390 @Override getTaskAffinity()1391 public String getTaskAffinity() { 1392 return taskAffinity; 1393 } 1394 1395 @Override getThemeResourceId()1396 public int getThemeResourceId() { 1397 return theme; 1398 } 1399 1400 @Override getUiOptions()1401 public int getUiOptions() { 1402 return uiOptions; 1403 } 1404 1405 @NonNull 1406 @Override getUpgradeKeySets()1407 public Set<String> getUpgradeKeySets() { 1408 return upgradeKeySets; 1409 } 1410 1411 @NonNull 1412 @Override getUsesLibraries()1413 public List<String> getUsesLibraries() { 1414 return usesLibraries; 1415 } 1416 1417 @NonNull 1418 @Override getUsesLibrariesSorted()1419 public String[] getUsesLibrariesSorted() { 1420 if (mUsesLibrariesSorted == null) { 1421 // Note lazy-sorting here doesn't break immutability because it always 1422 // return the same content. In the case of multi-threading, data race in accessing 1423 // mUsesLibrariesSorted might result in unnecessary creation of sorted copies 1424 // which is OK because the case is quite rare. 1425 mUsesLibrariesSorted = sortLibraries(usesLibraries); 1426 } 1427 return mUsesLibrariesSorted; 1428 } 1429 1430 @NonNull 1431 @Override getUsesNativeLibraries()1432 public List<String> getUsesNativeLibraries() { 1433 return usesNativeLibraries; 1434 } 1435 1436 @NonNull 1437 @Override getUsesOptionalLibraries()1438 public List<String> getUsesOptionalLibraries() { 1439 return usesOptionalLibraries; 1440 } 1441 1442 @NonNull 1443 @Override getUsesOptionalLibrariesSorted()1444 public String[] getUsesOptionalLibrariesSorted() { 1445 if (mUsesOptionalLibrariesSorted == null) { 1446 mUsesOptionalLibrariesSorted = sortLibraries(usesOptionalLibraries); 1447 } 1448 return mUsesOptionalLibrariesSorted; 1449 } 1450 1451 @NonNull 1452 @Override getUsesOptionalNativeLibraries()1453 public List<String> getUsesOptionalNativeLibraries() { 1454 return usesOptionalNativeLibraries; 1455 } 1456 1457 @NonNull 1458 @Override getUsesPermissions()1459 public List<ParsedUsesPermission> getUsesPermissions() { 1460 return usesPermissions; 1461 } 1462 1463 @NonNull 1464 @Override getUsesSdkLibraries()1465 public List<String> getUsesSdkLibraries() { return usesSdkLibraries; } 1466 1467 @NonNull 1468 @Override getUsesSdkLibrariesSorted()1469 public String[] getUsesSdkLibrariesSorted() { 1470 if (mUsesSdkLibrariesSorted == null) { 1471 mUsesSdkLibrariesSorted = sortLibraries(usesSdkLibraries); 1472 } 1473 return mUsesSdkLibrariesSorted; 1474 } 1475 1476 @Nullable 1477 @Override getUsesSdkLibrariesCertDigests()1478 public String[][] getUsesSdkLibrariesCertDigests() { return usesSdkLibrariesCertDigests; } 1479 1480 @Nullable 1481 @Override getUsesSdkLibrariesVersionsMajor()1482 public long[] getUsesSdkLibrariesVersionsMajor() { return usesSdkLibrariesVersionsMajor; } 1483 1484 @Nullable 1485 @Override getUsesSdkLibrariesOptional()1486 public boolean[] getUsesSdkLibrariesOptional() { 1487 return usesSdkLibrariesOptional; 1488 } 1489 1490 @NonNull 1491 @Override getUsesStaticLibraries()1492 public List<String> getUsesStaticLibraries() { 1493 return usesStaticLibraries; 1494 } 1495 1496 @NonNull 1497 @Override getUsesStaticLibrariesSorted()1498 public String[] getUsesStaticLibrariesSorted() { 1499 if (mUsesStaticLibrariesSorted == null) { 1500 mUsesStaticLibrariesSorted = sortLibraries(usesStaticLibraries); 1501 } 1502 return mUsesStaticLibrariesSorted; 1503 } 1504 1505 @Nullable 1506 @Override getUsesStaticLibrariesCertDigests()1507 public String[][] getUsesStaticLibrariesCertDigests() { 1508 return usesStaticLibrariesCertDigests; 1509 } 1510 1511 @Nullable 1512 @Override getUsesStaticLibrariesVersions()1513 public long[] getUsesStaticLibrariesVersions() { 1514 return usesStaticLibrariesVersions; 1515 } 1516 1517 @Override getVersionCode()1518 public int getVersionCode() { 1519 return versionCode; 1520 } 1521 1522 @Override getVersionCodeMajor()1523 public int getVersionCodeMajor() { 1524 return versionCodeMajor; 1525 } 1526 1527 @Nullable 1528 @Override getVersionName()1529 public String getVersionName() { 1530 return versionName; 1531 } 1532 1533 @Nullable 1534 @Override getVolumeUuid()1535 public String getVolumeUuid() { 1536 return volumeUuid; 1537 } 1538 1539 @Nullable 1540 @Override getZygotePreloadName()1541 public String getZygotePreloadName() { 1542 return zygotePreloadName; 1543 } 1544 1545 @Override isAllowCrossUidActivitySwitchFromBelow()1546 public boolean isAllowCrossUidActivitySwitchFromBelow() { 1547 return mAllowCrossUidActivitySwitchFromBelow; 1548 } 1549 1550 @Override hasPreserveLegacyExternalStorage()1551 public boolean hasPreserveLegacyExternalStorage() { 1552 return getBoolean(Booleans.PRESERVE_LEGACY_EXTERNAL_STORAGE); 1553 } 1554 1555 @Override hasRequestForegroundServiceExemption()1556 public boolean hasRequestForegroundServiceExemption() { 1557 return getBoolean(Booleans.REQUEST_FOREGROUND_SERVICE_EXEMPTION); 1558 } 1559 1560 @Nullable 1561 @Override hasRequestRawExternalStorageAccess()1562 public Boolean hasRequestRawExternalStorageAccess() { 1563 return requestRawExternalStorageAccess; 1564 } 1565 1566 @Override isAllowAudioPlaybackCapture()1567 public boolean isAllowAudioPlaybackCapture() { 1568 return getBoolean(Booleans.ALLOW_AUDIO_PLAYBACK_CAPTURE); 1569 } 1570 1571 @Override isBackupAllowed()1572 public boolean isBackupAllowed() { 1573 return getBoolean(Booleans.ALLOW_BACKUP); 1574 } 1575 1576 @Override isClearUserDataAllowed()1577 public boolean isClearUserDataAllowed() { 1578 return getBoolean(Booleans.ALLOW_CLEAR_USER_DATA); 1579 } 1580 1581 @Override isClearUserDataOnFailedRestoreAllowed()1582 public boolean isClearUserDataOnFailedRestoreAllowed() { 1583 return getBoolean(Booleans.ALLOW_CLEAR_USER_DATA_ON_FAILED_RESTORE); 1584 } 1585 1586 @Override isAllowNativeHeapPointerTagging()1587 public boolean isAllowNativeHeapPointerTagging() { 1588 return getBoolean(Booleans.ALLOW_NATIVE_HEAP_POINTER_TAGGING); 1589 } 1590 1591 @Override isTaskReparentingAllowed()1592 public boolean isTaskReparentingAllowed() { 1593 return getBoolean(Booleans.ALLOW_TASK_REPARENTING); 1594 } 1595 isAnyDensity()1596 public boolean isAnyDensity() { 1597 if (anyDensity == null) { 1598 return targetSdkVersion >= Build.VERSION_CODES.DONUT; 1599 } 1600 1601 return anyDensity; 1602 } 1603 1604 @Override isBackupInForeground()1605 public boolean isBackupInForeground() { 1606 return getBoolean(Booleans.BACKUP_IN_FOREGROUND); 1607 } 1608 1609 @Override isHardwareAccelerated()1610 public boolean isHardwareAccelerated() { 1611 return getBoolean(Booleans.HARDWARE_ACCELERATED); 1612 } 1613 1614 @Override isSaveStateDisallowed()1615 public boolean isSaveStateDisallowed() { 1616 return getBoolean(Booleans.CANT_SAVE_STATE); 1617 } 1618 1619 @Override isCrossProfile()1620 public boolean isCrossProfile() { 1621 return getBoolean(Booleans.CROSS_PROFILE); 1622 } 1623 1624 @Override isDebuggable()1625 public boolean isDebuggable() { 1626 return getBoolean(Booleans.DEBUGGABLE); 1627 } 1628 1629 @Override isDefaultToDeviceProtectedStorage()1630 public boolean isDefaultToDeviceProtectedStorage() { 1631 return getBoolean(Booleans.DEFAULT_TO_DEVICE_PROTECTED_STORAGE); 1632 } 1633 1634 @Override isDirectBootAware()1635 public boolean isDirectBootAware() { 1636 return getBoolean(Booleans.DIRECT_BOOT_AWARE); 1637 } 1638 1639 @Override isEnabled()1640 public boolean isEnabled() { 1641 return getBoolean(Booleans.ENABLED); 1642 } 1643 1644 @Override isExternalStorage()1645 public boolean isExternalStorage() { 1646 return getBoolean(Booleans.EXTERNAL_STORAGE); 1647 } 1648 1649 @Override isExtractNativeLibrariesRequested()1650 public boolean isExtractNativeLibrariesRequested() { 1651 return getBoolean(Booleans.EXTRACT_NATIVE_LIBS); 1652 } 1653 1654 @Override isForceQueryable()1655 public boolean isForceQueryable() { 1656 return getBoolean(Booleans.FORCE_QUERYABLE); 1657 } 1658 1659 @Override isFullBackupOnly()1660 public boolean isFullBackupOnly() { 1661 return getBoolean(Booleans.FULL_BACKUP_ONLY); 1662 } 1663 1664 @Override isGame()1665 public boolean isGame() { 1666 return getBoolean(Booleans.GAME); 1667 } 1668 1669 @Override isDeclaredHavingCode()1670 public boolean isDeclaredHavingCode() { 1671 return getBoolean(Booleans.HAS_CODE); 1672 } 1673 1674 @Override isHasDomainUrls()1675 public boolean isHasDomainUrls() { 1676 return getBoolean(Booleans.HAS_DOMAIN_URLS); 1677 } 1678 1679 @Override isUserDataFragile()1680 public boolean isUserDataFragile() { 1681 return getBoolean(Booleans.HAS_FRAGILE_USER_DATA); 1682 } 1683 1684 @Override isIsolatedSplitLoading()1685 public boolean isIsolatedSplitLoading() { 1686 return getBoolean(Booleans.ISOLATED_SPLIT_LOADING); 1687 } 1688 1689 @Override isKillAfterRestoreAllowed()1690 public boolean isKillAfterRestoreAllowed() { 1691 return getBoolean(Booleans.KILL_AFTER_RESTORE); 1692 } 1693 1694 @Override isLargeHeap()1695 public boolean isLargeHeap() { 1696 return getBoolean(Booleans.LARGE_HEAP); 1697 } 1698 1699 @Override isLeavingSharedUser()1700 public boolean isLeavingSharedUser() { 1701 return getBoolean(Booleans.LEAVING_SHARED_UID); 1702 } 1703 1704 @Override isMultiArch()1705 public boolean isMultiArch() { 1706 return getBoolean(Booleans.MULTI_ARCH); 1707 } 1708 1709 @Override isOnBackInvokedCallbackEnabled()1710 public boolean isOnBackInvokedCallbackEnabled() { 1711 return getBoolean(Booleans.ENABLE_ON_BACK_INVOKED_CALLBACK); 1712 } 1713 1714 @Override isResourceOverlay()1715 public boolean isResourceOverlay() { 1716 return getBoolean(Booleans.OVERLAY); 1717 } 1718 1719 @Override isOverlayIsStatic()1720 public boolean isOverlayIsStatic() { 1721 return getBoolean(Booleans.OVERLAY_IS_STATIC); 1722 } 1723 1724 @Override isPartiallyDirectBootAware()1725 public boolean isPartiallyDirectBootAware() { 1726 return getBoolean(Booleans.PARTIALLY_DIRECT_BOOT_AWARE); 1727 } 1728 1729 @Override isPersistent()1730 public boolean isPersistent() { 1731 return getBoolean(Booleans.PERSISTENT); 1732 } 1733 1734 @Override isProfileable()1735 public boolean isProfileable() { 1736 return !getBoolean(Booleans.DISALLOW_PROFILING); 1737 } 1738 1739 @Override isProfileableByShell()1740 public boolean isProfileableByShell() { 1741 return isProfileable() && getBoolean(Booleans.PROFILEABLE_BY_SHELL); 1742 } 1743 1744 @Override isRequestLegacyExternalStorage()1745 public boolean isRequestLegacyExternalStorage() { 1746 return getBoolean(Booleans.REQUEST_LEGACY_EXTERNAL_STORAGE); 1747 } 1748 1749 @Override isRequiredForAllUsers()1750 public boolean isRequiredForAllUsers() { 1751 return getBoolean(Booleans.REQUIRED_FOR_ALL_USERS); 1752 } 1753 1754 @Override isResetEnabledSettingsOnAppDataCleared()1755 public boolean isResetEnabledSettingsOnAppDataCleared() { 1756 return getBoolean(Booleans.RESET_ENABLED_SETTINGS_ON_APP_DATA_CLEARED); 1757 } 1758 isResizeable()1759 public boolean isResizeable() { 1760 if (resizeable == null) { 1761 return targetSdkVersion >= Build.VERSION_CODES.DONUT; 1762 } 1763 1764 return resizeable; 1765 } 1766 1767 @Override isResizeableActivityViaSdkVersion()1768 public boolean isResizeableActivityViaSdkVersion() { 1769 return getBoolean(Booleans.RESIZEABLE_ACTIVITY_VIA_SDK_VERSION); 1770 } 1771 1772 @Override isRestoreAnyVersion()1773 public boolean isRestoreAnyVersion() { 1774 return getBoolean(Booleans.RESTORE_ANY_VERSION); 1775 } 1776 1777 @Override isSdkLibrary()1778 public boolean isSdkLibrary() { 1779 return getBoolean(Booleans.SDK_LIBRARY); 1780 } 1781 1782 @Override isStaticSharedLibrary()1783 public boolean isStaticSharedLibrary() { 1784 return getBoolean(Booleans.STATIC_SHARED_LIBRARY); 1785 } 1786 isExtraLargeScreensSupported()1787 public boolean isExtraLargeScreensSupported() { 1788 if (supportsExtraLargeScreens == null) { 1789 return targetSdkVersion >= Build.VERSION_CODES.GINGERBREAD; 1790 } 1791 1792 return supportsExtraLargeScreens; 1793 } 1794 isLargeScreensSupported()1795 public boolean isLargeScreensSupported() { 1796 if (supportsLargeScreens == null) { 1797 return targetSdkVersion >= Build.VERSION_CODES.DONUT; 1798 } 1799 1800 return supportsLargeScreens; 1801 } 1802 isNormalScreensSupported()1803 public boolean isNormalScreensSupported() { 1804 return supportsNormalScreens == null || supportsNormalScreens; 1805 } 1806 1807 @Override isRtlSupported()1808 public boolean isRtlSupported() { 1809 return getBoolean(Booleans.SUPPORTS_RTL); 1810 } 1811 isSmallScreensSupported()1812 public boolean isSmallScreensSupported() { 1813 if (supportsSmallScreens == null) { 1814 return targetSdkVersion >= Build.VERSION_CODES.DONUT; 1815 } 1816 1817 return supportsSmallScreens; 1818 } 1819 1820 @Override isTestOnly()1821 public boolean isTestOnly() { 1822 return getBoolean(Booleans.TEST_ONLY); 1823 } 1824 1825 @Override is32BitAbiPreferred()1826 public boolean is32BitAbiPreferred() { 1827 return getBoolean(Booleans.USE_32_BIT_ABI); 1828 } 1829 1830 @Override isUseEmbeddedDex()1831 public boolean isUseEmbeddedDex() { 1832 return getBoolean(Booleans.USE_EMBEDDED_DEX); 1833 } 1834 1835 @Override isCleartextTrafficAllowed()1836 public boolean isCleartextTrafficAllowed() { 1837 return getBoolean(Booleans.USES_CLEARTEXT_TRAFFIC); 1838 } 1839 1840 @Override isNonSdkApiRequested()1841 public boolean isNonSdkApiRequested() { 1842 return getBoolean(Booleans.USES_NON_SDK_API); 1843 } 1844 1845 @Override isVisibleToInstantApps()1846 public boolean isVisibleToInstantApps() { 1847 return getBoolean(Booleans.VISIBLE_TO_INSTANT_APPS); 1848 } 1849 1850 @Override isVmSafeMode()1851 public boolean isVmSafeMode() { 1852 return getBoolean(Booleans.VM_SAFE_MODE); 1853 } 1854 removeUsesOptionalNativeLibrary(String libraryName)1855 @Override public PackageImpl removeUsesOptionalNativeLibrary(String libraryName) { 1856 this.usesOptionalNativeLibraries = CollectionUtils.remove(this.usesOptionalNativeLibraries, 1857 libraryName); 1858 return this; 1859 } 1860 1861 @Override setAllowAudioPlaybackCapture(boolean value)1862 public PackageImpl setAllowAudioPlaybackCapture(boolean value) { 1863 return setBoolean(Booleans.ALLOW_AUDIO_PLAYBACK_CAPTURE, value); 1864 } 1865 1866 @Override setBackupAllowed(boolean value)1867 public PackageImpl setBackupAllowed(boolean value) { 1868 return setBoolean(Booleans.ALLOW_BACKUP, value); 1869 } 1870 1871 @Override setClearUserDataAllowed(boolean value)1872 public PackageImpl setClearUserDataAllowed(boolean value) { 1873 return setBoolean(Booleans.ALLOW_CLEAR_USER_DATA, value); 1874 } 1875 1876 @Override setClearUserDataOnFailedRestoreAllowed(boolean value)1877 public PackageImpl setClearUserDataOnFailedRestoreAllowed(boolean value) { 1878 return setBoolean(Booleans.ALLOW_CLEAR_USER_DATA_ON_FAILED_RESTORE, value); 1879 } 1880 1881 @Override setAllowNativeHeapPointerTagging(boolean value)1882 public PackageImpl setAllowNativeHeapPointerTagging(boolean value) { 1883 return setBoolean(Booleans.ALLOW_NATIVE_HEAP_POINTER_TAGGING, value); 1884 } 1885 1886 @Override setTaskReparentingAllowed(boolean value)1887 public PackageImpl setTaskReparentingAllowed(boolean value) { 1888 return setBoolean(Booleans.ALLOW_TASK_REPARENTING, value); 1889 } 1890 1891 @Override setAnyDensity(int anyDensity)1892 public PackageImpl setAnyDensity(int anyDensity) { 1893 if (anyDensity == 1) { 1894 return this; 1895 } 1896 1897 this.anyDensity = anyDensity < 0; 1898 return this; 1899 } 1900 1901 @Override 1902 public PackageImpl setAppComponentFactory(@Nullable String appComponentFactory) { 1903 this.appComponentFactory = appComponentFactory; 1904 return this; 1905 } 1906 1907 @Override 1908 public ParsingPackage setAttributionsAreUserVisible(boolean attributionsAreUserVisible) { 1909 setBoolean(Booleans.ATTRIBUTIONS_ARE_USER_VISIBLE, attributionsAreUserVisible); 1910 return this; 1911 } 1912 1913 @Override 1914 public PackageImpl setAutoRevokePermissions(int value) { 1915 autoRevokePermissions = value; 1916 return this; 1917 } 1918 1919 @Override 1920 public PackageImpl setBackupAgentName(@Nullable String backupAgentName) { 1921 this.backupAgentName = backupAgentName; 1922 return this; 1923 } 1924 1925 @Override 1926 public PackageImpl setBackupInForeground(boolean value) { 1927 return setBoolean(Booleans.BACKUP_IN_FOREGROUND, value); 1928 } 1929 1930 @Override 1931 public PackageImpl setBannerResourceId(int value) { 1932 banner = value; 1933 return this; 1934 } 1935 1936 @Override 1937 public PackageImpl setHardwareAccelerated(boolean value) { 1938 return setBoolean(Booleans.HARDWARE_ACCELERATED, value); 1939 } 1940 1941 @Override 1942 public PackageImpl setBaseRevisionCode(int value) { 1943 baseRevisionCode = value; 1944 return this; 1945 } 1946 1947 @Override 1948 public PackageImpl setSaveStateDisallowed(boolean value) { 1949 return setBoolean(Booleans.CANT_SAVE_STATE, value); 1950 } 1951 1952 @Override 1953 public PackageImpl setCategory(int value) { 1954 category = value; 1955 return this; 1956 } 1957 1958 @Override 1959 public PackageImpl setClassLoaderName(@Nullable String classLoaderName) { 1960 this.classLoaderName = classLoaderName; 1961 return this; 1962 } 1963 1964 @Override 1965 public PackageImpl setApplicationClassName(@Nullable String className) { 1966 this.className = className == null ? null : className.trim(); 1967 return this; 1968 } 1969 1970 @Override 1971 public PackageImpl setCompatibleWidthLimitDp(int value) { 1972 compatibleWidthLimitDp = value; 1973 return this; 1974 } 1975 1976 @Override 1977 public PackageImpl setCompileSdkVersion(int value) { 1978 compileSdkVersion = value; 1979 return this; 1980 } 1981 1982 @Override 1983 public ParsingPackage setCompileSdkVersionCodeName(String compileSdkVersionCodeName) { 1984 this.compileSdkVersionCodeName = compileSdkVersionCodeName; 1985 return this; 1986 } 1987 1988 @Override 1989 public PackageImpl setCrossProfile(boolean value) { 1990 return setBoolean(Booleans.CROSS_PROFILE, value); 1991 } 1992 1993 @Override 1994 public PackageImpl setDataExtractionRulesResourceId(int value) { 1995 dataExtractionRules = value; 1996 return this; 1997 } 1998 1999 @Override 2000 public PackageImpl setDebuggable(boolean value) { 2001 return setBoolean(Booleans.DEBUGGABLE, value); 2002 } 2003 2004 @Override 2005 public PackageImpl setDescriptionResourceId(int value) { 2006 descriptionRes = value; 2007 return this; 2008 } 2009 2010 @Override 2011 public PackageImpl setEnabled(boolean value) { 2012 return setBoolean(Booleans.ENABLED, value); 2013 } 2014 2015 @Override 2016 public PackageImpl setExternalStorage(boolean value) { 2017 return setBoolean(Booleans.EXTERNAL_STORAGE, value); 2018 } 2019 2020 @Override 2021 public PackageImpl setExtractNativeLibrariesRequested(boolean value) { 2022 return setBoolean(Booleans.EXTRACT_NATIVE_LIBS, value); 2023 } 2024 2025 @Override 2026 public PackageImpl setForceQueryable(boolean value) { 2027 return setBoolean(Booleans.FORCE_QUERYABLE, value); 2028 } 2029 2030 @Override 2031 public PackageImpl setFullBackupContentResourceId(int value) { 2032 fullBackupContent = value; 2033 return this; 2034 } 2035 2036 @Override 2037 public PackageImpl setFullBackupOnly(boolean value) { 2038 return setBoolean(Booleans.FULL_BACKUP_ONLY, value); 2039 } 2040 2041 @Override 2042 public PackageImpl setGame(boolean value) { 2043 return setBoolean(Booleans.GAME, value); 2044 } 2045 2046 @Override 2047 public PackageImpl setGwpAsanMode(@ApplicationInfo.GwpAsanMode int value) { 2048 gwpAsanMode = value; 2049 return this; 2050 } 2051 2052 @Override 2053 public PackageImpl setDeclaredHavingCode(boolean value) { 2054 return setBoolean(Booleans.HAS_CODE, value); 2055 } 2056 2057 @Override 2058 public PackageImpl setHasDomainUrls(boolean value) { 2059 return setBoolean(Booleans.HAS_DOMAIN_URLS, value); 2060 } 2061 2062 @Override 2063 public PackageImpl setUserDataFragile(boolean value) { 2064 return setBoolean(Booleans.HAS_FRAGILE_USER_DATA, value); 2065 } 2066 2067 @Override 2068 public PackageImpl setIconResourceId(int value) { 2069 iconRes = value; 2070 return this; 2071 } 2072 2073 @Override 2074 public PackageImpl setInstallLocation(int value) { 2075 installLocation = value; 2076 return this; 2077 } 2078 2079 @Override 2080 public PackageImpl setIsolatedSplitLoading(boolean value) { 2081 return setBoolean(Booleans.ISOLATED_SPLIT_LOADING, value); 2082 } 2083 2084 @Override 2085 public PackageImpl setKillAfterRestoreAllowed(boolean value) { 2086 return setBoolean(Booleans.KILL_AFTER_RESTORE, value); 2087 } 2088 2089 @Override 2090 public ParsingPackage setKnownActivityEmbeddingCerts(@NonNull Set<String> knownEmbeddingCerts) { 2091 mKnownActivityEmbeddingCerts = knownEmbeddingCerts; 2092 return this; 2093 } 2094 2095 @Override 2096 public PackageImpl setLabelResourceId(int value) { 2097 labelRes = value; 2098 return this; 2099 } 2100 2101 @Override 2102 public PackageImpl setLargeHeap(boolean value) { 2103 return setBoolean(Booleans.LARGE_HEAP, value); 2104 } 2105 2106 @Override 2107 public PackageImpl setLargestWidthLimitDp(int value) { 2108 largestWidthLimitDp = value; 2109 return this; 2110 } 2111 2112 @Override 2113 public PackageImpl setLeavingSharedUser(boolean value) { 2114 return setBoolean(Booleans.LEAVING_SHARED_UID, value); 2115 } 2116 2117 @Override 2118 public PackageImpl setLocaleConfigResourceId(int value) { 2119 mLocaleConfigRes = value; 2120 return this; 2121 } 2122 2123 @Override 2124 public PackageImpl setLogoResourceId(int value) { 2125 logo = value; 2126 return this; 2127 } 2128 2129 @Override 2130 public PackageImpl setManageSpaceActivityName(@Nullable String manageSpaceActivityName) { 2131 this.manageSpaceActivityName = manageSpaceActivityName; 2132 return this; 2133 } 2134 2135 @Override 2136 public PackageImpl setMaxAspectRatio(float value) { 2137 maxAspectRatio = value; 2138 return this; 2139 } 2140 2141 @Override 2142 public PackageImpl setMaxSdkVersion(int value) { 2143 maxSdkVersion = value; 2144 return this; 2145 } 2146 2147 @Override 2148 public PackageImpl setMemtagMode(@ApplicationInfo.MemtagMode int value) { 2149 memtagMode = value; 2150 return this; 2151 } 2152 2153 @Override 2154 public PackageImpl setMetaData(@Nullable Bundle value) { 2155 metaData = value; 2156 return this; 2157 } 2158 2159 @Override 2160 public PackageImpl setMinAspectRatio(float value) { 2161 minAspectRatio = value; 2162 return this; 2163 } 2164 2165 @Override 2166 public PackageImpl setMinExtensionVersions(@Nullable SparseIntArray value) { 2167 minExtensionVersions = value; 2168 return this; 2169 } 2170 2171 @Override 2172 public PackageImpl setMinSdkVersion(int value) { 2173 minSdkVersion = value; 2174 return this; 2175 } 2176 2177 @Override 2178 public PackageImpl setMultiArch(boolean value) { 2179 return setBoolean(Booleans.MULTI_ARCH, value); 2180 } 2181 2182 @Override 2183 public PackageImpl setNativeHeapZeroInitialized( 2184 @ApplicationInfo.NativeHeapZeroInitialized int value) { 2185 nativeHeapZeroInitialized = value; 2186 return this; 2187 } 2188 2189 @Override 2190 public PackageImpl setNetworkSecurityConfigResourceId(int value) { 2191 networkSecurityConfigRes = value; 2192 return this; 2193 } 2194 2195 @Override 2196 public PackageImpl setNonLocalizedLabel(@Nullable CharSequence value) { 2197 nonLocalizedLabel = value == null ? null : value.toString().trim(); 2198 return this; 2199 } 2200 2201 @Override 2202 public ParsingPackage setOnBackInvokedCallbackEnabled(boolean value) { 2203 setBoolean(Booleans.ENABLE_ON_BACK_INVOKED_CALLBACK, value); 2204 return this; 2205 } 2206 2207 @Override 2208 public ParsingPackage setAllowCrossUidActivitySwitchFromBelow(boolean value) { 2209 mAllowCrossUidActivitySwitchFromBelow = value; 2210 return this; 2211 } 2212 2213 @Override 2214 public PackageImpl setResourceOverlay(boolean value) { 2215 return setBoolean(Booleans.OVERLAY, value); 2216 } 2217 2218 @Override 2219 public PackageImpl setOverlayCategory(@Nullable String overlayCategory) { 2220 this.overlayCategory = overlayCategory; 2221 return this; 2222 } 2223 2224 @Override 2225 public PackageImpl setOverlayIsStatic(boolean value) { 2226 return setBoolean(Booleans.OVERLAY_IS_STATIC, value); 2227 } 2228 2229 @Override 2230 public PackageImpl setOverlayPriority(int value) { 2231 overlayPriority = value; 2232 return this; 2233 } 2234 2235 @Override 2236 public PackageImpl setOverlayTarget(@Nullable String overlayTarget) { 2237 this.overlayTarget = TextUtils.safeIntern(overlayTarget); 2238 return this; 2239 } 2240 2241 @Override 2242 public PackageImpl setOverlayTargetOverlayableName( 2243 @Nullable String overlayTargetOverlayableName) { 2244 this.overlayTargetOverlayableName = overlayTargetOverlayableName; 2245 return this; 2246 } 2247 2248 @Override 2249 public PackageImpl setPartiallyDirectBootAware(boolean value) { 2250 return setBoolean(Booleans.PARTIALLY_DIRECT_BOOT_AWARE, value); 2251 } 2252 2253 @Override 2254 public PackageImpl setPermission(@Nullable String permission) { 2255 this.permission = permission; 2256 return this; 2257 } 2258 2259 @Override 2260 public PackageImpl setPreserveLegacyExternalStorage(boolean value) { 2261 return setBoolean(Booleans.PRESERVE_LEGACY_EXTERNAL_STORAGE, value); 2262 } 2263 2264 @Override 2265 public PackageImpl setProcessName(String processName) { 2266 this.processName = processName; 2267 return this; 2268 } 2269 2270 @Override 2271 public PackageImpl setProcesses(@NonNull Map<String,ParsedProcess> value) { 2272 processes = value; 2273 return this; 2274 } 2275 2276 @Override 2277 public PackageImpl setProfileable(boolean value) { 2278 return setBoolean(Booleans.DISALLOW_PROFILING, !value); 2279 } 2280 2281 @Override 2282 public PackageImpl setProfileableByShell(boolean value) { 2283 return setBoolean(Booleans.PROFILEABLE_BY_SHELL, value); 2284 } 2285 2286 @Override 2287 public PackageImpl setRequestForegroundServiceExemption(boolean value) { 2288 return setBoolean(Booleans.REQUEST_FOREGROUND_SERVICE_EXEMPTION, value); 2289 } 2290 2291 @Override 2292 public PackageImpl setRequestLegacyExternalStorage(boolean value) { 2293 return setBoolean(Booleans.REQUEST_LEGACY_EXTERNAL_STORAGE, value); 2294 } 2295 2296 @Override 2297 public PackageImpl setRequestRawExternalStorageAccess(@Nullable Boolean value) { 2298 requestRawExternalStorageAccess = value; 2299 return this; 2300 } 2301 2302 @Override 2303 public PackageImpl setRequiredAccountType(@Nullable String requiredAccountType) { 2304 this.requiredAccountType = TextUtils.nullIfEmpty(requiredAccountType); 2305 return this; 2306 } 2307 2308 @Override 2309 public PackageImpl setRequiredForAllUsers(boolean value) { 2310 return setBoolean(Booleans.REQUIRED_FOR_ALL_USERS, value); 2311 } 2312 2313 @Override 2314 public PackageImpl setRequiresSmallestWidthDp(int value) { 2315 requiresSmallestWidthDp = value; 2316 return this; 2317 } 2318 2319 @Override 2320 public ParsingPackage setResetEnabledSettingsOnAppDataCleared( 2321 boolean resetEnabledSettingsOnAppDataCleared) { 2322 setBoolean(Booleans.RESET_ENABLED_SETTINGS_ON_APP_DATA_CLEARED, 2323 resetEnabledSettingsOnAppDataCleared); 2324 return this; 2325 } 2326 2327 @Override 2328 public PackageImpl setResizeable(int resizeable) { 2329 if (resizeable == 1) { 2330 return this; 2331 } 2332 2333 this.resizeable = resizeable < 0; 2334 return this; 2335 } 2336 2337 @Override 2338 public PackageImpl setResizeableActivity(@Nullable Boolean value) { 2339 resizeableActivity = value; 2340 return this; 2341 } 2342 2343 @Override 2344 public PackageImpl setResizeableActivityViaSdkVersion(boolean value) { 2345 return setBoolean(Booleans.RESIZEABLE_ACTIVITY_VIA_SDK_VERSION, value); 2346 } 2347 2348 @Override 2349 public PackageImpl setRestoreAnyVersion(boolean value) { 2350 return setBoolean(Booleans.RESTORE_ANY_VERSION, value); 2351 } 2352 2353 @Override 2354 public PackageImpl setRestrictedAccountType(@Nullable String restrictedAccountType) { 2355 this.restrictedAccountType = restrictedAccountType; 2356 return this; 2357 } 2358 2359 @Override 2360 public PackageImpl setEmergencyInstaller(@Nullable String emergencyInstaller) { 2361 this.mEmergencyInstaller = emergencyInstaller; 2362 return this; 2363 } 2364 2365 @Override 2366 public PackageImpl setRoundIconResourceId(int value) { 2367 roundIconRes = value; 2368 return this; 2369 } 2370 2371 @Override 2372 public PackageImpl setSdkLibraryName(String sdkLibraryName) { 2373 this.sdkLibraryName = TextUtils.safeIntern(sdkLibraryName); 2374 return this; 2375 } 2376 2377 @Override 2378 public PackageImpl setSdkLibVersionMajor(int sdkLibVersionMajor) { 2379 this.sdkLibVersionMajor = sdkLibVersionMajor; 2380 return this; 2381 } 2382 2383 @Override 2384 public PackageImpl setSdkLibrary(boolean value) { 2385 return setBoolean(Booleans.SDK_LIBRARY, value); 2386 } 2387 2388 @Override 2389 public PackageImpl setSharedUserId(String sharedUserId) { 2390 this.sharedUserId = TextUtils.safeIntern(sharedUserId); 2391 return this; 2392 } 2393 2394 @Override 2395 public PackageImpl setSharedUserLabelResourceId(int value) { 2396 sharedUserLabel = value; 2397 return this; 2398 } 2399 2400 @Override 2401 public PackageImpl setSplitClassLoaderName(int splitIndex, String classLoaderName) { 2402 this.splitClassLoaderNames[splitIndex] = classLoaderName; 2403 return this; 2404 } 2405 2406 @Override 2407 public PackageImpl setSplitHasCode(int splitIndex, boolean splitHasCode) { 2408 this.splitFlags[splitIndex] = splitHasCode 2409 ? this.splitFlags[splitIndex] | ApplicationInfo.FLAG_HAS_CODE 2410 : this.splitFlags[splitIndex] & ~ApplicationInfo.FLAG_HAS_CODE; 2411 return this; 2412 } 2413 2414 @Override 2415 public PackageImpl setStaticSharedLibraryName(String staticSharedLibraryName) { 2416 this.staticSharedLibraryName = TextUtils.safeIntern(staticSharedLibraryName); 2417 return this; 2418 } 2419 2420 @Override 2421 public PackageImpl setStaticSharedLibraryVersion(long value) { 2422 staticSharedLibVersion = value; 2423 return this; 2424 } 2425 2426 @Override 2427 public PackageImpl setStaticSharedLibrary(boolean value) { 2428 return setBoolean(Booleans.STATIC_SHARED_LIBRARY, value); 2429 } 2430 2431 @Override 2432 public PackageImpl setExtraLargeScreensSupported(int supportsExtraLargeScreens) { 2433 if (supportsExtraLargeScreens == 1) { 2434 return this; 2435 } 2436 2437 this.supportsExtraLargeScreens = supportsExtraLargeScreens < 0; 2438 return this; 2439 } 2440 2441 @Override 2442 public PackageImpl setLargeScreensSupported(int supportsLargeScreens) { 2443 if (supportsLargeScreens == 1) { 2444 return this; 2445 } 2446 2447 this.supportsLargeScreens = supportsLargeScreens < 0; 2448 return this; 2449 } 2450 2451 @Override 2452 public PackageImpl setNormalScreensSupported(int supportsNormalScreens) { 2453 if (supportsNormalScreens == 1) { 2454 return this; 2455 } 2456 2457 this.supportsNormalScreens = supportsNormalScreens < 0; 2458 return this; 2459 } 2460 2461 @Override 2462 public PackageImpl setRtlSupported(boolean value) { 2463 return setBoolean(Booleans.SUPPORTS_RTL, value); 2464 } 2465 2466 @Override 2467 public PackageImpl setSmallScreensSupported(int supportsSmallScreens) { 2468 if (supportsSmallScreens == 1) { 2469 return this; 2470 } 2471 2472 this.supportsSmallScreens = supportsSmallScreens < 0; 2473 return this; 2474 } 2475 2476 @Override 2477 public PackageImpl setTargetSandboxVersion(int value) { 2478 targetSandboxVersion = value; 2479 return this; 2480 } 2481 2482 @Override 2483 public PackageImpl setTargetSdkVersion(int value) { 2484 targetSdkVersion = value; 2485 return this; 2486 } 2487 2488 @Override 2489 public PackageImpl setTaskAffinity(@Nullable String taskAffinity) { 2490 this.taskAffinity = taskAffinity; 2491 return this; 2492 } 2493 2494 @Override 2495 public PackageImpl setTestOnly(boolean value) { 2496 return setBoolean(Booleans.TEST_ONLY, value); 2497 } 2498 2499 @Override 2500 public PackageImpl setThemeResourceId(int value) { 2501 theme = value; 2502 return this; 2503 } 2504 2505 @Override 2506 public PackageImpl setUiOptions(int value) { 2507 uiOptions = value; 2508 return this; 2509 } 2510 2511 @Override 2512 public PackageImpl setUpgradeKeySets(@NonNull Set<String> value) { 2513 upgradeKeySets = value; 2514 return this; 2515 } 2516 2517 @Override 2518 public PackageImpl set32BitAbiPreferred(boolean value) { 2519 return setBoolean(Booleans.USE_32_BIT_ABI, value); 2520 } 2521 2522 @Override 2523 public PackageImpl setUseEmbeddedDex(boolean value) { 2524 return setBoolean(Booleans.USE_EMBEDDED_DEX, value); 2525 } 2526 2527 @Override 2528 public PackageImpl setCleartextTrafficAllowed(boolean value) { 2529 return setBoolean(Booleans.USES_CLEARTEXT_TRAFFIC, value); 2530 } 2531 2532 @Override 2533 public PackageImpl setNonSdkApiRequested(boolean value) { 2534 return setBoolean(Booleans.USES_NON_SDK_API, value); 2535 } 2536 2537 @Override 2538 public PackageImpl setVersionName(String versionName) { 2539 this.versionName = versionName; 2540 return this; 2541 } 2542 2543 @Override 2544 public PackageImpl setVisibleToInstantApps(boolean value) { 2545 return setBoolean(Booleans.VISIBLE_TO_INSTANT_APPS, value); 2546 } 2547 2548 @Override 2549 public PackageImpl setVmSafeMode(boolean value) { 2550 return setBoolean(Booleans.VM_SAFE_MODE, value); 2551 } 2552 2553 @Override 2554 public PackageImpl setVolumeUuid(@Nullable String volumeUuid) { 2555 this.volumeUuid = TextUtils.safeIntern(volumeUuid); 2556 return this; 2557 } 2558 2559 @Override 2560 public PackageImpl setZygotePreloadName(@Nullable String zygotePreloadName) { 2561 this.zygotePreloadName = zygotePreloadName; 2562 return this; 2563 } 2564 2565 @Override 2566 public PackageImpl sortActivities() { 2567 Collections.sort(this.activities, ORDER_COMPARATOR); 2568 return this; 2569 } 2570 2571 @Override 2572 public PackageImpl sortReceivers() { 2573 Collections.sort(this.receivers, ORDER_COMPARATOR); 2574 return this; 2575 } 2576 2577 @Override 2578 public PackageImpl sortServices() { 2579 Collections.sort(this.services, ORDER_COMPARATOR); 2580 return this; 2581 } 2582 2583 public ApplicationInfo toAppInfoWithoutStateWithoutFlags() { 2584 ApplicationInfo appInfo = new ApplicationInfo(); 2585 2586 // Lines that are commented below are state related and should not be assigned here. 2587 // They are left in as placeholders, since there is no good backwards compatible way to 2588 // separate these. 2589 appInfo.appComponentFactory = appComponentFactory; 2590 appInfo.backupAgentName = backupAgentName; 2591 appInfo.banner = banner; 2592 appInfo.category = category; 2593 appInfo.classLoaderName = classLoaderName; 2594 appInfo.className = className; 2595 appInfo.compatibleWidthLimitDp = compatibleWidthLimitDp; 2596 appInfo.compileSdkVersion = compileSdkVersion; 2597 appInfo.compileSdkVersionCodename = compileSdkVersionCodeName; 2598 // appInfo.credentialProtectedDataDir 2599 appInfo.crossProfile = isCrossProfile(); 2600 // appInfo.dataDir 2601 appInfo.descriptionRes = descriptionRes; 2602 // appInfo.deviceProtectedDataDir 2603 appInfo.enabled = getBoolean(Booleans.ENABLED); 2604 // appInfo.enabledSetting 2605 appInfo.fullBackupContent = fullBackupContent; 2606 appInfo.dataExtractionRulesRes = dataExtractionRules; 2607 // TODO(b/135203078): See PackageImpl#getHiddenApiEnforcementPolicy 2608 // appInfo.mHiddenApiPolicy 2609 // appInfo.hiddenUntilInstalled 2610 appInfo.icon = 2611 (ParsingPackageUtils.sUseRoundIcon && roundIconRes != 0) ? roundIconRes : iconRes; 2612 appInfo.iconRes = iconRes; 2613 appInfo.roundIconRes = roundIconRes; 2614 appInfo.installLocation = installLocation; 2615 appInfo.labelRes = labelRes; 2616 appInfo.largestWidthLimitDp = largestWidthLimitDp; 2617 appInfo.logo = logo; 2618 appInfo.manageSpaceActivityName = manageSpaceActivityName; 2619 appInfo.maxAspectRatio = maxAspectRatio; 2620 appInfo.metaData = metaData; 2621 appInfo.minAspectRatio = minAspectRatio; 2622 appInfo.minSdkVersion = minSdkVersion; 2623 appInfo.name = className; 2624 // appInfo.nativeLibraryDir 2625 // appInfo.nativeLibraryRootDir 2626 // appInfo.nativeLibraryRootRequiresIsa 2627 appInfo.networkSecurityConfigRes = networkSecurityConfigRes; 2628 appInfo.nonLocalizedLabel = nonLocalizedLabel; 2629 appInfo.packageName = packageName; 2630 appInfo.permission = permission; 2631 // appInfo.primaryCpuAbi 2632 appInfo.processName = getProcessName(); 2633 appInfo.requiresSmallestWidthDp = requiresSmallestWidthDp; 2634 // appInfo.resourceDirs 2635 // appInfo.secondaryCpuAbi 2636 // appInfo.secondaryNativeLibraryDir 2637 // appInfo.seInfo 2638 // appInfo.seInfoUser 2639 // appInfo.sharedLibraryFiles 2640 // appInfo.sharedLibraryInfos 2641 // appInfo.showUserIcon 2642 appInfo.splitClassLoaderNames = splitClassLoaderNames; 2643 appInfo.splitDependencies = (splitDependencies == null || splitDependencies.size() == 0) 2644 ? null : splitDependencies; 2645 appInfo.splitNames = splitNames; 2646 appInfo.storageUuid = mStorageUuid; 2647 appInfo.targetSandboxVersion = targetSandboxVersion; 2648 appInfo.targetSdkVersion = targetSdkVersion; 2649 appInfo.taskAffinity = taskAffinity; 2650 appInfo.theme = theme; 2651 // appInfo.uid 2652 appInfo.uiOptions = uiOptions; 2653 appInfo.volumeUuid = volumeUuid; 2654 appInfo.zygotePreloadName = zygotePreloadName; 2655 appInfo.setGwpAsanMode(gwpAsanMode); 2656 appInfo.setMemtagMode(memtagMode); 2657 appInfo.setNativeHeapZeroInitialized(nativeHeapZeroInitialized); 2658 appInfo.setRequestRawExternalStorageAccess(requestRawExternalStorageAccess); 2659 appInfo.setBaseCodePath(mBaseApkPath); 2660 appInfo.setBaseResourcePath(mBaseApkPath); 2661 appInfo.setCodePath(mPath); 2662 appInfo.setResourcePath(mPath); 2663 appInfo.setSplitCodePaths(ArrayUtils.size(splitCodePaths) == 0 ? null : splitCodePaths); 2664 appInfo.setSplitResourcePaths(ArrayUtils.size(splitCodePaths) == 0 ? null : splitCodePaths); 2665 appInfo.setVersionCode(mLongVersionCode); 2666 appInfo.setAppClassNamesByProcess(buildAppClassNamesByProcess()); 2667 appInfo.setLocaleConfigRes(mLocaleConfigRes); 2668 if (!mKnownActivityEmbeddingCerts.isEmpty()) { 2669 appInfo.setKnownActivityEmbeddingCerts(mKnownActivityEmbeddingCerts); 2670 } 2671 appInfo.allowCrossUidActivitySwitchFromBelow = mAllowCrossUidActivitySwitchFromBelow; 2672 2673 return appInfo; 2674 } 2675 2676 private PackageImpl setBoolean(@Booleans.Flags long flag, boolean value) { 2677 if (value) { 2678 mBooleans |= flag; 2679 } else { 2680 mBooleans &= ~flag; 2681 } 2682 return this; 2683 } 2684 2685 private boolean getBoolean(@Booleans.Flags long flag) { 2686 return (mBooleans & flag) != 0; 2687 } 2688 2689 private PackageImpl setBoolean2(@Booleans2.Flags long flag, boolean value) { 2690 if (value) { 2691 mBooleans2 |= flag; 2692 } else { 2693 mBooleans2 &= ~flag; 2694 } 2695 return this; 2696 } 2697 2698 private boolean getBoolean2(@Booleans2.Flags long flag) { 2699 return (mBooleans2 & flag) != 0; 2700 } 2701 2702 // Derived fields 2703 private int mBaseAppInfoFlags; 2704 private int mBaseAppInfoPrivateFlags; 2705 private int mBaseAppInfoPrivateFlagsExt; 2706 private String mBaseAppDataCredentialProtectedDirForSystemUser; 2707 private String mBaseAppDataDeviceProtectedDirForSystemUser; 2708 2709 ParsingPackageUtils.Callback mCallback; 2710 2711 @VisibleForTesting 2712 public PackageImpl(@NonNull String packageName, @NonNull String baseApkPath, 2713 @NonNull String path, @Nullable TypedArray manifestArray, boolean isCoreApp, 2714 @Nullable ParsingPackageUtils.Callback callback) { 2715 this.packageName = TextUtils.safeIntern(packageName); 2716 this.mBaseApkPath = baseApkPath; 2717 this.mPath = path; 2718 this.mCallback = callback; 2719 2720 if (manifestArray != null) { 2721 versionCode = manifestArray.getInteger(R.styleable.AndroidManifest_versionCode, 0); 2722 versionCodeMajor = manifestArray.getInteger( 2723 R.styleable.AndroidManifest_versionCodeMajor, 0); 2724 setBaseRevisionCode( 2725 manifestArray.getInteger(R.styleable.AndroidManifest_revisionCode, 0)); 2726 setVersionName(manifestArray.getNonConfigurationString( 2727 R.styleable.AndroidManifest_versionName, 0)); 2728 2729 setCompileSdkVersion(manifestArray.getInteger( 2730 R.styleable.AndroidManifest_compileSdkVersion, 0)); 2731 setCompileSdkVersionCodeName(manifestArray.getNonConfigurationString( 2732 R.styleable.AndroidManifest_compileSdkVersionCodename, 0)); 2733 2734 setIsolatedSplitLoading(manifestArray.getBoolean( 2735 R.styleable.AndroidManifest_isolatedSplits, false)); 2736 2737 } 2738 this.manifestPackageName = this.packageName; 2739 setBoolean(Booleans.CORE_APP, isCoreApp); 2740 } 2741 2742 @Override 2743 public PackageImpl hideAsParsed() { 2744 assignDerivedFields(); 2745 return this; 2746 } 2747 2748 @Override 2749 public AndroidPackageInternal hideAsFinal() { 2750 if (mStorageUuid == null) { 2751 assignDerivedFields(); 2752 } 2753 assignDerivedFields2(); 2754 makeImmutable(); 2755 return this; 2756 } 2757 2758 private static String[] sortLibraries(List<String> libraryNames) { 2759 int size = libraryNames.size(); 2760 if (size == 0) { 2761 return EmptyArray.STRING; 2762 } 2763 var arr = libraryNames.toArray(EmptyArray.STRING); 2764 Arrays.sort(arr); 2765 return arr; 2766 } 2767 2768 private void assignDerivedFields2() { 2769 mBaseAppInfoFlags = AppInfoUtils.appInfoFlags(this); 2770 mBaseAppInfoPrivateFlags = AppInfoUtils.appInfoPrivateFlags(this); 2771 mBaseAppInfoPrivateFlagsExt = AppInfoUtils.appInfoPrivateFlagsExt(this, 2772 mCallback == null ? false : 2773 mCallback.getHiddenApiWhitelistedApps().contains(this.packageName)); 2774 String baseAppDataDir = Environment.getDataDirectoryPath(getVolumeUuid()) + File.separator; 2775 String systemUserSuffix = File.separator + UserHandle.USER_SYSTEM + File.separator; 2776 mBaseAppDataCredentialProtectedDirForSystemUser = TextUtils.safeIntern( 2777 baseAppDataDir + Environment.DIR_USER_CE + systemUserSuffix); 2778 mBaseAppDataDeviceProtectedDirForSystemUser = TextUtils.safeIntern( 2779 baseAppDataDir + Environment.DIR_USER_DE + systemUserSuffix); 2780 } 2781 2782 private void makeImmutable() { 2783 usesLibraries = Collections.unmodifiableList(usesLibraries); 2784 usesOptionalLibraries = Collections.unmodifiableList(usesOptionalLibraries); 2785 usesNativeLibraries = Collections.unmodifiableList(usesNativeLibraries); 2786 usesOptionalNativeLibraries = Collections.unmodifiableList(usesOptionalNativeLibraries); 2787 originalPackages = Collections.unmodifiableList(originalPackages); 2788 adoptPermissions = Collections.unmodifiableList(adoptPermissions); 2789 requestedPermissions = Collections.unmodifiableSet(requestedPermissions); 2790 protectedBroadcasts = Collections.unmodifiableList(protectedBroadcasts); 2791 apexSystemServices = Collections.unmodifiableList(apexSystemServices); 2792 2793 activities = Collections.unmodifiableList(activities); 2794 receivers = Collections.unmodifiableList(receivers); 2795 services = Collections.unmodifiableList(services); 2796 providers = Collections.unmodifiableList(providers); 2797 permissions = Collections.unmodifiableList(permissions); 2798 permissionGroups = Collections.unmodifiableList(permissionGroups); 2799 instrumentations = Collections.unmodifiableList(instrumentations); 2800 2801 overlayables = Collections.unmodifiableMap(overlayables); 2802 libraryNames = Collections.unmodifiableList(libraryNames); 2803 usesStaticLibraries = Collections.unmodifiableList(usesStaticLibraries); 2804 usesSdkLibraries = Collections.unmodifiableList(usesSdkLibraries); 2805 configPreferences = Collections.unmodifiableList(configPreferences); 2806 reqFeatures = Collections.unmodifiableList(reqFeatures); 2807 featureGroups = Collections.unmodifiableList(featureGroups); 2808 usesPermissions = Collections.unmodifiableList(usesPermissions); 2809 usesSdkLibraries = Collections.unmodifiableList(usesSdkLibraries); 2810 implicitPermissions = Collections.unmodifiableSet(implicitPermissions); 2811 upgradeKeySets = Collections.unmodifiableSet(upgradeKeySets); 2812 keySetMapping = Collections.unmodifiableMap(keySetMapping); 2813 attributions = Collections.unmodifiableList(attributions); 2814 preferredActivityFilters = Collections.unmodifiableList(preferredActivityFilters); 2815 processes = Collections.unmodifiableMap(processes); 2816 mProperties = Collections.unmodifiableMap(mProperties); 2817 queriesIntents = Collections.unmodifiableList(queriesIntents); 2818 queriesPackages = Collections.unmodifiableList(queriesPackages); 2819 queriesProviders = Collections.unmodifiableSet(queriesProviders); 2820 mimeGroups = Collections.unmodifiableSet(mimeGroups); 2821 mKnownActivityEmbeddingCerts = Collections.unmodifiableSet(mKnownActivityEmbeddingCerts); 2822 } 2823 2824 @Override 2825 public long getLongVersionCode() { 2826 return PackageInfo.composeLongVersionCode(versionCodeMajor, versionCode); 2827 } 2828 2829 @Override 2830 public PackageImpl removePermission(int index) { 2831 this.permissions.remove(index); 2832 return this; 2833 } 2834 2835 @Override 2836 public PackageImpl addUsesOptionalLibrary(int index, String libraryName) { 2837 this.usesOptionalLibraries = CollectionUtils.add(usesOptionalLibraries, index, 2838 TextUtils.safeIntern(libraryName)); 2839 return this; 2840 } 2841 2842 @Override 2843 public PackageImpl addUsesLibrary(int index, String libraryName) { 2844 this.usesLibraries = CollectionUtils.add(usesLibraries, index, 2845 TextUtils.safeIntern(libraryName)); 2846 return this; 2847 } 2848 2849 @Override 2850 public PackageImpl removeUsesLibrary(String libraryName) { 2851 this.usesLibraries = CollectionUtils.remove(this.usesLibraries, libraryName); 2852 return this; 2853 } 2854 2855 @Override 2856 public PackageImpl removeUsesOptionalLibrary(String libraryName) { 2857 this.usesOptionalLibraries = CollectionUtils.remove(this.usesOptionalLibraries, 2858 libraryName); 2859 return this; 2860 } 2861 2862 @Override 2863 public PackageImpl setSigningDetails(@NonNull SigningDetails value) { 2864 signingDetails = value; 2865 return this; 2866 } 2867 2868 @Override 2869 public PackageImpl setRestrictUpdateHash(@Nullable byte... value) { 2870 restrictUpdateHash = value; 2871 return this; 2872 } 2873 2874 @Override 2875 public PackageImpl setPersistent(boolean value) { 2876 setBoolean(Booleans.PERSISTENT, value); 2877 return this; 2878 } 2879 2880 @Override 2881 public PackageImpl setDefaultToDeviceProtectedStorage(boolean value) { 2882 setBoolean(Booleans.DEFAULT_TO_DEVICE_PROTECTED_STORAGE, value); 2883 return this; 2884 } 2885 2886 @Override 2887 public PackageImpl setDirectBootAware(boolean value) { 2888 setBoolean(Booleans.DIRECT_BOOT_AWARE, value); 2889 return this; 2890 } 2891 2892 @Override 2893 public PackageImpl clearProtectedBroadcasts() { 2894 protectedBroadcasts.clear(); 2895 return this; 2896 } 2897 2898 @Override 2899 public PackageImpl clearOriginalPackages() { 2900 originalPackages.clear(); 2901 return this; 2902 } 2903 2904 @Override 2905 public PackageImpl clearAdoptPermissions() { 2906 adoptPermissions.clear(); 2907 return this; 2908 } 2909 2910 @Override 2911 public PackageImpl setPath(@NonNull String path) { 2912 this.mPath = path; 2913 return this; 2914 } 2915 2916 // TODO(b/135203078): Move PackageManagerService#renameStaticSharedLibraryPackage 2917 // into initial package parsing 2918 @Override 2919 public PackageImpl setPackageName(@NonNull String packageName) { 2920 this.packageName = TextUtils.safeIntern(packageName); 2921 2922 int permissionsSize = permissions.size(); 2923 for (int index = 0; index < permissionsSize; index++) { 2924 ComponentMutateUtils.setPackageName(permissions.get(index), this.packageName); 2925 } 2926 2927 int permissionGroupsSize = permissionGroups.size(); 2928 for (int index = 0; index < permissionGroupsSize; index++) { 2929 ComponentMutateUtils.setPackageName(permissionGroups.get(index), this.packageName); 2930 } 2931 2932 int activitiesSize = activities.size(); 2933 for (int index = 0; index < activitiesSize; index++) { 2934 ComponentMutateUtils.setPackageName(activities.get(index), this.packageName); 2935 } 2936 2937 int receiversSize = receivers.size(); 2938 for (int index = 0; index < receiversSize; index++) { 2939 ComponentMutateUtils.setPackageName(receivers.get(index), this.packageName); 2940 } 2941 2942 int providersSize = providers.size(); 2943 for (int index = 0; index < providersSize; index++) { 2944 ComponentMutateUtils.setPackageName(providers.get(index), this.packageName); 2945 } 2946 2947 int servicesSize = services.size(); 2948 for (int index = 0; index < servicesSize; index++) { 2949 ComponentMutateUtils.setPackageName(services.get(index), this.packageName); 2950 } 2951 2952 int instrumentationsSize = instrumentations.size(); 2953 for (int index = 0; index < instrumentationsSize; index++) { 2954 ComponentMutateUtils.setPackageName(instrumentations.get(index), this.packageName); 2955 } 2956 2957 return this; 2958 } 2959 2960 @Override 2961 public PackageImpl setAllComponentsDirectBootAware(boolean allComponentsDirectBootAware) { 2962 int activitiesSize = activities.size(); 2963 for (int index = 0; index < activitiesSize; index++) { 2964 ComponentMutateUtils.setDirectBootAware(activities.get(index), 2965 allComponentsDirectBootAware); 2966 } 2967 2968 int receiversSize = receivers.size(); 2969 for (int index = 0; index < receiversSize; index++) { 2970 ComponentMutateUtils.setDirectBootAware(receivers.get(index), 2971 allComponentsDirectBootAware); 2972 } 2973 2974 int providersSize = providers.size(); 2975 for (int index = 0; index < providersSize; index++) { 2976 ComponentMutateUtils.setDirectBootAware(providers.get(index), 2977 allComponentsDirectBootAware); 2978 } 2979 2980 int servicesSize = services.size(); 2981 for (int index = 0; index < servicesSize; index++) { 2982 ComponentMutateUtils.setDirectBootAware(services.get(index), 2983 allComponentsDirectBootAware); 2984 } 2985 2986 return this; 2987 } 2988 2989 @Override 2990 public PackageImpl setBaseApkPath(@NonNull String baseApkPath) { 2991 this.mBaseApkPath = TextUtils.safeIntern(baseApkPath); 2992 return this; 2993 } 2994 2995 @Override 2996 public PackageImpl setNativeLibraryDir(@Nullable String nativeLibraryDir) { 2997 this.nativeLibraryDir = TextUtils.safeIntern(nativeLibraryDir); 2998 return this; 2999 } 3000 3001 @Override 3002 public PackageImpl setNativeLibraryRootDir(@Nullable String nativeLibraryRootDir) { 3003 this.nativeLibraryRootDir = TextUtils.safeIntern(nativeLibraryRootDir); 3004 return this; 3005 } 3006 3007 @Override 3008 public PackageImpl setPrimaryCpuAbi(@Nullable String primaryCpuAbi) { 3009 this.primaryCpuAbi = TextUtils.safeIntern(primaryCpuAbi); 3010 return this; 3011 } 3012 3013 @Override 3014 public PackageImpl setSecondaryCpuAbi(@Nullable String secondaryCpuAbi) { 3015 this.secondaryCpuAbi = TextUtils.safeIntern(secondaryCpuAbi); 3016 return this; 3017 } 3018 3019 @Override 3020 public PackageImpl setSecondaryNativeLibraryDir(@Nullable String secondaryNativeLibraryDir) { 3021 this.secondaryNativeLibraryDir = TextUtils.safeIntern(secondaryNativeLibraryDir); 3022 return this; 3023 } 3024 3025 @Override 3026 public PackageImpl setSplitCodePaths(@Nullable String[] splitCodePaths) { 3027 this.splitCodePaths = splitCodePaths; 3028 if (splitCodePaths != null) { 3029 int size = splitCodePaths.length; 3030 for (int index = 0; index < size; index++) { 3031 this.splitCodePaths[index] = TextUtils.safeIntern(this.splitCodePaths[index]); 3032 } 3033 } 3034 return this; 3035 } 3036 3037 @Override 3038 public PackageImpl capPermissionPriorities() { 3039 int size = permissionGroups.size(); 3040 for (int index = size - 1; index >= 0; --index) { 3041 // TODO(b/135203078): Builder/immutability 3042 ComponentMutateUtils.setPriority(permissionGroups.get(index), 0); 3043 } 3044 return this; 3045 } 3046 3047 @Override 3048 public PackageImpl markNotActivitiesAsNotExportedIfSingleUser() { 3049 // ignore export request for single user receivers 3050 int receiversSize = receivers.size(); 3051 for (int index = 0; index < receiversSize; index++) { 3052 ParsedActivity receiver = receivers.get(index); 3053 if ((receiver.getFlags() & ActivityInfo.FLAG_SINGLE_USER) != 0) { 3054 ComponentMutateUtils.setExported(receiver, false); 3055 } 3056 } 3057 3058 // ignore export request for single user services 3059 int servicesSize = services.size(); 3060 for (int index = 0; index < servicesSize; index++) { 3061 ParsedService service = services.get(index); 3062 if ((service.getFlags() & ActivityInfo.FLAG_SINGLE_USER) != 0) { 3063 ComponentMutateUtils.setExported(service, false); 3064 } 3065 } 3066 3067 // ignore export request for single user providers 3068 int providersSize = providers.size(); 3069 for (int index = 0; index < providersSize; index++) { 3070 ParsedProvider provider = providers.get(index); 3071 if ((provider.getFlags() & ActivityInfo.FLAG_SINGLE_USER) != 0) { 3072 ComponentMutateUtils.setExported(provider, false); 3073 } 3074 } 3075 3076 return this; 3077 } 3078 3079 @Override 3080 public PackageImpl setCoreApp(boolean coreApp) { 3081 return setBoolean(Booleans.CORE_APP, coreApp); 3082 } 3083 3084 @Override 3085 public PackageImpl setVersionCode(int versionCode) { 3086 this.versionCode = versionCode; 3087 return this; 3088 } 3089 3090 @Override 3091 public PackageImpl setVersionCodeMajor(int versionCodeMajor) { 3092 this.versionCodeMajor = versionCodeMajor; 3093 return this; 3094 } 3095 3096 @Override 3097 public ApplicationInfo toAppInfoWithoutState() { 3098 ApplicationInfo appInfo = toAppInfoWithoutStateWithoutFlags(); 3099 appInfo.flags = mBaseAppInfoFlags; 3100 appInfo.privateFlags = mBaseAppInfoPrivateFlags; 3101 appInfo.privateFlagsExt = mBaseAppInfoPrivateFlagsExt; 3102 appInfo.nativeLibraryDir = nativeLibraryDir; 3103 appInfo.nativeLibraryRootDir = nativeLibraryRootDir; 3104 appInfo.nativeLibraryRootRequiresIsa = nativeLibraryRootRequiresIsa; 3105 appInfo.primaryCpuAbi = primaryCpuAbi; 3106 appInfo.secondaryCpuAbi = secondaryCpuAbi; 3107 appInfo.secondaryNativeLibraryDir = secondaryNativeLibraryDir; 3108 appInfo.seInfoUser = SEInfoUtil.COMPLETE_STR; 3109 appInfo.uid = uid; 3110 return appInfo; 3111 } 3112 3113 @Override 3114 public int describeContents() { 3115 return 0; 3116 } 3117 3118 @Override 3119 public void writeToParcel(Parcel dest, int flags) { 3120 sForBoolean.parcel(this.supportsSmallScreens, dest, flags); 3121 sForBoolean.parcel(this.supportsNormalScreens, dest, flags); 3122 sForBoolean.parcel(this.supportsLargeScreens, dest, flags); 3123 sForBoolean.parcel(this.supportsExtraLargeScreens, dest, flags); 3124 sForBoolean.parcel(this.resizeable, dest, flags); 3125 sForBoolean.parcel(this.anyDensity, dest, flags); 3126 dest.writeInt(this.versionCode); 3127 dest.writeInt(this.versionCodeMajor); 3128 dest.writeInt(this.baseRevisionCode); 3129 sForInternedString.parcel(this.versionName, dest, flags); 3130 dest.writeInt(this.compileSdkVersion); 3131 dest.writeString(this.compileSdkVersionCodeName); 3132 sForInternedString.parcel(this.packageName, dest, flags); 3133 dest.writeString(this.mBaseApkPath); 3134 dest.writeString(this.restrictedAccountType); 3135 dest.writeString(this.requiredAccountType); 3136 dest.writeString(this.mEmergencyInstaller); 3137 sForInternedString.parcel(this.overlayTarget, dest, flags); 3138 dest.writeString(this.overlayTargetOverlayableName); 3139 dest.writeString(this.overlayCategory); 3140 dest.writeInt(this.overlayPriority); 3141 sForInternedStringValueMap.parcel(this.overlayables, dest, flags); 3142 sForInternedString.parcel(this.sdkLibraryName, dest, flags); 3143 dest.writeInt(this.sdkLibVersionMajor); 3144 sForInternedString.parcel(this.staticSharedLibraryName, dest, flags); 3145 dest.writeLong(this.staticSharedLibVersion); 3146 sForInternedStringList.parcel(this.libraryNames, dest, flags); 3147 sForInternedStringList.parcel(this.usesLibraries, dest, flags); 3148 sForInternedStringList.parcel(this.usesOptionalLibraries, dest, flags); 3149 sForInternedStringList.parcel(this.usesNativeLibraries, dest, flags); 3150 sForInternedStringList.parcel(this.usesOptionalNativeLibraries, dest, flags); 3151 3152 sForInternedStringList.parcel(this.usesStaticLibraries, dest, flags); 3153 dest.writeLongArray(this.usesStaticLibrariesVersions); 3154 if (this.usesStaticLibrariesCertDigests == null) { 3155 dest.writeInt(-1); 3156 } else { 3157 dest.writeInt(this.usesStaticLibrariesCertDigests.length); 3158 for (int index = 0; index < this.usesStaticLibrariesCertDigests.length; index++) { 3159 dest.writeStringArray(this.usesStaticLibrariesCertDigests[index]); 3160 } 3161 } 3162 3163 sForInternedStringList.parcel(this.usesSdkLibraries, dest, flags); 3164 dest.writeLongArray(this.usesSdkLibrariesVersionsMajor); 3165 if (this.usesSdkLibrariesCertDigests == null) { 3166 dest.writeInt(-1); 3167 } else { 3168 dest.writeInt(this.usesSdkLibrariesCertDigests.length); 3169 for (int index = 0; index < this.usesSdkLibrariesCertDigests.length; index++) { 3170 dest.writeStringArray(this.usesSdkLibrariesCertDigests[index]); 3171 } 3172 } 3173 dest.writeBooleanArray(this.usesSdkLibrariesOptional); 3174 3175 sForInternedString.parcel(this.sharedUserId, dest, flags); 3176 dest.writeInt(this.sharedUserLabel); 3177 dest.writeTypedList(this.configPreferences); 3178 dest.writeTypedList(this.reqFeatures); 3179 dest.writeTypedList(this.featureGroups); 3180 dest.writeByteArray(this.restrictUpdateHash); 3181 dest.writeStringList(this.originalPackages); 3182 sForInternedStringList.parcel(this.adoptPermissions, dest, flags); 3183 sForInternedStringSet.parcel(this.requestedPermissions, dest, flags); 3184 ParsingUtils.writeParcelableList(dest, this.usesPermissions); 3185 sForInternedStringSet.parcel(this.implicitPermissions, dest, flags); 3186 sForStringSet.parcel(this.upgradeKeySets, dest, flags); 3187 ParsingPackageUtils.writeKeySetMapping(dest, this.keySetMapping); 3188 sForInternedStringList.parcel(this.protectedBroadcasts, dest, flags); 3189 ParsingUtils.writeParcelableList(dest, this.activities); 3190 ParsingUtils.writeParcelableList(dest, this.apexSystemServices); 3191 ParsingUtils.writeParcelableList(dest, this.receivers); 3192 ParsingUtils.writeParcelableList(dest, this.services); 3193 ParsingUtils.writeParcelableList(dest, this.providers); 3194 ParsingUtils.writeParcelableList(dest, this.attributions); 3195 ParsingUtils.writeParcelableList(dest, this.permissions); 3196 ParsingUtils.writeParcelableList(dest, this.permissionGroups); 3197 ParsingUtils.writeParcelableList(dest, this.instrumentations); 3198 sForIntentInfoPairs.parcel(this.preferredActivityFilters, dest, flags); 3199 dest.writeMap(this.processes); 3200 dest.writeBundle(this.metaData); 3201 sForInternedString.parcel(this.volumeUuid, dest, flags); 3202 dest.writeParcelable(this.signingDetails, flags); 3203 dest.writeString(this.mPath); 3204 dest.writeTypedList(this.queriesIntents, flags); 3205 sForInternedStringList.parcel(this.queriesPackages, dest, flags); 3206 sForInternedStringSet.parcel(this.queriesProviders, dest, flags); 3207 dest.writeString(this.appComponentFactory); 3208 dest.writeString(this.backupAgentName); 3209 dest.writeInt(this.banner); 3210 dest.writeInt(this.category); 3211 dest.writeString(this.classLoaderName); 3212 dest.writeString(this.className); 3213 dest.writeInt(this.compatibleWidthLimitDp); 3214 dest.writeInt(this.descriptionRes); 3215 dest.writeInt(this.fullBackupContent); 3216 dest.writeInt(this.dataExtractionRules); 3217 dest.writeInt(this.iconRes); 3218 dest.writeInt(this.installLocation); 3219 dest.writeInt(this.labelRes); 3220 dest.writeInt(this.largestWidthLimitDp); 3221 dest.writeInt(this.logo); 3222 dest.writeString(this.manageSpaceActivityName); 3223 dest.writeFloat(this.maxAspectRatio); 3224 dest.writeFloat(this.minAspectRatio); 3225 dest.writeInt(this.minSdkVersion); 3226 dest.writeInt(this.maxSdkVersion); 3227 dest.writeInt(this.networkSecurityConfigRes); 3228 dest.writeCharSequence(this.nonLocalizedLabel); 3229 dest.writeString(this.permission); 3230 dest.writeString(this.processName); 3231 dest.writeInt(this.requiresSmallestWidthDp); 3232 dest.writeInt(this.roundIconRes); 3233 dest.writeInt(this.targetSandboxVersion); 3234 dest.writeInt(this.targetSdkVersion); 3235 dest.writeString(this.taskAffinity); 3236 dest.writeInt(this.theme); 3237 dest.writeInt(this.uiOptions); 3238 dest.writeString(this.zygotePreloadName); 3239 dest.writeStringArray(this.splitClassLoaderNames); 3240 dest.writeStringArray(this.splitCodePaths); 3241 dest.writeSparseArray(this.splitDependencies); 3242 dest.writeIntArray(this.splitFlags); 3243 dest.writeStringArray(this.splitNames); 3244 dest.writeIntArray(this.splitRevisionCodes); 3245 sForBoolean.parcel(this.resizeableActivity, dest, flags); 3246 dest.writeInt(this.autoRevokePermissions); 3247 sForInternedStringSet.parcel(this.mimeGroups, dest, flags); 3248 dest.writeInt(this.gwpAsanMode); 3249 dest.writeSparseIntArray(this.minExtensionVersions); 3250 dest.writeMap(this.mProperties); 3251 dest.writeInt(this.memtagMode); 3252 dest.writeInt(this.nativeHeapZeroInitialized); 3253 sForBoolean.parcel(this.requestRawExternalStorageAccess, dest, flags); 3254 dest.writeInt(this.mLocaleConfigRes); 3255 sForStringSet.parcel(mKnownActivityEmbeddingCerts, dest, flags); 3256 sForInternedString.parcel(this.manifestPackageName, dest, flags); 3257 dest.writeString(this.nativeLibraryDir); 3258 dest.writeString(this.nativeLibraryRootDir); 3259 dest.writeBoolean(this.nativeLibraryRootRequiresIsa); 3260 sForInternedString.parcel(this.primaryCpuAbi, dest, flags); 3261 sForInternedString.parcel(this.secondaryCpuAbi, dest, flags); 3262 dest.writeString(this.secondaryNativeLibraryDir); 3263 dest.writeInt(this.uid); 3264 dest.writeLong(this.mBooleans); 3265 dest.writeLong(this.mBooleans2); 3266 dest.writeBoolean(this.mAllowCrossUidActivitySwitchFromBelow); 3267 } 3268 3269 public PackageImpl(Parcel in) { 3270 this(in, /* callback */ null); 3271 } 3272 3273 public PackageImpl(@NonNull Parcel in, @Nullable ParsingPackageUtils.Callback callback) { 3274 mCallback = callback; 3275 // We use the boot classloader for all classes that we load. 3276 final ClassLoader boot = Object.class.getClassLoader(); 3277 this.supportsSmallScreens = sForBoolean.unparcel(in); 3278 this.supportsNormalScreens = sForBoolean.unparcel(in); 3279 this.supportsLargeScreens = sForBoolean.unparcel(in); 3280 this.supportsExtraLargeScreens = sForBoolean.unparcel(in); 3281 this.resizeable = sForBoolean.unparcel(in); 3282 this.anyDensity = sForBoolean.unparcel(in); 3283 this.versionCode = in.readInt(); 3284 this.versionCodeMajor = in.readInt(); 3285 this.baseRevisionCode = in.readInt(); 3286 this.versionName = sForInternedString.unparcel(in); 3287 this.compileSdkVersion = in.readInt(); 3288 this.compileSdkVersionCodeName = in.readString(); 3289 this.packageName = sForInternedString.unparcel(in); 3290 this.mBaseApkPath = in.readString(); 3291 this.restrictedAccountType = in.readString(); 3292 this.requiredAccountType = in.readString(); 3293 this.mEmergencyInstaller = in.readString(); 3294 this.overlayTarget = sForInternedString.unparcel(in); 3295 this.overlayTargetOverlayableName = in.readString(); 3296 this.overlayCategory = in.readString(); 3297 this.overlayPriority = in.readInt(); 3298 this.overlayables = sForInternedStringValueMap.unparcel(in); 3299 this.sdkLibraryName = sForInternedString.unparcel(in); 3300 this.sdkLibVersionMajor = in.readInt(); 3301 this.staticSharedLibraryName = sForInternedString.unparcel(in); 3302 this.staticSharedLibVersion = in.readLong(); 3303 this.libraryNames = sForInternedStringList.unparcel(in); 3304 this.usesLibraries = sForInternedStringList.unparcel(in); 3305 this.usesOptionalLibraries = sForInternedStringList.unparcel(in); 3306 this.usesNativeLibraries = sForInternedStringList.unparcel(in); 3307 this.usesOptionalNativeLibraries = sForInternedStringList.unparcel(in); 3308 3309 this.usesStaticLibraries = sForInternedStringList.unparcel(in); 3310 this.usesStaticLibrariesVersions = in.createLongArray(); 3311 { 3312 int digestsSize = in.readInt(); 3313 if (digestsSize >= 0) { 3314 this.usesStaticLibrariesCertDigests = new String[digestsSize][]; 3315 for (int index = 0; index < digestsSize; index++) { 3316 this.usesStaticLibrariesCertDigests[index] = sForInternedStringArray.unparcel( 3317 in); 3318 } 3319 } 3320 } 3321 3322 this.usesSdkLibraries = sForInternedStringList.unparcel(in); 3323 this.usesSdkLibrariesVersionsMajor = in.createLongArray(); 3324 { 3325 int digestsSize = in.readInt(); 3326 if (digestsSize >= 0) { 3327 this.usesSdkLibrariesCertDigests = new String[digestsSize][]; 3328 for (int index = 0; index < digestsSize; index++) { 3329 this.usesSdkLibrariesCertDigests[index] = sForInternedStringArray.unparcel(in); 3330 } 3331 } 3332 } 3333 this.usesSdkLibrariesOptional = in.createBooleanArray(); 3334 3335 this.sharedUserId = sForInternedString.unparcel(in); 3336 this.sharedUserLabel = in.readInt(); 3337 this.configPreferences = in.createTypedArrayList(ConfigurationInfo.CREATOR); 3338 this.reqFeatures = in.createTypedArrayList(FeatureInfo.CREATOR); 3339 this.featureGroups = in.createTypedArrayList(FeatureGroupInfo.CREATOR); 3340 this.restrictUpdateHash = in.createByteArray(); 3341 this.originalPackages = in.createStringArrayList(); 3342 this.adoptPermissions = sForInternedStringList.unparcel(in); 3343 this.requestedPermissions = sForInternedStringSet.unparcel(in); 3344 this.usesPermissions = ParsingUtils.createTypedInterfaceList(in, 3345 ParsedUsesPermissionImpl.CREATOR); 3346 this.implicitPermissions = sForInternedStringSet.unparcel(in); 3347 this.upgradeKeySets = sForStringSet.unparcel(in); 3348 this.keySetMapping = ParsingPackageUtils.readKeySetMapping(in); 3349 this.protectedBroadcasts = sForInternedStringList.unparcel(in); 3350 3351 this.activities = ParsingUtils.createTypedInterfaceList(in, ParsedActivityImpl.CREATOR); 3352 this.apexSystemServices = ParsingUtils.createTypedInterfaceList(in, 3353 ParsedApexSystemServiceImpl.CREATOR); 3354 this.receivers = ParsingUtils.createTypedInterfaceList(in, ParsedActivityImpl.CREATOR); 3355 this.services = ParsingUtils.createTypedInterfaceList(in, ParsedServiceImpl.CREATOR); 3356 this.providers = ParsingUtils.createTypedInterfaceList(in, ParsedProviderImpl.CREATOR); 3357 this.attributions = ParsingUtils.createTypedInterfaceList(in, 3358 ParsedAttributionImpl.CREATOR); 3359 this.permissions = ParsingUtils.createTypedInterfaceList(in, ParsedPermissionImpl.CREATOR); 3360 this.permissionGroups = ParsingUtils.createTypedInterfaceList(in, 3361 ParsedPermissionGroupImpl.CREATOR); 3362 this.instrumentations = ParsingUtils.createTypedInterfaceList(in, 3363 ParsedInstrumentationImpl.CREATOR); 3364 this.preferredActivityFilters = sForIntentInfoPairs.unparcel(in); 3365 this.processes = in.readHashMap(ParsedProcessImpl.class.getClassLoader()); 3366 this.metaData = in.readBundle(boot); 3367 this.volumeUuid = sForInternedString.unparcel(in); 3368 this.signingDetails = in.readParcelable(boot, android.content.pm.SigningDetails.class); 3369 this.mPath = in.readString(); 3370 this.queriesIntents = in.createTypedArrayList(Intent.CREATOR); 3371 this.queriesPackages = sForInternedStringList.unparcel(in); 3372 this.queriesProviders = sForInternedStringSet.unparcel(in); 3373 this.appComponentFactory = in.readString(); 3374 this.backupAgentName = in.readString(); 3375 this.banner = in.readInt(); 3376 this.category = in.readInt(); 3377 this.classLoaderName = in.readString(); 3378 this.className = in.readString(); 3379 this.compatibleWidthLimitDp = in.readInt(); 3380 this.descriptionRes = in.readInt(); 3381 this.fullBackupContent = in.readInt(); 3382 this.dataExtractionRules = in.readInt(); 3383 this.iconRes = in.readInt(); 3384 this.installLocation = in.readInt(); 3385 this.labelRes = in.readInt(); 3386 this.largestWidthLimitDp = in.readInt(); 3387 this.logo = in.readInt(); 3388 this.manageSpaceActivityName = in.readString(); 3389 this.maxAspectRatio = in.readFloat(); 3390 this.minAspectRatio = in.readFloat(); 3391 this.minSdkVersion = in.readInt(); 3392 this.maxSdkVersion = in.readInt(); 3393 this.networkSecurityConfigRes = in.readInt(); 3394 this.nonLocalizedLabel = in.readCharSequence(); 3395 this.permission = in.readString(); 3396 this.processName = in.readString(); 3397 this.requiresSmallestWidthDp = in.readInt(); 3398 this.roundIconRes = in.readInt(); 3399 this.targetSandboxVersion = in.readInt(); 3400 this.targetSdkVersion = in.readInt(); 3401 this.taskAffinity = in.readString(); 3402 this.theme = in.readInt(); 3403 this.uiOptions = in.readInt(); 3404 this.zygotePreloadName = in.readString(); 3405 this.splitClassLoaderNames = in.createStringArray(); 3406 this.splitCodePaths = in.createStringArray(); 3407 this.splitDependencies = in.readSparseArray(boot); 3408 this.splitFlags = in.createIntArray(); 3409 this.splitNames = in.createStringArray(); 3410 this.splitRevisionCodes = in.createIntArray(); 3411 this.resizeableActivity = sForBoolean.unparcel(in); 3412 3413 this.autoRevokePermissions = in.readInt(); 3414 this.mimeGroups = sForInternedStringSet.unparcel(in); 3415 this.gwpAsanMode = in.readInt(); 3416 this.minExtensionVersions = in.readSparseIntArray(); 3417 this.mProperties = in.readHashMap(boot); 3418 this.memtagMode = in.readInt(); 3419 this.nativeHeapZeroInitialized = in.readInt(); 3420 this.requestRawExternalStorageAccess = sForBoolean.unparcel(in); 3421 this.mLocaleConfigRes = in.readInt(); 3422 this.mKnownActivityEmbeddingCerts = sForStringSet.unparcel(in); 3423 this.manifestPackageName = sForInternedString.unparcel(in); 3424 this.nativeLibraryDir = in.readString(); 3425 this.nativeLibraryRootDir = in.readString(); 3426 this.nativeLibraryRootRequiresIsa = in.readBoolean(); 3427 this.primaryCpuAbi = sForInternedString.unparcel(in); 3428 this.secondaryCpuAbi = sForInternedString.unparcel(in); 3429 this.secondaryNativeLibraryDir = in.readString(); 3430 this.uid = in.readInt(); 3431 this.mBooleans = in.readLong(); 3432 this.mBooleans2 = in.readLong(); 3433 this.mAllowCrossUidActivitySwitchFromBelow = in.readBoolean(); 3434 3435 assignDerivedFields(); 3436 assignDerivedFields2(); 3437 3438 // Do not call makeImmutable here as cached parsing will need 3439 // to mutate this instance before it's finalized. 3440 } 3441 3442 @NonNull 3443 public static final Creator<PackageImpl> CREATOR = new Creator<PackageImpl>() { 3444 @Override 3445 public PackageImpl createFromParcel(Parcel source) { 3446 return new PackageImpl(source); 3447 } 3448 3449 @Override 3450 public PackageImpl[] newArray(int size) { 3451 return new PackageImpl[size]; 3452 } 3453 }; 3454 3455 @NonNull 3456 @Override 3457 public String getManifestPackageName() { 3458 return manifestPackageName; 3459 } 3460 3461 public boolean isStub() { 3462 return getBoolean2(Booleans2.STUB); 3463 } 3464 3465 @Nullable 3466 @Override 3467 public String getNativeLibraryDir() { 3468 return nativeLibraryDir; 3469 } 3470 3471 @Nullable 3472 @Override 3473 public String getNativeLibraryRootDir() { 3474 return nativeLibraryRootDir; 3475 } 3476 3477 @Override 3478 public boolean isNativeLibraryRootRequiresIsa() { 3479 return nativeLibraryRootRequiresIsa; 3480 } 3481 3482 @Nullable 3483 @Override 3484 public String getPrimaryCpuAbi() { 3485 return primaryCpuAbi; 3486 } 3487 3488 @Nullable 3489 @Override 3490 public String getSecondaryCpuAbi() { 3491 return secondaryCpuAbi; 3492 } 3493 3494 @Nullable 3495 @Override 3496 public String getSecondaryNativeLibraryDir() { 3497 return secondaryNativeLibraryDir; 3498 } 3499 3500 @Override 3501 public boolean isCoreApp() { 3502 return getBoolean(Booleans.CORE_APP); 3503 } 3504 3505 @Override 3506 public boolean isSystem() { 3507 return getBoolean(Booleans.SYSTEM); 3508 } 3509 3510 @Override 3511 public boolean isUpdatableSystem() { 3512 return getBoolean2(Booleans2.UPDATABLE_SYSTEM); 3513 } 3514 3515 @Override 3516 public boolean isFactoryTest() { 3517 return getBoolean(Booleans.FACTORY_TEST); 3518 } 3519 3520 @Override 3521 public boolean isApex() { 3522 return getBoolean2(Booleans2.APEX); 3523 } 3524 3525 @Override 3526 public boolean isSystemExt() { 3527 return getBoolean(Booleans.SYSTEM_EXT); 3528 } 3529 3530 @Override 3531 public boolean isPrivileged() { 3532 return getBoolean(Booleans.PRIVILEGED); 3533 } 3534 3535 @Override 3536 public boolean isOem() { 3537 return getBoolean(Booleans.OEM); 3538 } 3539 3540 @Override 3541 public boolean isVendor() { 3542 return getBoolean(Booleans.VENDOR); 3543 } 3544 3545 @Override 3546 public boolean isProduct() { 3547 return getBoolean(Booleans.PRODUCT); 3548 } 3549 3550 @Override 3551 public boolean isOdm() { 3552 return getBoolean(Booleans.ODM); 3553 } 3554 3555 @Override 3556 public boolean isSignedWithPlatformKey() { 3557 return getBoolean(Booleans.SIGNED_WITH_PLATFORM_KEY); 3558 } 3559 3560 /** 3561 * This is an appId, the uid if the userId is == USER_SYSTEM 3562 */ 3563 @Override 3564 public int getUid() { 3565 return uid; 3566 } 3567 3568 @Override 3569 public PackageImpl setStub(boolean value) { 3570 setBoolean2(Booleans2.STUB, value); 3571 return this; 3572 } 3573 3574 @Override 3575 public PackageImpl setNativeLibraryRootRequiresIsa(boolean value) { 3576 nativeLibraryRootRequiresIsa = value; 3577 return this; 3578 } 3579 3580 @Override 3581 public PackageImpl setSystem(boolean value) { 3582 setBoolean(Booleans.SYSTEM, value); 3583 return this; 3584 } 3585 3586 @Override 3587 public PackageImpl setUpdatableSystem(boolean value) { 3588 return setBoolean2(Booleans2.UPDATABLE_SYSTEM, value); 3589 } 3590 3591 @Override 3592 public PackageImpl setFactoryTest(boolean value) { 3593 setBoolean(Booleans.FACTORY_TEST, value); 3594 return this; 3595 } 3596 3597 @Override 3598 public PackageImpl setApex(boolean isApex) { 3599 setBoolean2(Booleans2.APEX, isApex); 3600 return this; 3601 } 3602 3603 @Override 3604 public PackageImpl setSystemExt(boolean value) { 3605 setBoolean(Booleans.SYSTEM_EXT, value); 3606 return this; 3607 } 3608 3609 @Override 3610 public PackageImpl setPrivileged(boolean value) { 3611 setBoolean(Booleans.PRIVILEGED, value); 3612 return this; 3613 } 3614 3615 @Override 3616 public PackageImpl setOem(boolean value) { 3617 setBoolean(Booleans.OEM, value); 3618 return this; 3619 } 3620 3621 @Override 3622 public PackageImpl setVendor(boolean value) { 3623 setBoolean(Booleans.VENDOR, value); 3624 return this; 3625 } 3626 3627 @Override 3628 public PackageImpl setProduct(boolean value) { 3629 setBoolean(Booleans.PRODUCT, value); 3630 return this; 3631 } 3632 3633 @Override 3634 public PackageImpl setOdm(boolean value) { 3635 setBoolean(Booleans.ODM, value); 3636 return this; 3637 } 3638 3639 @Override 3640 public PackageImpl setSignedWithPlatformKey(boolean value) { 3641 setBoolean(Booleans.SIGNED_WITH_PLATFORM_KEY, value); 3642 return this; 3643 } 3644 3645 @Override 3646 public PackageImpl setUid(int value) { 3647 uid = value; 3648 return this; 3649 } 3650 3651 // The following methods are explicitly not inside any interface. These are hidden under 3652 // PackageImpl which is only accessible to the system server. This is to prevent/discourage 3653 // usage of these fields outside of the utility classes. 3654 public String getBaseAppDataCredentialProtectedDirForSystemUser() { 3655 return mBaseAppDataCredentialProtectedDirForSystemUser; 3656 } 3657 3658 public String getBaseAppDataDeviceProtectedDirForSystemUser() { 3659 return mBaseAppDataDeviceProtectedDirForSystemUser; 3660 } 3661 3662 /** 3663 * Flags used for a internal bitset. These flags should never be persisted or exposed outside 3664 * of this class. It is expected that PackageCacher explicitly clears itself whenever the 3665 * Parcelable implementation changes such that all these flags can be re-ordered or invalidated. 3666 */ 3667 private static class Booleans { 3668 @LongDef({ 3669 EXTERNAL_STORAGE, 3670 HARDWARE_ACCELERATED, 3671 ALLOW_BACKUP, 3672 KILL_AFTER_RESTORE, 3673 RESTORE_ANY_VERSION, 3674 FULL_BACKUP_ONLY, 3675 PERSISTENT, 3676 DEBUGGABLE, 3677 VM_SAFE_MODE, 3678 HAS_CODE, 3679 ALLOW_TASK_REPARENTING, 3680 ALLOW_CLEAR_USER_DATA, 3681 LARGE_HEAP, 3682 USES_CLEARTEXT_TRAFFIC, 3683 SUPPORTS_RTL, 3684 TEST_ONLY, 3685 MULTI_ARCH, 3686 EXTRACT_NATIVE_LIBS, 3687 GAME, 3688 STATIC_SHARED_LIBRARY, 3689 OVERLAY, 3690 ISOLATED_SPLIT_LOADING, 3691 HAS_DOMAIN_URLS, 3692 PROFILEABLE_BY_SHELL, 3693 BACKUP_IN_FOREGROUND, 3694 USE_EMBEDDED_DEX, 3695 DEFAULT_TO_DEVICE_PROTECTED_STORAGE, 3696 DIRECT_BOOT_AWARE, 3697 PARTIALLY_DIRECT_BOOT_AWARE, 3698 RESIZEABLE_ACTIVITY_VIA_SDK_VERSION, 3699 ALLOW_CLEAR_USER_DATA_ON_FAILED_RESTORE, 3700 ALLOW_AUDIO_PLAYBACK_CAPTURE, 3701 REQUEST_LEGACY_EXTERNAL_STORAGE, 3702 USES_NON_SDK_API, 3703 HAS_FRAGILE_USER_DATA, 3704 CANT_SAVE_STATE, 3705 ALLOW_NATIVE_HEAP_POINTER_TAGGING, 3706 PRESERVE_LEGACY_EXTERNAL_STORAGE, 3707 REQUIRED_FOR_ALL_USERS, 3708 OVERLAY_IS_STATIC, 3709 USE_32_BIT_ABI, 3710 VISIBLE_TO_INSTANT_APPS, 3711 FORCE_QUERYABLE, 3712 CROSS_PROFILE, 3713 ENABLED, 3714 DISALLOW_PROFILING, 3715 REQUEST_FOREGROUND_SERVICE_EXEMPTION, 3716 ATTRIBUTIONS_ARE_USER_VISIBLE, 3717 RESET_ENABLED_SETTINGS_ON_APP_DATA_CLEARED, 3718 SDK_LIBRARY, 3719 CORE_APP, 3720 SYSTEM, 3721 FACTORY_TEST, 3722 SYSTEM_EXT, 3723 PRIVILEGED, 3724 OEM, 3725 VENDOR, 3726 PRODUCT, 3727 ODM, 3728 SIGNED_WITH_PLATFORM_KEY, 3729 NATIVE_LIBRARY_ROOT_REQUIRES_ISA, 3730 }) 3731 public @interface Flags {} 3732 3733 private static final long EXTERNAL_STORAGE = 1L; 3734 private static final long HARDWARE_ACCELERATED = 1L << 1; 3735 private static final long ALLOW_BACKUP = 1L << 2; 3736 private static final long KILL_AFTER_RESTORE = 1L << 3; 3737 private static final long RESTORE_ANY_VERSION = 1L << 4; 3738 private static final long FULL_BACKUP_ONLY = 1L << 5; 3739 private static final long PERSISTENT = 1L << 6; 3740 private static final long DEBUGGABLE = 1L << 7; 3741 private static final long VM_SAFE_MODE = 1L << 8; 3742 private static final long HAS_CODE = 1L << 9; 3743 private static final long ALLOW_TASK_REPARENTING = 1L << 10; 3744 private static final long ALLOW_CLEAR_USER_DATA = 1L << 11; 3745 private static final long LARGE_HEAP = 1L << 12; 3746 private static final long USES_CLEARTEXT_TRAFFIC = 1L << 13; 3747 private static final long SUPPORTS_RTL = 1L << 14; 3748 private static final long TEST_ONLY = 1L << 15; 3749 private static final long MULTI_ARCH = 1L << 16; 3750 private static final long EXTRACT_NATIVE_LIBS = 1L << 17; 3751 private static final long GAME = 1L << 18; 3752 private static final long STATIC_SHARED_LIBRARY = 1L << 19; 3753 private static final long OVERLAY = 1L << 20; 3754 private static final long ISOLATED_SPLIT_LOADING = 1L << 21; 3755 private static final long HAS_DOMAIN_URLS = 1L << 22; 3756 private static final long PROFILEABLE_BY_SHELL = 1L << 23; 3757 private static final long BACKUP_IN_FOREGROUND = 1L << 24; 3758 private static final long USE_EMBEDDED_DEX = 1L << 25; 3759 private static final long DEFAULT_TO_DEVICE_PROTECTED_STORAGE = 1L << 26; 3760 private static final long DIRECT_BOOT_AWARE = 1L << 27; 3761 private static final long PARTIALLY_DIRECT_BOOT_AWARE = 1L << 28; 3762 private static final long RESIZEABLE_ACTIVITY_VIA_SDK_VERSION = 1L << 29; 3763 private static final long ALLOW_CLEAR_USER_DATA_ON_FAILED_RESTORE = 1L << 30; 3764 private static final long ALLOW_AUDIO_PLAYBACK_CAPTURE = 1L << 31; 3765 private static final long REQUEST_LEGACY_EXTERNAL_STORAGE = 1L << 32; 3766 private static final long USES_NON_SDK_API = 1L << 33; 3767 private static final long HAS_FRAGILE_USER_DATA = 1L << 34; 3768 private static final long CANT_SAVE_STATE = 1L << 35; 3769 private static final long ALLOW_NATIVE_HEAP_POINTER_TAGGING = 1L << 36; 3770 private static final long PRESERVE_LEGACY_EXTERNAL_STORAGE = 1L << 37; 3771 private static final long REQUIRED_FOR_ALL_USERS = 1L << 38; 3772 private static final long OVERLAY_IS_STATIC = 1L << 39; 3773 private static final long USE_32_BIT_ABI = 1L << 40; 3774 private static final long VISIBLE_TO_INSTANT_APPS = 1L << 41; 3775 private static final long FORCE_QUERYABLE = 1L << 42; 3776 private static final long CROSS_PROFILE = 1L << 43; 3777 private static final long ENABLED = 1L << 44; 3778 private static final long DISALLOW_PROFILING = 1L << 45; 3779 private static final long REQUEST_FOREGROUND_SERVICE_EXEMPTION = 1L << 46; 3780 private static final long ATTRIBUTIONS_ARE_USER_VISIBLE = 1L << 47; 3781 private static final long RESET_ENABLED_SETTINGS_ON_APP_DATA_CLEARED = 1L << 48; 3782 private static final long SDK_LIBRARY = 1L << 49; 3783 private static final long ENABLE_ON_BACK_INVOKED_CALLBACK = 1L << 50; 3784 private static final long LEAVING_SHARED_UID = 1L << 51; 3785 private static final long CORE_APP = 1L << 52; 3786 private static final long SYSTEM = 1L << 53; 3787 private static final long FACTORY_TEST = 1L << 54; 3788 private static final long SYSTEM_EXT = 1L << 56; 3789 private static final long PRIVILEGED = 1L << 57; 3790 private static final long OEM = 1L << 58; 3791 private static final long VENDOR = 1L << 59; 3792 private static final long PRODUCT = 1L << 60; 3793 private static final long ODM = 1L << 61; 3794 private static final long SIGNED_WITH_PLATFORM_KEY = 1L << 62; 3795 private static final long NATIVE_LIBRARY_ROOT_REQUIRES_ISA = 1L << 63; 3796 } 3797 3798 private static class Booleans2 { 3799 @LongDef({ 3800 STUB, 3801 APEX, 3802 UPDATABLE_SYSTEM, 3803 }) 3804 public @interface Flags {} 3805 3806 private static final long STUB = 1L; 3807 private static final long APEX = 1L << 1; 3808 private static final long UPDATABLE_SYSTEM = 1L << 2; 3809 } 3810 } 3811