fix(ctl): the broadcast fallback only stands in for a missing content command

This commit is contained in:
Kurt Himebauch committed 2026-11-09 12:26:37 -05:00
1 parent 05f50c3232
commit 941cfe9c44
2 files changed
+49 -1

No files matched your search

+6 -1
View File
@@ -100,6 +100,10 @@ def encode_request(request: dict) -> str:
def receiver_call(adb: str, serial: str, method: str, request: dict | None, timeout: float) -> dict:
"""The agent bridge through a broadcast, for shells without the `content` command."""
# Its receiver is registered by the running app; a broadcast does not start the app the way `content call` does
running = run_adb(adb, serial, "shell", f"pidof {PACKAGE}", timeout=30)
if not running.stdout.decode(errors="replace").strip():
raise ControlError(f"{PACKAGE} is not running and this shell has no `content` command to start it; open DroidDeck once", "APP_NOT_RUNNING")
call_id = uuid.uuid4().hex[:16]
remote = f"/sdcard/Android/data/{PACKAGE}/files/agent-calls/{call_id}.json"
command = ["shell", "am", "broadcast", "-a", f"{PACKAGE}.AGENT_CALL", "-p", PACKAGE,
@@ -129,7 +133,8 @@ def provider_call(adb: str, serial: str, method: str, arg: str | None = None, re
command.extend(["--extra", f"request:s:{encoded}"])
result = run_adb(adb, serial, *command, timeout=timeout)
output = (result.stdout + result.stderr).decode(errors="replace")
if "content: inaccessible or not found" in output:
# Only the shell's own answer for a missing `content` binary, never a command's output that quotes it
if result.returncode == 127 and "Result:" not in output and "content: inaccessible or not found" in result.stderr.decode(errors="replace") + output:
return receiver_call(adb, serial, method, request, timeout)
response = _content_result(output)
if result.returncode != 0 and response.get("ok") is not False: