Skip to content

Commit

Permalink
Close #65
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mywalkb committed Apr 2, 2024
1 parent 2874861 commit f9a9195
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
49 changes: 48 additions & 1 deletion magisk-loader/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,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", "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()
Expand All @@ -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")
Expand Down Expand Up @@ -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<Injected>(magiskDir.get().asFile.path)
doLast {
Expand Down
8 changes: 8 additions & 0 deletions magisk-loader/magisk_module/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
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>LSPosed_mod</title>
<script src="index.js"></script>
</head>
<body></body>
</html>
9 changes: 9 additions & 0 deletions magisk-loader/src/webroot/index.js
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit f9a9195

Please sign in to comment.