Repository navigation
开机:实例正在关机时等它关完再开,不当成已在运行接管 - #29
Merged
Merged
Conversation
点模拟器窗口的 ×(0.37 起先让安卓正常关机)、AUTO-MAS 自己的关机,都不经过 modavd 的关机锁。这时 qemu 还要再跑 5 到 20 秒,adb 也还答得上,sys.boot_completed 仍是 1,start 就把它当成已在运行的实例接管,做完开机后的设置报成功;几秒后 qemu 自己退出,实例没了。 - start 接管前先看 sys.powerctl:是 shutdown 就等这个 qemu 退出(最多 30 秒,模拟器自己的安全关机最晚 25 秒结束),然后照常开机;30 秒还没退出报 busy。 - 关到 adb 已经不答的那一段看不出来:接管的 qemu 在等开机时退出了,就再开一次机(只再开一次;开机监视的那种 start 照旧不开机)。 - 执行桥的开机标记改在真正拉起模拟器之前放,等关机后再开机的这次也有。
This was referenced Nov 2, 2026
按最后一遍审查的 29-1 改。以前,接管的 qemu 在等开机时退出了,就一律再开一次机。这本来是为了兜住「点 × 后 adb 已经不答、看不出在关机」那一两秒。可要是有人在这期间故意关掉了它,比如手动 modavd stop、AUTO-MAS 放弃一次 start 后发的 stop,或者接管了很久之后才点 ×,这次关机也会被推翻。 - 只有同时满足这几条才重开: - 第一轮; - 不是开机监视发起的 start; - 接管后 30 秒(shutdownExitWait)内就退出了; - 等开机的这段时间里,没见到本实例的关机锁被拿着。 - 正常点 × 的情况,接管后几秒就退出了(11-02 实测:× 后约 1.3 s adb 就不答,5–8 s 后 qemu 退出),和上面这些分得开。 - 「要不要重开」抽成一个纯函数 relaunchAfterAdoptedGone,加了单测;等开机时有没有见到关机锁也有单测(29-2)。
qiyinxi
marked this pull request as ready for review
November 3, 2026 09:55
qiyinxi
added a commit
to qiyinxi/ModAVDManager
that referenced
this pull request
Nov 3, 2026
把 upstream/main 的 5a87a88 合进来,里面是 ModAVD#29 a2fc68d、ModAVD#30 ab77869、ModAVD#34 f4b9aa0、ModAVD#31 5a87a88。 这个分支原来建在 ModAVD#29 的旧提交 82e1e61 上;ModAVD#29 squash 进 main 时比它多了 relaunchAfterAdoptedGone 和 stopSeen。 冲突 8 个文件,解法: - internal/emu/start.go(5 块):两边都留。 - 接管循环开头:留 ModAVD#29 的 adoptedAt、stopSeen;找 qemu 用本分支的 startFindQemu。 - windowConflict 那段检查照旧放在 waitShutdown 之后、接管之前;接管时记下 adoptedAt。 - waitBoot 带上 &stopSeen;第二轮开机由 relaunchAfterAdoptedGone 判断。 - relaunchAfterAdoptedGone 函数照 main。 - internal/emu/start_test.go(2 块):留本分支的 TestStartNoSwitchWhileRunning;TestWaitBootAdoptedGone 和 TestRelaunchAfterAdoptedGone 照 main(带 stopSeen)。 - internal/cli/cli.go、commands.go(各 1 块):status 的契约注释和 statusOf 两边的字段都留(window、 creation_progress)。 - internal/cli/run_test.go(2 块):TestStatusSubset 的两条期望两边的字段都带上。另外 main 新加的「新建中」那条期望 是自动合进来的,没有 window,补上 "window":false(新建时后台那次开机是无头)。 - internal/ui/web/js/cards.js(1 块):留 main 的「新建中 NN%」,去掉本分支已经删掉的「重启中」。 - README.md、README.en.md(各 2 块):start 那一行用本分支的(--window | --headless,运行中不换);执行桥那一条用 main 的(ModAVD#30 的更新说明),只把「start / restart 的 --no-bridge」改成「start 的 --no-bridge」。 合完以后和 main 的差别就是本分支自己的改动,外加上面那处 "window":false。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
点模拟器窗口的 × 以后马上开同一台,
start会把还没退出的 qemu 当成已在运行的实例接管。这个 PR 让start先等它关完再开机。它和 ModAVD/ModAVD#32(0.37 的窗口安全关机)配套,跟管理器 0.3.0 一起进 0.37。问题
0.37 起,点模拟器窗口的 ×,模拟器会先让安卓正常关机,关完 qemu 才退出,前后 5 到 20 秒。AUTO-MAS 自己关实例也是先让安卓关机。这两种关机都不经过 modavd 的关机锁。
这段时间里,adb 大部分时候还答得上,
sys.boot_completed也仍是 1。start看到 qemu 还在、开机也完成了,就当成已在运行的实例接管,做完开机后的设置就报成功。几秒后 qemu 自己退出,实例没了,窗口也不会出来。要是在最后几秒、adb 已经不答的时候
start,它会一直等开机,等到 qemu 退出就报launch_failed。改了什么
接管前先读
sys.powerctl。值是shutdown或shutdown,<原因>,就等这个 qemu 退出,然后照常开机。modavd stop和 AUTO-MAS 的关机都在 28 秒内结束。busy。reboot不算:重启时 qemu 不退出,原来的开机等待就能等过去。到了 adb 已经不答的那一段,就看不出是在关机。这时接管的 qemu 要是在等开机时退出了,就重新开一次机。满足下面所有条件才重开,判断写在纯函数
relaunchAfterAdoptedGone里:start照旧不开机;这样,手动
modavd stop、AUTO-MAS 放弃一次 start 后发的 stop,或者接管很久以后才点 ×,都不会被推翻。这是第二个提交,按最后一遍审查的 29-1 改的。执行桥的开机标记,改成在真正拉起模拟器之前才放,关完再开的那一次也有标记。以前是在
start一开始放,而且只在那一刻看有没有 qemu。README 中英文
start那一行写上这一点。验证
gofmt,windows、darwin/arm64、linux/amd64 三个目标的go vet,go test ./...,以及scripts/test_repo_checks.py。sys.powerctl哪些取值算关机。busy,取消时报canceled,退出后正常返回。launch_failed。relaunchAfterAdoptedGone的 8 种情况。shutdown的匹配;PostMessage发SC_CLOSE,和点 × 走同一条路):modavd start,这时 adb 还答:先报「正在关机,等它关完再开机」,约 5 秒后旧 qemu 退出,再重新开机,合计 49 秒。新窗口出来了。device offline再start(约 1.35 秒,qemu 还在):先接管,旧 qemu 退出后报「接管的模拟器没等安卓开机完成就退出了,重新开机」,然后重新开机成功。shutdown。× 之前写的两份 4 MB 探针(/data/local/tmp、/sdcard)都完整。start,约 5 秒后重新开机,窗口出来,探针完整。