Skip to content

Commit

Permalink
update to magisk 25.2
Browse files Browse the repository at this point in the history
  • Loading branch information
wuxianlin committed Oct 29, 2022
1 parent 2fc499e commit aa744fc
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 47 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
path: Magisk
repository: topjohnwu/Magisk
ref: f822ca5b23bea0a1b7a6e97841e253398e79fb8e
ref: 6066b5cf86703512451a021cf1aaf1a877530af7
submodules: 'recursive'
fetch-depth: 0

Expand All @@ -27,7 +27,7 @@ jobs:
with:
path: libsu
repository: topjohnwu/libsu
ref: fb87c2464d127a5eaef5216792dd05cd8ef6123c
ref: 9aa478c054d8d53b66b4401cb60e7139d46ede49
fetch-depth: 0

- name: Set up JDK 11
Expand All @@ -42,9 +42,9 @@ jobs:

- name: Set up GitHub env
run: |
ndk_ver=$(sed -n 's/^magisk.fullNdkVersion=//p' Magisk/gradle.properties)
ndk_ver=$(sed -n 's/^magisk.ondkVersion=//p' Magisk/gradle.properties)
echo ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT >> $GITHUB_ENV
echo MAGISK_NDK_VERSION=$ndk_ver >> $GITHUB_ENV
echo ONDK_VERSION=$ndk_ver >> $GITHUB_ENV
- name: Set up NDK
run: |
Expand All @@ -59,18 +59,20 @@ jobs:
run: |
cd libsu
./gradlew :core:build
./gradlew :io:build
./gradlew :service:build
./gradlew :nio:build
- name: Copy libsuu libs
run: |
mkdir Magisk/app/libs
cp libsu/io/build/outputs/aar/io-release.aar Magisk/app/libs/
cp libsu/nio/build/outputs/aar/nio-release.aar Magisk/app/libs/
cp libsu/service/build/outputs/aar/service-release.aar Magisk/app/libs/
cp libsu/core/build/outputs/aar/core-release.aar Magisk/app/libs/
- name: Update Magisk Version
run: |
cp Magisk/config.prop.sample Magisk/config.prop
sed -i s/version=string/version=23.0/g Magisk/config.prop
sed -i s/version=string/version=25.2/g Magisk/config.prop
curl -s https://android.googlesource.com/platform/build/+/refs/heads/master/target/product/security/testkey.x509.pem?format=TEXT | base64 -d > testkey.x509.pem
curl -s https://android.googlesource.com/platform/build/+/refs/heads/master/target/product/security/testkey.pk8?format=TEXT | base64 -d > testkey.pk8
openssl pkcs8 -in testkey.pk8 -inform DER -outform PEM -out testkey.priv.pem -nocrypt
Expand Down Expand Up @@ -100,7 +102,8 @@ jobs:

- name: Apply Magisk test Patches
run: |
git -C Magisk apply ../patches/Magisk/mountbind2product.diff
git -C Magisk apply ../patches/Magisk/patch_vivo_do_mount_check.diff
#git -C Magisk apply ../patches/Magisk/mountbind2product.diff
- name: Build Magisk test
run: |
Expand Down
37 changes: 25 additions & 12 deletions patches/Magisk/Magisk-su2suu.diff
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt
index 227a6065..95885d83 100644
index 0c7e64024..71fdb361e 100644
--- a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt
+++ b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt
@@ -193,7 +193,7 @@ open class MainActivity : BaseUIActivity<MainViewModel, ActivityMainMd2Binding>(
@@ -168,7 +168,7 @@ class MainActivity : SplashActivity<ActivityMainMd2Binding>() {
if (!Info.isEmulator && Info.env.isActive && System.getenv("PATH")
?.split(':')
?.filterNot { File("$it/magisk").exists() }
- ?.any { File("$it/su").exists() } == true) {
+ ?.any { File("$it/suu").exists() } == true) {
MagiskDialog(this)
.applyTitle(R.string.unsupport_general_title)
.applyMessage(R.string.unsupport_other_su_msg)
MagiskDialog(this).apply {
setTitle(R.string.unsupport_general_title)
setMessage(R.string.unsupport_other_su_msg)
diff --git a/native/jni/core/applets.cpp b/native/jni/core/applets.cpp
index 8d0d81446..41b8e8b01 100644
--- a/native/jni/core/applets.cpp
+++ b/native/jni/core/applets.cpp
@@ -10,7 +10,7 @@ using namespace std;

using main_fun = int (*)(int, char *[]);

-constexpr const char *applets[] = { "su", "resetprop", "zygisk", nullptr };
+constexpr const char *applets[] = { "suu", "resetprop", "zygisk", nullptr };
static main_fun applet_mains[] = { su_client_main, resetprop_main, zygisk_main, nullptr };

static int call_applet(int argc, char *argv[]) {
diff --git a/native/jni/include/magisk.hpp b/native/jni/include/magisk.hpp
index f954f10e..384a2914 100644
index 466e5f439..4ff87265a 100644
--- a/native/jni/include/magisk.hpp
+++ b/native/jni/include/magisk.hpp
@@ -24,7 +24,7 @@ extern std::string MAGISKTMP;
#define ROOTOVL INTLROOT "/rootdir"
#define ROOTMNT ROOTOVL "/.mount_list"
@@ -28,7 +28,7 @@ extern std::string MAGISKTMP;
#define ZYGISKBIN INTLROOT "/zygisk"
#define SELINUXMOCK INTLROOT "/selinux"

-constexpr const char *applet_names[] = { "su", "resetprop", "magiskhide", nullptr };
+constexpr const char *applet_names[] = { "suu", "resetprop", "magiskhide", nullptr };
constexpr const char *init_applet[] = { "magiskpolicy", "supolicy", nullptr };
-constexpr const char *applet_names[] = { "su", "resetprop", nullptr };
+constexpr const char *applet_names[] = { "suu", "resetprop", nullptr };

#define POST_FS_DATA_WAIT_TIME 40
#define POST_FS_DATA_SCRIPT_MAX_TIME 35
16 changes: 16 additions & 0 deletions patches/Magisk/patch_vivo_do_mount_check.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/scripts/boot_patch.sh b/scripts/boot_patch.sh
index c334e8d84..53766851a 100644
--- a/scripts/boot_patch.sh
+++ b/scripts/boot_patch.sh
@@ -205,6 +205,11 @@ if [ -f kernel ]; then
# After: [mov w2, #-32768]
./magiskboot hexpatch kernel 821B8012 E2FF8F12

+ # patch vivo do_mount_check
+ # /system -> /syswxl
+ # python3 -c "print(hex(int.from_bytes(b'/system', 'big')^int('bdbcbbbab9b8b7', 16)))"
+ ./magiskboot hexpatch kernel 0092CFC2C9CDDDDA00 0092CFC2C9CEC0DB00
+
# Force kernel to load rootfs
# skip_initramfs -> want_initramfs
./magiskboot hexpatch kernel \
26 changes: 15 additions & 11 deletions patches/Magisk/use-local-libsu.diff
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 4c50bed2..64c27c3d 100644
index 71007e627..1880339b8 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -181,7 +181,7 @@ android.applicationVariants.all {
@@ -66,6 +66,8 @@ configurations.all {
}

dependencies {
- implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
+ implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar", "*.aar"))))
implementation(kotlin("stdlib"))
// Some dependencies request JDK 8 stdlib, specify manually here to prevent version mismatch
implementation(kotlin("stdlib-jdk8"))
@@ -208,8 +208,8 @@ dependencies {
implementation("com.caverock:androidsvg:1.4")
+
implementation(project(":app:shared"))

val vLibsu = "3.1.2"
implementation("com.github.topjohnwu:jtar:1.0.0")
@@ -78,10 +80,10 @@ dependencies {
implementation("dev.rikka.rikkax.recyclerview:recyclerview-ktx:1.3.1")
implementation("io.noties.markwon:core:4.6.2")

- val vLibsu = "5.0.2"
- implementation("com.github.topjohnwu.libsu:core:${vLibsu}")
- implementation("com.github.topjohnwu.libsu:io:${vLibsu}")
- implementation("com.github.topjohnwu.libsu:service:${vLibsu}")
- implementation("com.github.topjohnwu.libsu:nio:${vLibsu}")
+ //val vLibsu = "5.0.2"
+ //implementation("com.github.topjohnwu.libsu:core:${vLibsu}")
+ //implementation("com.github.topjohnwu.libsu:io:${vLibsu}")
+ //implementation("com.github.topjohnwu.libsu:service:${vLibsu}")
+ //implementation("com.github.topjohnwu.libsu:nio:${vLibsu}")

val vRetrofit = "2.9.0"
implementation("com.squareup.retrofit2:retrofit:${vRetrofit}")
32 changes: 16 additions & 16 deletions patches/libsu/libsu-su2suu.diff
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
diff --git a/core/src/main/java/com/topjohnwu/superuser/internal/BuilderImpl.java b/core/src/main/java/com/topjohnwu/superuser/internal/BuilderImpl.java
index 90a4dbd..dda4b9c 100644
index ae18065..fff8a79 100644
--- a/core/src/main/java/com/topjohnwu/superuser/internal/BuilderImpl.java
+++ b/core/src/main/java/com/topjohnwu/superuser/internal/BuilderImpl.java
@@ -47,7 +47,7 @@ public class BuilderImpl extends Shell.Builder {
@@ -100,7 +100,7 @@ public final class BuilderImpl extends Shell.Builder {
// Root mount master
if (!hasFlags(FLAG_NON_ROOT_SHELL) && hasFlags(FLAG_MOUNT_MASTER)) {
try {
- shell = build("su", "--mount-master");
+ shell = build("suu", "--mount-master");
if (shell.getStatus() != Shell.ROOT_MOUNT_MASTER)
if (!shell.isRoot())
shell = null;
} catch (NoShellException ignore) {}
@@ -56,7 +56,7 @@ public class BuilderImpl extends Shell.Builder {
@@ -109,7 +109,7 @@ public final class BuilderImpl extends Shell.Builder {
// Normal root shell
if (shell == null && !hasFlags(FLAG_NON_ROOT_SHELL)) {
try {
- shell = build("su");
+ shell = build("suu");
if (shell.getStatus() != ROOT_SHELL)
if (!shell.isRoot()) {
shell = null;
} catch (NoShellException ignore) {}
}
diff --git a/core/src/main/java/com/topjohnwu/superuser/internal/Utils.java b/core/src/main/java/com/topjohnwu/superuser/internal/Utils.java
index 9c08d72..6129b7c 100644
index 1e3575f..7a5a0fb 100644
--- a/core/src/main/java/com/topjohnwu/superuser/internal/Utils.java
+++ b/core/src/main/java/com/topjohnwu/superuser/internal/Utils.java
@@ -34,7 +34,7 @@ import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Collections;

-@RestrictTo(RestrictTo.Scope.LIBRARY)
+//@RestrictTo(RestrictTo.Scope.LIBRARY)
public final class Utils {

@SuppressLint("StaticFieldLeak")
@@ -151,7 +151,7 @@ public final class Utils {
}
// noinspection ConstantConditions
for (String path : System.getenv("PATH").split(":")) {
- File su = new File(path, "su");
+ File su = new File(path, "suu");
if (su.canExecute()) {
// We don't actually know whether the app has been granted root access.
// Do NOT set the value as a confirmed state.

0 comments on commit aa744fc

Please sign in to comment.