From 4959cf817fd94250c92d6c8a96b38a7244656803 Mon Sep 17 00:00:00 2001 From: Chris Rawles Date: Wed, 16 Oct 2024 11:26:12 -0700 Subject: [PATCH] Fix bug where stopwatch was not cleared before/after task execution. PiperOrigin-RevId: 686578732 --- android_world/task_evals/single/clock.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/android_world/task_evals/single/clock.py b/android_world/task_evals/single/clock.py index 80d576f..4c02e4a 100644 --- a/android_world/task_evals/single/clock.py +++ b/android_world/task_evals/single/clock.py @@ -100,11 +100,27 @@ def _is_timer_set( return False +def _close_clock_app(env: interface.AsyncEnv): + """Closes the clock app.""" + adb_utils.clear_app_data( + adb_utils.extract_package_name(adb_utils.get_adb_activity("clock")), + env.controller, + ) + + class _ClockEval(task_eval.TaskEval): """Base class for clock tasks.""" app_names = ("clock",) + def initialize_task(self, env: interface.AsyncEnv): + super().initialize_task(env) + _close_clock_app(env) + + def tear_down(self, env: interface.AsyncEnv): + super().tear_down(env) + _close_clock_app(env) + class ClockTimerEntry(_ClockEval): """Task for checking if timer is set (but not started)."""