fix(res): remove static caching map for xml renames (#1364)
This commit is contained in:
@@ -1,46 +1,33 @@
|
||||
package jadx.core.xmlgen;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import jadx.core.dex.info.ClassInfo;
|
||||
import jadx.core.dex.nodes.ClassNode;
|
||||
import jadx.core.dex.instructions.args.ArgType;
|
||||
import jadx.core.dex.nodes.RootNode;
|
||||
|
||||
/*
|
||||
* modifies android:name attributes and xml tags which are old class names
|
||||
* but were changed during deobfuscation
|
||||
* Modifies android:name attributes and xml tags which were changed during deobfuscation
|
||||
*/
|
||||
public class XmlDeobf {
|
||||
private static final Map<String, String> DEOBF_MAP = new HashMap<>();
|
||||
|
||||
private XmlDeobf() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String deobfClassName(RootNode rootNode, String potencialClassName, String packageName) {
|
||||
potencialClassName = potencialClassName.replace('$', '.');
|
||||
if (packageName != null && potencialClassName.startsWith(".")) {
|
||||
potencialClassName = packageName + potencialClassName;
|
||||
public static String deobfClassName(RootNode root, String potentialClassName, String packageName) {
|
||||
if (potentialClassName.indexOf('.') == -1) {
|
||||
return null;
|
||||
}
|
||||
return getNewClassName(rootNode, potencialClassName);
|
||||
}
|
||||
|
||||
private static String getNewClassName(RootNode rootNode, String old) {
|
||||
if (DEOBF_MAP.isEmpty()) {
|
||||
for (ClassNode classNode : rootNode.getClasses(true)) {
|
||||
ClassInfo classInfo = classNode.getClassInfo();
|
||||
if (classInfo.hasAlias()) {
|
||||
String oldName = classInfo.getFullName();
|
||||
String newName = classInfo.getAliasFullName();
|
||||
if (!oldName.equals(newName)) {
|
||||
DEOBF_MAP.put(oldName, newName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (packageName != null && potentialClassName.startsWith(".")) {
|
||||
potentialClassName = packageName + potentialClassName;
|
||||
}
|
||||
return DEOBF_MAP.get(old);
|
||||
ArgType clsType = ArgType.object(potentialClassName);
|
||||
ClassInfo classInfo = root.getInfoStorage().getCls(clsType);
|
||||
if (classInfo == null) {
|
||||
// unknown class reference
|
||||
return null;
|
||||
}
|
||||
return classInfo.getAliasFullName();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user