File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -229,21 +229,32 @@ def get_display_unique_id_flag(self) -> str:
229229 return f"-d { self .unique_display_id } "
230230
231231
232- class UnknownAndroidDisplay (AndroidDisplay ):
232+ class SingleAndroidDisplay (AndroidDisplay ):
233233 """
234- Fallback display for when the Agent OS is not able to determine the displays .
234+ Single display when there is only one display connected .
235235 """
236236
237- def __init__ (self ) -> None :
238- super ().__init__ (0 , "Unknown" , 0 )
237+ def __init__ (self , display_name : str ) -> None :
238+ super ().__init__ (0 , display_name , 0 )
239239
240+ # In case of a single display, the display id flag is not needed
240241 def get_display_id_flag (self ) -> str :
241242 return ""
242243
244+ # In case of a single display, the display unique id flag is not needed
243245 def get_display_unique_id_flag (self ) -> str :
244246 return ""
245247
246248
249+ class UnknownAndroidDisplay (SingleAndroidDisplay ):
250+ """
251+ Fallback display for when the Agent OS is not able to determine the displays.
252+ """
253+
254+ def __init__ (self ) -> None :
255+ super ().__init__ ("Unknown" )
256+
257+
247258class AndroidAgentOs (ABC ):
248259 """
249260 Abstract base class for Android Agent OS. Cannot be instantiated directly.
Original file line number Diff line number Diff line change 1414 ANDROID_KEY ,
1515 AndroidAgentOs ,
1616 AndroidDisplay ,
17+ SingleAndroidDisplay ,
1718 UnknownAndroidDisplay ,
1819)
1920from askui .tools .android .android_agent_os_error import AndroidAgentOsError
@@ -116,6 +117,10 @@ def get_connected_displays(self) -> list[AndroidDisplay]:
116117 )
117118 if not displays :
118119 return [UnknownAndroidDisplay ()]
120+
121+ if len (displays ) == 1 :
122+ return [SingleAndroidDisplay (displays [0 ].display_name )]
123+
119124 return displays
120125
121126 def set_display_by_index (self , display_index : int = 0 ) -> None :
You can’t perform that action at this time.
0 commit comments