From 2f9a77670bf22e4db64ae7b5e7b8a2068d33d0f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=90=A6?= Date: Thu, 28 Sep 2023 11:28:44 +0800 Subject: [PATCH] fix: Android objects support specifying adb_path (cherry picked from commit 90345b9cfbbfe605863ca65a78154dab26322862) --- airtest/core/android/android.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/airtest/core/android/android.py b/airtest/core/android/android.py index 29129a2b..fe768ac1 100644 --- a/airtest/core/android/android.py +++ b/airtest/core/android/android.py @@ -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() @@ -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: @@ -241,7 +242,7 @@ 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 @@ -249,9 +250,9 @@ def get_default_device(self): 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):