Skip to content

Commit

Permalink
Add check for stuck sending screen in SMS validator. In case the emul…
Browse files Browse the repository at this point in the history
…ator fails for an unknown reason.

PiperOrigin-RevId: 693065043
  • Loading branch information
Chris Rawles authored and The android_world Authors committed Nov 4, 2024
1 parent 27ce392 commit af271d0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions android_world/task_evals/common_validators/sms_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ def is_successful(self, env: interface.AsyncEnv) -> float:
)
== "com.simplemobiletools.smsmessenger"
)
if _check_if_stuck_at_sending(env):
raise ValueError(
"Message could not be sent due to Android/emulator issue."
)
return 1.0 if sms_was_sent and in_correct_app else 0.0

@classmethod
Expand All @@ -272,3 +276,12 @@ def generate_random_params(cls) -> dict[str, str | int]:
"number": number,
"message": message,
}


def _check_if_stuck_at_sending(env: interface.AsyncEnv) -> bool:
"""Checks if the app is stuck at the sending screen."""
state = env.get_state()
for element in state.ui_elements:
if element.text is not None and element.text.startswith("Sending"):
return True
return False

0 comments on commit af271d0

Please sign in to comment.