MCPcopy Create free account
hub / github.com/Action-State-Labs/android-action-kernel / get_screen_state

Function get_screen_state

kernel.py:22–38  ·  view source on GitHub ↗

Dumps the current UI XML and returns the sanitized JSON string.

()

Source from the content-addressed store, hash-verified

20
21
22def get_screen_state() -> str:
23 """Dumps the current UI XML and returns the sanitized JSON string."""
24 # 1. Capture XML from device
25 run_adb_command(["shell", "uiautomator", "dump", Config.SCREEN_DUMP_PATH])
26
27 # 2. Pull to local machine
28 run_adb_command(["pull", Config.SCREEN_DUMP_PATH, Config.LOCAL_DUMP_PATH])
29
30 # 3. Read & Sanitize
31 if not os.path.exists(Config.LOCAL_DUMP_PATH):
32 return "Error: Could not capture screen."
33
34 with open(Config.LOCAL_DUMP_PATH, "r", encoding="utf-8") as f:
35 xml_content = f.read()
36
37 elements = sanitizer.get_interactive_elements(xml_content)
38 return json.dumps(elements, indent=2)
39
40
41def run_agent(goal: str, max_steps: int = None) -> None:

Callers 1

run_agentFunction · 0.85

Calls 1

run_adb_commandFunction · 0.90

Tested by

no test coverage detected