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

Commit 444c3c35 authored by Jeremy Meyer's avatar Jeremy Meyer Committed by Android (Google) Code Review
Browse files

Merge "Don't double check for flags in the manifest" into main

parents 445b8efb f267602e
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -1190,7 +1190,20 @@ public final class AssetManager implements AutoCloseable {
     */
    public @NonNull XmlResourceParser openXmlResourceParser(int cookie, @NonNull String fileName)
            throws IOException {
        try (XmlBlock block = openXmlBlockAsset(cookie, fileName, true)) {
        return openXmlResourceParser(cookie, fileName, true);
    }

    /**
     * Retrieve a parser for a compiled XML file.
     *
     * @param cookie Identifier of the package to be opened.
     * @param fileName The name of the file to retrieve.
     * @param hasFlags Whether the parser should check for flags on each element
     * @hide
     */
    public @NonNull XmlResourceParser openXmlResourceParser(int cookie, @NonNull String fileName,
            boolean hasFlags) throws IOException {
        try (XmlBlock block = openXmlBlockAsset(cookie, fileName, hasFlags)) {
            XmlResourceParser parser = block.newParser(ID_NULL, new Validator());
            // If openXmlBlockAsset doesn't throw, it will always return an XmlBlock object with
            // a valid native pointer, which makes newParser always return non-null. But let's
+5 −1
Original line number Diff line number Diff line
@@ -672,8 +672,12 @@ public class ParsingPackageUtils {
            return input.error(INSTALL_PARSE_FAILED_BAD_MANIFEST,
                    "Failed adding asset path: " + apkPath);
        }
        // We pass false for hasFlags because manifest flags are handled separately in the parsing
        // code. If the xml parser also checks and removes flags, not only will it be slower but
        // also PackageManager will not work properly because it won't collect the referenced flags
        // and won't be able to invalidate the package cache when one of those flags changes.
        try (XmlResourceParser parser = assets.openXmlResourceParser(cookie,
                ANDROID_MANIFEST_FILENAME)) {
                ANDROID_MANIFEST_FILENAME, false)) {
            Resources res = new Resources(assets, mDisplayMetrics, null);
            ParseResult<ParsingPackage> parseResult = parseSplitApk(input, pkg, res,
                    parser, flags, splitIndex);