Skip to content

Commit

Permalink
Update VMCore.java
Browse files Browse the repository at this point in the history
  • Loading branch information
nnjun committed Jun 7, 2021
1 parent 27660d7 commit 556f37b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Bcore/src/main/java/top/niunaijun/blackbox/core/VMCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

import dalvik.system.DexFile;
import top.niunaijun.blackbox.BlackBoxCore;
Expand Down Expand Up @@ -59,25 +60,25 @@ public static void dumpDex(ClassLoader classLoader, String packageName) {
int availableProcessors = Runtime.getRuntime().availableProcessors();
ExecutorService executorService = Executors.newFixedThreadPool(availableProcessors <= 0 ? 1 : availableProcessors + 1);
CountDownLatch countDownLatch = new CountDownLatch(cookies.size());
AtomicInteger atomicInteger = new AtomicInteger(0);

BlackBoxCore.getBDumpManager().noticeMonitor(result.dumpProcess(cookies.size(), 0));
BlackBoxCore.getBDumpManager().noticeMonitor(result.dumpProcess(cookies.size(), atomicInteger.getAndIncrement()));
for (int i = 0; i < cookies.size(); i++) {
long cookie = cookies.get(i);
if (cookie == 0) {
countDownLatch.countDown();
continue;
}
FileUtils.mkdirs(file);
int finalI = i;
if (i == 1) {
if (atomicInteger.get() == 1) {
try {
Thread.sleep(500);
} catch (InterruptedException ignored) {
}
}
executorService.execute(() -> {
dumpDex(cookie, file.getAbsolutePath(), BlackBoxCore.get().isFixCodeItem());
BlackBoxCore.getBDumpManager().noticeMonitor(result.dumpProcess(cookies.size(), finalI + 1));
BlackBoxCore.getBDumpManager().noticeMonitor(result.dumpProcess(cookies.size(), atomicInteger.getAndIncrement()));
countDownLatch.countDown();
});
}
Expand Down

0 comments on commit 556f37b

Please sign in to comment.