mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 13:26:02 +00:00
* fix(session): the bottom screen takes touch again while a game runs Since #2763, a transparent KeepTopActivity covers every other display while a session is on top. Its window is NOT_TOUCHABLE, but Android gives a translucent activity alone in its task an ActivityRecordInputSink that eats every touch on that display (ENABLE_TOUCH_OPAQUE_ACTIVITIES, on for this target SDK). With the dual-screen panel closed, the bottom screen's launcher, Cocoon or any other app could not be touched until the session ended, and the guard stayed over it after Home/PiP as well. - The guard now takes touches itself: a touch removes it from that display. - It comes back when the session is top-resumed again, or after 5 s if the session kept the top spot (the user touched the bottom screen once and stayed in the game). - Stopping or entering PiP removes the guards; PiP keeps the session at adj 50 with or without them, so they protected nothing there. A/B on a Retroid Pocket Duo (Android 16, Cocoon as bottom home): the guard is on top in every state it was on top on main, except the 5 s after a bottom touch and PiP. Under lmkd pressure (kills down to adj 50, bottom home killed 14-31 times per run) neither build lost the top spot. * test(session): A/B tool for the keep-top guard on rooted dual screens, with Duo findings * test(session): the guard A/B tool stops on a failed session start and cleans up an interrupted pressure run
107 lines
5.6 KiB
Python
107 lines
5.6 KiB
Python
from pathlib import Path
|
|
import sys
|
|
import unittest
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
import memory_guard_ab as ab
|
|
|
|
|
|
ACTIVITIES = """\
|
|
Display #2 (activities from top to bottom):
|
|
* Task{b24f3e8 #1421 type=standard A=10120:com.droiddeck.launcher.keeptop U=0 visible=true visibleRequested=true mode=fullscreen translucent=true sz=1}
|
|
* Hist #0: ActivityRecord{10082571 u0 com.droiddeck.launcher/.session.KeepTopActivity t1421}
|
|
* Task{3002b72 #6 type=home U=0 visible=true visibleRequested=true mode=fullscreen translucent=false sz=2}
|
|
* Task{b347c40 #7 type=home A=10082:com.android.launcher3 nonResizable U=0 rootTaskId=6 visible=false visibleRequested=false mode=fullscreen translucent=true sz=1}
|
|
* Task{1ea585a #1448 type=home A=10130:rip.moth.cocoonshell nonResizable U=0 rootTaskId=6 visible=true visibleRequested=true mode=fullscreen translucent=false sz=1}
|
|
|
|
Display #0 (activities from top to bottom):
|
|
* Task{972c91 #1434 type=standard A=10120:com.droiddeck.launcher U=0 visible=true visibleRequested=true mode=fullscreen translucent=false sz=2}
|
|
* Hist #1: ActivityRecord{240807202 u0 com.droiddeck.launcher/.session.KeepTopActivity t1633}
|
|
* Hist #0: ActivityRecord{126627493 u0 com.droiddeck.launcher/.SessionActivity t1434}
|
|
* Task{93ad796 #1 type=home U=0 visible=false visibleRequested=false mode=fullscreen translucent=true sz=1}
|
|
* Task{ae41383 #1408 type=home I=com.android.launcher3/.uioverrides.QuickstepLauncher U=0 rootTaskId=1 visible=true visibleRequested=true mode=fullscreen translucent=true sz=1}
|
|
"""
|
|
|
|
WINDOWS = """\
|
|
Window #19 Window{6dc6ad8 u0 NavigationBar2}:
|
|
mDisplayId=2 rootTaskId=1 mSession=Session{1 2:u0a1} mClient=android.os.BinderProxy@1
|
|
Window #20 Window{cde10e4 u0 com.droiddeck.launcher}:
|
|
mDisplayId=2 rootTaskId=1 mSession=Session{2 3:u0a120} mClient=android.os.BinderProxy@2
|
|
Window #21 Window{d8e62b4 u0 com.droiddeck.launcher/com.droiddeck.launcher.session.KeepTopActivity}:
|
|
mDisplayId=2 taskId=1425 mSession=Session{2 3:u0a120} mClient=android.os.BinderProxy@3
|
|
Window #22 Window{aeb9be7 u0 com.droiddeck.launcher}:
|
|
mDisplayId=0 rootTaskId=1 mSession=Session{2 3:u0a120} mClient=android.os.BinderProxy@4
|
|
"""
|
|
|
|
DISPLAYS = """\
|
|
Display: mDisplayId=2 (organized)
|
|
init=1280x960 320dpi mMinSizeOfResizeableTaskDp=220 cur=1280x960 app=1280x960 rng=960x960-1280x1280
|
|
Display: mDisplayId=0 (organized)
|
|
init=1080x1920 369dpi mMinSizeOfResizeableTaskDp=220 cur=1920x1080 app=1920x1080 rng=1080x1080-1920x1920
|
|
"""
|
|
|
|
EVENTS = """\
|
|
11-19 22:50:25.389 514 514 I killinfo: [28834,10129,995,50,95820,1,28492]
|
|
11-19 22:50:26.239 514 514 I killinfo: [29132,1000,102,50,84792,1,43120]
|
|
11-19 22:50:33.400 514 514 I killinfo: [25557,10120,0,0,94252,1,79084]
|
|
11-19 22:50:29.811 2034 3827 I am_proc_died: [0,31749,rip.moth.cocoonshell,102,2]
|
|
11-19 22:50:30.199 2034 3827 I am_proc_died: [0,2286,rip.moth.cocoonshell,102,2]
|
|
11-19 22:50:33.535 2034 10103 I am_proc_died: [0,25557,com.droiddeck.launcher,0,2]
|
|
11-19 22:50:34.551 2034 11587 I wm_task_to_front: [0,1408,0]
|
|
11-19 22:42:44.766 2034 2707 I wm_create_activity: [0,1239004,1628,com.droiddeck.launcher/.session.KeepTopActivity,NULL,NULL,NULL,411107328]
|
|
11-19 22:42:44.816 16856 16856 I wm_on_top_resumed_lost_called: [24689759,com.droiddeck.launcher.SessionActivity,topStateChangedWhenResumed]
|
|
11-19 22:42:44.817 16856 16856 I wm_on_top_resumed_lost_called: [24689760,com.droiddeck.launcher.MainActivity,pausing]
|
|
"""
|
|
|
|
|
|
class DumpParsingTest(unittest.TestCase):
|
|
def test_focused_display(self):
|
|
self.assertEqual(2, ab.focused_display(" FocusedDisplayId: 2\n FocusedApplications:\n"))
|
|
self.assertIsNone(ab.focused_display(""))
|
|
|
|
def test_guards_and_sessions_are_counted_on_every_display(self):
|
|
self.assertEqual(2, ab.guard_count(ACTIVITIES))
|
|
self.assertEqual(1, ab.session_count(ACTIVITIES))
|
|
|
|
def test_the_bottom_home_is_the_visible_home_on_another_display(self):
|
|
self.assertEqual((2, "rip.moth.cocoonshell"), ab.bottom_home(ACTIVITIES, 0))
|
|
|
|
def test_no_bottom_home_without_another_display(self):
|
|
self.assertIsNone(ab.bottom_home(ACTIVITIES.split("\n\n")[1], 0))
|
|
|
|
def test_panel_windows_are_the_apps_bare_windows_on_that_display(self):
|
|
self.assertEqual(1, ab.panel_windows(WINDOWS, 2))
|
|
self.assertEqual(1, ab.panel_windows(WINDOWS, 0))
|
|
self.assertEqual(0, ab.panel_windows(WINDOWS, 3))
|
|
|
|
def test_logical_size_follows_rotation(self):
|
|
self.assertEqual((1920, 1080), ab.logical_size(DISPLAYS, 0))
|
|
self.assertEqual((1280, 960), ab.logical_size(DISPLAYS, 2))
|
|
self.assertIsNone(ab.logical_size(DISPLAYS, 5))
|
|
|
|
|
|
class SummaryTest(unittest.TestCase):
|
|
def test_max_adj_skips_samples_after_death(self):
|
|
self.assertEqual(50, ab.max_adj(["0", "50", "DEAD", ""]))
|
|
self.assertIsNone(ab.max_adj(["DEAD"]))
|
|
|
|
def test_events_summary(self):
|
|
summary = ab.summarize_events(EVENTS)
|
|
self.assertEqual(3, summary["lmkd_kills"])
|
|
self.assertEqual(1, summary["lmkd_kills_down_to_adj0"])
|
|
self.assertEqual({"com.droiddeck.launcher": 1, "rip.moth.cocoonshell": 2}, summary["processes_died"])
|
|
self.assertEqual(0, summary["droiddeck_died_at_adj"])
|
|
self.assertEqual(1, summary["session_top_lost"])
|
|
self.assertEqual(1, summary["task_to_front"])
|
|
self.assertEqual(1, summary["guard_creates"])
|
|
|
|
def test_a_quiet_log_summarizes_to_nothing(self):
|
|
summary = ab.summarize_events("")
|
|
self.assertEqual(0, summary["lmkd_kills"])
|
|
self.assertIsNone(summary["droiddeck_died_at_adj"])
|
|
self.assertEqual({}, summary["processes_died"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|