diff --git a/magisk-loader/build.gradle.kts b/magisk-loader/build.gradle.kts index 12ba07a25..b8de965ed 100644 --- a/magisk-loader/build.gradle.kts +++ b/magisk-loader/build.gradle.kts @@ -128,6 +128,46 @@ val zipAll = task("zipAll") { group = "LSPosed" } +val generateWebRoot = tasks.register("generateWebRoot") { + group = "LSPosed" + val webroottmp = File("$projectDir/build/intermediates/generateWebRoot") + val webrootsrc = File(webroottmp, "src") + + onlyIf { + val os = org.gradle.internal.os.OperatingSystem.current() + if (os.isWindows) { + exec { + commandLine("cmd", "/c", "where", "yarn") + isIgnoreExitValue = true + }.exitValue == 0 + } else { + exec { + commandLine("which", "yarn") + isIgnoreExitValue = true + }.exitValue == 0 + } + } + + doFirst { + webroottmp.mkdirs() + webrootsrc.mkdirs() + } + + from("$projectDir/src/webroot") + into(webrootsrc) + + doLast { + exec { + workingDir = webroottmp + commandLine("yarn", "add", "parcel-bundler", "kernelsu", "--dev") + } + exec { + workingDir = webroottmp + commandLine("./node_modules/.bin/parcel", "build", "src/index.html") + } + } +} + fun afterEval() = android.applicationVariants.forEach { variant -> val variantCapped = variant.name.replaceFirstChar { it.uppercase() } val variantLowered = variant.name.lowercase() @@ -147,7 +187,8 @@ fun afterEval() = android.applicationVariants.forEach { variant -> "assemble$variantCapped", ":app:package$buildTypeCapped", ":daemon:package$buildTypeCapped", - ":dex2oat:externalNativeBuild${buildTypeCapped}" + ":dex2oat:externalNativeBuild${buildTypeCapped}", + generateWebRoot ) into(magiskDir) from("${rootProject.projectDir}/README.md") @@ -219,6 +260,12 @@ fun afterEval() = android.applicationVariants.forEach { variant -> from(dexOutPath) rename("classes.dex", "lspd.dex") } + into("webroot") { + from("$projectDir/build/intermediates/generateWebRoot/dist") { + include("**/*.js") + include("**/*.html") + } + } val injected = objects.newInstance(magiskDir.get().asFile.path) doLast { diff --git a/magisk-loader/magisk_module/customize.sh b/magisk-loader/magisk_module/customize.sh index 75067f9ea..75758b5d8 100644 --- a/magisk-loader/magisk_module/customize.sh +++ b/magisk-loader/magisk_module/customize.sh @@ -93,6 +93,14 @@ extract "$ZIPFILE" 'cli' '/data/adb/lspd/bin' if [ "$FLAVOR" == "zygisk" ]; then mkdir -p "$MODPATH/zygisk" + + # webroot only for zygisk + mkdir -p "$MODPATH/webroot" + extract "$ZIPFILE" "webroot/index.html" "$MODPATH/webroot" true + # evaluate if use awk or tr -s ' ' | cut -d' ' -f5 + SRCJS=$(unzip -l "$ZIPFILE" | grep "webroot/src" | grep -v sha256 | awk '{print $4}') + extract "$ZIPFILE" "$SRCJS" "$MODPATH/webroot" true + if [ "$ARCH" = "arm" ] || [ "$ARCH" = "arm64" ]; then extract "$ZIPFILE" "lib/armeabi-v7a/liblspd.so" "$MODPATH/zygisk" true mv "$MODPATH/zygisk/liblspd.so" "$MODPATH/zygisk/armeabi-v7a.so" diff --git a/magisk-loader/src/webroot/index.html b/magisk-loader/src/webroot/index.html new file mode 100644 index 000000000..e55daef9f --- /dev/null +++ b/magisk-loader/src/webroot/index.html @@ -0,0 +1,9 @@ + + + + + LSPosed_mod + + + + diff --git a/magisk-loader/src/webroot/index.js b/magisk-loader/src/webroot/index.js new file mode 100644 index 000000000..8c068bb63 --- /dev/null +++ b/magisk-loader/src/webroot/index.js @@ -0,0 +1,9 @@ +import { exec } from 'kernelsu'; +import { toast } from 'kernelsu'; + +async function open_manager() { + toast('LSPosed_mod Manager starting...'); + const { errno, stdout, stderr } = await exec('am start -c org.lsposed.manager.LAUNCH_MANAGER com.android.shell/.BugreportWarningActivity', { cwd: '/system' }); +} + +open_manager();