Skip to content

Support x86 emulator and Add press_keys、go_recent #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions hmdriver2/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ def init(self):
time.sleep(0.5)

def _get_local_agent_path(self) -> str:
"""Return the local path of the agent file."""
target_agent = "uitest_agent_v1.1.0.so"
"""Return the local path of the agent file, based on the cpu_abi version (e.g., 'so/arm64-v8a/agent.so')."""
cpu_abi = self.hdc.cpu_abi()

target_agent = os.path.join("so", cpu_abi, "agent.so")
return os.path.join(os.path.dirname(os.path.realpath(__file__)), "assets", target_agent)

def _get_remote_md5sum(self, file_path: str) -> Optional[str]:
Expand Down
Binary file added hmdriver2/assets/so/arm64-v8a/agent.so
Binary file not shown.
Binary file added hmdriver2/assets/so/x86_64/agent.so
Binary file not shown.
Binary file removed hmdriver2/assets/uitest_agent_v1.0.7.so
Binary file not shown.
Binary file removed hmdriver2/assets/uitest_agent_v1.1.0.so
Binary file not shown.
13 changes: 13 additions & 0 deletions hmdriver2/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,23 @@ def go_back(self):
def go_home(self):
self.hdc.send_key(KeyCode.HOME)

@delay
def go_recent(self):
self.press_keys(KeyCode.META_LEFT, KeyCode.TAB)

@delay
def press_key(self, key_code: Union[KeyCode, int]):
self.hdc.send_key(key_code)

@delay
def press_keys(self, key_code1: Union[KeyCode, int], key_code2: Union[KeyCode, int]):
"""Press two keys in sequence, given their integer key codes."""
code1 = key_code1.value if isinstance(key_code1, KeyCode) else key_code1
code2 = key_code2.value if isinstance(key_code2, KeyCode) else key_code2

api = "Driver.triggerCombineKeys"
self._invoke(api, args=[code1, code2])

def screen_on(self):
self.hdc.wakeup()

Expand Down