Add patcher for manager
This commit is contained in:
parent
7876d84f65
commit
efd701b7e0
|
|
@ -36,6 +36,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation project(":patch")
|
||||||
implementation project(":imanager")
|
implementation project(":imanager")
|
||||||
implementation project(path: ':lspcore')
|
implementation project(path: ':lspcore')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
package org.lsposed.lspatch
|
||||||
|
|
||||||
|
import org.lsposed.patch.LSPatch
|
||||||
|
|
||||||
|
object Patcher {
|
||||||
|
class Options(
|
||||||
|
private val apkPaths: List<String>,
|
||||||
|
private val outputPath: String,
|
||||||
|
private val debuggable: Boolean,
|
||||||
|
private val sigbypassLevel: Int,
|
||||||
|
private val v1: Boolean,
|
||||||
|
private val v2: Boolean,
|
||||||
|
private val v3: Boolean,
|
||||||
|
private val useManager: Boolean,
|
||||||
|
private val verbose: Boolean,
|
||||||
|
private val embeddedModules: List<String>
|
||||||
|
) {
|
||||||
|
fun toStringArray(): Array<String> {
|
||||||
|
return arrayListOf<String>().run {
|
||||||
|
add("-f");
|
||||||
|
addAll(apkPaths)
|
||||||
|
add("-o"); add(outputPath)
|
||||||
|
if (debuggable) add("-d")
|
||||||
|
add("-l"); add(sigbypassLevel.toString())
|
||||||
|
add("--v1"); add(v1.toString())
|
||||||
|
add("--v2"); add(v2.toString())
|
||||||
|
add("--v3"); add(v3.toString())
|
||||||
|
if (useManager) add("--manager")
|
||||||
|
if (verbose) add("-v")
|
||||||
|
if (embeddedModules.isNotEmpty()) {
|
||||||
|
add("-m"); addAll(embeddedModules)
|
||||||
|
}
|
||||||
|
|
||||||
|
toTypedArray()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun patch(options: Options) {
|
||||||
|
LSPatch(*options.toStringArray()).doCommandLine()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -73,7 +73,7 @@ public class LSPatch {
|
||||||
@Parameter(names = {"--v3"}, arity = 1, description = "Sign with v3 signature")
|
@Parameter(names = {"--v3"}, arity = 1, description = "Sign with v3 signature")
|
||||||
private boolean v3 = true;
|
private boolean v3 = true;
|
||||||
|
|
||||||
@Parameter(names = {"--manager"}, arity = 1, description = "Whether use manager (Cannot be true when has module embedded)")
|
@Parameter(names = {"--manager"}, description = "Use manager (Cannot work with embedding modules)")
|
||||||
private boolean useManager = false;
|
private boolean useManager = false;
|
||||||
|
|
||||||
@Parameter(names = {"-v", "--verbose"}, description = "Verbose output")
|
@Parameter(names = {"-v", "--verbose"}, description = "Verbose output")
|
||||||
|
|
@ -109,14 +109,17 @@ public class LSPatch {
|
||||||
AlignmentRules.constantForSuffix(".bin", 4096)
|
AlignmentRules.constantForSuffix(".bin", 4096)
|
||||||
));
|
));
|
||||||
|
|
||||||
private static JCommander jCommander;
|
private final JCommander jCommander;
|
||||||
|
|
||||||
public static void main(String... args) throws IOException {
|
public LSPatch(String... args) {
|
||||||
LSPatch lsPatch = new LSPatch();
|
|
||||||
jCommander = JCommander.newBuilder()
|
jCommander = JCommander.newBuilder()
|
||||||
.addObject(lsPatch)
|
.addObject(this)
|
||||||
.build();
|
.build();
|
||||||
jCommander.parse(args);
|
jCommander.parse(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String... args) throws IOException {
|
||||||
|
LSPatch lsPatch = new LSPatch(args);
|
||||||
try {
|
try {
|
||||||
lsPatch.doCommandLine();
|
lsPatch.doCommandLine();
|
||||||
} catch (PatchError e) {
|
} catch (PatchError e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue