Skip to content

Commit

Permalink
feat: adapt windows env
Browse files Browse the repository at this point in the history
  • Loading branch information
codematrixer committed Sep 14, 2024
1 parent 43f47a1 commit c690ed8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
13 changes: 7 additions & 6 deletions hmdriver2/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ def __check_device_so_file_exists() -> bool:

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

def __get_local_md5sum(f: str) -> str:
"""Calculate the MD5 checksum of a local file."""
Expand All @@ -183,10 +183,11 @@ def _restart_uitest_service(self):
shell 44416 1 2 11:03:42 ? 00:00:01 uitest start-daemon com.hmtest.uitest@4x9@1"
"""
try:
# pids: list = self.hdc.shell("pidof uitest").output.strip().split()
result = self.hdc.shell("ps -ef | grep uitest | grep singleness").output.strip()
result = self.hdc.shell("ps -ef").output.strip()
lines = result.splitlines()
for line in lines:
filtered_lines = [line for line in lines if 'uitest' in line and 'singleness' in line]

for line in filtered_lines:
if 'uitest start-daemon singleness' in line:
parts = line.split()
pid = parts[1]
Expand Down
7 changes: 2 additions & 5 deletions hmdriver2/hdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def list_apps(self) -> List[str]:
return [item.strip() for item in raw]

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

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

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

def hide_keyboard(self):
self.shell("uinput -K -d 2 -i 2 -u 2")

def tap(self, x: int, y: int) -> None:
self.shell(f"uitest uiInput click {x} {y}")

Expand Down

0 comments on commit c690ed8

Please sign in to comment.