use of jadx.core.xmlgen.entry.ResourceEntry in project jadx by skylot.
the class ResTableParser method makeDump.
public CodeWriter makeDump() throws IOException {
CodeWriter writer = new CodeWriter();
writer.add("app package: ").add(resStorage.getAppPackage());
writer.startLine();
ValuesParser vp = new ValuesParser(strings, resStorage.getResourcesNames());
for (ResourceEntry ri : resStorage.getResources()) {
writer.startLine(ri + ": " + vp.getValueString(ri));
}
writer.finish();
return writer;
}
use of jadx.core.xmlgen.entry.ResourceEntry in project jadx by skylot.
the class AndroidResourcesUtils method addResourceFields.
private static void addResourceFields(ClassNode resCls, ResourceStorage resStorage, boolean rClsExists) {
Map<Integer, FieldNode> resFieldsMap = fillResFieldsMap(resCls);
Map<String, ResClsInfo> innerClsMap = new TreeMap<>();
if (rClsExists) {
for (ClassNode innerClass : resCls.getInnerClasses()) {
ResClsInfo innerResCls = new ResClsInfo(innerClass);
innerClass.getFields().forEach(field -> innerResCls.getFieldsMap().put(field.getName(), field));
innerClsMap.put(innerClass.getShortName(), innerResCls);
}
}
for (ResourceEntry resource : resStorage.getResources()) {
String resTypeName = resource.getTypeName();
String resName = resTypeName.equals("style") ? resource.getKeyName().replace('.', '_') : resource.getKeyName();
ResClsInfo typeClsInfo = innerClsMap.computeIfAbsent(resTypeName, name -> getClassForResType(resCls, rClsExists, name));
typeClsInfo.getFieldsMap().computeIfAbsent(resName, name -> {
ClassNode typeCls = typeClsInfo.getTypeCls();
FieldInfo rFieldInfo = FieldInfo.from(typeCls.root(), typeCls.getClassInfo(), resName, ArgType.INT);
FieldNode newResField = new FieldNode(typeCls, rFieldInfo, AccessFlags.PUBLIC | AccessFlags.STATIC | AccessFlags.FINAL);
newResField.addAttr(new EncodedValue(EncodedType.ENCODED_INT, resource.getId()));
typeCls.getFields().add(newResField);
if (rClsExists) {
newResField.addInfoComment("Added by JADX");
}
return newResField;
});
FieldNode fieldNode = resFieldsMap.get(resource.getId());
if (fieldNode != null && !fieldNode.getName().equals(resName) && NameMapper.isValidAndPrintable(resName) && resCls.root().getArgs().isRenameValid()) {
fieldNode.add(AFlag.DONT_RENAME);
fieldNode.getFieldInfo().setAlias(resName);
}
}
}
use of jadx.core.xmlgen.entry.ResourceEntry in project jadx by skylot.
the class ResProtoParser method parse.
private void parse(String packageName, List<Type> types) {
for (Type type : types) {
String typeName = type.getName();
for (Entry entry : type.getEntryList()) {
int id = entry.getEntryId().getId();
String entryName = entry.getName();
for (ConfigValue configValue : entry.getConfigValueList()) {
String config = parse(configValue.getConfig());
ResourceEntry resEntry = new ResourceEntry(id, packageName, typeName, entryName, config);
resStorage.add(resEntry);
ProtoValue protoValue;
if (configValue.getValue().getValueCase() == Value.ValueCase.ITEM) {
protoValue = new ProtoValue(parse(configValue.getValue().getItem()));
} else {
protoValue = parse(configValue.getValue().getCompoundValue());
}
resEntry.setProtoValue(protoValue);
}
}
}
}
use of jadx.core.xmlgen.entry.ResourceEntry in project jadx by skylot.
the class ResXmlGen method makeResourcesXml.
public List<ResContainer> makeResourcesXml() {
Map<String, ICodeWriter> contMap = new HashMap<>();
for (ResourceEntry ri : resStorage.getResources()) {
if (SKIP_RES_TYPES.contains(ri.getTypeName())) {
continue;
}
String fn = getFileName(ri);
ICodeWriter cw = contMap.get(fn);
if (cw == null) {
cw = new SimpleCodeWriter();
cw.add("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
cw.startLine("<resources>");
cw.incIndent();
contMap.put(fn, cw);
}
addValue(cw, ri);
}
List<ResContainer> files = new ArrayList<>(contMap.size());
for (Map.Entry<String, ICodeWriter> entry : contMap.entrySet()) {
String fileName = entry.getKey();
ICodeWriter content = entry.getValue();
content.decIndent();
content.startLine("</resources>");
ICodeInfo codeInfo = content.finish();
files.add(ResContainer.textResource(fileName, codeInfo));
}
Collections.sort(files);
return files;
}
use of jadx.core.xmlgen.entry.ResourceEntry in project jadx by skylot.
the class XmlGenUtils method makeXmlDump.
public static ICodeInfo makeXmlDump(ICodeWriter writer, ResourceStorage resStorage) {
writer.startLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
writer.startLine("<resources>");
writer.incIndent();
Set<String> addedValues = new HashSet<>();
for (ResourceEntry ri : resStorage.getResources()) {
if (addedValues.add(ri.getTypeName() + '.' + ri.getKeyName())) {
String format = String.format("<public type=\"%s\" name=\"%s\" id=\"0x%08x\" />", ri.getTypeName(), ri.getKeyName(), ri.getId());
writer.startLine(format);
}
}
writer.decIndent();
writer.startLine("</resources>");
return writer.finish();
}
Aggregations