mirror of
https://github.com/revanced/Apktool.git
synced 2025-05-09 10:14:25 +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")) {
|
||||
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 {
|
||||
@ -341,6 +344,13 @@ public class Main {
|
||||
.desc("Print advanced information.")
|
||||
.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")
|
||||
.longOpt("no-src")
|
||||
.desc("Do not decode sources.")
|
||||
@ -502,6 +512,7 @@ public class Main {
|
||||
|
||||
// check for advance mode
|
||||
if (isAdvanceMode()) {
|
||||
decodeOptions.addOption(jobsOption);
|
||||
decodeOptions.addOption(noDbgOption);
|
||||
decodeOptions.addOption(keepResOption);
|
||||
decodeOptions.addOption(analysisOption);
|
||||
@ -511,6 +522,7 @@ public class Main {
|
||||
decodeOptions.addOption(forceManOption);
|
||||
decodeOptions.addOption(resolveResModeOption);
|
||||
|
||||
buildOptions.addOption(jobsOption);
|
||||
buildOptions.addOption(apiLevelOption);
|
||||
buildOptions.addOption(debugBuiOption);
|
||||
buildOptions.addOption(netSecConfOption);
|
||||
@ -561,6 +573,7 @@ public class Main {
|
||||
for (Option op : frameOptions.getOptions()) {
|
||||
allOptions.addOption(op);
|
||||
}
|
||||
allOptions.addOption(jobsOption);
|
||||
allOptions.addOption(apiLevelOption);
|
||||
allOptions.addOption(analysisOption);
|
||||
allOptions.addOption(debugDecOption);
|
||||
|
@ -79,9 +79,9 @@ public class ApkBuilder {
|
||||
}
|
||||
|
||||
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 {
|
||||
mWorker = new BackgroundWorker();
|
||||
mWorker = new BackgroundWorker(mConfig.jobs);
|
||||
mApkInfo = ApkInfo.load(mApkDir);
|
||||
|
||||
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 {
|
||||
ExtFile apkFile = mApkInfo.getApkFile();
|
||||
try {
|
||||
mWorker = new BackgroundWorker();
|
||||
mWorker = new BackgroundWorker(mConfig.jobs);
|
||||
if (!mConfig.forceDelete && outDir.exists()) {
|
||||
throw new OutDirExistsException();
|
||||
}
|
||||
@ -95,7 +95,8 @@ public class ApkDecoder {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
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()) {
|
||||
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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
public class BackgroundWorker {
|
||||
|
||||
private static final int THREADS_COUNT = Runtime.getRuntime().availableProcessors();
|
||||
private final ArrayList<Future<?>> mWorkerFutures = new ArrayList<>();
|
||||
private final ExecutorService mExecutor;
|
||||
private volatile boolean mSubmitAllowed = true;
|
||||
|
||||
public BackgroundWorker() {
|
||||
this(THREADS_COUNT);
|
||||
}
|
||||
|
||||
public BackgroundWorker(int threads) {
|
||||
mExecutor = Executors.newFixedThreadPool(threads);
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ public class Config {
|
||||
public boolean baksmaliDebugMode = true;
|
||||
|
||||
// Common options
|
||||
public int jobs = Runtime.getRuntime().availableProcessors();
|
||||
public String frameworkDirectory = null;
|
||||
public String frameworkTag = null;
|
||||
public String aaptPath = "";
|
||||
|
@ -36,14 +36,6 @@ public class ZipUtils {
|
||||
// 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)
|
||||
throws BrutException, IOException {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user