1 /* 2 * Copyright (C) 2021 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 android.content.pm.parsing; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.content.pm.PackageInfo; 22 import android.content.pm.PackageParser.SigningDetails; 23 import android.content.pm.VerifierInfo; 24 25 import com.android.internal.util.DataClass; 26 27 import java.util.List; 28 29 /** 30 * Lightweight parsed details about a single APK file. 31 * 32 * @hide 33 */ 34 @DataClass(genConstructor = false, genConstDefs = false) 35 public class ApkLite { 36 /** Name of the package as used to identify it in the system */ 37 private final @NonNull String mPackageName; 38 /** Path where this APK file was found on disk */ 39 private final @NonNull String mPath; 40 /** Split name of this APK */ 41 private final @Nullable String mSplitName; 42 /** Dependencies of the split APK */ 43 /** Name of the split APK that this APK depends on */ 44 private final @Nullable String mUsesSplitName; 45 /** Name of the split APK that this APK is a configuration for */ 46 private final @Nullable String mConfigForSplit; 47 48 /** Major version number of this package */ 49 private final int mVersionCodeMajor; 50 /** Minor version number of this package */ 51 private final int mVersionCode; 52 /** Revision code of this APK */ 53 private final int mRevisionCode; 54 /** 55 * Indicate the install location of this package 56 * 57 * @see {@link PackageInfo#INSTALL_LOCATION_AUTO} 58 * @see {@link PackageInfo#INSTALL_LOCATION_INTERNAL_ONLY} 59 * @see {@link PackageInfo#INSTALL_LOCATION_PREFER_EXTERNAL} 60 */ 61 private final int mInstallLocation; 62 /** Indicate the minimum SDK version number that the app requires */ 63 private final int mMinSdkVersion; 64 /** Indicate the SDK version number that the application is targeting */ 65 private final int mTargetSdkVersion; 66 /** Information about a package verifiers as used during package verification */ 67 private final @NonNull VerifierInfo[] mVerifiers; 68 /** Signing-related data of an application package */ 69 private final @NonNull SigningDetails mSigningDetails; 70 71 /** Indicate whether this APK is a 'feature' split */ 72 private final boolean mFeatureSplit; 73 /** Indicate whether each split should be load into their own Context objects */ 74 private final boolean mIsolatedSplits; 75 /** 76 * Indicate whether this package requires at least one split (either feature or resource) 77 * to be present in order to function 78 */ 79 private final boolean mSplitRequired; 80 /** Indicate whether this app is coreApp */ 81 private final boolean mCoreApp; 82 /** Indicate whether this app can be debugged */ 83 private final boolean mDebuggable; 84 /** Indicate whether this app is profileable by Shell */ 85 private final boolean mProfileableByShell; 86 /** Indicate whether this app needs to be loaded into other applications' processes */ 87 private final boolean mMultiArch; 88 /** Indicate whether the 32 bit version of the ABI should be used */ 89 private final boolean mUse32bitAbi; 90 /** Indicate whether installer extracts native libraries */ 91 private final boolean mExtractNativeLibs; 92 /** 93 * Indicate whether this package wants to run the dex within its APK but not extracted 94 * or locally compiled variants. 95 */ 96 private final boolean mUseEmbeddedDex; 97 98 /** Name of the overlay-able set of elements package */ 99 private final @Nullable String mTargetPackageName; 100 /** Indicate whether the overlay is static */ 101 private final boolean mOverlayIsStatic; 102 /** Indicate the priority of this overlay package */ 103 private final int mOverlayPriority; 104 105 /** 106 * Indicate the policy to deal with user data when rollback is committed 107 * 108 * @see {@link android.content.pm.PackageManager.RollbackDataPolicy#RESTORE} 109 * @see {@link android.content.pm.PackageManager.RollbackDataPolicy#WIPE} 110 * @see {@link android.content.pm.PackageManager.RollbackDataPolicy#RETAIN} 111 */ 112 private final int mRollbackDataPolicy; 113 ApkLite(String path, String packageName, String splitName, boolean isFeatureSplit, String configForSplit, String usesSplitName, boolean isSplitRequired, int versionCode, int versionCodeMajor, int revisionCode, int installLocation, List<VerifierInfo> verifiers, SigningDetails signingDetails, boolean coreApp, boolean debuggable, boolean profileableByShell, boolean multiArch, boolean use32bitAbi, boolean useEmbeddedDex, boolean extractNativeLibs, boolean isolatedSplits, String targetPackageName, boolean overlayIsStatic, int overlayPriority, int minSdkVersion, int targetSdkVersion, int rollbackDataPolicy)114 public ApkLite(String path, String packageName, String splitName, boolean isFeatureSplit, 115 String configForSplit, String usesSplitName, boolean isSplitRequired, int versionCode, 116 int versionCodeMajor, int revisionCode, int installLocation, 117 List<VerifierInfo> verifiers, SigningDetails signingDetails, boolean coreApp, 118 boolean debuggable, boolean profileableByShell, boolean multiArch, boolean use32bitAbi, 119 boolean useEmbeddedDex, boolean extractNativeLibs, boolean isolatedSplits, 120 String targetPackageName, boolean overlayIsStatic, int overlayPriority, 121 int minSdkVersion, int targetSdkVersion, int rollbackDataPolicy) { 122 mPath = path; 123 mPackageName = packageName; 124 mSplitName = splitName; 125 mFeatureSplit = isFeatureSplit; 126 mConfigForSplit = configForSplit; 127 mUsesSplitName = usesSplitName; 128 mSplitRequired = isSplitRequired; 129 mVersionCode = versionCode; 130 mVersionCodeMajor = versionCodeMajor; 131 mRevisionCode = revisionCode; 132 mInstallLocation = installLocation; 133 mVerifiers = verifiers.toArray(new VerifierInfo[verifiers.size()]); 134 mSigningDetails = signingDetails; 135 mCoreApp = coreApp; 136 mDebuggable = debuggable; 137 mProfileableByShell = profileableByShell; 138 mMultiArch = multiArch; 139 mUse32bitAbi = use32bitAbi; 140 mUseEmbeddedDex = useEmbeddedDex; 141 mExtractNativeLibs = extractNativeLibs; 142 mIsolatedSplits = isolatedSplits; 143 mTargetPackageName = targetPackageName; 144 mOverlayIsStatic = overlayIsStatic; 145 mOverlayPriority = overlayPriority; 146 mMinSdkVersion = minSdkVersion; 147 mTargetSdkVersion = targetSdkVersion; 148 mRollbackDataPolicy = rollbackDataPolicy; 149 } 150 151 /** 152 * Return {@link #mVersionCode} and {@link #mVersionCodeMajor} combined together as a 153 * single long value. The {@link #mVersionCodeMajor} is placed in the upper 32 bits. 154 */ getLongVersionCode()155 public long getLongVersionCode() { 156 return PackageInfo.composeLongVersionCode(mVersionCodeMajor, mVersionCode); 157 } 158 159 160 161 // Code below generated by codegen v1.0.22. 162 // 163 // DO NOT MODIFY! 164 // CHECKSTYLE:OFF Generated code 165 // 166 // To regenerate run: 167 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/parsing/ApkLite.java 168 // 169 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 170 // Settings > Editor > Code Style > Formatter Control 171 //@formatter:off 172 173 174 /** 175 * Name of the package as used to identify it in the system 176 */ 177 @DataClass.Generated.Member getPackageName()178 public @NonNull String getPackageName() { 179 return mPackageName; 180 } 181 182 /** 183 * Path where this APK file was found on disk 184 */ 185 @DataClass.Generated.Member getPath()186 public @NonNull String getPath() { 187 return mPath; 188 } 189 190 /** 191 * Split name of this APK 192 */ 193 @DataClass.Generated.Member getSplitName()194 public @Nullable String getSplitName() { 195 return mSplitName; 196 } 197 198 /** 199 * Name of the split APK that this APK depends on 200 */ 201 @DataClass.Generated.Member getUsesSplitName()202 public @Nullable String getUsesSplitName() { 203 return mUsesSplitName; 204 } 205 206 /** 207 * Name of the split APK that this APK is a configuration for 208 */ 209 @DataClass.Generated.Member getConfigForSplit()210 public @Nullable String getConfigForSplit() { 211 return mConfigForSplit; 212 } 213 214 /** 215 * Major version number of this package 216 */ 217 @DataClass.Generated.Member getVersionCodeMajor()218 public int getVersionCodeMajor() { 219 return mVersionCodeMajor; 220 } 221 222 /** 223 * Minor version number of this package 224 */ 225 @DataClass.Generated.Member getVersionCode()226 public int getVersionCode() { 227 return mVersionCode; 228 } 229 230 /** 231 * Revision code of this APK 232 */ 233 @DataClass.Generated.Member getRevisionCode()234 public int getRevisionCode() { 235 return mRevisionCode; 236 } 237 238 /** 239 * Indicate the install location of this package 240 * 241 * @see {@link PackageInfo#INSTALL_LOCATION_AUTO} 242 * @see {@link PackageInfo#INSTALL_LOCATION_INTERNAL_ONLY} 243 * @see {@link PackageInfo#INSTALL_LOCATION_PREFER_EXTERNAL} 244 */ 245 @DataClass.Generated.Member getInstallLocation()246 public int getInstallLocation() { 247 return mInstallLocation; 248 } 249 250 /** 251 * Indicate the minimum SDK version number that the app requires 252 */ 253 @DataClass.Generated.Member getMinSdkVersion()254 public int getMinSdkVersion() { 255 return mMinSdkVersion; 256 } 257 258 /** 259 * Indicate the SDK version number that the application is targeting 260 */ 261 @DataClass.Generated.Member getTargetSdkVersion()262 public int getTargetSdkVersion() { 263 return mTargetSdkVersion; 264 } 265 266 /** 267 * Information about a package verifiers as used during package verification 268 */ 269 @DataClass.Generated.Member getVerifiers()270 public @NonNull VerifierInfo[] getVerifiers() { 271 return mVerifiers; 272 } 273 274 /** 275 * Signing-related data of an application package 276 */ 277 @DataClass.Generated.Member getSigningDetails()278 public @NonNull SigningDetails getSigningDetails() { 279 return mSigningDetails; 280 } 281 282 /** 283 * Indicate whether this APK is a 'feature' split 284 */ 285 @DataClass.Generated.Member isFeatureSplit()286 public boolean isFeatureSplit() { 287 return mFeatureSplit; 288 } 289 290 /** 291 * Indicate whether each split should be load into their own Context objects 292 */ 293 @DataClass.Generated.Member isIsolatedSplits()294 public boolean isIsolatedSplits() { 295 return mIsolatedSplits; 296 } 297 298 /** 299 * Indicate whether this package requires at least one split (either feature or resource) 300 * to be present in order to function 301 */ 302 @DataClass.Generated.Member isSplitRequired()303 public boolean isSplitRequired() { 304 return mSplitRequired; 305 } 306 307 /** 308 * Indicate whether this app is coreApp 309 */ 310 @DataClass.Generated.Member isCoreApp()311 public boolean isCoreApp() { 312 return mCoreApp; 313 } 314 315 /** 316 * Indicate whether this app can be debugged 317 */ 318 @DataClass.Generated.Member isDebuggable()319 public boolean isDebuggable() { 320 return mDebuggable; 321 } 322 323 /** 324 * Indicate whether this app is profileable by Shell 325 */ 326 @DataClass.Generated.Member isProfileableByShell()327 public boolean isProfileableByShell() { 328 return mProfileableByShell; 329 } 330 331 /** 332 * Indicate whether this app needs to be loaded into other applications' processes 333 */ 334 @DataClass.Generated.Member isMultiArch()335 public boolean isMultiArch() { 336 return mMultiArch; 337 } 338 339 /** 340 * Indicate whether the 32 bit version of the ABI should be used 341 */ 342 @DataClass.Generated.Member isUse32bitAbi()343 public boolean isUse32bitAbi() { 344 return mUse32bitAbi; 345 } 346 347 /** 348 * Indicate whether installer extracts native libraries 349 */ 350 @DataClass.Generated.Member isExtractNativeLibs()351 public boolean isExtractNativeLibs() { 352 return mExtractNativeLibs; 353 } 354 355 /** 356 * Indicate whether this package wants to run the dex within its APK but not extracted 357 * or locally compiled variants. 358 */ 359 @DataClass.Generated.Member isUseEmbeddedDex()360 public boolean isUseEmbeddedDex() { 361 return mUseEmbeddedDex; 362 } 363 364 /** 365 * Name of the overlay-able set of elements package 366 */ 367 @DataClass.Generated.Member getTargetPackageName()368 public @Nullable String getTargetPackageName() { 369 return mTargetPackageName; 370 } 371 372 /** 373 * Indicate whether the overlay is static 374 */ 375 @DataClass.Generated.Member isOverlayIsStatic()376 public boolean isOverlayIsStatic() { 377 return mOverlayIsStatic; 378 } 379 380 /** 381 * Indicate the priority of this overlay package 382 */ 383 @DataClass.Generated.Member getOverlayPriority()384 public int getOverlayPriority() { 385 return mOverlayPriority; 386 } 387 388 /** 389 * Indicate the policy to deal with user data when rollback is committed 390 * 391 * @see {@link android.content.pm.PackageManager.RollbackDataPolicy#RESTORE} 392 * @see {@link android.content.pm.PackageManager.RollbackDataPolicy#WIPE} 393 * @see {@link android.content.pm.PackageManager.RollbackDataPolicy#RETAIN} 394 */ 395 @DataClass.Generated.Member getRollbackDataPolicy()396 public int getRollbackDataPolicy() { 397 return mRollbackDataPolicy; 398 } 399 400 @DataClass.Generated( 401 time = 1610596637723L, 402 codegenVersion = "1.0.22", 403 sourceFile = "frameworks/base/core/java/android/content/pm/parsing/ApkLite.java", 404 inputSignatures = "private final @android.annotation.NonNull java.lang.String mPackageName\nprivate final @android.annotation.NonNull java.lang.String mPath\nprivate final @android.annotation.Nullable java.lang.String mSplitName\nprivate final @android.annotation.Nullable java.lang.String mUsesSplitName\nprivate final @android.annotation.Nullable java.lang.String mConfigForSplit\nprivate final int mVersionCodeMajor\nprivate final int mVersionCode\nprivate final int mRevisionCode\nprivate final int mInstallLocation\nprivate final int mMinSdkVersion\nprivate final int mTargetSdkVersion\nprivate final @android.annotation.NonNull android.content.pm.VerifierInfo[] mVerifiers\nprivate final @android.annotation.NonNull android.content.pm.PackageParser.SigningDetails mSigningDetails\nprivate final boolean mFeatureSplit\nprivate final boolean mIsolatedSplits\nprivate final boolean mSplitRequired\nprivate final boolean mCoreApp\nprivate final boolean mDebuggable\nprivate final boolean mProfileableByShell\nprivate final boolean mMultiArch\nprivate final boolean mUse32bitAbi\nprivate final boolean mExtractNativeLibs\nprivate final boolean mUseEmbeddedDex\nprivate final @android.annotation.Nullable java.lang.String mTargetPackageName\nprivate final boolean mOverlayIsStatic\nprivate final int mOverlayPriority\nprivate final int mRollbackDataPolicy\npublic long getLongVersionCode()\nclass ApkLite extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genConstructor=false, genConstDefs=false)") 405 @Deprecated __metadata()406 private void __metadata() {} 407 408 409 //@formatter:on 410 // End of generated code 411 412 } 413