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

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

上级 a27ba3ff
package jadx.core.xmlgen; package jadx.core.xmlgen;
import java.util.HashMap;
import java.util.Map;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import jadx.core.dex.info.ClassInfo; 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; import jadx.core.dex.nodes.RootNode;
/* /*
* modifies android:name attributes and xml tags which are old class names * Modifies android:name attributes and xml tags which were changed during deobfuscation
* but were changed during deobfuscation
*/ */
public class XmlDeobf { public class XmlDeobf {
private static final Map<String, String> DEOBF_MAP = new HashMap<>();
private XmlDeobf() { private XmlDeobf() {
} }
@Nullable @Nullable
public static String deobfClassName(RootNode rootNode, String potencialClassName, String packageName) { public static String deobfClassName(RootNode root, String potentialClassName, String packageName) {
potencialClassName = potencialClassName.replace('$', '.'); if (potentialClassName.indexOf('.') == -1) {
if (packageName != null && potencialClassName.startsWith(".")) { return null;
potencialClassName = packageName + potencialClassName;
} }
return getNewClassName(rootNode, potencialClassName); if (packageName != null && potentialClassName.startsWith(".")) {
} potentialClassName = packageName + potentialClassName;
}
private static String getNewClassName(RootNode rootNode, String old) { ArgType clsType = ArgType.object(potentialClassName);
if (DEOBF_MAP.isEmpty()) { ClassInfo classInfo = root.getInfoStorage().getCls(clsType);
for (ClassNode classNode : rootNode.getClasses(true)) { if (classInfo == null) {
ClassInfo classInfo = classNode.getClassInfo(); // unknown class reference
if (classInfo.hasAlias()) { return null;
String oldName = classInfo.getFullName();
String newName = classInfo.getAliasFullName();
if (!oldName.equals(newName)) {
DEOBF_MAP.put(oldName, newName);
}
}
}
} }
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.
先完成此消息的编辑!
想要评论请 注册