Skip to content

Commit f9a9195

Browse files
committed
Close #65
Idea of ManyullynSword. From KernelSU using WebUI the parasitic manager can be opened when opening the web page. In the future the web page could become an alternative manager, without parasitic and without installation.
1 parent 2874861 commit f9a9195

File tree

4 files changed

+74
-1
lines changed

4 files changed

+74
-1
lines changed

magisk-loader/build.gradle.kts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,46 @@ val zipAll = task("zipAll") {
128128
group = "LSPosed"
129129
}
130130

131+
val generateWebRoot = tasks.register<Copy>("generateWebRoot") {
132+
group = "LSPosed"
133+
val webroottmp = File("$projectDir/build/intermediates/generateWebRoot")
134+
val webrootsrc = File(webroottmp, "src")
135+
136+
onlyIf {
137+
val os = org.gradle.internal.os.OperatingSystem.current()
138+
if (os.isWindows) {
139+
exec {
140+
commandLine("cmd", "/c", "where", "yarn")
141+
isIgnoreExitValue = true
142+
}.exitValue == 0
143+
} else {
144+
exec {
145+
commandLine("which", "yarn")
146+
isIgnoreExitValue = true
147+
}.exitValue == 0
148+
}
149+
}
150+
151+
doFirst {
152+
webroottmp.mkdirs()
153+
webrootsrc.mkdirs()
154+
}
155+
156+
from("$projectDir/src/webroot")
157+
into(webrootsrc)
158+
159+
doLast {
160+
exec {
161+
workingDir = webroottmp
162+
commandLine("yarn", "add", "parcel-bundler", "kernelsu", "--dev")
163+
}
164+
exec {
165+
workingDir = webroottmp
166+
commandLine("./node_modules/.bin/parcel", "build", "src/index.html")
167+
}
168+
}
169+
}
170+
131171
fun afterEval() = android.applicationVariants.forEach { variant ->
132172
val variantCapped = variant.name.replaceFirstChar { it.uppercase() }
133173
val variantLowered = variant.name.lowercase()
@@ -147,7 +187,8 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
147187
"assemble$variantCapped",
148188
":app:package$buildTypeCapped",
149189
":daemon:package$buildTypeCapped",
150-
":dex2oat:externalNativeBuild${buildTypeCapped}"
190+
":dex2oat:externalNativeBuild${buildTypeCapped}",
191+
generateWebRoot
151192
)
152193
into(magiskDir)
153194
from("${rootProject.projectDir}/README.md")
@@ -219,6 +260,12 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
219260
from(dexOutPath)
220261
rename("classes.dex", "lspd.dex")
221262
}
263+
into("webroot") {
264+
from("$projectDir/build/intermediates/generateWebRoot/dist") {
265+
include("**/*.js")
266+
include("**/*.html")
267+
}
268+
}
222269

223270
val injected = objects.newInstance<Injected>(magiskDir.get().asFile.path)
224271
doLast {

magisk-loader/magisk_module/customize.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ extract "$ZIPFILE" 'cli' '/data/adb/lspd/bin'
9393

9494
if [ "$FLAVOR" == "zygisk" ]; then
9595
mkdir -p "$MODPATH/zygisk"
96+
97+
# webroot only for zygisk
98+
mkdir -p "$MODPATH/webroot"
99+
extract "$ZIPFILE" "webroot/index.html" "$MODPATH/webroot" true
100+
# evaluate if use awk or tr -s ' ' | cut -d' ' -f5
101+
SRCJS=$(unzip -l "$ZIPFILE" | grep "webroot/src" | grep -v sha256 | awk '{print $4}')
102+
extract "$ZIPFILE" "$SRCJS" "$MODPATH/webroot" true
103+
96104
if [ "$ARCH" = "arm" ] || [ "$ARCH" = "arm64" ]; then
97105
extract "$ZIPFILE" "lib/armeabi-v7a/liblspd.so" "$MODPATH/zygisk" true
98106
mv "$MODPATH/zygisk/liblspd.so" "$MODPATH/zygisk/armeabi-v7a.so"

magisk-loader/src/webroot/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8"/>
5+
<title>LSPosed_mod</title>
6+
<script src="index.js"></script>
7+
</head>
8+
<body></body>
9+
</html>

magisk-loader/src/webroot/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { exec } from 'kernelsu';
2+
import { toast } from 'kernelsu';
3+
4+
async function open_manager() {
5+
toast('LSPosed_mod Manager starting...');
6+
const { errno, stdout, stderr } = await exec('am start -c org.lsposed.manager.LAUNCH_MANAGER com.android.shell/.BugreportWarningActivity', { cwd: '/system' });
7+
}
8+
9+
open_manager();

0 commit comments

Comments
 (0)