fix(res): XML parsing: handling of TYPE_DYNAMIC_REFERENCE entries (#919, PR #923)

This commit is contained in:
Jan S
2020-04-29 20:47:20 +02:00
committed by GitHub
parent 7f5092c0d5
commit 258ecad277
2 changed files with 16 additions and 0 deletions
@@ -48,6 +48,18 @@ public class ParserConstants {
protected static final int TYPE_DIMENSION = 0x05;
// The 'data' holds a complex number encoding a fraction of a container.
protected static final int TYPE_FRACTION = 0x06;
/**
* The 'data' holds a dynamic reference, a reference to another resource table entry.
* See https://github.com/skylot/jadx/issues/919
*/
protected static final int TYPE_DYNAMIC_REFERENCE = 0x07;
/**
* According to the sources of apktool this type seem to be related to themes
* See https://github.com/skylot/jadx/issues/919
*/
protected static final int TYPE_DYNAMIC_ATTRIBUTE = 0x08;
// Beginning of integer flavors...
protected static final int TYPE_FIRST_INT = 0x10;
// The 'data' is a raw integer value of the form n..n.
@@ -100,6 +100,7 @@ public class ValuesParser extends ParserConstants {
case TYPE_INT_COLOR_RGB4:
return String.format("#%03x", data & 0xFFF);
case TYPE_DYNAMIC_REFERENCE:
case TYPE_REFERENCE: {
String ri = resMap.get(data);
if (ri == null) {
@@ -131,6 +132,9 @@ public class ValuesParser extends ParserConstants {
return decodeComplex(data, false);
case TYPE_FRACTION:
return decodeComplex(data, true);
case TYPE_DYNAMIC_ATTRIBUTE:
LOG.warn("Data type TYPE_DYNAMIC_ATTRIBUTE not yet supported: {}", data);
return " TYPE_DYNAMIC_ATTRIBUTE: " + data;
default:
LOG.warn("Unknown data type: 0x{} {}", Integer.toHexString(dataType), data);