Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
XixianLiang committed Oct 16, 2024
1 parent e968f6d commit ec8f26b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
41 changes: 32 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,46 @@ It can send random or scripted input events to test an HarmonyOS app, achieve hi
bash run_sample.sh
```

2. **Start HMDroidbot:**
3. **Setting up `config.ymal`**

Use the correct param based on your PC operating system.

Run droidbot by `python -m`.
(Required) `env` is necessary to lanuch HMDroidbot
```bash
# config.ymal
env: <windows, macOS or Linux>
```

(Optional) You can configure other parameters in the config.yaml file to run Droidbot more conveniently, avoiding the need to specify them via command-line arguments. See ***Run HMDroidbot by yaml configuration*** below.


1. **Start HMDroidbot:**

**:+1: (Recommand) Run HMDroidbot by configuring `config.ymal` file. Here's an example `config.ymal` configuration.**
```bash
# env: the system of your PC (e.g. windows, macOS, Linux)
env: macOS
# system: the target harmonyOS
system: harmonyOS
device: 23E**********1843
output_dir: output
apk_path: <absolute_path_to_hap>
count: 1000
```
Then, simply run `droidbot` or `python -m droidbot.start` to start.
**Run HMDroidbot by `python -m`**
```bash
python3 -m droidbot.start -a <absolute_path_to_hap> -o output_dir -is_harmonyos
```
Run droidbot by `droidbot`
**Run HMDroidbot by `droidbot`**
```bash
droidbot -a <absolute_path_to_hap> -o output_dir -is_harmonyos
```


> Attention! -a is used to specify the path to hap, please use absolute path here!
That's it! You will find much useful information, including the UTG, generated in the output dir.
Expand All @@ -106,10 +133,6 @@ It can send random or scripted input events to test an HarmonyOS app, achieve hi
## Trouble shooting
You should use the correct `SYSTEM` variable in `droidbot/adapter/hdc.py`.

<img width="687" alt="image" src="https://github.com/user-attachments/assets/b8de8da9-7d95-4e1e-b032-8cb5a5b00bc3">

We used WSL to develop this project. so the hdc tool we used in this project is actually `hdc.exe` by adding `/mnt/.../hdc.exe` on windows to the WSL PATH.
Due to HarmonyOS NEXT being in beta, the process of configuring the hdc environment is somewhat complex (especially on WSL). The overall idea for WSL configuration is to install the hdc tool on the host system and export the `hdc.exe` from the host system path through the WSL `mnt` path (since the phone is connected to the host system, this eliminates the need to configure USB port forwarding). If you encounter any issues while setting up the environment, please feel free to contact us.
Expand Down
2 changes: 1 addition & 1 deletion droidbot/input_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def start(self, input_manager:"InputManager"):
event = self.generate_event()
input_manager.add_event(event)

self.logger.info("Cost time {:3f}s".format((current_time := time.perf_counter()) - self.cache_time))
self.logger.debug("Input event cost time {:3f}s".format((current_time := time.perf_counter()) - self.cache_time))
self.cache_time = current_time
except KeyboardInterrupt:
break
Expand Down
6 changes: 5 additions & 1 deletion droidbot/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ def main():
it starts a droidbot according to the arguments given in cmd line
"""
opts = parse_args()

if not any(os.path.exists(ymal_path := os.path.join(os.getcwd(), _)) for _ in ["config.yml", "config.ymal"]):
logger.error("config.ymal not found")
return

with open(os.path.join(os.getcwd(), "config.yml"), "r") as fp:
with open(ymal_path, "r") as fp:
config_dir:dict[str, str] = yaml.safe_load(fp)
for key, value in config_dir.items():
if key.lower() == "system" and value:
Expand Down

0 comments on commit ec8f26b

Please sign in to comment.