Skip to content

Commit c690ed8

Browse files
committed
feat: adapt windows env
1 parent 43f47a1 commit c690ed8

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

hmdriver2/_client.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ def __check_device_so_file_exists() -> bool:
154154

155155
def __get_remote_md5sum() -> str:
156156
"""Get the MD5 checksum of the file on the device."""
157-
command = "md5sum /data/local/tmp/agent.so | awk '{ print $1 }'"
158-
result = self.hdc.shell(command).output.strip()
159-
return result
157+
command = "md5sum /data/local/tmp/agent.so"
158+
data = self.hdc.shell(command).output.strip()
159+
return data.split()[0]
160160

161161
def __get_local_md5sum(f: str) -> str:
162162
"""Calculate the MD5 checksum of a local file."""
@@ -183,10 +183,11 @@ def _restart_uitest_service(self):
183183
shell 44416 1 2 11:03:42 ? 00:00:01 uitest start-daemon com.hmtest.uitest@4x9@1"
184184
"""
185185
try:
186-
# pids: list = self.hdc.shell("pidof uitest").output.strip().split()
187-
result = self.hdc.shell("ps -ef | grep uitest | grep singleness").output.strip()
186+
result = self.hdc.shell("ps -ef").output.strip()
188187
lines = result.splitlines()
189-
for line in lines:
188+
filtered_lines = [line for line in lines if 'uitest' in line and 'singleness' in line]
189+
190+
for line in filtered_lines:
190191
if 'uitest start-daemon singleness' in line:
191192
parts = line.split()
192193
pid = parts[1]

hmdriver2/hdc.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ def list_apps(self) -> List[str]:
106106
return [item.strip() for item in raw]
107107

108108
def has_app(self, package_name: str) -> bool:
109-
data = self.shell(f"bm dump -a | grep {package_name}").output
110-
return True if data else False
109+
data = self.shell("bm dump -a").output
110+
return True if package_name in data else False
111111

112112
def start_app(self, package_name: str, ability_name: str):
113113
return self.shell(f"aa start -a {ability_name} -b {package_name}")
@@ -170,9 +170,6 @@ def send_key(self, key_code: Union[KeyCode, int]) -> None:
170170

171171
self.shell(f"uitest uiInput keyEvent {key_code}")
172172

173-
def hide_keyboard(self):
174-
self.shell("uinput -K -d 2 -i 2 -u 2")
175-
176173
def tap(self, x: int, y: int) -> None:
177174
self.shell(f"uitest uiInput click {x} {y}")
178175

0 commit comments

Comments
 (0)