未验证 提交 bdb2efdb 编写于 作者: S Skylot

fix(res): remove static caching map for xml renames (#1364)

上级 a27ba3ff
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;
}
ArgType clsType = ArgType.object(potentialClassName);
ClassInfo classInfo = root.getInfoStorage().getCls(clsType);
if (classInfo == null) {
// unknown class reference
return null;
}
return DEOBF_MAP.get(old);
return classInfo.getAliasFullName();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册