Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 20ee3dc9 authored by Martijn Coenen's avatar Martijn Coenen Committed by Android (Google) Code Review
Browse files

Merge "Add PARSE_IS_SYSTEM_DIR when parsing /system APEXes."

parents 40feb860 f4b9070e
Loading
Loading
Loading
Loading
+16 −2
Original line number Original line Diff line number Diff line
@@ -8444,6 +8444,21 @@ public class PackageParser {
    public static PackageInfo generatePackageInfoFromApex(File apexFile, boolean collectCerts)
    public static PackageInfo generatePackageInfoFromApex(File apexFile, boolean collectCerts)
            throws PackageParserException {
            throws PackageParserException {
        PackageInfo pi = new PackageInfo();
        PackageInfo pi = new PackageInfo();
        int parseFlags = 0;
        if (collectCerts) {
            parseFlags |= PARSE_COLLECT_CERTIFICATES;
            try {
                if (apexFile.getCanonicalPath().startsWith("/system")) {
                    // Don't need verify the APK integrity of APEXes on /system, just like
                    // we don't do that for APKs.
                    // TODO(b/126514108): we may be able to do this for APEXes on /data as well.
                    parseFlags |= PARSE_IS_SYSTEM_DIR;
                }
            } catch (IOException e) {
                throw new PackageParserException(INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION,
                        "Failed to get path for " + apexFile.getPath(), e);
            }
        }


        // TODO(b/123086053) properly fill in the ApplicationInfo with data from AndroidManifest
        // TODO(b/123086053) properly fill in the ApplicationInfo with data from AndroidManifest
        // Add ApplicationInfo to the PackageInfo.
        // Add ApplicationInfo to the PackageInfo.
@@ -8458,8 +8473,7 @@ public class PackageParser {


        // TODO(b/123052859): We should avoid these repeated calls to parseApkLite each time
        // TODO(b/123052859): We should avoid these repeated calls to parseApkLite each time
        // we want to generate information for APEX modules.
        // we want to generate information for APEX modules.
        PackageParser.ApkLite apk = PackageParser.parseApkLite(apexFile,
        PackageParser.ApkLite apk = PackageParser.parseApkLite(apexFile, parseFlags);
            collectCerts ? PackageParser.PARSE_COLLECT_CERTIFICATES : 0);


        pi.packageName = apk.packageName;
        pi.packageName = apk.packageName;
        ai.packageName = apk.packageName;
        ai.packageName = apk.packageName;