From a59cd12c01826d7e68b7c7cd58ce356be9cceb14 Mon Sep 17 00:00:00 2001 From: YoursFunny Date: Mon, 6 Jul 2026 01:31:11 +0800 Subject: [PATCH] fix: patch to fix atx_agent_url on arm64-v8a --- deploy/Windows/patch.py | 32 ++++++++++++++++++++++++++++++-- module/device/method/utils.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/deploy/Windows/patch.py b/deploy/Windows/patch.py index a1d3be0..2d1e4fb 100644 --- a/deploy/Windows/patch.py +++ b/deploy/Windows/patch.py @@ -59,17 +59,34 @@ def patch_uiautomator2(): https://tool.appetizer.io is added to bypass the wall in China but https://tool.appetizer.io is slow outside of CN plus some CN users cannot access it for unknown reason. - So we patch `uiautomator2/init.py` to a local assets cache `uiautomator2cache/cache`. + 1. So we patch `uiautomator2/init.py` to a local assets cache `uiautomator2cache/cache`. appdir = os.path.join(os.path.expanduser('~'), '.uiautomator2') to: appdir = os.path.join(__file__, '../../uiautomator2cache') - And we also remove minicap installations since emulators doesn't need it. + 2. And we also remove minicap installations since emulators doesn't need it. for url in self.minicap_urls: self.push_url(url) to: for url in []: self.push_url(url) + + 3. Fix atx_agent_url so ARM Mac can have correct ATX installed + ``` + @property + def atx_agent_url(self): + files = { + 'armeabi-v7a': 'atx-agent_{v}_linux_armv7.tar.gz', + 'arm64-v8a': 'atx-agent_{v}_linux_armv7.tar.gz', + 'armeabi': 'atx-agent_{v}_linux_armv6.tar.gz', + 'x86': 'atx-agent_{v}_linux_386.tar.gz', + 'x86_64': 'atx-agent_{v}_linux_386.tar.gz', + } + ``` + where + 'arm64-v8a': 'atx-agent_{v}_linux_armv7.tar.gz', + to + 'arm64-v8a': 'atx-agent_{v}_linux_arm64.tar.gz', """ init_file = './toolkit/Lib/site-packages/uiautomator2/init.py' cache_dir = './toolkit/Lib/site-packages/uiautomator2cache/cache' @@ -92,6 +109,17 @@ def patch_uiautomator2(): else: logger.info(f'{init_file} minicap_urls no need to patch') + # Patch atx_agent_url + res = re.search(r"'arm64-v8a': 'atx-agent_\{v}_linux_armv7.tar.gz'", content) + if res: + content = re.sub(r"'arm64-v8a': 'atx-agent_\{v}_linux_armv7.tar.gz'", + "'arm64-v8a': 'atx-agent_{v}_linux_arm64.tar.gz'", + content) + modified = True + logger.info(f'{init_file} atx_agent_url patched') + else: + logger.info(f'{init_file} atx_agent_url no need to patch') + # Patch appdir if os.path.exists(cache_dir): res = re.search(r'appdir ?=(.*)\n', content) diff --git a/module/device/method/utils.py b/module/device/method/utils.py index e22eeb2..18aceef 100644 --- a/module/device/method/utils.py +++ b/module/device/method/utils.py @@ -72,6 +72,39 @@ def setup_logger(*args, **kwargs): u2.setup_logger = setup_logger u2.init.setup_logger = setup_logger + +# Patch Initer +class PatchedIniter(u2.init.Initer): + @property + def atx_agent_url(self): + files = { + 'armeabi-v7a': 'atx-agent_{v}_linux_armv7.tar.gz', + # 'arm64-v8a': 'atx-agent_{v}_linux_armv7.tar.gz', + 'arm64-v8a': 'atx-agent_{v}_linux_arm64.tar.gz', + 'armeabi': 'atx-agent_{v}_linux_armv6.tar.gz', + 'x86': 'atx-agent_{v}_linux_386.tar.gz', + 'x86_64': 'atx-agent_{v}_linux_386.tar.gz', + } + name = None + for abi in self.abis: + name = files.get(abi) + if name: + break + if not name: + raise Exception( + "arch(%s) need to be supported yet, please report an issue in github" + % self.abis) + return u2.init.GITHUB_BASEURL + '/atx-agent/releases/download/%s/%s' % ( + u2.version.__atx_agent_version__, name.format(v=u2.version.__atx_agent_version__)) + + @property + def minicap_urls(self): + return [] + + +u2.init.Initer = PatchedIniter + + def is_port_using(port_num): """ if port is using by others, return True. else return False """ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)