1) 下载源码
git clone git@gitee.com:MayuriNFC/Magisk.git
使用国内镜像站
2) 切换标签:
git checkout v22.0
3)下载/更新依赖
git submodule init
git sumodule update
4)下载对应ndk(自动下载出错了,用了手动下载),
wget -c 'https://dl.google.com/android/repository/android-ndk-r21d-linux-x86_64.zip'
用其它版本可能会报错,还是指定版本好
def setup_ndk(args):
os_name = platform.system().lower()
ndk_ver = config['ndkVersion']
url = f'https://dl.google.com/android/repository/android-ndk-r{ndk_ver}-{os_name}-x86_64.zip'
5)修改gradle源:(两处都改了)
./build.gradle.kts
diff --git a/build.gradle.kts b/build.gradle.kts
index 8e33c5517..f78f86ef0 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -9,8 +9,12 @@ plugins {
buildscript {
repositories {
+ //add aliyun
+ maven { url =uri("http://maven.aliyun.com/nexus/content/groups/public/") }
+ maven {url =uri("https://developer.huawei.com/repo/")}
+ jcenter { url= uri("http://jcenter.bintray.com/")}
google()
- jcenter()
+ //jcenter()
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
}
@@ -52,8 +56,12 @@ fun Task.applyOptimize() = doLast {
subprojects {
repositories {
+ //add aliyun
+ maven { url =uri("http://maven.aliyun.com/nexus/content/groups/public/") }
+ maven {url =uri("https://developer.huawei.com/repo/")}
+ jcenter { url= uri("http://jcenter.bintray.com/")}
google()
- jcenter()
+ //jcenter()
maven { url = uri("https://jitpack.io") }
maven { url = uri("http://oss.sonatype.org/content/repositories/snapshots") }
}
6)修改app包名(防检测)
--- a/native/jni/include/magisk.hpp
+++ b/native/jni/include/magisk.hpp
@@ -3,7 +3,8 @@
#include <string>
#define MAIN_SOCKET "d30138f2310a9fb9c54a3e0c21f58591"
-#define JAVA_PACKAGE_NAME "com.topjohnwu.magisk"
+// #define JAVA_PACKAGE_NAME "com.topjohnwu.magisk"
+#define JAVA_PACKAGE_NAME "com.xxx.xxx"
#define LOGFILE "/cache/magisk.log"
#define UNBLOCKFILE "/dev/.magisk_unblock"
:
diff --git a/native/jni/include/magisk.hpp b/native/jni/include/magisk.hpp
index f954f10ef..4bfbf28fd 100644
--- a/native/jni/include/magisk.hpp
+++ b/native/jni/include/magisk.hpp
@@ -3,7 +3,8 @@
#include <string>
#define MAIN_SOCKET "d30138f2310a9fb9c54a3e0c21f58591"
-#define JAVA_PACKAGE_NAME "com.topjohnwu.magisk"
+#define JAVA_PACKAGE_NAME "com.xxx.xxx"
#define LOGFILE "/cache/magisk.log"
#define UNBLOCKFILE "/dev/.magisk_unblock"
#define SECURE_DIR "/data/adb"
:
diff --git a/native/jni/include/magisk.hpp b/native/jni/include/magisk.hpp
index f954f10ef..4bfbf28fd 100644
--- a/native/jni/include/magisk.hpp
+++ b/native/jni/include/magisk.hpp
@@ -3,7 +3,8 @@
#include <string>
#define MAIN_SOCKET "d30138f2310a9fb9c54a3e0c21f58591"
-#define JAVA_PACKAGE_NAME "com.topjohnwu.magisk"
+#define JAVA_PACKAGE_NAME "com.xxx.xxx"
#define LOGFILE "/cache/magisk.log"
#define UNBLOCKFILE "/dev/.magisk_unblock"
#define SECURE_DIR "/data/adb"
diff --git a/native/jni/su/connect.cpp b/native/jni/su/connect.cpp
index 542b196a0..357351c19 100644
--- a/native/jni/su/connect.cpp
+++ b/native/jni/su/connect.cpp
@@ -145,7 +145,8 @@ static void exec_cmd(const char *action, vector<Extra> &data,
// Finally, fallback to start activity with component name
args[4] = "-n";
- sprintf(target, "%s/.ui.surequest.SuRequestActivity", info->str[SU_MANAGER].data());
+ // sprintf(target, "%s/.ui.surequest.SuRequestActivity", info->str[SU_MANAGER].data());
+ sprintf(target, "%s/com.topjohnwu.magisk.ui.surequest.ui.surequest.SuRequestActivity", info->str[SU_MANAGER].data());
exec.fd = -2;
exec.fork = fork_dont_care;
exec_command(exec);
7) 编译./build.py app
小米5s- android6.1 验证通过, 可以某个厂商检测