Skip to content

Commit

Permalink
fix: don't rename R class fields alias (PR #492)
Browse files Browse the repository at this point in the history
* fix: R class fields alias
* implemented with clearer approach
  • Loading branch information
tRuNKator authored and skylot committed Mar 22, 2019
1 parent 2e9039d commit 5f0dbf8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jadx-core/src/main/java/jadx/core/deobf/Deobfuscator.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Set;
import java.util.TreeSet;

import jadx.core.dex.attributes.AFlag;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
Expand Down Expand Up @@ -225,6 +226,8 @@ private void processClass(ClassNode cls) {
clsInfo.rename(cls.dex().root(), fullName);
}
for (FieldNode field : cls.getFields()) {
if (field.contains(AFlag.DONT_RENAME))
continue;
renameField(field);
}
for (MethodNode mth : cls.getMethods()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum AFlag {
DONT_SHRINK,
DONT_INLINE,
DONT_GENERATE,
DONT_RENAME, // do not rename during deobfuscation
SKIP,
REMOVE,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.TreeMap;

import com.android.dx.rop.code.AccessFlags;
import jadx.core.dex.attributes.AFlag;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
Expand Down Expand Up @@ -124,6 +125,7 @@ private static void addResourceFields(ClassNode resCls, ResourceStorage resStora
if (fieldNode != null
&& !fieldNode.getName().equals(resName)
&& NameMapper.isValidIdentifier(resName)) {
fieldNode.add(AFlag.DONT_RENAME);
fieldNode.getFieldInfo().setAlias(resName);
}
}
Expand Down

0 comments on commit 5f0dbf8

Please sign in to comment.