scripts/private-emulator.py owns a disposable headless API 31 emulator. android_startup.py launches Werkzeug and waits for visible Home; it waits out only the System UI "isn't responding" dialog, so an app ANR still fails. Its regression tests run in make test. The input, profile and Workbook document-picker tests use it, find controls by text or content description, and allow a cold system picker more time. Local tests (on the final tree of this series, published pins, no local overrides, through build-queue): make test including ziran fmt --check, gui-smoke, gui-test, gallery-gui-test and web-smoke on private displays. Not run on these pins: the private-emulator Android gate. On an earlier pin the x86_64 APK built and validated and android-input-test passed until Entity's add-node page, which needs Kryon's density damage fix (78af4090); it runs with the next Kryon pin update. Co-Authored-By: Claude Opus 5.5 <[email protected]>
61 lines
2.5 KiB
Python
61 lines
2.5 KiB
Python
"""Wait for visible Home on an explicitly selected private Android emulator."""
|
|
import re
|
|
import shutil
|
|
import time
|
|
import xml.etree.ElementTree as ET
|
|
|
|
from android_labels import label_position
|
|
|
|
|
|
def wait_for_system_ui(adb, frame, output):
|
|
# Preserve evidence and wait only for the observed system dialog. An app
|
|
# ANR must remain a test failure.
|
|
if not label_position(frame, "Wait"):
|
|
return False
|
|
path = "/data/local/tmp/werk-startup-window.xml"
|
|
adb("shell", "rm", "-f", path)
|
|
dumped = adb("shell", "uiautomator", "dump", "--compressed", path, check=False)
|
|
if dumped.returncode:
|
|
return False
|
|
tree = adb("shell", "cat", path, check=False)
|
|
if tree.returncode:
|
|
return False
|
|
data = tree.stdout.decode()
|
|
if "System UI isn" not in data or "responding" not in data:
|
|
return False
|
|
try:
|
|
nodes = ET.fromstring(data).iter("node")
|
|
except ET.ParseError:
|
|
return False
|
|
for node in nodes:
|
|
if node.get("text") == "Wait":
|
|
bounds = list(map(int, re.findall(r"\d+", node.get("bounds", ""))))
|
|
if len(bounds) == 4:
|
|
shutil.copyfile(frame, output / "system-ui-dialog.png")
|
|
(output / "system-ui-window.xml").write_text(data)
|
|
print("Waiting for the private guest's System UI", flush=True)
|
|
adb("shell", "input", "tap", str((bounds[0] + bounds[2]) // 2),
|
|
str((bounds[1] + bounds[3]) // 2))
|
|
return True
|
|
return False
|
|
|
|
|
|
def launch_home(adb, output, package, name, timeout=180):
|
|
launch = adb("shell", "am", "start", "-W", "-n",
|
|
package + "/android.app.NativeActivity").stdout.decode()
|
|
(output / (name + ".txt")).write_text(launch)
|
|
# Android's launch metric can time out before a cold software guest draws
|
|
# its first frame. Require visible Home before interacting with its list.
|
|
deadline = time.monotonic() + timeout
|
|
system_waits = 0
|
|
while time.monotonic() < deadline:
|
|
frame = output / (name + "-home.png")
|
|
frame.write_bytes(adb("exec-out", "screencap", "-p").stdout)
|
|
if any(label_position(frame, word) for word in ("Werkzeug", "Pass", "Auth", "Calculator")):
|
|
print("Android Home visible after " + name, flush=True)
|
|
return
|
|
if system_waits == 0 and wait_for_system_ui(adb, frame, output):
|
|
system_waits = 1
|
|
time.sleep(.5)
|
|
raise AssertionError("Android Home did not become visible after " + name + ": " + launch)
|