Skip to content

Commit

Permalink
[DEX] Fix rename types
Browse files Browse the repository at this point in the history
REAndroid committed Mar 2, 2024
1 parent 31834dc commit 35a9087
Showing 2 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/reandroid/dex/key/TypeKey.java
Original file line number Diff line number Diff line change
@@ -241,6 +241,8 @@ public int compareInnerFirst(TypeKey other) {
if(diff > 0 && name1.charAt(diff) == '$' && diff > name1.lastIndexOf('/') + 1){
return CompareUtil.compare(name2, name1);
}
name1 = this.getTypeName();
name2 = other.getTypeName();
return CompareUtil.compare(name1, name2);
}
@Override
23 changes: 17 additions & 6 deletions src/main/java/com/reandroid/dex/refactor/RenameTypes.java
Original file line number Diff line number Diff line change
@@ -50,11 +50,10 @@ public int apply(DexClassRepository classRepository) {
while (iterator.hasNext()){
StringId stringId = iterator.next();
String text = map.get(stringId.getString());
if(text == null){
continue;
if(text != null){
stringId.setString(text);
count ++;
}
stringId.setString(text);
count ++;
}
return count;
}
@@ -83,7 +82,7 @@ private Map<String, String> buildMap() {

int estimatedSize = 1;
if(renameSignatures){
estimatedSize = estimatedSize + 1;
estimatedSize = estimatedSize + 2;
}
if(renameSource){
estimatedSize = estimatedSize + 1;
@@ -109,14 +108,26 @@ private Map<String, String> buildMap() {
map.put(name1, name2);

if(renameSignatures){
name1 = first.getTypeName();
name2 = second.getTypeName();

name1 = name1.replace(';', '<');
name2 = name2.replace(';', '<');

map.put(name1, name2);

name1 = first.getTypeName();
name2 = second.getTypeName();

name1 = name1.substring(0, name1.length() - 1);
name2 = name2.substring(0, name2.length() - 1);

map.put(name1, name2);
}

for(int j = 1; j < arrayDepth; j++){
name1 = first.getArrayType(j);
name2 = first.getArrayType(j);
name2 = second.getArrayType(j);
map.put(name1, name2);
if(renameSignatures && j == 1){
name1 = name1.replace(';', '<');

0 comments on commit 35a9087

Please sign in to comment.