Add `needRamdisk` and `changeBoot` module flags.

pull/147/head
Fox2Code 2 years ago
parent d35489bcc5
commit 897c99b345

@ -46,9 +46,11 @@ This the manager support these new optional properties
minApi=<int>
maxApi=<int>
minMagisk=<int>
needRamdisk=<boolean>
support=<url>
donate=<url>
config=<package>
changeBoot=<boolean>
```
Note: All urls must start with `https://`, or else will be ignored
Note²: For `minMagisk`, `XX.Y` is parsed as `XXY00`, so you can just put the Magisk version name.
@ -57,10 +59,12 @@ Note²: For `minMagisk`, `XX.Y` is parsed as `XXY00`, so you can just put the Ma
(See: [Codenames, Tags, and Build Numbers](https://source.android.com/setup/start/build-numbers))
- `minMagisk` tell the manager which is the minimum Magisk version required for the module
(Often for magisk `xx.y` the version code is `xxyzz`, `zz` being non `00` on canary builds)
- `needRamdisk` tell the manager the module need boot ramdisk to be installed
- `support` support link to direct users when they need support for you modules
- `donate` donate link to direct users to where they can financially support your project
- `config` package name of the application that configure your module
(Note: The icon won't appear in the module list if the module or target app is not installed)
- `changeBoot` tell the manager the module may change the boot image
Note: Fox's Mmm use fallback
[here](app/src/main/java/com/fox2code/mmm/utils/PropUtils.java#L36)

@ -1,3 +0,0 @@
package com.fox2code.mmm.manager;
parcelable ModuleInfo;

@ -206,6 +206,7 @@ public class AndroidacyRepoData extends RepoData {
} catch (Exception e) {
moduleInfo.minMagisk = 0;
}
moduleInfo.needRamdisk = jsonObject.optBoolean("needRamdisk", false);
moduleInfo.support = filterURL(jsonObject.optString("support"));
moduleInfo.donate = filterURL(jsonObject.optString("donate"));
String config = jsonObject.optString("config", "");

@ -20,6 +20,7 @@ public class InstallerInitializer extends Shell.Initializer {
new File("/system/bin/magisk");
private static String MAGISK_PATH;
private static int MAGISK_VERSION_CODE;
private static boolean HAS_RAMDISK;
public static final int ERROR_OK = 0;
public static final int ERROR_NO_PATH = 1;
@ -44,6 +45,10 @@ public class InstallerInitializer extends Shell.Initializer {
return InstallerInitializer.MAGISK_VERSION_CODE;
}
public static boolean peekHasRamdisk() {
return InstallerInitializer.HAS_RAMDISK;
}
public static void tryGetMagiskPathAsync(Callback callback) {
tryGetMagiskPathAsync(callback, false);
}
@ -90,14 +95,22 @@ public class InstallerInitializer extends Shell.Initializer {
private static String tryGetMagiskPath(boolean forceCheck) {
String MAGISK_PATH = InstallerInitializer.MAGISK_PATH;
int MAGISK_VERSION_CODE;
boolean HAS_RAMDISK = InstallerInitializer.HAS_RAMDISK;
if (MAGISK_PATH != null && !forceCheck) return MAGISK_PATH;
ArrayList<String> output = new ArrayList<>();
if(!Shell.cmd("magisk -V", "magisk --path").to(output).exec().isSuccess()) {
if(!Shell.cmd("if grep ' / ' /proc/mounts | grep -q '/dev/root' &> /dev/null; " +
"then echo true; else echo false; fi", "magisk -V", "magisk --path")
.to(output).exec().isSuccess()) {
if (output.size() != 0) {
HAS_RAMDISK = "false".equals(output.get(0)) ||
"true".equalsIgnoreCase(System.getProperty("ro.build.ab_update"));
}
InstallerInitializer.HAS_RAMDISK = HAS_RAMDISK;
return null;
}
MAGISK_PATH = output.size() < 2 ? "" : output.get(1);
MAGISK_PATH = output.size() < 3 ? "" : output.get(2);
Log.d(TAG, "Magisk runtime path: " + MAGISK_PATH);
MAGISK_VERSION_CODE = Integer.parseInt(output.get(0));
MAGISK_VERSION_CODE = Integer.parseInt(output.get(1));
Log.d(TAG, "Magisk version code: " + MAGISK_VERSION_CODE);
if (MAGISK_VERSION_CODE >= Constants.MAGISK_VER_CODE_FLAT_MODULES &&
MAGISK_VERSION_CODE < Constants.MAGISK_VER_CODE_PATH_SUPPORT &&

@ -27,10 +27,12 @@ public class ModuleInfo {
public String description;
public String updateJson;
// Community meta
public boolean changeBoot;
public String support;
public String donate;
public String config;
// Community restrictions
public boolean needRamdisk;
public int minMagisk;
public int minApi;
public int maxApi;
@ -50,9 +52,11 @@ public class ModuleInfo {
this.author = moduleInfo.author;
this.description = moduleInfo.description;
this.updateJson = moduleInfo.updateJson;
this.changeBoot = moduleInfo.changeBoot;
this.support = moduleInfo.support;
this.donate = moduleInfo.donate;
this.config = moduleInfo.config;
this.needRamdisk = moduleInfo.needRamdisk;
this.minMagisk = moduleInfo.minMagisk;
this.minApi = moduleInfo.minApi;
this.maxApi = moduleInfo.maxApi;

@ -94,7 +94,10 @@ public class ModuleViewListBuilder {
InstallerInitializer.peekMagiskVersion())) ||
// If 64bit only system, skip 32bit only modules
(no32bitSupport && (AppUpdateManager.getFlagsForModule(repoModule.id)
& AppUpdateManager.FLAG_COMPAT_NEED_32BIT) != 0)
& AppUpdateManager.FLAG_COMPAT_NEED_32BIT) != 0) ||
// If module need ramdisk but boot doesn't have one
(repoModule.moduleInfo.needRamdisk &&
!InstallerInitializer.peekHasRamdisk())
) continue; // Skip adding incompatible modules
ModuleHolder moduleHolder = this.mappedModuleHolders.get(repoModule.id);
if (moduleHolder == null) {

@ -192,6 +192,9 @@ public class PropUtils {
moduleInfo.updateJson = value;
readUpdateJson = true;
break;
case "changeBoot":
moduleInfo.changeBoot = Boolean.parseBoolean(value);
break;
case "support":
// Do not accept invalid or too broad support links
if (isInvalidURL(value) ||
@ -207,6 +210,9 @@ public class PropUtils {
case "config":
moduleInfo.config = value;
break;
case "needRamdisk":
moduleInfo.needRamdisk = Boolean.parseBoolean(value);
break;
case "minMagisk":
try {
int i = value.indexOf('.');

Loading…
Cancel
Save