Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 897c99b

Browse files
committed
Add needRamdisk and changeBoot module flags.
1 parent d35489b commit 897c99b

File tree

7 files changed

+35
-7
lines changed

7 files changed

+35
-7
lines changed

DEVELOPERS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ This the manager support these new optional properties
4646
minApi=<int>
4747
maxApi=<int>
4848
minMagisk=<int>
49+
needRamdisk=<boolean>
4950
support=<url>
5051
donate=<url>
5152
config=<package>
53+
changeBoot=<boolean>
5254
```
5355
Note: All urls must start with `https://`, or else will be ignored
5456
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
5759
(See: [Codenames, Tags, and Build Numbers](https://source.android.com/setup/start/build-numbers))
5860
- `minMagisk` tell the manager which is the minimum Magisk version required for the module
5961
(Often for magisk `xx.y` the version code is `xxyzz`, `zz` being non `00` on canary builds)
62+
- `needRamdisk` tell the manager the module need boot ramdisk to be installed
6063
- `support` support link to direct users when they need support for you modules
6164
- `donate` donate link to direct users to where they can financially support your project
6265
- `config` package name of the application that configure your module
6366
(Note: The icon won't appear in the module list if the module or target app is not installed)
67+
- `changeBoot` tell the manager the module may change the boot image
6468

6569
Note: Fox's Mmm use fallback
6670
[here](app/src/main/java/com/fox2code/mmm/utils/PropUtils.java#L36)

app/src/main/aidl/com/fox2code/mmm/manager/ModuleInfo.aidl

Lines changed: 0 additions & 3 deletions
This file was deleted.

app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ protected List<RepoModule> populate(JSONObject jsonObject) throws JSONException
206206
} catch (Exception e) {
207207
moduleInfo.minMagisk = 0;
208208
}
209+
moduleInfo.needRamdisk = jsonObject.optBoolean("needRamdisk", false);
209210
moduleInfo.support = filterURL(jsonObject.optString("support"));
210211
moduleInfo.donate = filterURL(jsonObject.optString("donate"));
211212
String config = jsonObject.optString("config", "");

app/src/main/java/com/fox2code/mmm/installer/InstallerInitializer.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class InstallerInitializer extends Shell.Initializer {
2020
new File("/system/bin/magisk");
2121
private static String MAGISK_PATH;
2222
private static int MAGISK_VERSION_CODE;
23+
private static boolean HAS_RAMDISK;
2324

2425
public static final int ERROR_OK = 0;
2526
public static final int ERROR_NO_PATH = 1;
@@ -44,6 +45,10 @@ public static int peekMagiskVersion() {
4445
return InstallerInitializer.MAGISK_VERSION_CODE;
4546
}
4647

48+
public static boolean peekHasRamdisk() {
49+
return InstallerInitializer.HAS_RAMDISK;
50+
}
51+
4752
public static void tryGetMagiskPathAsync(Callback callback) {
4853
tryGetMagiskPathAsync(callback, false);
4954
}
@@ -90,14 +95,22 @@ public void run() {
9095
private static String tryGetMagiskPath(boolean forceCheck) {
9196
String MAGISK_PATH = InstallerInitializer.MAGISK_PATH;
9297
int MAGISK_VERSION_CODE;
98+
boolean HAS_RAMDISK = InstallerInitializer.HAS_RAMDISK;
9399
if (MAGISK_PATH != null && !forceCheck) return MAGISK_PATH;
94100
ArrayList<String> output = new ArrayList<>();
95-
if(!Shell.cmd("magisk -V", "magisk --path").to(output).exec().isSuccess()) {
101+
if(!Shell.cmd("if grep ' / ' /proc/mounts | grep -q '/dev/root' &> /dev/null; " +
102+
"then echo true; else echo false; fi", "magisk -V", "magisk --path")
103+
.to(output).exec().isSuccess()) {
104+
if (output.size() != 0) {
105+
HAS_RAMDISK = "false".equals(output.get(0)) ||
106+
"true".equalsIgnoreCase(System.getProperty("ro.build.ab_update"));
107+
}
108+
InstallerInitializer.HAS_RAMDISK = HAS_RAMDISK;
96109
return null;
97110
}
98-
MAGISK_PATH = output.size() < 2 ? "" : output.get(1);
111+
MAGISK_PATH = output.size() < 3 ? "" : output.get(2);
99112
Log.d(TAG, "Magisk runtime path: " + MAGISK_PATH);
100-
MAGISK_VERSION_CODE = Integer.parseInt(output.get(0));
113+
MAGISK_VERSION_CODE = Integer.parseInt(output.get(1));
101114
Log.d(TAG, "Magisk version code: " + MAGISK_VERSION_CODE);
102115
if (MAGISK_VERSION_CODE >= Constants.MAGISK_VER_CODE_FLAT_MODULES &&
103116
MAGISK_VERSION_CODE < Constants.MAGISK_VER_CODE_PATH_SUPPORT &&

app/src/main/java/com/fox2code/mmm/manager/ModuleInfo.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ public class ModuleInfo {
2727
public String description;
2828
public String updateJson;
2929
// Community meta
30+
public boolean changeBoot;
3031
public String support;
3132
public String donate;
3233
public String config;
3334
// Community restrictions
35+
public boolean needRamdisk;
3436
public int minMagisk;
3537
public int minApi;
3638
public int maxApi;
@@ -50,9 +52,11 @@ public ModuleInfo(ModuleInfo moduleInfo) {
5052
this.author = moduleInfo.author;
5153
this.description = moduleInfo.description;
5254
this.updateJson = moduleInfo.updateJson;
55+
this.changeBoot = moduleInfo.changeBoot;
5356
this.support = moduleInfo.support;
5457
this.donate = moduleInfo.donate;
5558
this.config = moduleInfo.config;
59+
this.needRamdisk = moduleInfo.needRamdisk;
5660
this.minMagisk = moduleInfo.minMagisk;
5761
this.minApi = moduleInfo.minApi;
5862
this.maxApi = moduleInfo.maxApi;

app/src/main/java/com/fox2code/mmm/module/ModuleViewListBuilder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ public void appendRemoteModules() {
9494
InstallerInitializer.peekMagiskVersion())) ||
9595
// If 64bit only system, skip 32bit only modules
9696
(no32bitSupport && (AppUpdateManager.getFlagsForModule(repoModule.id)
97-
& AppUpdateManager.FLAG_COMPAT_NEED_32BIT) != 0)
97+
& AppUpdateManager.FLAG_COMPAT_NEED_32BIT) != 0) ||
98+
// If module need ramdisk but boot doesn't have one
99+
(repoModule.moduleInfo.needRamdisk &&
100+
!InstallerInitializer.peekHasRamdisk())
98101
) continue; // Skip adding incompatible modules
99102
ModuleHolder moduleHolder = this.mappedModuleHolders.get(repoModule.id);
100103
if (moduleHolder == null) {

app/src/main/java/com/fox2code/mmm/utils/PropUtils.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ public static void readProperties(ModuleInfo moduleInfo, InputStream inputStream
192192
moduleInfo.updateJson = value;
193193
readUpdateJson = true;
194194
break;
195+
case "changeBoot":
196+
moduleInfo.changeBoot = Boolean.parseBoolean(value);
197+
break;
195198
case "support":
196199
// Do not accept invalid or too broad support links
197200
if (isInvalidURL(value) ||
@@ -207,6 +210,9 @@ public static void readProperties(ModuleInfo moduleInfo, InputStream inputStream
207210
case "config":
208211
moduleInfo.config = value;
209212
break;
213+
case "needRamdisk":
214+
moduleInfo.needRamdisk = Boolean.parseBoolean(value);
215+
break;
210216
case "minMagisk":
211217
try {
212218
int i = value.indexOf('.');

0 commit comments

Comments
 (0)