# Keep-top guard A/B on dual screens `KeepTopActivity` (#2763, removed in the change that added this section) covered every other display while a session was on top, so that display's home was not its top activity. The reasoning: on the Thor, lmkd kills the bottom home under memory pressure, Android relaunches it to the front, the session loses the top spot, drops to adj 50 and is killed next. It had three side effects: - Android gives a translucent activity alone in its task an `ActivityRecordInputSink` that consumes every touch in the task bounds whatever the window's flags say (`ENABLE_TOUCH_OPAQUE_ACTIVITIES`), so the bottom screen took no touch (#2910 worked around it). - Cocoon tracks the top activity of each display; with a DroidDeck activity on the bottom it could not suspend or resume DroidDeck properly. - The Thor's `com.odin.gameassistant` gives every app with an activity on top of the bottom display that display's volume (`secondary_screen_volume_level`). With the guard up, all of DroidDeck's audio played at the bottom screen's volume (AudioFlinger track gain -37, -13 and -2.6 dB at levels 3, 8 and 13; -7.4 dB, the top level, once the guard was removed). The A/B below found no case on either device where the guard kept the session alive, so it was removed. ## Tool `tools/memory_guard_ab.py` drives a rooted dual-screen device over adb (`su` required) with a build that has the debugging tools: ```sh python3 tools/memory_guard_ab.py --label main --apk main.apk states python3 tools/memory_guard_ab.py --label fix --apk fix.apk states python3 tools/memory_guard_ab.py --label fix pressure --stop-mb 650 --hold 30 --runs 3 python3 tools/memory_guard_ab.py --label fix pressure --burst --stop-mb 1500 --hold 20 --runs 3 python3 tools/memory_guard_ab.py --label fix summarize ~/.cache/droiddeck-memory-guard-ab/fix-stop650-1-events.txt ``` Results are JSON lines in `~/.cache/droiddeck-memory-guard-ab/