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

Commit f267602e authored by Jeremy Meyer's avatar Jeremy Meyer
Browse files

Don't double check for flags in the manifest

With the recent support for r/w flags in xml files we started checking
for flags in the manfiest twice since we already had code specifically
handling flags in the manifest. This disables the new code when it is
the manifest.

Test: Automation
Flag: EXEMPT bugfix
Bug: 396992602
Change-Id: I55c1358ab38c8f35dd7ede77488feff5ad080d76
parent a2ec91ad
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);