mirror of
https://github.com/revanced/Apktool.git
synced 2025-05-09 18:24:26 +02:00
Support for configuring job count. (#3480)
* feat: make jobs configurable * chore: remove unused method
This commit is contained in:
parent
81aae6936a
commit
e56cb4f743
@ -130,6 +130,9 @@ public class Main {
|
|||||||
if (cli.hasOption("api") || cli.hasOption("api-level")) {
|
if (cli.hasOption("api") || cli.hasOption("api-level")) {
|
||||||
config.apiLevel = Integer.parseInt(cli.getOptionValue("api"));
|
config.apiLevel = Integer.parseInt(cli.getOptionValue("api"));
|
||||||
}
|
}
|
||||||
|
if (cli.hasOption("j") || cli.hasOption("jobs")) {
|
||||||
|
config.jobs = Integer.parseInt(cli.getOptionValue("j"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void cmdDecode(CommandLine cli, Config config) throws AndrolibException {
|
private static void cmdDecode(CommandLine cli, Config config) throws AndrolibException {
|
||||||
@ -341,6 +344,13 @@ public class Main {
|
|||||||
.desc("Print advanced information.")
|
.desc("Print advanced information.")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
Option jobsOption = Option.builder("j")
|
||||||
|
.longOpt("jobs")
|
||||||
|
.hasArg()
|
||||||
|
.type(Integer.class)
|
||||||
|
.desc("Sets the number of threads to use.")
|
||||||
|
.build();
|
||||||
|
|
||||||
Option noSrcOption = Option.builder("s")
|
Option noSrcOption = Option.builder("s")
|
||||||
.longOpt("no-src")
|
.longOpt("no-src")
|
||||||
.desc("Do not decode sources.")
|
.desc("Do not decode sources.")
|
||||||
@ -502,6 +512,7 @@ public class Main {
|
|||||||
|
|
||||||
// check for advance mode
|
// check for advance mode
|
||||||
if (isAdvanceMode()) {
|
if (isAdvanceMode()) {
|
||||||
|
decodeOptions.addOption(jobsOption);
|
||||||
decodeOptions.addOption(noDbgOption);
|
decodeOptions.addOption(noDbgOption);
|
||||||
decodeOptions.addOption(keepResOption);
|
decodeOptions.addOption(keepResOption);
|
||||||
decodeOptions.addOption(analysisOption);
|
decodeOptions.addOption(analysisOption);
|
||||||
@ -511,6 +522,7 @@ public class Main {
|
|||||||
decodeOptions.addOption(forceManOption);
|
decodeOptions.addOption(forceManOption);
|
||||||
decodeOptions.addOption(resolveResModeOption);
|
decodeOptions.addOption(resolveResModeOption);
|
||||||
|
|
||||||
|
buildOptions.addOption(jobsOption);
|
||||||
buildOptions.addOption(apiLevelOption);
|
buildOptions.addOption(apiLevelOption);
|
||||||
buildOptions.addOption(debugBuiOption);
|
buildOptions.addOption(debugBuiOption);
|
||||||
buildOptions.addOption(netSecConfOption);
|
buildOptions.addOption(netSecConfOption);
|
||||||
@ -561,6 +573,7 @@ public class Main {
|
|||||||
for (Option op : frameOptions.getOptions()) {
|
for (Option op : frameOptions.getOptions()) {
|
||||||
allOptions.addOption(op);
|
allOptions.addOption(op);
|
||||||
}
|
}
|
||||||
|
allOptions.addOption(jobsOption);
|
||||||
allOptions.addOption(apiLevelOption);
|
allOptions.addOption(apiLevelOption);
|
||||||
allOptions.addOption(analysisOption);
|
allOptions.addOption(analysisOption);
|
||||||
allOptions.addOption(debugDecOption);
|
allOptions.addOption(debugDecOption);
|
||||||
|
@ -79,9 +79,9 @@ public class ApkBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void build(File outFile) throws BrutException {
|
public void build(File outFile) throws BrutException {
|
||||||
LOGGER.info("Using Apktool " + ApktoolProperties.getVersion());
|
LOGGER.info("Using Apktool " + ApktoolProperties.getVersion() + " with " + mConfig.jobs + " thread(s).");
|
||||||
try {
|
try {
|
||||||
mWorker = new BackgroundWorker();
|
mWorker = new BackgroundWorker(mConfig.jobs);
|
||||||
mApkInfo = ApkInfo.load(mApkDir);
|
mApkInfo = ApkInfo.load(mApkDir);
|
||||||
|
|
||||||
if (mApkInfo.getSdkInfo() != null && mApkInfo.getSdkInfo().get("minSdkVersion") != null) {
|
if (mApkInfo.getSdkInfo() != null && mApkInfo.getSdkInfo().get("minSdkVersion") != null) {
|
||||||
|
@ -78,7 +78,7 @@ public class ApkDecoder {
|
|||||||
public ApkInfo decode(File outDir) throws AndrolibException, IOException, DirectoryException {
|
public ApkInfo decode(File outDir) throws AndrolibException, IOException, DirectoryException {
|
||||||
ExtFile apkFile = mApkInfo.getApkFile();
|
ExtFile apkFile = mApkInfo.getApkFile();
|
||||||
try {
|
try {
|
||||||
mWorker = new BackgroundWorker();
|
mWorker = new BackgroundWorker(mConfig.jobs);
|
||||||
if (!mConfig.forceDelete && outDir.exists()) {
|
if (!mConfig.forceDelete && outDir.exists()) {
|
||||||
throw new OutDirExistsException();
|
throw new OutDirExistsException();
|
||||||
}
|
}
|
||||||
@ -95,7 +95,8 @@ public class ApkDecoder {
|
|||||||
//noinspection ResultOfMethodCallIgnored
|
//noinspection ResultOfMethodCallIgnored
|
||||||
outDir.mkdirs();
|
outDir.mkdirs();
|
||||||
|
|
||||||
LOGGER.info("Using Apktool " + ApktoolProperties.getVersion() + " on " + mApkInfo.apkFileName);
|
LOGGER.info("Using Apktool " + ApktoolProperties.getVersion() + " on " + mApkInfo.apkFileName +
|
||||||
|
" with " + mConfig.jobs + " thread(s).");
|
||||||
|
|
||||||
if (mApkInfo.hasSources()) {
|
if (mApkInfo.hasSources()) {
|
||||||
switch (mConfig.decodeSources) {
|
switch (mConfig.decodeSources) {
|
||||||
|
@ -1,19 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||||
|
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package brut.androlib;
|
package brut.androlib;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
public class BackgroundWorker {
|
public class BackgroundWorker {
|
||||||
|
|
||||||
private static final int THREADS_COUNT = Runtime.getRuntime().availableProcessors();
|
|
||||||
private final ArrayList<Future<?>> mWorkerFutures = new ArrayList<>();
|
private final ArrayList<Future<?>> mWorkerFutures = new ArrayList<>();
|
||||||
private final ExecutorService mExecutor;
|
private final ExecutorService mExecutor;
|
||||||
private volatile boolean mSubmitAllowed = true;
|
private volatile boolean mSubmitAllowed = true;
|
||||||
|
|
||||||
public BackgroundWorker() {
|
|
||||||
this(THREADS_COUNT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BackgroundWorker(int threads) {
|
public BackgroundWorker(int threads) {
|
||||||
mExecutor = Executors.newFixedThreadPool(threads);
|
mExecutor = Executors.newFixedThreadPool(threads);
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ public class Config {
|
|||||||
public boolean baksmaliDebugMode = true;
|
public boolean baksmaliDebugMode = true;
|
||||||
|
|
||||||
// Common options
|
// Common options
|
||||||
|
public int jobs = Runtime.getRuntime().availableProcessors();
|
||||||
public String frameworkDirectory = null;
|
public String frameworkDirectory = null;
|
||||||
public String frameworkTag = null;
|
public String frameworkTag = null;
|
||||||
public String aaptPath = "";
|
public String aaptPath = "";
|
||||||
|
@ -36,14 +36,6 @@ public class ZipUtils {
|
|||||||
// Private constructor for utility class
|
// Private constructor for utility class
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void zipFolders(final File folder, final File zip, final File assets, final Collection<String> doNotCompress)
|
|
||||||
throws BrutException, IOException {
|
|
||||||
|
|
||||||
ZipOutputStream zipOutputStream = new ZipOutputStream(Files.newOutputStream(zip.toPath()));
|
|
||||||
zipFoldersPreserveStream(folder, zipOutputStream, assets, doNotCompress);
|
|
||||||
zipOutputStream.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void zipFoldersPreserveStream(final File folder, final ZipOutputStream zipOutputStream, final File assets, final Collection<String> doNotCompress)
|
public static void zipFoldersPreserveStream(final File folder, final ZipOutputStream zipOutputStream, final File assets, final Collection<String> doNotCompress)
|
||||||
throws BrutException, IOException {
|
throws BrutException, IOException {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user