Loading core/java/android/util/apk/ApkSignatureVerifier.java +4 −3 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.pm.PackageParser; import android.content.pm.PackageParser.PackageParserException; import android.content.pm.PackageParser.SigningDetails.SignatureSchemeVersion; import android.content.pm.Signature; import android.content.pm.parsing.ParsingPackageUtils; import android.os.Build; import android.os.Trace; import android.util.jar.StrictJarFile; Loading Loading @@ -361,7 +362,7 @@ public class ApkSignatureVerifier { // Gather certs from AndroidManifest.xml, which every APK must have, as an optimization // to not need to verify the whole APK when verifyFUll == false. final ZipEntry manifestEntry = jarFile.findEntry( PackageParser.ANDROID_MANIFEST_FILENAME); ParsingPackageUtils.ANDROID_MANIFEST_FILENAME); if (manifestEntry == null) { throw new PackageParserException(INSTALL_PARSE_FAILED_BAD_MANIFEST, "Package " + apkPath + " has no manifest"); Loading @@ -370,7 +371,7 @@ public class ApkSignatureVerifier { if (ArrayUtils.isEmpty(lastCerts)) { throw new PackageParserException(INSTALL_PARSE_FAILED_NO_CERTIFICATES, "Package " + apkPath + " has no certificates at entry " + PackageParser.ANDROID_MANIFEST_FILENAME); + ParsingPackageUtils.ANDROID_MANIFEST_FILENAME); } lastSigs = convertToSignatures(lastCerts); Loading @@ -383,7 +384,7 @@ public class ApkSignatureVerifier { final String entryName = entry.getName(); if (entryName.startsWith("META-INF/")) continue; if (entryName.equals(PackageParser.ANDROID_MANIFEST_FILENAME)) continue; if (entryName.equals(ParsingPackageUtils.ANDROID_MANIFEST_FILENAME)) continue; toVerify.add(entry); } Loading core/java/com/android/internal/content/NativeLibraryHelper.java +16 −13 Original line number Diff line number Diff line Loading @@ -27,9 +27,10 @@ import static android.system.OsConstants.S_IXOTH; import android.content.Context; import android.content.pm.PackageManager; import android.content.pm.PackageParser; import android.content.pm.PackageParser.PackageLite; import android.content.pm.PackageParser.PackageParserException; import android.content.pm.parsing.ApkLiteParseUtils; import android.content.pm.parsing.PackageLite; import android.content.pm.parsing.result.ParseResult; import android.content.pm.parsing.result.ParseTypeImpl; import android.os.Build; import android.os.IBinder; import android.os.SELinux; Loading Loading @@ -86,17 +87,19 @@ public class NativeLibraryHelper { final boolean debuggable; public static Handle create(File packageFile) throws IOException { try { final PackageLite lite = PackageParser.parsePackageLite(packageFile, 0); return create(lite); } catch (PackageParserException e) { throw new IOException("Failed to parse package: " + packageFile, e); final ParseTypeImpl input = ParseTypeImpl.forDefaultParsing(); final ParseResult<PackageLite> ret = ApkLiteParseUtils.parsePackageLite(input.reset(), packageFile, /* flags */ 0); if (ret.isError()) { throw new IOException("Failed to parse package: " + packageFile, ret.getException()); } return create(ret.getResult()); } public static Handle create(PackageLite lite) throws IOException { return create(lite.getAllCodePaths(), lite.multiArch, lite.extractNativeLibs, lite.debuggable); return create(lite.getAllApkPaths(), lite.isMultiArch(), lite.isExtractNativeLibs(), lite.isDebuggable()); } public static Handle create(List<String> codePaths, boolean multiArch, Loading @@ -122,14 +125,14 @@ public class NativeLibraryHelper { public static Handle createFd(PackageLite lite, FileDescriptor fd) throws IOException { final long[] apkHandles = new long[1]; final String path = lite.baseCodePath; final String path = lite.getBaseApkPath(); apkHandles[0] = nativeOpenApkFd(fd, path); if (apkHandles[0] == 0) { throw new IOException("Unable to open APK " + path + " from fd " + fd); } return new Handle(new String[]{path}, apkHandles, lite.multiArch, lite.extractNativeLibs, lite.debuggable); return new Handle(new String[]{path}, apkHandles, lite.isMultiArch(), lite.isExtractNativeLibs(), lite.isDebuggable()); } Handle(String[] apkPaths, long[] apkHandles, boolean multiArch, Loading core/java/com/android/internal/content/PackageHelper.java +4 −4 Original line number Diff line number Diff line Loading @@ -24,8 +24,8 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageInstaller.SessionParams; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageParser.PackageLite; import android.content.pm.dex.DexMetadataHelper; import android.content.pm.parsing.PackageLite; import android.os.Environment; import android.os.IBinder; import android.os.RemoteException; Loading Loading @@ -84,8 +84,8 @@ public class PackageHelper { /** * A group of external dependencies used in * {@link #resolveInstallVolume(Context, String, int, long)}. It can be backed by real values * from the system or mocked ones for testing purposes. * {@link #resolveInstallVolume(Context, String, int, long, TestableInterface)}. * It can be backed by real values from the system or mocked ones for testing purposes. */ public static abstract class TestableInterface { abstract public StorageManager getStorageManager(Context context); Loading Loading @@ -447,7 +447,7 @@ public class PackageHelper { long sizeBytes = 0; // Include raw APKs, and possibly unpacked resources for (String codePath : pkg.getAllCodePaths()) { for (String codePath : pkg.getAllApkPaths()) { final File codeFile = new File(codePath); sizeBytes += codeFile.length(); } Loading core/java/com/android/internal/content/om/OverlayScanner.java +14 −9 Original line number Diff line number Diff line Loading @@ -20,7 +20,10 @@ import static com.android.internal.content.om.OverlayConfig.TAG; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.pm.PackageParser; import android.content.pm.parsing.ApkLite; import android.content.pm.parsing.ApkLiteParseUtils; import android.content.pm.parsing.result.ParseResult; import android.content.pm.parsing.result.ParseTypeImpl; import android.util.ArrayMap; import android.util.Log; Loading Loading @@ -124,15 +127,17 @@ public class OverlayScanner { /** Extracts information about the overlay from its manifest. */ @VisibleForTesting public ParsedOverlayInfo parseOverlayManifest(File overlayApk) { try { final PackageParser.ApkLite apkLite = PackageParser.parseApkLite(overlayApk, 0); return apkLite.targetPackageName == null ? null : new ParsedOverlayInfo(apkLite.packageName, apkLite.targetPackageName, apkLite.targetSdkVersion, apkLite.overlayIsStatic, apkLite.overlayPriority, new File(apkLite.codePath)); } catch (PackageParser.PackageParserException e) { Log.w(TAG, "Got exception loading overlay.", e); final ParseTypeImpl input = ParseTypeImpl.forParsingWithoutPlatformCompat(); final ParseResult<ApkLite> ret = ApkLiteParseUtils.parseApkLite(input.reset(), overlayApk, /* flags */ 0); if (ret.isError()) { Log.w(TAG, "Got exception loading overlay.", ret.getException()); return null; } final ApkLite apkLite = ret.getResult(); return apkLite.getTargetPackageName() == null ? null : new ParsedOverlayInfo(apkLite.getPackageName(), apkLite.getTargetPackageName(), apkLite.getTargetSdkVersion(), apkLite.isOverlayIsStatic(), apkLite.getOverlayPriority(), new File(apkLite.getPath())); } } Loading
core/java/android/util/apk/ApkSignatureVerifier.java +4 −3 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.pm.PackageParser; import android.content.pm.PackageParser.PackageParserException; import android.content.pm.PackageParser.SigningDetails.SignatureSchemeVersion; import android.content.pm.Signature; import android.content.pm.parsing.ParsingPackageUtils; import android.os.Build; import android.os.Trace; import android.util.jar.StrictJarFile; Loading Loading @@ -361,7 +362,7 @@ public class ApkSignatureVerifier { // Gather certs from AndroidManifest.xml, which every APK must have, as an optimization // to not need to verify the whole APK when verifyFUll == false. final ZipEntry manifestEntry = jarFile.findEntry( PackageParser.ANDROID_MANIFEST_FILENAME); ParsingPackageUtils.ANDROID_MANIFEST_FILENAME); if (manifestEntry == null) { throw new PackageParserException(INSTALL_PARSE_FAILED_BAD_MANIFEST, "Package " + apkPath + " has no manifest"); Loading @@ -370,7 +371,7 @@ public class ApkSignatureVerifier { if (ArrayUtils.isEmpty(lastCerts)) { throw new PackageParserException(INSTALL_PARSE_FAILED_NO_CERTIFICATES, "Package " + apkPath + " has no certificates at entry " + PackageParser.ANDROID_MANIFEST_FILENAME); + ParsingPackageUtils.ANDROID_MANIFEST_FILENAME); } lastSigs = convertToSignatures(lastCerts); Loading @@ -383,7 +384,7 @@ public class ApkSignatureVerifier { final String entryName = entry.getName(); if (entryName.startsWith("META-INF/")) continue; if (entryName.equals(PackageParser.ANDROID_MANIFEST_FILENAME)) continue; if (entryName.equals(ParsingPackageUtils.ANDROID_MANIFEST_FILENAME)) continue; toVerify.add(entry); } Loading
core/java/com/android/internal/content/NativeLibraryHelper.java +16 −13 Original line number Diff line number Diff line Loading @@ -27,9 +27,10 @@ import static android.system.OsConstants.S_IXOTH; import android.content.Context; import android.content.pm.PackageManager; import android.content.pm.PackageParser; import android.content.pm.PackageParser.PackageLite; import android.content.pm.PackageParser.PackageParserException; import android.content.pm.parsing.ApkLiteParseUtils; import android.content.pm.parsing.PackageLite; import android.content.pm.parsing.result.ParseResult; import android.content.pm.parsing.result.ParseTypeImpl; import android.os.Build; import android.os.IBinder; import android.os.SELinux; Loading Loading @@ -86,17 +87,19 @@ public class NativeLibraryHelper { final boolean debuggable; public static Handle create(File packageFile) throws IOException { try { final PackageLite lite = PackageParser.parsePackageLite(packageFile, 0); return create(lite); } catch (PackageParserException e) { throw new IOException("Failed to parse package: " + packageFile, e); final ParseTypeImpl input = ParseTypeImpl.forDefaultParsing(); final ParseResult<PackageLite> ret = ApkLiteParseUtils.parsePackageLite(input.reset(), packageFile, /* flags */ 0); if (ret.isError()) { throw new IOException("Failed to parse package: " + packageFile, ret.getException()); } return create(ret.getResult()); } public static Handle create(PackageLite lite) throws IOException { return create(lite.getAllCodePaths(), lite.multiArch, lite.extractNativeLibs, lite.debuggable); return create(lite.getAllApkPaths(), lite.isMultiArch(), lite.isExtractNativeLibs(), lite.isDebuggable()); } public static Handle create(List<String> codePaths, boolean multiArch, Loading @@ -122,14 +125,14 @@ public class NativeLibraryHelper { public static Handle createFd(PackageLite lite, FileDescriptor fd) throws IOException { final long[] apkHandles = new long[1]; final String path = lite.baseCodePath; final String path = lite.getBaseApkPath(); apkHandles[0] = nativeOpenApkFd(fd, path); if (apkHandles[0] == 0) { throw new IOException("Unable to open APK " + path + " from fd " + fd); } return new Handle(new String[]{path}, apkHandles, lite.multiArch, lite.extractNativeLibs, lite.debuggable); return new Handle(new String[]{path}, apkHandles, lite.isMultiArch(), lite.isExtractNativeLibs(), lite.isDebuggable()); } Handle(String[] apkPaths, long[] apkHandles, boolean multiArch, Loading
core/java/com/android/internal/content/PackageHelper.java +4 −4 Original line number Diff line number Diff line Loading @@ -24,8 +24,8 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageInstaller.SessionParams; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageParser.PackageLite; import android.content.pm.dex.DexMetadataHelper; import android.content.pm.parsing.PackageLite; import android.os.Environment; import android.os.IBinder; import android.os.RemoteException; Loading Loading @@ -84,8 +84,8 @@ public class PackageHelper { /** * A group of external dependencies used in * {@link #resolveInstallVolume(Context, String, int, long)}. It can be backed by real values * from the system or mocked ones for testing purposes. * {@link #resolveInstallVolume(Context, String, int, long, TestableInterface)}. * It can be backed by real values from the system or mocked ones for testing purposes. */ public static abstract class TestableInterface { abstract public StorageManager getStorageManager(Context context); Loading Loading @@ -447,7 +447,7 @@ public class PackageHelper { long sizeBytes = 0; // Include raw APKs, and possibly unpacked resources for (String codePath : pkg.getAllCodePaths()) { for (String codePath : pkg.getAllApkPaths()) { final File codeFile = new File(codePath); sizeBytes += codeFile.length(); } Loading
core/java/com/android/internal/content/om/OverlayScanner.java +14 −9 Original line number Diff line number Diff line Loading @@ -20,7 +20,10 @@ import static com.android.internal.content.om.OverlayConfig.TAG; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.pm.PackageParser; import android.content.pm.parsing.ApkLite; import android.content.pm.parsing.ApkLiteParseUtils; import android.content.pm.parsing.result.ParseResult; import android.content.pm.parsing.result.ParseTypeImpl; import android.util.ArrayMap; import android.util.Log; Loading Loading @@ -124,15 +127,17 @@ public class OverlayScanner { /** Extracts information about the overlay from its manifest. */ @VisibleForTesting public ParsedOverlayInfo parseOverlayManifest(File overlayApk) { try { final PackageParser.ApkLite apkLite = PackageParser.parseApkLite(overlayApk, 0); return apkLite.targetPackageName == null ? null : new ParsedOverlayInfo(apkLite.packageName, apkLite.targetPackageName, apkLite.targetSdkVersion, apkLite.overlayIsStatic, apkLite.overlayPriority, new File(apkLite.codePath)); } catch (PackageParser.PackageParserException e) { Log.w(TAG, "Got exception loading overlay.", e); final ParseTypeImpl input = ParseTypeImpl.forParsingWithoutPlatformCompat(); final ParseResult<ApkLite> ret = ApkLiteParseUtils.parseApkLite(input.reset(), overlayApk, /* flags */ 0); if (ret.isError()) { Log.w(TAG, "Got exception loading overlay.", ret.getException()); return null; } final ApkLite apkLite = ret.getResult(); return apkLite.getTargetPackageName() == null ? null : new ParsedOverlayInfo(apkLite.getPackageName(), apkLite.getTargetPackageName(), apkLite.getTargetSdkVersion(), apkLite.isOverlayIsStatic(), apkLite.getOverlayPriority(), new File(apkLite.getPath())); } }