Adapt null resource to be treated as reference instead of empty string. (#3417)

* fix: handle null resolved items as references

* test: add color null test for aapt2
This commit is contained in:
Connor Tumbleson 2023-11-03 06:40:32 -04:00 committed by GitHub
parent 63b1976448
commit eec0288e69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View File

@ -32,9 +32,7 @@ public class ResValueFactory {
public ResScalarValue factory(int type, int value, String rawValue) throws AndrolibException {
switch (type) {
case TypedValue.TYPE_NULL:
if (value == TypedValue.DATA_NULL_UNDEFINED) { // Special case $empty as explicitly defined empty value
return new ResStringValue(null, value);
} else if (value == TypedValue.DATA_NULL_EMPTY) {
if (value == TypedValue.DATA_NULL_EMPTY) {
return new ResEmptyValue(value, rawValue, type);
}
return new ResReferenceValue(mPackage, 0, null);

View File

@ -71,6 +71,11 @@ public class BuildAndDecodeTest extends BaseTest {
assertTrue(sTestNewDir.isDirectory());
}
@Test
public void valuesColorsTest() throws BrutException {
compareValuesFiles("values/colors.xml");
}
@Test
public void valuesStringsTest() throws BrutException {
compareValuesFiles("values/strings.xml");

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="test_color1">#ff123456</color>
<color name="test_color2">@android:color/white</color>
<color name="test_color3">#00000000</color>
<color name="issue_3416">@null</color>
</resources>