Skip to content
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

Do not allow clearing Android logs if the emulator is not running #21578

Merged
merged 10 commits into from
Aug 22, 2024
17 changes: 16 additions & 1 deletion tools/python/run_adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,22 @@

def run_adb(android_sdk_root: str, args: typing.List[str]):
sdk_tool_paths = get_sdk_tool_paths(android_sdk_root)
run(sdk_tool_paths.adb, *args)
if is_emulator_running(sdk_tool_paths.adb):
run(sdk_tool_paths.adb, *args)
else:
print("No emulator is running.")
edgchen1 marked this conversation as resolved.
Show resolved Hide resolved


def is_emulator_running(adb_path) -> bool:
result = run(adb_path, "devices", capture_stdout=True)
output = result.stdout
output_str = output.decode("utf-8").strip()
lines = output_str.splitlines()
if len(lines) > 1:
for line in lines[1:]:
if "emulator" in line:
return True
return False


def main():
Expand Down
Loading