From 83a228197dfaed7e65992958edd5ce98c5a554ae Mon Sep 17 00:00:00 2001 From: qiyinxi Date: Sun, 29 Nov 2026 15:09:19 +0100 Subject: [PATCH 1/2] =?UTF-8?q?KernelSU=20=E6=AD=A3=E5=BC=8F=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E9=92=89=E5=80=BC=EF=BC=9A=E7=AE=A1=E7=90=86=E5=99=A8?= =?UTF-8?q?=E9=87=8C=E5=8F=AF=E4=BB=A5=E4=B8=8B=E8=BD=BD=E3=80=81=E5=90=AF?= =?UTF-8?q?=E7=94=A8=20KernelSU=EF=BC=8C=E5=90=AF=E7=94=A8=E5=A4=84?= =?UTF-8?q?=E5=86=99=E6=98=8E=E5=85=B3=E6=9C=BA=E5=8F=98=E6=85=A2=E7=9A=84?= =?UTF-8?q?=E5=B7=B2=E7=9F=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 钉上 ModAVDKernelSU v3.3.1-a14-6.1 附件 kernelsu.ko 的大小 259976 和 SHA-256 309e048b…4557c6。download_available 因此为真:「电脑检查」的 KernelSU 一块和实例菜单的「启用 KernelSU(实验)…」都显示,下载按钮可点,fetch --kernelsu 按钉值下载并核对;导入不是钉值的 kernelsu.ko 时报与固定清单 / 固定值不符,命令行建议 --lkm-sha256,网页建议下载按钮或命令行。没钉值时隐藏入口的行为不变,测试照旧注入测试清单守着;新加的测试守着内置清单的钉值、真实清单下拒收别的模块、显式信任仍可导入、下载请求正式地址并按钉值拒收。 启用对话框和「电脑检查」共用的风险提示加一句已知问题:启用 KernelSU 的实例每次关机多等几秒、下次开机多做一遍磁盘检查,原因还在查,链接到 ModAVD/ModAVD#309;对话框打开时焦点放在「取消」,不落到这个链接上。ksu install 成功后的普通输出和 ksu 的帮助也写这句(--json 不变);components 状态行在可下载时提示 fetch --kernelsu。README 的 KernelSU 一节改成可以直接下载,加「已知问题」两条(#309 关机卸载超时,#311 系统调用变慢)。假数据页面默认改成可下载。 Refs ModAVD/ModAVD#124 --- README.en.md | 7 +- README.md | 7 +- internal/cli/commands.go | 3 +- internal/cli/kernelsu.go | 7 ++ internal/cli/kernelsu_test.go | 17 ++++- internal/components/kernelsu_test.go | 96 ++++++++++++++++++++++++++++ internal/i18n/locales/en/cli.json | 4 +- internal/i18n/locales/en/web.json | 3 +- internal/kernelsu/profile.go | 6 +- internal/ui/web/dev/mock.js | 16 ++--- internal/ui/web/js/diagnostics.js | 14 +++- internal/ui/web/js/kernelsu.js | 6 +- scripts/test_kernelsu_ui.mjs | 17 ++++- 13 files changed, 181 insertions(+), 22 deletions(-) diff --git a/README.en.md b/README.en.md index ab83aa24..cf3ec2db 100644 --- a/README.en.md +++ b/README.en.md @@ -463,9 +463,14 @@ The 4 KiB guest helper in `internal/guest/regional/Regional.java` includes its c Available for supported Windows x86_64 Android 14 API 34 images. Import all five components before enabling an instance. -- After the official [ModAVDKernelSU asset](https://github.com/ModAVD/ModAVDKernelSU/releases) is published, download in System Check or run `modavd components fetch --kernelsu`. Until then the manager does not show KernelSU; once a self-built module is imported with the next command, it appears in System Check and in the instance's More actions. +- Download in System Check or run `modavd components fetch --kernelsu`. The kernel module is the official [ModAVDKernelSU asset](https://github.com/ModAVD/ModAVDKernelSU/releases), checked against a pinned size and SHA-256. - `modavd components import-ksu …`. For a locally built `kernelsu.ko`, add `--lkm-sha256 ` with a digest you have verified. The full kernel release must match. - `modavd ksu install|status|modules`, `modavd ksu module install … [--no-reboot]`, or `modavd ksu module remove [--no-reboot]`. - If boot fails, run `modavd ksu uninstall` to restore stock boot. The guest app and data remain by default. `--purge --yes` removes only managed KernelSU-specific data and the app, leaving the shared module directory intact. Third-party modules run as root inside the guest. Use trusted sources. Once KernelSU is enabled, the guest's existing root traces remain and KernelSU adds more, such as the KernelSU Manager app and its kernel module. Games and apps may detect them, and some games refuse to run or penalize the account. + +Known issues: + +- Once enabled, the instance takes a few extra seconds to shut down each time (`/data` times out unmounting while Android shuts down), and its next start replays the file system journal and runs an extra disk check. No data loss was seen in testing; the cause is still being investigated, see [ModAVD/ModAVD#309](https://github.com/ModAVD/ModAVD/issues/309). +- Once enabled, each system call is about 12–25 % slower; the effect on game frame rates has not been measured yet, see [ModAVD/ModAVD#311](https://github.com/ModAVD/ModAVD/issues/311). diff --git a/README.md b/README.md index ae1bcef0..dd467a34 100644 --- a/README.md +++ b/README.md @@ -466,9 +466,14 @@ go test ./... 仅支持 Windows x86_64 的 Android 14 API 34 受支持镜像。先导入五个组件,再给单个实例启用。 -- [ModAVDKernelSU](https://github.com/ModAVD/ModAVDKernelSU/releases) 的正式附件发布后,可在「电脑检查」下载,或运行 `modavd components fetch --kernelsu`。发布以前,管理器里不显示 KernelSU;用下一条导入自己编的模块以后,「电脑检查」和实例的「更多操作」里才有它。 +- 在「电脑检查」下载,或运行 `modavd components fetch --kernelsu`。内核模块是 [ModAVDKernelSU](https://github.com/ModAVD/ModAVDKernelSU/releases) 的正式附件,按固定的大小和 SHA-256 核对。 - `modavd components import-ksu <文件或文件夹>…`。自编的 `kernelsu.ko` 需要额外传入已核对的 `--lkm-sha256 `,并匹配完整内核版本。 - `modavd ksu install|status|modules`,或 `modavd ksu module install … [--no-reboot]` 和 `modavd ksu module remove [--no-reboot]`。 - 启动异常时用 `modavd ksu uninstall` 恢复原版启动。默认保留客体应用和数据。`--purge --yes` 只清理该功能管理的 KernelSU 专用数据和应用,保留共享模块目录。 第三方模块在客体内以 root 运行,请只使用可信来源。启用以后,客体原有的 root 痕迹还在,还会多出 KernelSU 管理器应用、内核模块等痕迹,游戏和应用可能检测到,有的游戏会因此拒绝运行或处罚账号。 + +已知问题: + +- 启用以后,实例每次关机会多等几秒(安卓关机时 `/data` 卸载超时),下次开机会回放文件系统日志、多做一遍磁盘检查。验证时没有看到丢数据,原因还在查,见 [ModAVD/ModAVD#309](https://github.com/ModAVD/ModAVD/issues/309)。 +- 启用以后,每次系统调用慢约 12–25 %,对游戏帧率的影响还没量,见 [ModAVD/ModAVD#311](https://github.com/ModAVD/ModAVD/issues/311)。 diff --git a/internal/cli/commands.go b/internal/cli/commands.go index 0c84b1f4..0f6d0454 100644 --- a/internal/cli/commands.go +++ b/internal/cli/commands.go @@ -374,7 +374,8 @@ func init() { details: "KernelSU 的五个文件(kernelsu.ko、ksuinit、ksud、KernelSU.apk、meta-overlayfs.zip)要先用 components import-ksu 导入到根目录的 sdk\\kernelsu。" + "install 会为该实例单独生成带 ksuinit 和 kernelsu.ko 的 ramdisk(不改全局系统镜像),冷启动装入 ksud、KernelSU Manager 和 meta-overlayfs,再冷启动一次使其生效。" + "uninstall 移除实例的 KernelSU ramdisk 恢复原版启动(加 --purge --yes 清理受管理的 KernelSU 数据和管理器应用)。" + - "module install 支持一次导入多个 .zip 模块(如 ReZygisk 与 Vector/LSPosed),自动按依赖顺序刷入并冷启动一次生效;加 --no-reboot 可暂不重启。", + "module install 支持一次导入多个 .zip 模块(如 ReZygisk 与 Vector/LSPosed),自动按依赖顺序刷入并冷启动一次生效;加 --no-reboot 可暂不重启。" + + "已知问题:启用以后实例每次关机会多等几秒,下次开机会多做一遍磁盘检查,原因还在查(ModAVD/ModAVD#309)。", flags: []flagSpec{ {name: "yes", kind: kindBool, help: "确认清理 KernelSU 客体数据"}, {name: "purge", kind: kindBool, help: "uninstall 时同时清理受管理的 KernelSU 数据和 KernelSU Manager"}, diff --git a/internal/cli/kernelsu.go b/internal/cli/kernelsu.go index 2acd2d34..a855df41 100644 --- a/internal/cli/kernelsu.go +++ b/internal/cli/kernelsu.go @@ -78,6 +78,9 @@ func kernelSUStateLine(s components.KernelSUStatus) string { case len(missing) < len(s.Files): state = " 不全,缺 " + strings.Join(missing, "、") } + if s.DownloadAvailable { + return "✗ KernelSU" + state + "(可选;用 components fetch --kernelsu 或 components import-ksu <文件或文件夹> 补全)" + } return "✗ KernelSU" + state + "(可选;用 components import-ksu <文件或文件夹> 导入)" } @@ -237,6 +240,10 @@ func formatKernelSUResult(w io.Writer, r *emu.KernelSUResult) { fmt.Fprintf(w, "(%s)", r.Version) } fmt.Fprintln(w) + if r.Installed { + // ModAVD/ModAVD#309: said after every successful install, not a warning of this run (--json unchanged) + fmt.Fprintln(w, "已知问题:启用 KernelSU 的实例每次关机会多等几秒,下次开机会多做一遍磁盘检查;原因还在查,见 https://github.com/ModAVD/ModAVD/issues/309") + } case "uninstall": fmt.Fprintf(w, "实例 %d 已移除 KernelSU\n", r.Index) default: diff --git a/internal/cli/kernelsu_test.go b/internal/cli/kernelsu_test.go index ee5b666c..33e02da2 100644 --- a/internal/cli/kernelsu_test.go +++ b/internal/cli/kernelsu_test.go @@ -84,7 +84,7 @@ func TestComponentsStatusAndImportKernelSU(t *testing.T) { t.Fatalf("exit %d, kernelsu %v", res.code, data["kernelsu"]) } res = h.run(t, nil, "components") - if !strings.Contains(res.stdout, "✗ KernelSU 未安装(可选") { + if !strings.Contains(res.stdout, "✗ KernelSU 未安装(可选") || !strings.Contains(res.stdout, "components fetch --kernelsu") { t.Fatalf("human status missing KernelSU line: %s", res.stdout) } @@ -128,6 +128,21 @@ func TestKernelSUCommands(t *testing.T) { } } + // A successful install says the known shutdown issue (ModAVD/ModAVD#309); --json keeps its shape and warnings. + res := h.run(t, nil, "ksu", "2", "install") + if !strings.Contains(res.stdout, "实例 2 已启用 KernelSU") || !strings.Contains(res.stdout, "已知问题") || + !strings.Contains(res.stdout, "issues/309") || strings.Contains(res.stdout, "警告") { + t.Fatalf("install output: %q", res.stdout) + } + if res := h.run(t, nil, "ksu", "2", "status"); strings.Contains(res.stdout, "已知问题") { + t.Fatalf("status should not repeat the known issue: %q", res.stdout) + } + res = h.run(t, nil, "ksu", "2", "install", "--json") + data := envelope(t, res.stdout)["data"].(map[string]any) + if w, ok := data["warnings"].([]any); !ok || len(w) != 0 || strings.Contains(res.stdout, "已知问题") { + t.Fatalf("install --json: %s", res.stdout) + } + // Bad usage checks if res := h.run(t, nil, "ksu", "2", "install", "--purge"); res.code != 2 { t.Fatalf("expected usage error for install --purge, got %d", res.code) diff --git a/internal/components/kernelsu_test.go b/internal/components/kernelsu_test.go index 0240f479..ee4f7a01 100644 --- a/internal/components/kernelsu_test.go +++ b/internal/components/kernelsu_test.go @@ -173,6 +173,102 @@ func TestKernelSULKMAdvice(t *testing.T) { } } +// TestOfficialKernelSUProfilePinned: the built-in profile pins the official kernelsu.ko (size and SHA-256), so the +// official module can be downloaded and the manager offers KernelSU. +func TestOfficialKernelSUProfilePinned(t *testing.T) { + profile := kernelsu.CurrentProfile() + if !kernelSUDownloadReady(profile) { + t.Fatalf("the built-in KernelSU profile is not downloadable: %+v", profile.Files) + } + lkm := profile.Files[0] + if !lkm.IsLKM || lkm.Size != 259976 || lkm.SHA256 != "309e048bc2aebcfa493c2b43274f4298c9105438c3be48d23be50b93aa4557c6" || + lkm.DownloadURL != kernelsu.OfficialLKMDownloadURL { + t.Fatalf("official LKM pin: %+v", lkm) + } +} + +// TestOfficialKernelSURefusesOtherLKM: with the pin, a kernelsu.ko that is not the official one (here one built for +// the right kernel) is refused as not matching the pin; the command line says --lkm-sha256 trusts a self-built one, +// the page points at its download button and the command, and --lkm-sha256 with the module's digest takes it. +func TestOfficialKernelSURefusesOtherLKM(t *testing.T) { + profile := kernelsu.CurrentProfile() + data := makeSyntheticLKM(profile.KernelRelease + " SMP preempt mod_unload modversions") + ko := filepath.Join(t.TempDir(), "kernelsu.ko") + if err := os.WriteFile(ko, data, 0o644); err != nil { + t.Fatal(err) + } + for _, c := range []struct { + name string + fromPage bool + want []string + }{ + {"command line", false, []string{"--lkm-sha256"}}, + {"page", true, []string{"下载 KernelSU 组件", "modavd components import-ksu", "--lkm-sha256"}}, + } { + _, err := classifyKernelSUImport([]ImportFile{{Path: ko}}, profile, profile.KernelRelease, "", c.fromPage) + if errs.CodeOf(err) != errs.ComponentsRejected { + t.Fatalf("%s: want the module refused, got %v", c.name, err) + } + e := errs.As(err) + if !strings.Contains(e.Message, "固定") { + t.Errorf("%s: message %q should say it does not match the pin", c.name, e.Message) + } + if strings.Contains(e.Advice, "尚未发布") { + t.Errorf("%s: advice %q still says the module is unreleased", c.name, e.Advice) + } + for _, w := range c.want { + if !strings.Contains(e.Advice, w) { + t.Errorf("%s: advice %q lacks %q", c.name, e.Advice, w) + } + } + } + sum := sha256.Sum256(data) + if _, err := classifyKernelSUImport([]ImportFile{{Path: ko}}, profile, profile.KernelRelease, hex.EncodeToString(sum[:]), false); err != nil { + t.Fatalf("--lkm-sha256 should trust the self-built module: %v", err) + } +} + +// TestFetchKernelSUOfficialChecksPin: with the built-in profile the root offers the download, fetch asks for the +// official kernelsu.ko at its pinned size, and a download that is not that file is refused (no network: a stub). +func TestFetchKernelSUOfficialChecksPin(t *testing.T) { + if runtime.GOOS != "windows" { + t.Skip("KernelSU import is Windows-only") + } + dir := testutil.TempDir(t) + bin := filepath.Join(dir, "sdk", "emulator", root.CurrentPlatform().Emulator) + if err := os.MkdirAll(filepath.Dir(bin), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(bin, []byte("emulator"), 0o644); err != nil { + t.Fatal(err) + } + r, err := root.New(dir) + if err != nil { + t.Fatal(err) + } + st := KernelSUState(r) + if !st.DownloadAvailable || st.Ready || st.Files[0].DownloadURL != kernelsu.OfficialLKMDownloadURL { + t.Fatalf("state with the built-in profile: %+v", st) + } + old := kernelSUDownloadFile + t.Cleanup(func() { kernelSUDownloadFile = old }) + var asked []download.FileOptions + kernelSUDownloadFile = func(_ context.Context, _ *download.Client, opts download.FileOptions) error { + asked = append(asked, opts) + return os.WriteFile(opts.Path, make([]byte, opts.Size), 0o644) // the right size, not the official content + } + _, err = FetchKernelSU(context.Background(), r, Options{}) + if errs.CodeOf(err) != errs.ComponentsRejected || !strings.Contains(errs.As(err).Message, "kernelsu.ko") { + t.Fatalf("a download that is not the official module: %v", err) + } + if len(asked) != 1 || asked[0].URL != kernelsu.OfficialLKMDownloadURL || asked[0].Size != kernelsu.OfficialLKMSize { + t.Fatalf("downloads %+v", asked) + } + if KernelSUState(r).Ready { + t.Fatal("a refused download should leave KernelSU not ready") + } +} + func TestFetchKernelSURequiresMatchingDownloads(t *testing.T) { if runtime.GOOS != "windows" { t.Skip("KernelSU import is Windows-only") diff --git a/internal/i18n/locales/en/cli.json b/internal/i18n/locales/en/cli.json index f9d689d5..730ff494 100644 --- a/internal/i18n/locales/en/cli.json +++ b/internal/i18n/locales/en/cli.json @@ -61,7 +61,7 @@ "Google Play 版镜像的压缩包": "Google Play system image archive", "HTTP 代理": "HTTP proxy", "KernelSU 的五个文件已经齐全、校验无误,没有改动(给的文件也核对过了)": "All five KernelSU files are already present and verified; nothing changed (the given files were also verified)", - "KernelSU 的五个文件(kernelsu.ko、ksuinit、ksud、KernelSU.apk、meta-overlayfs.zip)要先用 components import-ksu 导入到根目录的 sdk\\kernelsu。install 会为该实例单独生成带 ksuinit 和 kernelsu.ko 的 ramdisk(不改全局系统镜像),冷启动装入 ksud、KernelSU Manager 和 meta-overlayfs,再冷启动一次使其生效。uninstall 移除实例的 KernelSU ramdisk 恢复原版启动(加 --purge --yes 清理受管理的 KernelSU 数据和管理器应用)。module install 支持一次导入多个 .zip 模块(如 ReZygisk 与 Vector/LSPosed),自动按依赖顺序刷入并冷启动一次生效;加 --no-reboot 可暂不重启。": "Import the five KernelSU files (kernelsu.ko, ksuinit, ksud, KernelSU.apk, meta-overlayfs.zip) into sdk\\kernelsu first with components import-ksu. install builds a per-instance ramdisk containing ksuinit and kernelsu.ko without touching the global system image, cold boots to install ksud, KernelSU Manager, and meta-overlayfs, then cold boots once more to activate them. uninstall removes the instance's KernelSU ramdisk to restore stock boot (add --purge --yes to remove managed KernelSU data and the manager app). module install accepts multiple .zip modules at once (such as ReZygisk and Vector/LSPosed), installs them in dependency order, and cold boots once; pass --no-reboot to skip the reboot.", + "KernelSU 的五个文件(kernelsu.ko、ksuinit、ksud、KernelSU.apk、meta-overlayfs.zip)要先用 components import-ksu 导入到根目录的 sdk\\kernelsu。install 会为该实例单独生成带 ksuinit 和 kernelsu.ko 的 ramdisk(不改全局系统镜像),冷启动装入 ksud、KernelSU Manager 和 meta-overlayfs,再冷启动一次使其生效。uninstall 移除实例的 KernelSU ramdisk 恢复原版启动(加 --purge --yes 清理受管理的 KernelSU 数据和管理器应用)。module install 支持一次导入多个 .zip 模块(如 ReZygisk 与 Vector/LSPosed),自动按依赖顺序刷入并冷启动一次生效;加 --no-reboot 可暂不重启。已知问题:启用以后实例每次关机会多等几秒,下次开机会多做一遍磁盘检查,原因还在查(ModAVD/ModAVD#309)。": "Import the five KernelSU files (kernelsu.ko, ksuinit, ksud, KernelSU.apk, meta-overlayfs.zip) into sdk\\kernelsu first with components import-ksu. install builds a per-instance ramdisk containing ksuinit and kernelsu.ko without touching the global system image, cold boots to install ksud, KernelSU Manager, and meta-overlayfs, then cold boots once more to activate them. uninstall removes the instance's KernelSU ramdisk to restore stock boot (add --purge --yes to remove managed KernelSU data and the manager app). module install accepts multiple .zip modules at once (such as ReZygisk and Vector/LSPosed), installs them in dependency order, and cold boots once; pass --no-reboot to skip the reboot. Known issue: once enabled, the instance takes a few extra seconds to shut down each time and runs an extra disk check on its next start; the cause is still being investigated (ModAVD/ModAVD#309).", "MCP 服务已就绪,根目录 %s": "MCP server is ready, root folder %s", "Mirror 酱(CDK %v)": "MirrorChyan (CDK %v)", "ModAVD 实例 %d 关机失败: %s": "ModAVD instance %d failed to shut down: %s", @@ -120,6 +120,7 @@ "✓ Google Play 商店": "✓ Google Play Store", "✗ Google Play 商店%v(可选;用 components fetch --play-store 或 components import-playstore <文件> 补全)": "✗ Google Play Store%v (optional; add it with components fetch --play-store or components import-playstore )", "✗ KernelSU%v(可选;用 components import-ksu <文件或文件夹> 导入)": "✗ KernelSU%v (optional; import with components import-ksu )", + "✗ KernelSU%v(可选;用 components fetch --kernelsu 或 components import-ksu <文件或文件夹> 补全)": "✗ KernelSU%v (optional; add it with components fetch --kernelsu or components import-ksu )", "一台实例的状态": "Status of one instance", "一台实例的详细信息": "Details of one instance", "一次新建 N 台(1–9),按编号从小到大一台做完再建下一台;不能和 --index、--resume 一起用": "Create N instances (1–9), one after another in number order; not together with --index or --resume", @@ -225,6 +226,7 @@ "实例 %d 已刷入 %d 个 KernelSU 模块:\n": "Flashed %[2]d KernelSU modules into instance %[1]d:\n", "实例 %d 已卸载 KernelSU 模块:%s\n": "Uninstalled KernelSU module %[2]s from instance %[1]d\n", "实例 %d 已启用 KernelSU": "Enabled KernelSU on instance %d", + "已知问题:启用 KernelSU 的实例每次关机会多等几秒,下次开机会多做一遍磁盘检查;原因还在查,见 https://github.com/ModAVD/ModAVD/issues/309": "Known issue: an instance with KernelSU enabled takes a few extra seconds to shut down each time and runs an extra disk check on its next start; the cause is still being investigated, see https://github.com/ModAVD/ModAVD/issues/309", "实例 %d 已移除 KernelSU\n": "Removed KernelSU from instance %d\n", "实例 %d 已触发磁盘回收(trim)\n": "Instance %d disk reclaim (trim) triggered\n", "实例 %d 执行桥 %s:%s(脚本退出码 %d)\n": "Instance %d execution bridge %s: %s (script exit code %d)\n", diff --git a/internal/i18n/locales/en/web.json b/internal/i18n/locales/en/web.json index 408c0ebe..42f8b0cf 100644 --- a/internal/i18n/locales/en/web.json +++ b/internal/i18n/locales/en/web.json @@ -768,5 +768,6 @@ "模块会以 root 运行。仅导入你信任的第三方代码。": "Modules run as root. Import only third-party code you trust.", "下载 KernelSU 组件": "Download KernelSU components", "正式模块尚未发布": "The official module has not been released", - "游戏和应用可能检测到 root,有的游戏会因此拒绝运行或处罚账号;导入的模块在客体内以 root 运行。启用后开不了机时,先关机,再在实例的「更多操作」里点「移除 KernelSU…」,或运行 modavd ksu <编号> uninstall,恢复原版启动。": "Games and apps may detect root, and some games refuse to run or penalize the account; imported modules run as root in the guest. If the instance no longer starts after enabling, shut it down, then choose \"Remove KernelSU…\" in the instance's More actions menu, or run modavd ksu uninstall, to restore stock boot." + "游戏和应用可能检测到 root,有的游戏会因此拒绝运行或处罚账号;导入的模块在客体内以 root 运行。启用后开不了机时,先关机,再在实例的「更多操作」里点「移除 KernelSU…」,或运行 modavd ksu <编号> uninstall,恢复原版启动。": "Games and apps may detect root, and some games refuse to run or penalize the account; imported modules run as root in the guest. If the instance no longer starts after enabling, shut it down, then choose \"Remove KernelSU…\" in the instance's More actions menu, or run modavd ksu uninstall, to restore stock boot.", + "已知问题:启用 KernelSU 的实例每次关机会多等几秒,下次开机会多做一遍磁盘检查;原因还在查,见 {issue}。": "Known issue: an instance with KernelSU enabled takes a few extra seconds to shut down each time and runs an extra disk check on its next start. The cause is still being investigated; see {issue}." } diff --git a/internal/kernelsu/profile.go b/internal/kernelsu/profile.go index 67a2e1cf..a379c966 100644 --- a/internal/kernelsu/profile.go +++ b/internal/kernelsu/profile.go @@ -14,9 +14,9 @@ const ( ComponentVersion = "3.3.1" KernelVersionCode = "32680" KernelUAPIVersion = "5" - // Set all three values after the verified KernelSU LKM is first attached to a ModAVD Release. - OfficialLKMSize = 0 - OfficialLKMSHA256 = "" + // The official KernelSU LKM attached to the ModAVDKernelSU release below (its CI built it twice, byte-identical). + OfficialLKMSize = 259976 + OfficialLKMSHA256 = "309e048bc2aebcfa493c2b43274f4298c9105438c3be48d23be50b93aa4557c6" OfficialLKMDownloadURL = "https://github.com/ModAVD/ModAVDKernelSU/releases/download/v3.3.1-a14-6.1/a14-api34-6.1_kernelsu-v3.3.1_kernelsu.ko" ) diff --git a/internal/ui/web/dev/mock.js b/internal/ui/web/dev/mock.js index 351030a8..555409d7 100644 --- a/internal/ui/web/dev/mock.js +++ b/internal/ui/web/dev/mock.js @@ -3,8 +3,8 @@ // stays down), offline=1 (it never connects), shotfail=1 (every screenshot answers 500), diag=components-error|components-fail // (component status request or fetch fails), store=download|import (the root has the Google Play Store's five files, // fetched or imported), storefail=1 (an instance's 补全 Google Play 商店 fails in the guest and leaves it partial), -// nogsf=1 (复制 GSF ID finds no ID yet), ksu=none|ready|download (KernelSU's files: the official module not published -// and nothing imported, the default; imported; downloadable). window.__mockShots counts +// nogsf=1 (复制 GSF ID finds no ID yet), ksu=none|ready|download (KernelSU's files: a build without the official +// module and nothing imported; imported; downloadable, the default). window.__mockShots counts // screenshot requests per instance. Never used in production: the server does not serve /dev/. // Screens are drawn on a canvas: abstract shapes only, no real game content. @@ -268,18 +268,18 @@ function storeStatus() { files: STORE_FILES.map(([name, guest, size]) => ({ name, guest, size, present: s.ready })) }; } -// ---- KernelSU (实验): the root's five files (GET /api/components kernelsu). db.ksu (?ksu=): none (the default: the -// official module not published, nothing imported), ready (imported from the command line), download (the official -// module published, not downloaded yet). -const KSU_FILES = [['kernelsu.ko', 0, true], ['ksuinit', 658968], ['ksud', 5804528], ['KernelSU.apk', 13637206], ['meta-overlayfs.zip', 451415]]; +// ---- KernelSU (实验): the root's five files (GET /api/components kernelsu). db.ksu (?ksu=): download (the default: +// the official module pinned, not downloaded yet), none (a build without the official module, nothing imported), +// ready (downloaded or imported). +const KSU_FILES = [['kernelsu.ko', 259976, true], ['ksuinit', 658968], ['ksud', 5804528], ['KernelSU.apk', 13637206], ['meta-overlayfs.zip', 451415]]; function ksuStatus() { - const k = db.ksu || 'none'; + const k = db.ksu || 'download'; const ready = k === 'ready'; const download = k === 'download'; return { dir: ROOT + '\\sdk\\kernelsu', ready, source: ready ? 'import' : '', version: ready ? '3.3.1' : '', kernel_version: '6.1.23-android14-4-00257-g7e35917775b8-ab9964412', download_available: download, install_supported: true, - files: KSU_FILES.map(([name, size, lkm]) => ({ name, size: lkm && download ? 2097152 : size, present: ready, ...(lkm ? { is_lkm: true } : {}), + files: KSU_FILES.map(([name, size, lkm]) => ({ name, size, present: ready, ...(lkm ? { is_lkm: true } : {}), ...(!lkm || download ? { download_url: `https://github.com/ModAVD/ModAVDKernelSU/releases/download/mock/${name}` } : {}) })) }; } diff --git a/internal/ui/web/js/diagnostics.js b/internal/ui/web/js/diagnostics.js index 534e4b5f..9d7efac0 100644 --- a/internal/ui/web/js/diagnostics.js +++ b/internal/ui/web/js/diagnostics.js @@ -1,7 +1,7 @@ // 补全组件: the license dialog (from 电脑检查's 组件 item, the banner and its retry), and 设置 → 组件与问题反馈: // component status, 收集问题信息, 复制配置信息. Everything runs as API jobs; closing a dialog does not stop them. -import { t, comma, stop, gap, colon, paren, cap } from './i18n.js'; +import { t, tNode, comma, stop, gap, colon, paren, cap } from './i18n.js'; import { h, icon, btn, setText, showError, attr } from './dom.js'; import { S, update, subscribe, newestFirst } from './store.js'; import { api } from './api.js'; @@ -130,6 +130,16 @@ export async function importKernelSU(files) { // kernelsu.js): games may notice the root, and the way back when the instance no longer boots (the instance's // 移除 KernelSU, or `modavd ksu uninstall`: back to the stock ramdisk, apps and data kept). export const KSU_RISK = t('游戏和应用可能检测到 root,有的游戏会因此拒绝运行或处罚账号;导入的模块在客体内以 root 运行。启用后开不了机时,先关机,再在实例的「更多操作」里点「移除 KernelSU…」,或运行 modavd ksu <编号> uninstall,恢复原版启动。'); +// The known issue said with it (ModAVD/ModAVD#309: with kernelsu.ko loaded, /data does not unmount in time at shutdown). +export const KSU_KNOWN = t('已知问题:启用 KernelSU 的实例每次关机会多等几秒,下次开机会多做一遍磁盘检查;原因还在查,见 {issue}。'); +const KSU_ISSUE = 'https://github.com/ModAVD/ModAVD/issues/309'; + +// The warning box with both, for this block and the question before 启用. +export function ksuRiskNote() { + const issue = h('a', { href: KSU_ISSUE, target: '_blank', rel: 'noopener noreferrer', text: 'ModAVD/ModAVD#309' }); + return h('div', { class: 'note-box tone-warn' }, icon('alert'), + h('span', {}, KSU_RISK, h('br'), tNode(KSU_KNOWN, { issue }))); +} export function ksuBox() { const b = { sig: null }; @@ -154,7 +164,7 @@ export function ksuBox() { b.err = h('div', { class: 'form-error', role: 'alert', hidden: true }); b.choose = h('div', { class: 'diag-actions' }, b.download, b.own); b.note = h('p', { class: 'store-note' }); - b.risk = h('div', { class: 'note-box tone-warn' }, icon('alert'), h('span', { text: KSU_RISK })); + b.risk = ksuRiskNote(); b.links = h('ul'); b.el = h('section', { class: 'store-box', 'aria-labelledby': 'ksu-box-t', tabindex: '-1' }, h('div', { class: 'store-head' }, h('strong', { id: 'ksu-box-t', text: t('KernelSU 组件(实验)') }), h('span', { class: 'tag', text: t('可选') }), h('span', { class: 'spacer' }), b.pill), diff --git a/internal/ui/web/js/kernelsu.js b/internal/ui/web/js/kernelsu.js index e57f2280..4cb02e04 100644 --- a/internal/ui/web/js/kernelsu.js +++ b/internal/ui/web/js/kernelsu.js @@ -6,7 +6,7 @@ import { api } from './api.js'; import { S, instance } from './store.js'; import { openDialog, toast, toastError } from './ui.js'; import { quoted } from './format.js'; -import { loadDiagnostics, KSU_RISK } from './diagnostics.js'; +import { loadDiagnostics, ksuRiskNote } from './diagnostics.js'; import { openCheck } from './panels.js'; import * as A from './actions.js'; @@ -43,7 +43,7 @@ export async function openKernelSU(i, action) { ? tNode(t('为{who}单独生成带 KernelSU 的 ramdisk(不改全局系统镜像),装入 ksud、KernelSU Manager 和 meta-overlayfs 模块系统。'), { who: h('strong', { text: who }) }) : tNode(t('移除{who}的 KernelSU ramdisk,恢复原版镜像启动。'), { who: h('strong', { text: who }) })), !install && h('label', { class: 'checkbox' }, purgeBox, h('span', { text: t('同时清理管理器安装的 KernelSU 数据和应用(保留共享模块目录)') })), - install && h('div', { class: 'note-box tone-warn' }, icon('alert'), h('span', { text: KSU_RISK })), + install && ksuRiskNote(), h('div', { class: 'note-box tone-info' }, icon('info'), h('span', { text: install ? t('实验功能。首次启用可能先用原版镜像检查客体数据,再冷启动两次以激活 meta-overlayfs。{how}', { how }) @@ -51,6 +51,8 @@ export async function openKernelSU(i, action) { }))); const ctl = openDialog({ title: install ? t('启用 KernelSU?') : t('移除 KernelSU?'), cls: 'dlg-store', form: true, desc, + // 启用: the issue link in the warning is the body's first focusable; start on 取消 instead (Enter does not enable) + focus: install ? '.dlg-foot .btn-ghost' : undefined, body, actions: { ok }, onSubmit() { diff --git a/scripts/test_kernelsu_ui.mjs b/scripts/test_kernelsu_ui.mjs index c37afd8d..1b4964eb 100644 --- a/scripts/test_kernelsu_ui.mjs +++ b/scripts/test_kernelsu_ui.mjs @@ -238,6 +238,20 @@ test('the block says what enabling risks and the way back, and names no module', assert.ok(text.includes(D.KSU_RISK)); }); +test('the block says the known shutdown issue and links it', async () => { + const { b } = await ksuBlock(KSU.download); + const text = b.el.textContent; + assert.match(text, /已知问题/); + assert.match(text, /每次关机会多等几秒/); + assert.match(text, /磁盘检查/); + assert.match(text, /ModAVD\/ModAVD#309/); + assert.doesNotMatch(text, /\{issue\}|不会丢/); + const link = all(b.el).find(x => x.tagName === 'A' && x.getAttribute('href') === 'https://github.com/ModAVD/ModAVD/issues/309'); + assert.ok(link, 'a link to the issue'); + assert.equal(link.textContent, 'ModAVD/ModAVD#309'); + assert.equal(link.getAttribute('target'), '_blank'); +}); + test('下载 KernelSU 组件 can be clicked only when the official module can be downloaded', async () => { const off = await ksuBlock(KSU.ready); assert.equal(off.b.download.disabled, true); @@ -257,7 +271,7 @@ async function kernelsu(ksu) { 'api.js': { api: { get: async () => ({ modules: [] }) } }, 'ui.js': dialogs(r), 'format.js': { quoted: (inst, i) => `「实例 ${i}」` }, - 'diagnostics.js': { loadDiagnostics: async () => { S.components = components(ksu); }, KSU_RISK: '风险说明(替身)' }, + 'diagnostics.js': { loadDiagnostics: async () => { S.components = components(ksu); }, ksuRiskNote: () => h('div', { text: '风险说明(替身)' }) }, 'panels.js': { openCheck: o => r.checks.push(o) }, 'actions.js': { ksuInstall: (i, onErr) => r.posts.push(['install', i, onErr]), ksuUninstall: (i, purge) => r.posts.push(['uninstall', i, purge]) }, }); @@ -273,6 +287,7 @@ test('启用 asks with the risks and the way back; 移除 does not repeat them', const body = k.dialogs[0].options.body.textContent; assert.match(body, /风险说明(替身)/); assert.match(body, /实验功能/); + assert.equal(k.dialogs[0].options.focus, '.dlg-foot .btn-ghost'); // not the issue link in the warning k.dialogs[0].options.onSubmit(); assert.equal(k.posts[0][0], 'install'); await k.open(3, 'uninstall'); From e9f5688942919c14d08f4702cd6cabd038eb9d20 Mon Sep 17 00:00:00 2001 From: qiyinxi Date: Sun, 29 Nov 2026 15:15:10 +0100 Subject: [PATCH 2/2] =?UTF-8?q?KernelSU=20=E5=90=AF=E7=94=A8=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E5=86=99=E6=98=8E=E6=80=A7=E8=83=BD=E4=BC=9A=E9=99=8D?= =?UTF-8?q?=E4=BD=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 启用对话框和「电脑检查」共用的风险提示、ksu install 成功后的普通输出和 ksu 的帮助,在关机变慢那句后面另起一句:启用后系统调用会变慢,这台实例的性能会比不启用时低一些,链接到 ModAVD/ModAVD#311(--json 不变)。README 的已知问题第二条补上量性能、跑分时用没启用 KernelSU 的实例;测试守着新加的这句。 Refs ModAVD/ModAVD#124 Refs ModAVD/ModAVD#311 --- README.en.md | 2 +- README.md | 2 +- internal/cli/commands.go | 3 ++- internal/cli/kernelsu.go | 3 ++- internal/cli/kernelsu_test.go | 11 ++++++++++- internal/i18n/locales/en/cli.json | 3 ++- internal/i18n/locales/en/web.json | 3 ++- internal/ui/web/js/diagnostics.js | 14 ++++++++++---- scripts/test_kernelsu_ui.mjs | 21 +++++++++++++++++++++ 9 files changed, 51 insertions(+), 11 deletions(-) diff --git a/README.en.md b/README.en.md index cf3ec2db..d4688e36 100644 --- a/README.en.md +++ b/README.en.md @@ -473,4 +473,4 @@ Third-party modules run as root inside the guest. Use trusted sources. Once Kern Known issues: - Once enabled, the instance takes a few extra seconds to shut down each time (`/data` times out unmounting while Android shuts down), and its next start replays the file system journal and runs an extra disk check. No data loss was seen in testing; the cause is still being investigated, see [ModAVD/ModAVD#309](https://github.com/ModAVD/ModAVD/issues/309). -- Once enabled, each system call is about 12–25 % slower; the effect on game frame rates has not been measured yet, see [ModAVD/ModAVD#311](https://github.com/ModAVD/ModAVD/issues/311). +- Once enabled, each system call is about 12–25 % slower; the effect on game frame rates has not been measured yet, see [ModAVD/ModAVD#311](https://github.com/ModAVD/ModAVD/issues/311). For performance measurements and benchmarks, use an instance without KernelSU. diff --git a/README.md b/README.md index dd467a34..c7dffff8 100644 --- a/README.md +++ b/README.md @@ -476,4 +476,4 @@ go test ./... 已知问题: - 启用以后,实例每次关机会多等几秒(安卓关机时 `/data` 卸载超时),下次开机会回放文件系统日志、多做一遍磁盘检查。验证时没有看到丢数据,原因还在查,见 [ModAVD/ModAVD#309](https://github.com/ModAVD/ModAVD/issues/309)。 -- 启用以后,每次系统调用慢约 12–25 %,对游戏帧率的影响还没量,见 [ModAVD/ModAVD#311](https://github.com/ModAVD/ModAVD/issues/311)。 +- 启用以后,每次系统调用慢约 12–25 %,对游戏帧率的影响还没量,见 [ModAVD/ModAVD#311](https://github.com/ModAVD/ModAVD/issues/311)。量性能、跑分时请用没启用 KernelSU 的实例。 diff --git a/internal/cli/commands.go b/internal/cli/commands.go index 0f6d0454..06597a2a 100644 --- a/internal/cli/commands.go +++ b/internal/cli/commands.go @@ -375,7 +375,8 @@ func init() { "install 会为该实例单独生成带 ksuinit 和 kernelsu.ko 的 ramdisk(不改全局系统镜像),冷启动装入 ksud、KernelSU Manager 和 meta-overlayfs,再冷启动一次使其生效。" + "uninstall 移除实例的 KernelSU ramdisk 恢复原版启动(加 --purge --yes 清理受管理的 KernelSU 数据和管理器应用)。" + "module install 支持一次导入多个 .zip 模块(如 ReZygisk 与 Vector/LSPosed),自动按依赖顺序刷入并冷启动一次生效;加 --no-reboot 可暂不重启。" + - "已知问题:启用以后实例每次关机会多等几秒,下次开机会多做一遍磁盘检查,原因还在查(ModAVD/ModAVD#309)。", + "已知问题:启用以后实例每次关机会多等几秒,下次开机会多做一遍磁盘检查,原因还在查(ModAVD/ModAVD#309);" + + "启用以后系统调用会变慢,这台实例的性能会比不启用时低一些(ModAVD/ModAVD#311)。", flags: []flagSpec{ {name: "yes", kind: kindBool, help: "确认清理 KernelSU 客体数据"}, {name: "purge", kind: kindBool, help: "uninstall 时同时清理受管理的 KernelSU 数据和 KernelSU Manager"}, diff --git a/internal/cli/kernelsu.go b/internal/cli/kernelsu.go index a855df41..896eab79 100644 --- a/internal/cli/kernelsu.go +++ b/internal/cli/kernelsu.go @@ -241,8 +241,9 @@ func formatKernelSUResult(w io.Writer, r *emu.KernelSUResult) { } fmt.Fprintln(w) if r.Installed { - // ModAVD/ModAVD#309: said after every successful install, not a warning of this run (--json unchanged) + // ModAVD/ModAVD#309, #311: said after every successful install, not warnings of this run (--json unchanged) fmt.Fprintln(w, "已知问题:启用 KernelSU 的实例每次关机会多等几秒,下次开机会多做一遍磁盘检查;原因还在查,见 https://github.com/ModAVD/ModAVD/issues/309") + fmt.Fprintln(w, "已知问题:启用 KernelSU 后系统调用会变慢,这台实例的性能会比不启用时低一些,见 https://github.com/ModAVD/ModAVD/issues/311") } case "uninstall": fmt.Fprintf(w, "实例 %d 已移除 KernelSU\n", r.Index) diff --git a/internal/cli/kernelsu_test.go b/internal/cli/kernelsu_test.go index 33e02da2..1f69fb1c 100644 --- a/internal/cli/kernelsu_test.go +++ b/internal/cli/kernelsu_test.go @@ -128,12 +128,21 @@ func TestKernelSUCommands(t *testing.T) { } } - // A successful install says the known shutdown issue (ModAVD/ModAVD#309); --json keeps its shape and warnings. + // A successful install says the known shutdown and performance issues (ModAVD/ModAVD#309, #311), each on its own + // line; --json keeps its shape and warnings. res := h.run(t, nil, "ksu", "2", "install") if !strings.Contains(res.stdout, "实例 2 已启用 KernelSU") || !strings.Contains(res.stdout, "已知问题") || !strings.Contains(res.stdout, "issues/309") || strings.Contains(res.stdout, "警告") { t.Fatalf("install output: %q", res.stdout) } + if !strings.Contains(res.stdout, "\n已知问题:启用 KernelSU 后系统调用会变慢,这台实例的性能会比不启用时低一些,见 https://github.com/ModAVD/ModAVD/issues/311\n") || + strings.Index(res.stdout, "issues/311") < strings.Index(res.stdout, "issues/309") { + t.Fatalf("install output lacks the performance issue line: %q", res.stdout) + } + if r := h.run(t, nil, "help", "ksu"); !strings.Contains(r.stdout, "ModAVD/ModAVD#309") || + !strings.Contains(r.stdout, "系统调用会变慢") || !strings.Contains(r.stdout, "ModAVD/ModAVD#311") { + t.Fatalf("ksu help lacks the known issues: %q", r.stdout) + } if res := h.run(t, nil, "ksu", "2", "status"); strings.Contains(res.stdout, "已知问题") { t.Fatalf("status should not repeat the known issue: %q", res.stdout) } diff --git a/internal/i18n/locales/en/cli.json b/internal/i18n/locales/en/cli.json index 730ff494..c7f81c84 100644 --- a/internal/i18n/locales/en/cli.json +++ b/internal/i18n/locales/en/cli.json @@ -61,7 +61,7 @@ "Google Play 版镜像的压缩包": "Google Play system image archive", "HTTP 代理": "HTTP proxy", "KernelSU 的五个文件已经齐全、校验无误,没有改动(给的文件也核对过了)": "All five KernelSU files are already present and verified; nothing changed (the given files were also verified)", - "KernelSU 的五个文件(kernelsu.ko、ksuinit、ksud、KernelSU.apk、meta-overlayfs.zip)要先用 components import-ksu 导入到根目录的 sdk\\kernelsu。install 会为该实例单独生成带 ksuinit 和 kernelsu.ko 的 ramdisk(不改全局系统镜像),冷启动装入 ksud、KernelSU Manager 和 meta-overlayfs,再冷启动一次使其生效。uninstall 移除实例的 KernelSU ramdisk 恢复原版启动(加 --purge --yes 清理受管理的 KernelSU 数据和管理器应用)。module install 支持一次导入多个 .zip 模块(如 ReZygisk 与 Vector/LSPosed),自动按依赖顺序刷入并冷启动一次生效;加 --no-reboot 可暂不重启。已知问题:启用以后实例每次关机会多等几秒,下次开机会多做一遍磁盘检查,原因还在查(ModAVD/ModAVD#309)。": "Import the five KernelSU files (kernelsu.ko, ksuinit, ksud, KernelSU.apk, meta-overlayfs.zip) into sdk\\kernelsu first with components import-ksu. install builds a per-instance ramdisk containing ksuinit and kernelsu.ko without touching the global system image, cold boots to install ksud, KernelSU Manager, and meta-overlayfs, then cold boots once more to activate them. uninstall removes the instance's KernelSU ramdisk to restore stock boot (add --purge --yes to remove managed KernelSU data and the manager app). module install accepts multiple .zip modules at once (such as ReZygisk and Vector/LSPosed), installs them in dependency order, and cold boots once; pass --no-reboot to skip the reboot. Known issue: once enabled, the instance takes a few extra seconds to shut down each time and runs an extra disk check on its next start; the cause is still being investigated (ModAVD/ModAVD#309).", + "KernelSU 的五个文件(kernelsu.ko、ksuinit、ksud、KernelSU.apk、meta-overlayfs.zip)要先用 components import-ksu 导入到根目录的 sdk\\kernelsu。install 会为该实例单独生成带 ksuinit 和 kernelsu.ko 的 ramdisk(不改全局系统镜像),冷启动装入 ksud、KernelSU Manager 和 meta-overlayfs,再冷启动一次使其生效。uninstall 移除实例的 KernelSU ramdisk 恢复原版启动(加 --purge --yes 清理受管理的 KernelSU 数据和管理器应用)。module install 支持一次导入多个 .zip 模块(如 ReZygisk 与 Vector/LSPosed),自动按依赖顺序刷入并冷启动一次生效;加 --no-reboot 可暂不重启。已知问题:启用以后实例每次关机会多等几秒,下次开机会多做一遍磁盘检查,原因还在查(ModAVD/ModAVD#309);启用以后系统调用会变慢,这台实例的性能会比不启用时低一些(ModAVD/ModAVD#311)。": "Import the five KernelSU files (kernelsu.ko, ksuinit, ksud, KernelSU.apk, meta-overlayfs.zip) into sdk\\kernelsu first with components import-ksu. install builds a per-instance ramdisk containing ksuinit and kernelsu.ko without touching the global system image, cold boots to install ksud, KernelSU Manager, and meta-overlayfs, then cold boots once more to activate them. uninstall removes the instance's KernelSU ramdisk to restore stock boot (add --purge --yes to remove managed KernelSU data and the manager app). module install accepts multiple .zip modules at once (such as ReZygisk and Vector/LSPosed), installs them in dependency order, and cold boots once; pass --no-reboot to skip the reboot. Known issue: once enabled, the instance takes a few extra seconds to shut down each time and runs an extra disk check on its next start; the cause is still being investigated (ModAVD/ModAVD#309). Also, once enabled, system calls are slower, so the instance performs somewhat worse than without KernelSU (ModAVD/ModAVD#311).", "MCP 服务已就绪,根目录 %s": "MCP server is ready, root folder %s", "Mirror 酱(CDK %v)": "MirrorChyan (CDK %v)", "ModAVD 实例 %d 关机失败: %s": "ModAVD instance %d failed to shut down: %s", @@ -227,6 +227,7 @@ "实例 %d 已卸载 KernelSU 模块:%s\n": "Uninstalled KernelSU module %[2]s from instance %[1]d\n", "实例 %d 已启用 KernelSU": "Enabled KernelSU on instance %d", "已知问题:启用 KernelSU 的实例每次关机会多等几秒,下次开机会多做一遍磁盘检查;原因还在查,见 https://github.com/ModAVD/ModAVD/issues/309": "Known issue: an instance with KernelSU enabled takes a few extra seconds to shut down each time and runs an extra disk check on its next start; the cause is still being investigated, see https://github.com/ModAVD/ModAVD/issues/309", + "已知问题:启用 KernelSU 后系统调用会变慢,这台实例的性能会比不启用时低一些,见 https://github.com/ModAVD/ModAVD/issues/311": "Known issue: with KernelSU enabled, system calls are slower, so the instance performs somewhat worse than without it; see https://github.com/ModAVD/ModAVD/issues/311", "实例 %d 已移除 KernelSU\n": "Removed KernelSU from instance %d\n", "实例 %d 已触发磁盘回收(trim)\n": "Instance %d disk reclaim (trim) triggered\n", "实例 %d 执行桥 %s:%s(脚本退出码 %d)\n": "Instance %d execution bridge %s: %s (script exit code %d)\n", diff --git a/internal/i18n/locales/en/web.json b/internal/i18n/locales/en/web.json index 42f8b0cf..2eff404e 100644 --- a/internal/i18n/locales/en/web.json +++ b/internal/i18n/locales/en/web.json @@ -769,5 +769,6 @@ "下载 KernelSU 组件": "Download KernelSU components", "正式模块尚未发布": "The official module has not been released", "游戏和应用可能检测到 root,有的游戏会因此拒绝运行或处罚账号;导入的模块在客体内以 root 运行。启用后开不了机时,先关机,再在实例的「更多操作」里点「移除 KernelSU…」,或运行 modavd ksu <编号> uninstall,恢复原版启动。": "Games and apps may detect root, and some games refuse to run or penalize the account; imported modules run as root in the guest. If the instance no longer starts after enabling, shut it down, then choose \"Remove KernelSU…\" in the instance's More actions menu, or run modavd ksu uninstall, to restore stock boot.", - "已知问题:启用 KernelSU 的实例每次关机会多等几秒,下次开机会多做一遍磁盘检查;原因还在查,见 {issue}。": "Known issue: an instance with KernelSU enabled takes a few extra seconds to shut down each time and runs an extra disk check on its next start. The cause is still being investigated; see {issue}." + "已知问题:启用 KernelSU 的实例每次关机会多等几秒,下次开机会多做一遍磁盘检查;原因还在查,见 {issue}。": "Known issue: an instance with KernelSU enabled takes a few extra seconds to shut down each time and runs an extra disk check on its next start. The cause is still being investigated; see {issue}.", + "已知问题:启用 KernelSU 后系统调用会变慢,这台实例的性能会比不启用时低一些,见 {issue}。": "Known issue: with KernelSU enabled, system calls are slower, so the instance performs somewhat worse than without it; see {issue}." } diff --git a/internal/ui/web/js/diagnostics.js b/internal/ui/web/js/diagnostics.js index 9d7efac0..3f952f57 100644 --- a/internal/ui/web/js/diagnostics.js +++ b/internal/ui/web/js/diagnostics.js @@ -130,15 +130,21 @@ export async function importKernelSU(files) { // kernelsu.js): games may notice the root, and the way back when the instance no longer boots (the instance's // 移除 KernelSU, or `modavd ksu uninstall`: back to the stock ramdisk, apps and data kept). export const KSU_RISK = t('游戏和应用可能检测到 root,有的游戏会因此拒绝运行或处罚账号;导入的模块在客体内以 root 运行。启用后开不了机时,先关机,再在实例的「更多操作」里点「移除 KernelSU…」,或运行 modavd ksu <编号> uninstall,恢复原版启动。'); -// The known issue said with it (ModAVD/ModAVD#309: with kernelsu.ko loaded, /data does not unmount in time at shutdown). +// The known issues said with it (ModAVD/ModAVD#309: with kernelsu.ko loaded, /data does not unmount in time at shutdown; +// ModAVD/ModAVD#311: its syscall hooks make every system call slower). export const KSU_KNOWN = t('已知问题:启用 KernelSU 的实例每次关机会多等几秒,下次开机会多做一遍磁盘检查;原因还在查,见 {issue}。'); +export const KSU_KNOWN_PERF = t('已知问题:启用 KernelSU 后系统调用会变慢,这台实例的性能会比不启用时低一些,见 {issue}。'); const KSU_ISSUE = 'https://github.com/ModAVD/ModAVD/issues/309'; +const KSU_PERF_ISSUE = 'https://github.com/ModAVD/ModAVD/issues/311'; -// The warning box with both, for this block and the question before 启用. +const issueLink = (href, text) => h('a', { href, target: '_blank', rel: 'noopener noreferrer', text }); + +// The warning box with all of them, for this block and the question before 启用. export function ksuRiskNote() { - const issue = h('a', { href: KSU_ISSUE, target: '_blank', rel: 'noopener noreferrer', text: 'ModAVD/ModAVD#309' }); return h('div', { class: 'note-box tone-warn' }, icon('alert'), - h('span', {}, KSU_RISK, h('br'), tNode(KSU_KNOWN, { issue }))); + h('span', {}, KSU_RISK, + h('br'), tNode(KSU_KNOWN, { issue: issueLink(KSU_ISSUE, 'ModAVD/ModAVD#309') }), + h('br'), tNode(KSU_KNOWN_PERF, { issue: issueLink(KSU_PERF_ISSUE, 'ModAVD/ModAVD#311') }))); } export function ksuBox() { diff --git a/scripts/test_kernelsu_ui.mjs b/scripts/test_kernelsu_ui.mjs index 1b4964eb..80dfb411 100644 --- a/scripts/test_kernelsu_ui.mjs +++ b/scripts/test_kernelsu_ui.mjs @@ -252,6 +252,27 @@ test('the block says the known shutdown issue and links it', async () => { assert.equal(link.getAttribute('target'), '_blank'); }); +test('the block says the known performance issue and links it', async () => { + const { b } = await ksuBlock(KSU.download); + const text = b.el.textContent; + assert.match(text, /系统调用会变慢/); + assert.match(text, /性能会比不启用时低一些/); + assert.match(text, /ModAVD\/ModAVD#311/); + assert.doesNotMatch(text, /\{issue\}|%/); // no placeholder left, no figure + const link = all(b.el).find(x => x.tagName === 'A' && x.getAttribute('href') === 'https://github.com/ModAVD/ModAVD/issues/311'); + assert.ok(link, 'a link to the issue'); + assert.equal(link.textContent, 'ModAVD/ModAVD#311'); + assert.equal(link.getAttribute('target'), '_blank'); + assert.equal(link.getAttribute('rel'), 'noopener noreferrer'); + // each known issue on its own line, the performance one after the shutdown one + const span = all(b.el).find(x => x.childNodes.includes(link)); + const kids = [...span.childNodes]; + const i309 = kids.findIndex(x => x.tagName === 'A' && x.textContent === 'ModAVD/ModAVD#309'); + const i311 = kids.indexOf(link); + assert.ok(i309 >= 0 && i311 > i309, 'performance issue after the shutdown one'); + assert.ok(kids.slice(i309 + 1, i311).some(x => x.tagName === 'BR'), 'on its own line'); +}); + test('下载 KernelSU 组件 can be clicked only when the official module can be downloaded', async () => { const off = await ksuBlock(KSU.ready); assert.equal(off.b.download.disabled, true);