mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix(ctl): screenshots on phones with two screens take the main display (#2628)
screencap without -d prints a warning before the PNG when it finds more than one display, so droiddeckctl screenshot failed on foldables and dual-screen phones. Without --display, screenshot and record now use the physical display behind logical display 0 when there is more than one. Co-authored-by: alien2003 <11610652+alien2003@users.noreply.github.com>
This commit is contained in:
1 parent
68f1d5baa3
commit
f15c0af34e
2 files changed
+18
-1
No files matched your search
+3
-1
@@ -287,7 +287,9 @@ def displays(adb: str, serial: str) -> list[dict]:
|
||||
|
||||
def physical_display(adb: str, serial: str, logical: int | None) -> str | None:
|
||||
if logical is None:
|
||||
return None
|
||||
found = displays(adb, serial)
|
||||
main = next((d["physicalId"] for d in found if d["display"] == 0), None)
|
||||
return main if len(found) > 1 else None
|
||||
for d in displays(adb, serial):
|
||||
if d["display"] == logical:
|
||||
if not d["physicalId"]:
|
||||
|
||||
@@ -332,6 +332,21 @@ class DroiddeckctlTest(FakeAdbTest):
|
||||
shot = [c for c in self.calls() if c["args"][:2] == ["exec-out", "screencap"]][0]
|
||||
self.assertEqual(["exec-out", "screencap", "-p", "-d", "222"], shot["args"])
|
||||
|
||||
def test_screenshot_with_two_screens_takes_the_main_display(self):
|
||||
self.configure({}, dumpsys_display=DUMPSYS_DISPLAY)
|
||||
code, out = self.run_ctl("screenshot", str(self.dir / "shot.png"))
|
||||
self.assertEqual(0, code)
|
||||
shot = [c for c in self.calls() if c["args"][:2] == ["exec-out", "screencap"]][0]
|
||||
self.assertEqual(["exec-out", "screencap", "-p", "-d", "111"], shot["args"])
|
||||
|
||||
def test_screenshot_with_one_screen_names_no_display(self):
|
||||
one = DUMPSYS_DISPLAY.split(" Display 4:")[0]
|
||||
self.configure({}, dumpsys_display=one)
|
||||
code, out = self.run_ctl("screenshot", str(self.dir / "shot.png"))
|
||||
self.assertEqual(0, code)
|
||||
shot = [c for c in self.calls() if c["args"][:2] == ["exec-out", "screencap"]][0]
|
||||
self.assertEqual(["exec-out", "screencap", "-p"], shot["args"])
|
||||
|
||||
def test_displays(self):
|
||||
self.configure({}, dumpsys_display=DUMPSYS_DISPLAY)
|
||||
code, out = self.run_ctl("displays")
|
||||
|
||||
Reference in new issue
Block a user