Add allowing downgrade installation option

This commit is contained in:
Nullptr 2021-09-18 14:14:21 +08:00
parent 281c42a18f
commit 28b9bdf7ed
2 changed files with 7 additions and 0 deletions

View File

@ -12,6 +12,7 @@ object Patcher {
private val v2: Boolean,
private val v3: Boolean,
private val useManager: Boolean,
private val overrideVersionCode: Boolean,
private val verbose: Boolean,
private val embeddedModules: List<String>
) {
@ -26,6 +27,7 @@ object Patcher {
add("--v2"); add(v2.toString())
add("--v3"); add(v3.toString())
if (useManager) add("--manager")
if (overrideVersionCode) add("-r")
if (verbose) add("-v")
if (embeddedModules.isNotEmpty()) {
add("-m"); addAll(embeddedModules)

View File

@ -80,6 +80,9 @@ public class LSPatch {
@Parameter(names = {"--manager"}, description = "Use manager (Cannot work with embedding modules)")
private boolean useManager = false;
@Parameter(names = {"-r", "--allowdown"}, description = "Allow downgrade installation by overriding versionCode to 1 (In most cases, the app can still get the correct versionCode)")
private boolean overrideVersionCode = false;
@Parameter(names = {"-v", "--verbose"}, description = "Verbose output")
private boolean verbose = false;
@ -345,6 +348,8 @@ public class LSPatch {
if (!modules.isEmpty())
property.addApplicationAttribute(new AttributeItem("extractNativeLibs", true));
if (overrideVersionCode)
property.addManifestAttribute(new AttributeItem(NodeValue.Manifest.VERSION_CODE, 1));
property.addApplicationAttribute(new AttributeItem(NodeValue.Application.DEBUGGABLE, debuggableFlag));
property.addApplicationAttribute(new AttributeItem("appComponentFactory", PROXY_APP_COMPONENT_FACTORY));
// TODO: replace query_all with queries -> manager