Fix secondary display lifecycle cleanup

This commit is contained in:
AverageConsumer
2026-08-20 18:23:20 +02:00
parent 5fa5005786
commit 9e01fe2c2c
3 changed files with 47 additions and 4 deletions
@@ -58,6 +58,38 @@ check(position("if (secondaryEnabled) registerSecondaryDisplayListener();") <
"secondary display monitoring starts before initial discovery")
check(source:find("!monitor.hasDisplay(display.getDisplayId())", 1, true),
"a disconnected active display is rebound without replacing a live one")
check(source:find("private static volatile boolean secondaryHostResumed = false;",
1, true), "secondary output tracks the primary activity lifecycle")
check(source:find("if (on && secondaryHostResumed)", 1, true)
and source:find("self == null || !secondaryHostResumed || !secondaryEnabled",
1, true),
"paused hosts cannot reopen secondary output from a late mod frame")
local pause = position("protected void onPause()")
local paused = assert(source:find("secondaryHostResumed = false;", pause, true))
local teardown = assert(source:find("teardownSecondaryDisplay();", pause, true))
local pauseSuper = assert(source:find("super.onPause();", pause, true))
check(pause < paused and paused < teardown and teardown < pauseSuper,
"pause blocks secondary setup before dismissing its output")
local resume = position("public void onResume()")
local resumeSuper = assert(source:find("super.onResume();", resume, true))
local resumed = assert(source:find("secondaryHostResumed = true;", resume, true))
local resumeSetup = assert(source:find("setupSecondaryDisplay();", resume, true))
check(resume < resumeSuper and resumeSuper < resumed and resumed < resumeSetup,
"resume permits secondary setup only after the primary activity resumes")
local destroy = position("protected void onDestroy()")
local destroyTeardown = assert(source:find("teardownSecondaryDisplay();", destroy, true))
local destroySuper = assert(source:find("super.onDestroy();", destroy, true))
check(destroy < destroyTeardown and destroyTeardown < destroySuper,
"destroy always dismisses secondary output before SDL destruction")
local mainFile = assert(io.open("main.lua", "rb"))
local main = mainFile:read("*a")
mainFile:close()
check(main:find('require("src.render.SecondScreen").setEnabled(false)', 1, true),
"returning from a game disables mod-owned secondary output")
check(not source:lower():find("openxr", 1, true),
"generic Android activity must not require OpenXR")