From a3ce30dc96c7bcd0ee242abc03867671b2d7b991 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Tue, 30 Apr 2024 00:50:58 +0800 Subject: [PATCH 1/5] Fix: VALID_CLOUD_PACKAGE uses wrong package list causing cloud game client undetected during emulator start --- module/config/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/config/server.py b/module/config/server.py index ee3fc23f0..899284329 100644 --- a/module/config/server.py +++ b/module/config/server.py @@ -18,7 +18,7 @@ VALID_PACKAGE = set(list(VALID_SERVER.values())) VALID_CLOUD_SERVER = { 'CN-Official': 'com.miHoYo.cloudgames.hkrpg', } -VALID_CLOUD_PACKAGE = set(list(VALID_SERVER.values())) +VALID_CLOUD_PACKAGE = set(list(VALID_CLOUD_SERVER.values())) def set_lang(lang_: str): From 3179cdc81d6b0064c2a231dcc08e7e06a99efa47 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Sun, 28 Apr 2024 17:12:03 +0800 Subject: [PATCH 2/5] Opt: [ALAS] Lazy import onepush (cherry picked from commit 63fd8b63f6574137a0ec0840440cab951f4f40df) --- module/notify/__init__.py | 4 ++++ module/{ => notify}/notify.py | 0 2 files changed, 4 insertions(+) create mode 100644 module/notify/__init__.py rename module/{ => notify}/notify.py (100%) diff --git a/module/notify/__init__.py b/module/notify/__init__.py new file mode 100644 index 000000000..58df2006e --- /dev/null +++ b/module/notify/__init__.py @@ -0,0 +1,4 @@ +def handle_notify(*args, **kwargs): + # Lazy import onepush + from module.notify.notify import handle_notify + return handle_notify(*args, **kwargs) diff --git a/module/notify.py b/module/notify/notify.py similarity index 100% rename from module/notify.py rename to module/notify/notify.py From 6818a9d86cb88d00fa90059c1191a6657b83494c Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Mon, 29 Apr 2024 23:41:32 +0800 Subject: [PATCH 3/5] Fix: [ALAS] Patch u2.init.appdir in runtime --- module/device/method/utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/module/device/method/utils.py b/module/device/method/utils.py index 50b7ecc70..b4845a382 100644 --- a/module/device/method/utils.py +++ b/module/device/method/utils.py @@ -1,3 +1,4 @@ +import os import random import re import socket @@ -5,6 +6,7 @@ import time import typing as t import uiautomator2 as u2 +import uiautomator2cache from adbutils import AdbTimeout from lxml import etree @@ -51,6 +53,9 @@ from module.logger import logger RETRY_TRIES = 5 RETRY_DELAY = 3 +# Patch uiautomator2 appdir +u2.init.appdir = os.path.dirname(uiautomator2cache.__file__) + def is_port_using(port_num): """ if port is using by others, return True. else return False """ From 24fbff17ef86d094195c69718908363c5834d237 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Mon, 29 Apr 2024 23:43:54 +0800 Subject: [PATCH 4/5] Chore: [ALAS] Add method uninstall_uiautomator2 --- module/device/method/uiautomator_2.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/module/device/method/uiautomator_2.py b/module/device/method/uiautomator_2.py index 765f7dde6..c116bce94 100644 --- a/module/device/method/uiautomator_2.py +++ b/module/device/method/uiautomator_2.py @@ -242,6 +242,17 @@ class Uiautomator2(Connection): hierarchy = etree.fromstring(content.encode('utf-8')) return hierarchy + def uninstall_uiautomator2(self): + logger.info('Removing uiautomator2') + for file in [ + 'app-uiautomator.apk', + 'app-uiautomator-test.apk', + 'minitouch', + 'minitouch.so', + 'atx-agent', + ]: + self.adb_shell(["rm", f"/data/local/tmp/{file}"]) + @retry def resolution_uiautomator2(self, cal_rotation=True) -> t.Tuple[int, int]: """ From f959b090f0fc86e72992980e6cb855671257300e Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Tue, 30 Apr 2024 00:01:33 +0800 Subject: [PATCH 5/5] Chore: [ALAS] Patch uiautomator2 loggers so they can be logged in Alas --- module/device/method/utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/module/device/method/utils.py b/module/device/method/utils.py index b4845a382..352d4361b 100644 --- a/module/device/method/utils.py +++ b/module/device/method/utils.py @@ -56,6 +56,22 @@ RETRY_DELAY = 3 # Patch uiautomator2 appdir u2.init.appdir = os.path.dirname(uiautomator2cache.__file__) +# Patch uiautomator2 logger +u2_logger = u2.logger +u2_logger.debug = logger.info +u2_logger.info = logger.info +u2_logger.warning = logger.warning +u2_logger.error = logger.error +u2_logger.critical = logger.critical + + +def setup_logger(*args, **kwargs): + return u2_logger + + +u2.setup_logger = setup_logger +u2.init.setup_logger = setup_logger + def is_port_using(port_num): """ if port is using by others, return True. else return False """