Skip to content

Commit

Permalink
Upgrade BlackObfuscator version to 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nnjun committed Jan 8, 2022
1 parent 5b05fc2 commit 44b1fe5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {
implementation gradleApi()
//groovy sdk
implementation localGroovy()
implementation "com.github.CodingGay.BlackObfuscator:dex-tools:2.0"
implementation "com.github.CodingGay.BlackObfuscator:dex-tools:2.1"
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class BlackObfuscatorExtension {
boolean enabled = false
int depth = 1
String[] obfClass = []
String[] blackClass = []

BlackObfuscatorExtension(Project project) {

Expand All @@ -17,6 +18,7 @@ class BlackObfuscatorExtension {
"enabled=" + enabled +
", depth=" + depth +
", obfClass=" + Arrays.toString(obfClass) +
", blackClass=" + Arrays.toString(blackClass) +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ObfPlugin implements Plugin<Project> {
task.getOutputs().getFiles().collect().each() { element ->
def file = new File(element.toString())
ObfDex.obf(file.getAbsolutePath(),
sObfuscatorExtension.depth, sObfuscatorExtension.obfClass)
sObfuscatorExtension.depth, sObfuscatorExtension.obfClass, sObfuscatorExtension.blackClass)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@
* 此处无Bug
*/
public class ObfDex {
public static void obf(String dir, int depth, String[] obfClass) {
public static void obf(String dir, int depth, String[] obfClass, String[] blackClass) {
File file = new File(dir);
if (file.isDirectory()) {
File[] files = file.listFiles();
if (files == null)
return;
for (File input : files) {
if (input.isFile()) {
handleDex(input, depth, obfClass);
handleDex(input, depth, obfClass, blackClass);
} else {
obf(input.getAbsolutePath(), depth, obfClass);
obf(input.getAbsolutePath(), depth, obfClass, blackClass);
}
}
} else {
handleDex(file, depth, obfClass);
handleDex(file, depth, obfClass, blackClass);
}
}

private static void handleDex(File input, int depth, String[] obfClass) {
private static void handleDex(File input, int depth, String[] obfClass, String[] blackClass) {
if (!input.getAbsolutePath().endsWith(".dex"))
return;
File tempJar = null;
Expand All @@ -47,7 +47,7 @@ private static void handleDex(File input, int depth, String[] obfClass) {
tempJar = new File(input.getParent(), System.currentTimeMillis() + "obf" + input.getName() + ".jar");
splitDex = new File(input.getParent(), System.currentTimeMillis() + "split" + input.getName() + ".dex");
obfDex = new File(input.getParent(), System.currentTimeMillis() + "obf" + input.getName() + ".dex");
long l = DexLib2Utils.splitDex(input, splitDex, Arrays.asList(obfClass));
long l = DexLib2Utils.splitDex(input, splitDex, Arrays.asList(obfClass), Arrays.asList(blackClass));
if (l <= 0) {
System.out.println("Obfuscator Class not found");
return;
Expand Down

0 comments on commit 44b1fe5

Please sign in to comment.