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

Commit 6883dcb3 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "filter flagged xml elements (retry)" into main

parents cd5e9c37 97b44684
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ import android.ravenwood.annotation.RavenwoodKeepWholeClass;
import android.util.TypedValue;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.pm.pkg.component.AconfigFlags;
import com.android.internal.pm.pkg.parsing.ParsingPackageUtils;
import com.android.internal.util.XmlUtils;

import dalvik.annotation.optimization.CriticalNative;
@@ -50,6 +52,7 @@ import java.io.Reader;
@RavenwoodClassLoadHook(RavenwoodClassLoadHook.LIBANDROID_LOADING_HOOK)
public final class XmlBlock implements AutoCloseable {
    private static final boolean DEBUG=false;
    public static final String ANDROID_RESOURCES = "http://schemas.android.com/apk/res/android";

    @UnsupportedAppUsage
    public XmlBlock(byte[] data) {
@@ -343,6 +346,23 @@ public final class XmlBlock implements AutoCloseable {
            if (ev == ERROR_BAD_DOCUMENT) {
                throw new XmlPullParserException("Corrupt XML binary file");
            }
            if (useLayoutReadwrite() && ev == START_TAG) {
                AconfigFlags flags = ParsingPackageUtils.getAconfigFlags();
                if (flags.skipCurrentElement(/* pkg= */ null, this)) {
                    int depth = 1;
                    while (depth > 0) {
                        int ev2 = nativeNext(mParseState);
                        if (ev2 == ERROR_BAD_DOCUMENT) {
                            throw new XmlPullParserException("Corrupt XML binary file");
                        } else if (ev2 == START_TAG) {
                            depth++;
                        } else if (ev2 == END_TAG) {
                            depth--;
                        }
                    }
                    return next();
                }
            }
            if (mDecNextDepth) {
                mDepth--;
                mDecNextDepth = false;
@@ -368,6 +388,18 @@ public final class XmlBlock implements AutoCloseable {
            }
            return ev;
        }

        // Until ravenwood supports AconfigFlags, we just don't do layoutReadwriteFlags().
        @android.ravenwood.annotation.RavenwoodReplace(
                bug = 396458006, blockedBy = AconfigFlags.class)
        private static boolean useLayoutReadwrite() {
            return Flags.layoutReadwriteFlags();
        }

        private static boolean useLayoutReadwrite$ravenwood() {
            return false;
        }

        public void require(int type, String namespace, String name) throws XmlPullParserException,IOException {
            if (type != getEventType()
                || (namespace != null && !namespace.equals( getNamespace () ) )