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

Commit 316fe079 authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Enable "layout rw flags" feature backed by AconfigPackage" into main

parents 60e7442f 33cec824
Loading
Loading
Loading
Loading
+1 −12
Original line number Diff line number Diff line
@@ -349,7 +349,7 @@ public final class XmlBlock implements AutoCloseable {
                throw new XmlPullParserException("Corrupt XML binary file");
            }

            if (useLayoutReadwrite() && mUsesFeatureFlags && ev == START_TAG) {
            if (Flags.layoutReadwriteFlags() && mUsesFeatureFlags && ev == START_TAG) {
                FlagInfo flag = nativeGetFlagInfo(mParseState);
                if (flag != null && flag.mNameIndex > 0) {
                    AconfigFlags flags = ParsingPackageUtils.getAconfigFlags();
@@ -396,17 +396,6 @@ 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 () ) )
+1 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import java.util.concurrent.ConcurrentHashMap;
 * own copy of the code here.
 * @hide
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class AconfigFlags {
    private static final boolean DEBUG = false;
    private static final String LOG_TAG = "AconfigFlags";
+3 −0
Original line number Diff line number Diff line
@@ -151,6 +151,8 @@ import java.util.StringTokenizer;
 *
 * @hide
 */
@android.ravenwood.annotation.RavenwoodKeepPartialClass
@android.ravenwood.annotation.RavenwoodKeepStaticInitializer
public class ParsingPackageUtils {

    private static final String TAG = ParsingUtils.TAG;
@@ -3624,6 +3626,7 @@ public class ParsingPackageUtils {
    /**
     * Getter for the flags object
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static AconfigFlags getAconfigFlags() {
        return sAconfigFlags;
    }
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ android_ravenwood_test {
        "androidx.annotation_annotation",
        "androidx.test.ext.junit",
        "androidx.test.rules",
        "android.content.res.flags-aconfig-java",
        "configinfra_framework_flags_java_lib",
    ],
    srcs: [
        "test/**/*.java",
+8 −3
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertThrows;

import android.content.Context;
import android.content.res.XmlResourceParser;
import android.platform.test.annotations.DisabledOnRavenwood;
import android.util.Log;

import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -49,6 +48,14 @@ public class RavenwoodResApkTest {
    private static final Context sContext =
            InstrumentationRegistry.getInstrumentation().getContext();

    // Make sure all the relevant flags are enabled.
    @Test
    public void testCheckAconfigFlags() {
        assertTrue("layoutReadwriteFlags", android.content.res.Flags.layoutReadwriteFlags());
        assertTrue("useNewAconfigStorage", android.content.res.Flags.useNewAconfigStorage());
        assertTrue("newStoragePublicApi", android.provider.flags.Flags.newStoragePublicApi());
    }

    /**
     * Ensure the file "ravenwood-res.apk" exists.
     */
@@ -130,8 +137,6 @@ public class RavenwoodResApkTest {
    }

    @Test
    @DisabledOnRavenwood(bug = 396458006,
            reason = "RW flags in XML are all handled as enabled for now")
    public void testElementWithRwFlagDisabled() throws Exception {
        assertThat(getTextsFromEnabledChildren()).doesNotContain("rw-disabled");
    }
Loading