Repository navigation
fix: let clear_text see the "Unknown command" answer on Android 7-11 - #40
Merged
Jeomon merged 1 commit intoOct 25, 2026
Merged
Conversation
Before Android 12, `input` has no keycombination command. AOSP's Input (through BaseCommand on Android 10-11) prints "Error: Unknown command: keycombination" to stderr and still exits 0. adb shell keeps stderr apart from stdout, and shell() returns only stdout, so clear_text never saw the answer: it pressed Delete once, removing one character, and the text that followed was typed after the field's old contents. Merge stderr into stdout for the probe so the documented fallback runs. The test double now answers on stdout only when the command merges the streams, as a real device does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014TonJ1geSd97oAtSBZofUK
Member
|
Thanks |
Jeomon
pushed a commit
that referenced
this pull request
Nov 11, 2026
input draganddrop exists from Android 8.0. On Android 7.x, AOSP's Input prints "Error: Unknown command: draganddrop" to stderr and returns normally, so it exits 0. shell() returns stdout only and raises only on a non-zero exit, so drag() returned as if it had worked: the Drag tool told the agent "Dragged from ... and dropped on ..." while nothing moved, and the docstring's "earlier releases fail with an adb error" never happened. Merge stderr into stdout for the command and raise AdbError on "Unknown command", which every tool already turns into a message for the agent. Same cause as the clear_text fix in #40. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014TonJ1geSd97oAtSBZofUK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
clear_texttriesinput keycombination 113 29(Ctrl+A) and falls back to repeated Delete / Forward Delete when the output contains "Unknown command". The README documents that fallback for devices older than Android 12.On Android 7-11 the fallback never runs:
inputisapp_process … com.android.commands.input.Input. For an unknown subcommand it printsError: Unknown command: keycombinationto stderr and returns normally, so it exits 0. On Android 10-11 this goes throughBaseCommand.run, which catches theIllegalArgumentExceptionand prints toSystem.err. Android 9 prints withSystem.err.printlnandreturns.adb shellkeeps stderr separate from stdout, andcore.shell()returns stdout only. It raises only on a non-zero exit.So
outputis empty,clear_textassumes Ctrl+A worked, and it presses Delete once. That removes one character. Whentypeis called withclear=True, the new text is typed after the field's old contents.Change
2>&1to the probe, so the device shell merges stderr into stdout and the "Unknown command" answer is seen.test_old_devices_fall_back_to_repeated_deletestest double now returns the answer only when the command merges the streams, as a real device does. The old double returned it on stdout unconditionally, which is why the suite didn't catch this.Testing
uv run pytest: 577 passed, 21 skipped.ruff checkandruff format --checkare clean.mainand pass with the fix.subprocesspath, withANDROID_MCP_ADB_PATHpointing at a fakeadbthat mimics each device (stderr kept separate, exit 0):keycombinationunknown)keycombinationsupported)I don't have a physical Android 7-11 device, so the device behavior is taken from AOSP source:
cmds/input/.../Input.javaonandroid-9.0.0_r1andandroid11-release, andcore/java/com/android/internal/os/BaseCommand.java.