Skip to content

Commit

Permalink
Open parasitic manager through WebUI
Browse files Browse the repository at this point in the history
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 mywalkb/LSPosed_mod#65 for details.

Co-authored-by: mywalk <66966897+mywalkb@users.noreply.github.com>
  • Loading branch information
JingMatrix and mywalkb committed Aug 30, 2024
1 parent 33eb12d commit 373e43b
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 4 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
51 changes: 50 additions & 1 deletion magisk-loader/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions magisk-loader/magisk_module/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 9 additions & 0 deletions magisk-loader/src/webroot/index.html
Original file line number Diff line number Diff line change
@@ -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>
12 changes: 12 additions & 0 deletions magisk-loader/src/webroot/index.js
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit 373e43b

Please sign in to comment.