Skip to content

Commit

Permalink
fix: Android objects support specifying adb_path
Browse files Browse the repository at this point in the history
(cherry picked from commit 90345b9)
  • Loading branch information
yimelia committed Sep 28, 2023
1 parent b04ce0f commit 2f9a776
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions airtest/core/android/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(self, serialno=None, host=None,
ori_method=ORI_METHOD.MINICAP,
display_id=None,
input_event=None,
adb_path=None,
name=None):
super(Android, self).__init__()
self.serialno = serialno or self.get_default_device()
Expand All @@ -53,7 +54,7 @@ def __init__(self, serialno=None, host=None,
self.display_id = display_id
self.input_event = input_event
# init adb
self.adb = ADB(self.serialno, server_addr=host, display_id=self.display_id, input_event=self.input_event)
self.adb = ADB(self.serialno, adb_path=adb_path, server_addr=host, display_id=self.display_id, input_event=self.input_event)
self.adb.wait_for_device()
self.sdk_version = self.adb.sdk_version
if self.sdk_version >= SDK_VERISON_ANDROID10 and self._touch_method == TOUCH_METHOD.MINITOUCH:
Expand Down Expand Up @@ -241,17 +242,17 @@ def get_deprecated_var(self, old_name, new_name):
DeprecationWarning)
return getattr(self, new_name)

def get_default_device(self):
def get_default_device(self, adb_path=None):
"""
Get local default device when no serialno
Returns:
local device serialno
"""
if not ADB().devices(state="device"):
if not ADB(adb_path=adb_path).devices(state="device"):
raise IndexError("ADB devices not found")
return ADB().devices(state="device")[0][0]
return ADB(adb_path=adb_path).devices(state="device")[0][0]

@property
def uuid(self):
Expand Down

0 comments on commit 2f9a776

Please sign in to comment.