Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/askui/tools/android/agent_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,21 +229,32 @@ def get_display_unique_id_flag(self) -> str:
return f"-d {self.unique_display_id}"


class UnknownAndroidDisplay(AndroidDisplay):
class SingleAndroidDisplay(AndroidDisplay):
"""
Fallback display for when the Agent OS is not able to determine the displays.
Single display when there is only one display connected.
"""

def __init__(self) -> None:
super().__init__(0, "Unknown", 0)
def __init__(self, display_name: str) -> None:
super().__init__(0, display_name, 0)

# In case of a single display, the display id flag is not needed
def get_display_id_flag(self) -> str:
return ""

# In case of a single display, the display unique id flag is not needed
def get_display_unique_id_flag(self) -> str:
return ""


class UnknownAndroidDisplay(SingleAndroidDisplay):
"""
Fallback display for when the Agent OS is not able to determine the displays.
"""

def __init__(self) -> None:
super().__init__("Unknown")


class AndroidAgentOs(ABC):
"""
Abstract base class for Android Agent OS. Cannot be instantiated directly.
Expand Down
5 changes: 5 additions & 0 deletions src/askui/tools/android/ppadb_agent_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ANDROID_KEY,
AndroidAgentOs,
AndroidDisplay,
SingleAndroidDisplay,
UnknownAndroidDisplay,
)
from askui.tools.android.android_agent_os_error import AndroidAgentOsError
Expand Down Expand Up @@ -116,6 +117,10 @@ def get_connected_displays(self) -> list[AndroidDisplay]:
)
if not displays:
return [UnknownAndroidDisplay()]

if len(displays) == 1:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens in the scrcpy case? Can you check this?

return [SingleAndroidDisplay(displays[0].display_name)]

return displays

def set_display_by_index(self, display_index: int = 0) -> None:
Expand Down