Loading core/tests/resourceflaggingtests/Android.bp +12 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,17 @@ genrule { "--feature-flags test.package.falseFlag:ro=false,test.package.trueFlag:ro=true", } genrule { name: "resource-flagging-test-app-resources-compile2", tools: ["aapt2"], srcs: [ "flagged_resources_res/values/bools2.xml", ], out: ["values_bools2.arsc.flat"], cmd: "$(location aapt2) compile $(in) -o $(genDir) " + "--feature-flags test.package.falseFlag:ro=false,test.package.trueFlag:ro=true", } genrule { name: "resource-flagging-test-app-apk", tools: ["aapt2"], Loading @@ -40,6 +51,7 @@ genrule { srcs: [ "TestAppAndroidManifest.xml", ":resource-flagging-test-app-resources-compile", ":resource-flagging-test-app-resources-compile2", ], out: ["resapp.apk"], cmd: "$(location aapt2) link -o $(out) --manifest $(in)", Loading core/tests/resourceflaggingtests/flagged_resources_res/values/bools.xml +2 −0 Original line number Diff line number Diff line Loading @@ -5,4 +5,6 @@ <bool name="res2">false</bool> <bool name="res2" android:featureFlag="test.package.trueFlag">true</bool> <bool name="res3">false</bool> </resources> No newline at end of file core/tests/resourceflaggingtests/flagged_resources_res/values/bools2.xml 0 → 100644 +4 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <bool name="res3" android:featureFlag="test.package.trueFlag">true</bool> </resources> No newline at end of file core/tests/resourceflaggingtests/src/com/android/resourceflaggingtests/ResourceFlaggingTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,11 @@ public class ResourceFlaggingTest { assertThat(getBoolean("res2")).isTrue(); } @Test public void testFlagEnabledDifferentCompilationUnit() { assertThat(getBoolean("res3")).isTrue(); } private boolean getBoolean(String name) { int resId = mResources.getIdentifier(name, "bool", "com.android.intenal.flaggedresources"); assertThat(resId).isNotEqualTo(0); Loading tools/aapt2/ResourceParser.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ struct ParsedResource { Visibility::Level visibility_level = Visibility::Level::kUndefined; bool staged_api = false; bool allow_new = false; FlagStatus flag_status; FlagStatus flag_status = FlagStatus::NoFlag; std::optional<OverlayableItem> overlayable_item; std::optional<StagedId> staged_alias; Loading Loading
core/tests/resourceflaggingtests/Android.bp +12 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,17 @@ genrule { "--feature-flags test.package.falseFlag:ro=false,test.package.trueFlag:ro=true", } genrule { name: "resource-flagging-test-app-resources-compile2", tools: ["aapt2"], srcs: [ "flagged_resources_res/values/bools2.xml", ], out: ["values_bools2.arsc.flat"], cmd: "$(location aapt2) compile $(in) -o $(genDir) " + "--feature-flags test.package.falseFlag:ro=false,test.package.trueFlag:ro=true", } genrule { name: "resource-flagging-test-app-apk", tools: ["aapt2"], Loading @@ -40,6 +51,7 @@ genrule { srcs: [ "TestAppAndroidManifest.xml", ":resource-flagging-test-app-resources-compile", ":resource-flagging-test-app-resources-compile2", ], out: ["resapp.apk"], cmd: "$(location aapt2) link -o $(out) --manifest $(in)", Loading
core/tests/resourceflaggingtests/flagged_resources_res/values/bools.xml +2 −0 Original line number Diff line number Diff line Loading @@ -5,4 +5,6 @@ <bool name="res2">false</bool> <bool name="res2" android:featureFlag="test.package.trueFlag">true</bool> <bool name="res3">false</bool> </resources> No newline at end of file
core/tests/resourceflaggingtests/flagged_resources_res/values/bools2.xml 0 → 100644 +4 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <bool name="res3" android:featureFlag="test.package.trueFlag">true</bool> </resources> No newline at end of file
core/tests/resourceflaggingtests/src/com/android/resourceflaggingtests/ResourceFlaggingTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,11 @@ public class ResourceFlaggingTest { assertThat(getBoolean("res2")).isTrue(); } @Test public void testFlagEnabledDifferentCompilationUnit() { assertThat(getBoolean("res3")).isTrue(); } private boolean getBoolean(String name) { int resId = mResources.getIdentifier(name, "bool", "com.android.intenal.flaggedresources"); assertThat(resId).isNotEqualTo(0); Loading
tools/aapt2/ResourceParser.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ struct ParsedResource { Visibility::Level visibility_level = Visibility::Level::kUndefined; bool staged_api = false; bool allow_new = false; FlagStatus flag_status; FlagStatus flag_status = FlagStatus::NoFlag; std::optional<OverlayableItem> overlayable_item; std::optional<StagedId> staged_alias; Loading