diff options
author | Yan Wang <yawanng@google.com> | 2019-07-24 10:40:38 -0700 |
---|---|---|
committer | Yan Wang <yawanng@google.com> | 2019-07-30 19:04:20 -0700 |
commit | 59aab11f092b4f9d817c331a470fa8d2fad445ab (patch) | |
tree | 12d66a092bd2a107e015cd9c59fa8e70ac4d8919 /startop/scripts/app_startup/lib/adb_utils.py | |
parent | 06f54882c06da4b3090f2edfe321c07b1a7ec2a6 (diff) |
startop: Rewrite the perfetto trace collection part.
Test: pytest perfetto_trace_collector_test.py
Bug: 138233615
Change-Id: If13d895029e734a5e52bed73c5f870bb3f036c2f
Diffstat (limited to 'startop/scripts/app_startup/lib/adb_utils.py')
-rw-r--r-- | startop/scripts/app_startup/lib/adb_utils.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/startop/scripts/app_startup/lib/adb_utils.py b/startop/scripts/app_startup/lib/adb_utils.py index 0e0065defd7f..1c60a17ada1b 100644 --- a/startop/scripts/app_startup/lib/adb_utils.py +++ b/startop/scripts/app_startup/lib/adb_utils.py @@ -104,4 +104,21 @@ def blocking_wait_for_logcat_displayed_time(timestamp: datetime.datetime, return None displayed_time = result[result.rfind('+'):] - return parse_time_to_milliseconds(displayed_time)
\ No newline at end of file + return parse_time_to_milliseconds(displayed_time) + +def delete_file_on_device(file_path: str) -> None: + """ Deletes a file on the device. """ + cmd_utils.run_adb_shell_command( + "[[ -f '{file_path}' ]] && rm -f '{file_path}' || " + "exit 0".format(file_path=file_path)) + +def set_prop(property: str, value: str) -> None: + """ Sets property using adb shell. """ + cmd_utils.run_adb_shell_command('setprop "{property}" "{value}"'.format( + property=property, value=value)) + +def pull_file(device_file_path: str, output_file_path: str) -> None: + """ Pulls file from device to output """ + cmd_utils.run_shell_command('adb pull "{device_file_path}" "{output_file_path}"'. + format(device_file_path=device_file_path, + output_file_path=output_file_path)) |