Open parasitic manager through WebUI

Open the parasitic manager using WebUI of KernelSU / APtach.
In the future the web page could become an alternative manager,
without parasitic manager at all.

See https://github.com/mywalkb/LSPosed_mod/issues/65 for details.

Co-authored-by: mywalk <66966897+mywalkb@users.noreply.github.com>
This commit is contained in:
JingMatrix 2024-08-26 15:45:50 +02:00
parent 201af3f165
commit f8409ad34b
5 changed files with 87 additions and 4 deletions

View File

@ -64,14 +64,16 @@ jobs:
with:
gradle-home-cache-cleanup: true
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Setup ninja
uses: seanmiddleditch/gha-setup-ninja@master
with:
version: 1.12.0
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:

View File

@ -126,6 +126,46 @@ val zipAll = task("zipAll") {
group = "LSPosed"
}
val generateWebRoot = tasks.register<Copy>("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", "pnpm")
isIgnoreExitValue = true
}.exitValue == 0
} else {
exec {
commandLine("which", "pnpm")
isIgnoreExitValue = true
}.exitValue == 0
}
}
doFirst {
webroottmp.mkdirs()
webrootsrc.mkdirs()
}
from("$projectDir/src/webroot")
into(webrootsrc)
doLast {
exec {
workingDir = webroottmp
commandLine("pnpm", "add", "-D", "parcel-bundler", "kernelsu")
}
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()
@ -145,7 +185,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")
@ -218,6 +259,14 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
from(dexOutPath)
rename("classes.dex", "lspd.dex")
}
into("webroot") {
if (flavorLowered.startsWith("zygisk")) {
from("$projectDir/build/intermediates/generateWebRoot/dist") {
include("**/*.js")
include("**/*.html")
}
}
}
val injected = objects.newInstance<Injected>(magiskDir.get().asFile.path)
doLast {

View File

@ -90,7 +90,18 @@ rm -f /data/adb/lspd/manager.apk
extract "$ZIPFILE" 'manager.apk' "$MODPATH"
if [ "$FLAVOR" == "zygisk" ]; then
# extract for KernelSU and APatch
if [ "$KSU" ] || [ "$APATCH" ]; then
# 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
fi
mkdir -p "$MODPATH/zygisk"
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"

View File

@ -0,0 +1,9 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>JingMatrix/LSPosed</title>
<script src="index.js"></script>
</head>
<body></body>
</html>

View File

@ -0,0 +1,12 @@
import { exec } from "kernelsu";
import { toast } from "kernelsu";
async function open_manager() {
toast("LSPosed Manager starting...");
const { errno, stdout, stderr } = await exec(
"am start -c org.lsposed.manager.LAUNCH_MANAGER com.android.shell/.BugreportWarningActivity",
{ cwd: "/system" }
);
}
open_manager();