Skip to content

(feat) hugepage model; (fix) vnc fullscreen bug; (fix) start vm open vnc#34

Merged
BigfootACA merged 10 commits into
Droid-VM:masterfrom
HuJK:master
Jul 7, 2026
Merged

(feat) hugepage model; (fix) vnc fullscreen bug; (fix) start vm open vnc#34
BigfootACA merged 10 commits into
Droid-VM:masterfrom
HuJK:master

Conversation

@HuJK

@HuJK HuJK commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

改動*n

  1. hugepage model 重構,現在由統一的 HugePageModel 來和 gh-hugepage-model 交互,提供高階 API ,隱藏 v6 v7=v8 v9 之間的版本差異。然後相容 v9 版本的 gh-hugepage-model 新功能: 新版 acquire
  2. bump prebuilt 版本
  3. vnc 模式的 fullscreen 有問題,修正
  4. 外面的 start vm 總是打開 UART ,修正成內部一樣的路線
  5. 網路: 新增對 ip_forward 的監視
  6. CI: 新增 non-ascii 檢測,程式碼出現 non-ascii 直接不通過
  7. CL 新增字串拼接複雜度檢測, += 後面最多出現一個 + ,超過報錯,需要改用 fmt 或 PathJoin
  8. acquire 三個按鈕改版
  9. 新增 acquire stop reason

HuJK and others added 6 commits July 5, 2026 10:22
Expose the module's three acquire algorithms in the UI and reflect which one is
running.

- Buttons: v1/v2/v3 on the process-list "waiting for acquire" row and a new
  "Acquire huge pages" item on the main status screen (shared acquire_buttons.xml,
  same row style as the stat rows). Each writes acquire=1/2/3 via
  HugePageOps.acquire(int mode, ...).
- Per-mode spinner: read acquire_mode from refill_stat (readPoolPages index 5,
  -1 when the module can't report it). While a run is in flight only the running
  mode spins (tap = stop) and the other two grey out; an unknown mode (old module)
  falls back to spinning all three.
- Enable only on a real deficit: loaded && pool_want > 0 && avail+served < want.
  Disabled when not loaded, already at target, or soft-disabled (want=0).
- Gentler defaults: pool-size minimum lowered to 0 (ti_min=0MiB); soft-disable
  writes pool_want=0; Enable/Save auto-fill uses v1 (migrate only, no zram
  eviction, no reboot risk).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaHcvnHaZk8qqpKiS25Hbk
Point the prebuilts submodule at 2c31cecdedb5110e8861b8b698ba5b538725cfb7
(same DroidVM-Prebuilt-Root 4016dba, rebuilt).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaHcvnHaZk8qqpKiS25Hbk
…as VM info

Starting a VM from the list auto-opened VMConsoleActivity (UART) unconditionally
(MainVMFragment.onVMStateChanged hard-coded it), while the VM-info console button
(ConsoleButton.openDefaultConsole) is display-aware: native display, else VNC,
else the serial console. So a VNC/native VM started from the list wrongly popped
the UART console instead of its display.

Extract that routing into a shared VmConsoleRouter.openDefault(); the info button
and the list auto-open now both call it, so they agree. ConsoleButton's chooser
open-helpers delegate to the router too (single source of truth).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaHcvnHaZk8qqpKiS25Hbk
netd owns net.ipv4.ip_forward and net.ipv6.conf.all.forwarding globally and
clears them whenever it retunes tethering, silently black-holing every
forwarded guest packet. IptablesBackend enables them once at init;
DefaultRouterWatcher now re-asserts them on its 5s tick for as long as a
running LINUX + L3 network needs kernel forwarding.

Gated on hasL3LinuxBridge() -- the same condition the routing rules use -- so
with no L3 bridge netd's value is left alone rather than forcing global
forwarding on the phone. Both families are covered because netd flips v4 and
v6 together. Reads before writing via runQuiet so the poll stays out of
logcat; only a value netd actually reset is corrected and logged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaHcvnHaZk8qqpKiS25Hbk
Two Python checks wired into a new Checks workflow (push + PR):

- check_ascii.py: fails on any non-ASCII byte in a tracked file, so a stray
  smart-quote, em-dash, arrow or CJK char can't slip into code, comments or
  config. Genuine i18n / natural-language files are exempt via
  scripts/ci/ascii_allow.txt (translations, privacy text, docs, ...).
- check_translations.py: fails if any values-<locale>/strings.xml is missing,
  has extra, or has stale entries vs the translatable keys in
  values/strings.xml, so nothing ships half-translated.

Fixes so the current tree passes:
- Replace the check/cross emoji in the virtualization setup step with inline
  tinted vector icons (ImageSpan over ic_check/ic_close); widen showDetail() to
  CharSequence; add status_supported/status_unsupported colors. The mode menu
  already used circle icons; only a stale glyph comment remained.
- Convert typographic dashes/arrows/minus-sign and stray CJK in the hugepage
  and Try comments to ASCII.
- Add the 4 missing zh-rTW strings (vm_exit_crash, vm_exit_guest_panic,
  vm_exit_watchdog, vm_rebooting).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaHcvnHaZk8qqpKiS25Hbk

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文件名应为 VMConsoleRouter.java

Comment on lines +970 to +975
<string name="hugepage_proc_acquire_v1">v1</string>
<string name="hugepage_proc_acquire_v2">v2</string>
<string name="hugepage_proc_acquire_v3">v3</string>
<string name="hugepage_proc_acquire_v1_desc">获取 v1(alloc_contig_pages 扫描)</string>
<string name="hugepage_proc_acquire_v2_desc">获取 v2(迁移+系统回收)</string>
<string name="hugepage_proc_acquire_v3_desc">获取 v3(迁移+逐块挤到 zram)</string>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按钮的字符串不展示v1/v2/v3字样
改为只有一个获取按钮,按下弹出PopupMenu(使用MaterialMenu变种),三个选项alloc_contig_pages 扫描 迁移+系统回收 迁移+逐块挤到 zram
不使用全角符号

Comment thread app/src/main/res/values/strings.xml Outdated
<string name="hugepage_acquire_v3_explain">Uses folio_isolate_lru + reclaim_pages to precisely push pages into swap/zram\nthen alloc_contig_range to collect huge pages</string>
<string name="hugepage_proc_acquire_running">Acquiring huge pages…</string>
<string name="hugepage_proc_acquire_done">Acquire done</string>
<string name="hugepage_acquire_degraded">Downgraded — ran %1$s instead</string>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

非ASCII字符

Comment thread scripts/ci/ascii_allow.txt Outdated
# build files, layouts, manifests and config must stay ASCII.

# UI strings: translation source (values/) and the translations themselves.
app/src/main/res/values*/strings.xml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

英文翻译app/src/main/res/values/strings.xml也不能有非ASCII字符
这里可以写app/src/main/res/values-*/strings.xml

Comment on lines -626 to -639
private void doUnload() {
btnModuleToggle.setEnabled(false);
runOnPool(() -> {
var result = runList("rmmod", "gh_hugepage_reserve").isSuccess();
runOnUiThread(() -> {
var msg = result ?
R.string.hugepage_unloaded :
R.string.hugepage_unload_failed;
Toast.makeText(this, msg, LENGTH_SHORT).show();
refreshStatus(true);
});
});
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unload按钮需要保留
可以放到菜单menu_hugepage_activity.xml

private List<Try<LoadImpl, Void>> loadLadder(long pages) {
var log = new ArrayList<Try<LoadImpl, Void>>();
var w = "pool_want=\"" + pages + "\"";
var t = "pool_target=\"" + pages + "\"";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用fmt函数格式化字符串
不要使用+拼接字符串
涉及行: 368, 431, 432, 441, 514, 515, 622

Comment on lines +452 to +453
? run("insmod \"%s\"", KO_PATH)
: run("insmod \"%s\" %s", KO_PATH, arg);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用escapedString包裹路径

: R.string.hugepage_acquire_v1_explain;
// Title = "Acquire huge pages" + the mode badge, e.g. "Acquire huge pages v1".
String title = ctx.getString(R.string.hugepage_acquire_pages_title)
+ " " + ctx.getString(modeLabel);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用fmt

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

通用模板可以放到lib复用

* warning below, and only when netd actually reset the value.
*/
private void ensureSysctlOne(@NonNull String path, @NonNull String name) {
var cur = RunUtils.runQuiet("cat " + path).getOutString();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shellReadFile

… shell calls, ASCII base strings

Addresses BigfootACA's review comments:
- Rename VmConsoleRouter -> VMConsoleRouter (VM initialism); update references.
- Move the generic Try<I,V> degradation-ladder helper to lib/utils for reuse
  (now public; javadoc de-specialised from HugePageModel).
- HugePageModel: wrap the module path in escapedString(); build strings with
  fmt() instead of + concatenation.
- HugePageActivity: fmt() for the acquire-dialog title.
- DefaultRouterWatcher: read the sysctl via shellReadFile().
- Base values/strings.xml is ASCII-only now (typographic ellipsis/em-dash ->
  "..." / "-"), and the non-ASCII allowlist narrows to values-*/strings.xml so
  the English source file is checked too.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaHcvnHaZk8qqpKiS25Hbk
HuJK and others added 3 commits July 7, 2026 03:18
… ones

Add scripts/ci/check_string_concat.py (wired into the Checks workflow): a
Java-literal-aware scanner that fails when a bare + joins a string literal with a
runtime expression ("x=" + v), which reads better as fmt("x=%s", v). It masks
comments and string/char literals first, so + inside a literal ("wlan+", "%s+",
"\s+") and literal+literal constants are not flagged; a line can opt out with a
trailing // concat-ok comment.

A glance-obvious accumulator append stays as-is: a += statement with at most ONE
+ (s += "x" + y) reads clearly and is exempt; a += chaining two or more +
(s += "a" + b + "c") loses the exemption and is flagged. Only concatenation that
doesn't read at a glance is pushed to fmt(). The + count is scoped per statement
(to the next ; { }).

Convert the pre-existing complex concatenations across the codebase to fmt()
(mostly Log calls); route filesystem-path joins through pathJoin(). Simple
single-+ += appends are left as +=. StringUtils.pathJoin's own body keeps its +
with a // concat-ok note -- it is the canonical joiner and fmt() there would be
a hot-path cost.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaHcvnHaZk8qqpKiS25Hbk
The gh_hugepage_reserve module now exports acquire_stop_reason in refill_stat
(why the last user-triggered acquire stopped). Thread it through Snapshot as a
pass-through display string (like state/totalServed) and append it to the
acquire-done Toast, so the user sees the reason in the bubble instead of having
to read dmesg. Kernel free text; appended raw (localization is a follow-up).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@BigfootACA BigfootACA merged commit 7f956d4 into Droid-VM:master Jul 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants