Merge pull request #436 from LmeSzinc/dev

Bug fix
This commit is contained in:
LmeSzinc 2024-04-30 00:53:52 +08:00 committed by GitHub
commit 3579d68ad0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 37 additions and 1 deletions

View File

@ -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):

View File

@ -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]:
"""

View File

@ -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,25 @@ from module.logger import logger
RETRY_TRIES = 5
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 """

View File

@ -0,0 +1,4 @@
def handle_notify(*args, **kwargs):
# Lazy import onepush
from module.notify.notify import handle_notify
return handle_notify(*args, **kwargs)