Skip to content

Commit 44b1fe5

Browse files
committed
Upgrade BlackObfuscator version to 2.1
1 parent 5b05fc2 commit 44b1fe5

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

plugin/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies {
1111
implementation gradleApi()
1212
//groovy sdk
1313
implementation localGroovy()
14-
implementation "com.github.CodingGay.BlackObfuscator:dex-tools:2.0"
14+
implementation "com.github.CodingGay.BlackObfuscator:dex-tools:2.1"
1515
}
1616

1717
repositories {

plugin/src/main/groovy/top/niunaijun/blackobfuscator/BlackObfuscatorExtension.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class BlackObfuscatorExtension {
55
boolean enabled = false
66
int depth = 1
77
String[] obfClass = []
8+
String[] blackClass = []
89

910
BlackObfuscatorExtension(Project project) {
1011

@@ -17,6 +18,7 @@ class BlackObfuscatorExtension {
1718
"enabled=" + enabled +
1819
", depth=" + depth +
1920
", obfClass=" + Arrays.toString(obfClass) +
21+
", blackClass=" + Arrays.toString(blackClass) +
2022
'}';
2123
}
2224
}

plugin/src/main/groovy/top/niunaijun/blackobfuscator/ObfPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class ObfPlugin implements Plugin<Project> {
3434
task.getOutputs().getFiles().collect().each() { element ->
3535
def file = new File(element.toString())
3636
ObfDex.obf(file.getAbsolutePath(),
37-
sObfuscatorExtension.depth, sObfuscatorExtension.obfClass)
37+
sObfuscatorExtension.depth, sObfuscatorExtension.obfClass, sObfuscatorExtension.blackClass)
3838
}
3939
}
4040
}

plugin/src/main/java/top/niunaijun/blackobfuscator/core/ObfDex.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@
1919
* 此处无Bug
2020
*/
2121
public class ObfDex {
22-
public static void obf(String dir, int depth, String[] obfClass) {
22+
public static void obf(String dir, int depth, String[] obfClass, String[] blackClass) {
2323
File file = new File(dir);
2424
if (file.isDirectory()) {
2525
File[] files = file.listFiles();
2626
if (files == null)
2727
return;
2828
for (File input : files) {
2929
if (input.isFile()) {
30-
handleDex(input, depth, obfClass);
30+
handleDex(input, depth, obfClass, blackClass);
3131
} else {
32-
obf(input.getAbsolutePath(), depth, obfClass);
32+
obf(input.getAbsolutePath(), depth, obfClass, blackClass);
3333
}
3434
}
3535
} else {
36-
handleDex(file, depth, obfClass);
36+
handleDex(file, depth, obfClass, blackClass);
3737
}
3838
}
3939

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

0 commit comments

Comments
 (0)