decode unknown resource id as hex

This commit is contained in:
REAndroid 2023-03-28 06:22:17 -04:00
parent a7b3a466d0
commit 0e161a4321
2 changed files with 17 additions and 2 deletions

View File

@ -479,9 +479,12 @@ public class ResXmlPullParser implements XmlResourceParser {
if(attribute==null){
return null;
}
String name = mDecoder.decodeResourceName(attribute.getNameResourceID());
if(name == null){
String name;
int resourceId = attribute.getNameResourceID();
if(resourceId == 0 || mDecoder==null){
name = attribute.getName();
}else {
name = mDecoder.decodeResourceName(attribute.getNameResourceID(), true);
}
return name;
}

View File

@ -39,12 +39,24 @@ public class Decoder {
this.currentPackageId = currentPackageId;
}
public String decodeResourceName(int resourceId){
return decodeResourceName(resourceId, true);
}
public String decodeResourceName(int resourceId, boolean defaultHex){
if(resourceId == 0){
return null;
}
EntryGroup entryGroup = getEntryStore().getEntryGroup(resourceId);
if(entryGroup!=null){
return entryGroup.getSpecName();
}
if(defaultHex){
return hexResourceName(resourceId);
}
return null;
}
private String hexResourceName(int resourceId){
return String.format("@0x%08x", resourceId);
}
public String decodeValue(Value value){
if(value==null){
return null;