From ec8f26be28892c70b0da7e392748a9a0fddf326c Mon Sep 17 00:00:00 2001 From: XixianLiang <51265902107@stu.ecnu.edu.cn> Date: Wed, 16 Oct 2024 16:01:18 +0800 Subject: [PATCH] update README --- README.md | 41 +++++++++++++++++++++++++++++++--------- droidbot/input_policy.py | 2 +- droidbot/start.py | 6 +++++- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9afceab5..ca560de9 100644 --- a/README.md +++ b/README.md @@ -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: + ``` + + (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: + count: 1000 + ``` + + Then, simply run `droidbot` or `python -m droidbot.start` to start. + + **Run HMDroidbot by `python -m`** ```bash python3 -m droidbot.start -a -o output_dir -is_harmonyos ``` - Run droidbot by `droidbot` + **Run HMDroidbot by `droidbot`** ```bash droidbot -a -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. @@ -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`. - -image - 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. diff --git a/droidbot/input_policy.py b/droidbot/input_policy.py index a127a173..47e7b4b6 100644 --- a/droidbot/input_policy.py +++ b/droidbot/input_policy.py @@ -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 diff --git a/droidbot/start.py b/droidbot/start.py index 941c2e40..1a13e2ba 100644 --- a/droidbot/start.py +++ b/droidbot/start.py @@ -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: