Skip to content

Commit e1b6192

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents ccd2063 + 5efbd5e commit e1b6192

7 files changed

Lines changed: 148 additions & 76 deletions

File tree

campaign/event_20260520_cn/b2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ class Config(ConfigBase):
6464
MAP_WALK_USE_CURRENT_FLEET = True
6565
# ===== End of generated config =====
6666

67+
HOMO_STORAGE = ((8, 6), [(137.405, 104.804), (1046.044, 104.804), (-12.171, 652.093), (1166.717, 652.093)])
68+
MAP_ENSURE_EDGE_INSIGHT_CORNER = 'bottom-right'
69+
6770

6871
class Campaign(CampaignBase):
6972
MAP = MAP

campaign/event_20260520_cn/d2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ class Config(ConfigBase):
6565
MAP_WALK_USE_CURRENT_FLEET = True
6666
# ===== End of generated config =====
6767

68+
HOMO_STORAGE = ((8, 6), [(137.405, 104.804), (1046.044, 104.804), (-12.171, 652.093), (1166.717, 652.093)])
69+
MAP_ENSURE_EDGE_INSIGHT_CORNER = 'bottom-right'
70+
6871

6972
class Campaign(CampaignBase):
7073
MAP = MAP

module/device/connection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
from module.device.connection_attr import ConnectionAttr
2020
from module.device.env import IS_LINUX, IS_MACINTOSH, IS_WINDOWS
2121
from module.device.method.pool import WORKER_POOL
22+
from module.device.method.remove_warning import remove_shell_warning
2223
from module.device.method.utils import (PackageNotInstalled, RETRY_TRIES, get_serial_pair, handle_adb_error,
2324
handle_unknown_host_service, possible_reasons, random_port, recv_all,
24-
remove_shell_warning, retry_sleep)
25+
retry_sleep)
2526
from module.exception import EmulatorNotRunningError, RequestHumanTakeover
2627
from module.logger import logger
2728
from module.map.map_grids import SelectedGrids

module/device/method/adb.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
from module.base.decorator import Config
1111
from module.config.server import DICT_PACKAGE_TO_ACTIVITY
1212
from module.device.connection import Connection
13+
from module.device.method.remove_warning import remove_screenshot_warning
1314
from module.device.method.utils import (ImageTruncated, PackageNotInstalled, RETRY_TRIES, handle_adb_error,
14-
handle_unknown_host_service, remove_prefix, retry_sleep)
15+
handle_unknown_host_service, retry_sleep)
1516
from module.exception import RequestHumanTakeover, ScriptError
1617
from module.logger import logger
1718

@@ -120,10 +121,7 @@ def __load_screenshot(screenshot, method):
120121
else:
121122
raise ScriptError(f'Unknown method to load screenshots: {method}')
122123

123-
# fix compatibility issues for adb screencap decode problem when the data is from vmos pro
124-
# When use adb screencap for a screenshot from vmos pro, there would be a header more than that from emulator
125-
# which would cause image decode problem. So i check and remove the header there.
126-
screenshot = remove_prefix(screenshot, b'long long=8 fun*=10\n')
124+
screenshot = remove_screenshot_warning(screenshot)
127125

128126
image = np.frombuffer(screenshot, np.uint8)
129127
if image is None:
@@ -166,6 +164,7 @@ def screenshot_adb(self):
166164
@Config.when(DEVICE_OVER_HTTP=True)
167165
def screenshot_adb(self):
168166
data = self.adb_shell(['screencap'], stream=True)
167+
data = remove_screenshot_warning(data)
169168
if len(data) < 500:
170169
logger.warning(f'Unexpected screenshot: {data}')
171170

@@ -174,6 +173,7 @@ def screenshot_adb(self):
174173
@retry
175174
def screenshot_adb_nc(self):
176175
data = self.adb_shell_nc(['screencap'])
176+
data = remove_screenshot_warning(data)
177177
if len(data) < 500:
178178
logger.warning(f'Unexpected screenshot: {data}')
179179

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
from typing import overload
2+
3+
4+
@overload
5+
def remove_shell_warning(s: bytes) -> bytes: ...
6+
7+
8+
@overload
9+
def remove_shell_warning(s: str) -> str: ...
10+
11+
12+
def remove_shell_warning(s):
13+
"""
14+
Remove warnings from shell
15+
16+
1. Warnings in VMOS shell
17+
https://github.com/LmeSzinc/AzurLaneAutoScript/issues/1425
18+
19+
WARNING: linker: [vdso]: unused DT entry: type 0x70000001 arg 0x0\n
20+
\x89PNG\r\n\x1a\n\x00\x00\x00\rIH...
21+
22+
2. This linker thingy might appear multiple times when executing multiple commands
23+
24+
mek_8q:/dev # getprop | grep gnss
25+
WARNING: linker: Warning: "[vdso]" unused DT entry: unknown processor-specific (type 0x70000001 arg 0x0) (ignoring)
26+
WARNING: linker: Warning: "[vdso]" unused DT entry: unknown processor-specific (type 0x70000001 arg 0x0) (ignoring)
27+
[init.svc.gnss_service]: [running]
28+
[init.svc_debug_pid.gnss_service]: [406]
29+
[ro.boottime.gnss_service]: [27308752875]
30+
31+
Args:
32+
s (str | bytes): bytes or str
33+
34+
Returns:
35+
str | bytes: Shell output with warnings removed
36+
"""
37+
if isinstance(s, bytes):
38+
while 1:
39+
if s.startswith(b'WARNING: linker:'):
40+
_, _, s = s.partition(b'\n')
41+
else:
42+
break
43+
elif isinstance(s, str):
44+
while 1:
45+
if s.startswith('WARNING: linker:'):
46+
_, _, s = s.partition('\n')
47+
else:
48+
break
49+
50+
return s
51+
52+
53+
@overload
54+
def remove_screenshot_warning(s: bytes) -> bytes: ...
55+
56+
57+
@overload
58+
def remove_screenshot_warning(s: str) -> str: ...
59+
60+
61+
def remove_screenshot_warning(s):
62+
"""
63+
Remove warnings when taking screenshot
64+
65+
1. Errors in waydroid screencap render
66+
https://github.com/LmeSzinc/AzurLaneAutoScript/issues/4760
67+
68+
Failed to create //.cache for shader cache (Read-only file system)---disabling.\n
69+
70+
2. Warning when taking screenshot from multiscreen device
71+
72+
[Warning] Multiple displays were found, but no display id was specified! Defaulting to the first display found,
73+
however this default is not guaranteed to be consistent across captures.\n
74+
A display id should be specified.\n
75+
See "dumpsys SurfaceFlinger --display-id" for valid display IDs.\n
76+
\x89PNG...
77+
78+
3. Another format of multiscreen warning
79+
https://github.com/LmeSzinc/AzurLaneAutoScript/issues/5682
80+
81+
[Warning] Multiple displays were found, but no display id was specified! Defaulting to the first display found,
82+
however this default is not guaranteed to be consistent across captures. A display id should be specified.\n
83+
A display ID can be specified with the [-d display-id] option.\n
84+
See "dumpsys SurfaceFlinger --display-id" for valid display IDs.\n
85+
\x89PNG...
86+
87+
4. Unknown header on VMOS PRO screenshot
88+
https://github.com/LmeSzinc/AzurLaneAutoScript/pull/940
89+
90+
long long=8 fun*=10\n\x89PNG...
91+
92+
Args:
93+
s (str | bytes): bytes or str
94+
95+
Returns:
96+
str | bytes: Screenshot data with warnings removed
97+
"""
98+
if isinstance(s, bytes):
99+
if s.startswith(b'Failed to create'):
100+
_, _, s = s.partition(b'\n')
101+
if s.startswith(b'[Warning] Multiple displays'):
102+
_, _, s = s.partition(b'\n')
103+
if s.startswith(b'A display id') or s.startswith(b'A display ID'):
104+
_, _, s = s.partition(b'\n')
105+
if s.startswith(b'See "dumpsys'):
106+
_, _, s = s.partition(b'\n')
107+
if s.startswith(b'long long=8'):
108+
_, _, s = s.partition(b'\n')
109+
110+
elif isinstance(s, str):
111+
if s.startswith('Failed to create'):
112+
_, _, s = s.partition('\n')
113+
if s.startswith('[Warning] Multiple displays'):
114+
_, _, s = s.partition('\n')
115+
if s.startswith('A display id') or s.startswith('A display ID'):
116+
_, _, s = s.partition('\n')
117+
if s.startswith('See "dumpsys'):
118+
_, _, s = s.partition('\n')
119+
if s.startswith('long long=8'):
120+
_, _, s = s.partition('\n')
121+
122+
return s

module/device/method/utils.py

Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from adbutils import AdbTimeout
1111
from lxml import etree
1212

13+
from module.device.method.remove_warning import remove_shell_warning
14+
1315
try:
1416
# adbutils 0.x
1517
from adbutils import _AdbStreamConnection as AdbConnection
@@ -327,74 +329,6 @@ def remove_suffix(s, suffix):
327329
return s[:-len(suffix)] if s.endswith(suffix) else s
328330

329331

330-
def remove_shell_warning(s):
331-
"""
332-
Remove warnings from shell
333-
334-
1. Warnings in VMOS shell
335-
https://github.com/LmeSzinc/AzurLaneAutoScript/issues/1425
336-
337-
WARNING: linker: [vdso]: unused DT entry: type 0x70000001 arg 0x0\n\x89PNG\r\n\x1a\n\x00\x00\x00\rIH
338-
339-
2. This linker thingy might appear multiple times when executing multiple commands
340-
341-
mek_8q:/dev # getprop | grep gnss
342-
WARNING: linker: Warning: "[vdso]" unused DT entry: unknown processor-specific (type 0x70000001 arg 0x0) (ignoring)
343-
WARNING: linker: Warning: "[vdso]" unused DT entry: unknown processor-specific (type 0x70000001 arg 0x0) (ignoring)
344-
[init.svc.gnss_service]: [running]
345-
[init.svc_debug_pid.gnss_service]: [406]
346-
[ro.boottime.gnss_service]: [27308752875]
347-
348-
3. Errors in waydroid screencap render
349-
https://github.com/LmeSzinc/AzurLaneAutoScript/issues/4760
350-
351-
Failed to create //.cache for shader cache (Read-only file system)---disabling.\n
352-
353-
4. Warning when taking screenshot from multiscreen device
354-
355-
[Warning] Multiple displays were found, but no display id was specified! Defaulting to the first display found,
356-
however this default is not guaranteed to be consistent across captures.\n
357-
A display id should be specified.\n
358-
See "dumpsys SurfaceFlinger --display-id" for valid display IDs.\n
359-
\x89PNG...
360-
361-
Args:
362-
s (T): bytes or str
363-
364-
Returns:
365-
T:
366-
"""
367-
if isinstance(s, bytes):
368-
while 1:
369-
if s.startswith(b'WARNING: linker:'):
370-
_, _, s = s.partition(b'\n')
371-
else:
372-
break
373-
if s.startswith(b'Failed to create'):
374-
_, _, s = s.partition(b'\n')
375-
if s.startswith(b'[Warning] Multiple displays'):
376-
_, _, s = s.partition(b'\n')
377-
if s.startswith(b'A display id'):
378-
_, _, s = s.partition(b'\n')
379-
if s.startswith(b'See "dumpsys'):
380-
_, _, s = s.partition(b'\n')
381-
elif isinstance(s, str):
382-
while 1:
383-
if s.startswith('WARNING: linker:'):
384-
_, _, s = s.partition('\n')
385-
else:
386-
break
387-
if s.startswith('Failed to create'):
388-
_, _, s = s.partition('\n')
389-
if s.startswith('[Warning] Multiple displays'):
390-
_, _, s = s.partition('\n')
391-
if s.startswith('A display id'):
392-
_, _, s = s.partition('\n')
393-
if s.startswith('See "dumpsys'):
394-
_, _, s = s.partition('\n')
395-
return s
396-
397-
398332
class IniterNoMinicap(u2.init.Initer):
399333
@property
400334
def minicap_urls(self):

module/map/map_fleet_preparation.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,17 @@ def in_use(self):
267267

268268
# Cropping FLEET_*_IN_USE to avoid detecting info_bar, also do the trick.
269269
# It also avoids wasting time on handling the info_bar.
270-
image = rgb2gray(self.main.image_crop(self._in_use.button, copy=False))
271-
return np.std(image.flatten(), ddof=1) > self.FLEET_IN_USE_STD
270+
image = self.main.image_crop(self._in_use.button, copy=False)
271+
272+
# special fix for Perseus skin, which color is so flat
273+
# https://github.com/LmeSzinc/AzurLaneAutoScript/issues/5678
274+
# no ship is in color (71, 70, 63)
275+
color = cv2.mean(image)[:3]
276+
if color_similar(color, (224, 154, 114), threshold=30):
277+
return True
278+
279+
gray = rgb2gray(image)
280+
return np.std(gray.flatten(), ddof=1) > self.FLEET_IN_USE_STD
272281

273282
def bar_opened(self):
274283
"""

0 commit comments

Comments
 (0)