mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-23 21:25:57 +08:00
Fix: Use environ variable ANDROID_ADB_SERVER_PORT (#1233)
This commit is contained in:
@@ -104,7 +104,7 @@ class Connection:
|
|||||||
for k in list(os.environ.keys()):
|
for k in list(os.environ.keys()):
|
||||||
if k.lower().endswith('_proxy'):
|
if k.lower().endswith('_proxy'):
|
||||||
del os.environ[k]
|
del os.environ[k]
|
||||||
self.adb_client = AdbClient('127.0.0.1', 5037)
|
_ = self.adb_client
|
||||||
|
|
||||||
# Parse custom serial
|
# Parse custom serial
|
||||||
self.serial = str(self.config.Emulator_Serial)
|
self.serial = str(self.config.Emulator_Serial)
|
||||||
@@ -207,6 +207,22 @@ class Connection:
|
|||||||
file = 'adb.exe'
|
file = 'adb.exe'
|
||||||
return file
|
return file
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def adb_client(self) -> AdbClient:
|
||||||
|
host = '127.0.0.1'
|
||||||
|
port = 5037
|
||||||
|
|
||||||
|
# Trying to get adb port from env
|
||||||
|
env = os.environ.get('ANDROID_ADB_SERVER_PORT', None)
|
||||||
|
if env is not None:
|
||||||
|
try:
|
||||||
|
port = int(env)
|
||||||
|
except ValueError:
|
||||||
|
logger.warning(f'Invalid environ variable ANDROID_ADB_SERVER_PORT={port}, using default port')
|
||||||
|
|
||||||
|
logger.attr('AdbClient', f'AdbClient({host}, {port})')
|
||||||
|
return AdbClient(host, port)
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def adb(self) -> AdbDevice:
|
def adb(self) -> AdbDevice:
|
||||||
return AdbDevice(self.adb_client, self.serial)
|
return AdbDevice(self.adb_client, self.serial)
|
||||||
@@ -497,7 +513,8 @@ class Connection:
|
|||||||
# Kill current client
|
# Kill current client
|
||||||
self.adb_client.server_kill()
|
self.adb_client.server_kill()
|
||||||
# Init adb client
|
# Init adb client
|
||||||
self.adb_client = AdbClient('127.0.0.1', 5037)
|
del_cached_property(self, 'adb_client')
|
||||||
|
_ = self.adb_client
|
||||||
|
|
||||||
def serial_check(self):
|
def serial_check(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user