Skip to content

fix: report Drag as unsupported on Android 7 instead of a silent no-op - #44

Merged
Jeomon merged 1 commit into
CursorTouch:masterfrom
aftabkh4n:fix/drag-reports-unsupported-android
Nov 11, 2026
Merged

Jeomon merged 1 commit into
CursorTouch:masterfrom
aftabkh4n:fix/drag-reports-unsupported-android

Conversation

@aftabkh4n

Copy link
Copy Markdown
Contributor

Problem

input draganddrop was added in Android 8.0. In AOSP cmds/input/.../Input.java, android-7.1.2_r1 has no draganddrop branch, and android-8.0.0_r1 adds it.

On Android 7.x, an unknown subcommand prints Error: Unknown command: draganddrop to stderr and returns, so the process exits 0. core.shell() returns stdout only and raises only on a non-zero exit. As a result adb.drag() returned normally, and the Drag tool told the agent "Dragged from (x1,y1) and dropped on (x2,y2)" while nothing had moved. The agent then continues from a state that never happened.

The drag() docstring said older releases "fail with an adb error", but they never did.

This is the same cause as the clear_text fix in #40.

Change

  • adb/input.py: run input draganddrop … 2>&1. If the output contains "Unknown command", raise AdbError("Drag needs Android 8 or later: …"). Session.operation already turns AdbError into a ToolError, so the agent gets a clear message.
  • Docstring updated to describe what actually happens.

Testing

  • uv run pytest: 584 passed, 21 skipped. ruff check and ruff format --check are clean.
  • New test test_drag_on_a_device_without_draganddrop_raises. Its fake device returns the answer only when the command merges stderr, as a real device does. It fails on master and passes with this change.
  • End to end through the real subprocess path, with ANDROID_MCP_ADB_PATH pointing at a fake adb that keeps stderr separate and exits 0:
Fake device Before After
Android 7 (draganddrop unknown) returns normally, so the tool reports success AdbError: Drag needs Android 8 or later …
Android 8+ drag sent drag sent, unchanged

I don't have a physical Android 7 device. The behavior is taken from AOSP source (android-7.1.2_r1 and android-8.0.0_r1).

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 CursorTouch#40.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014TonJ1geSd97oAtSBZofUK
@Jeomon

Jeomon commented Nov 11, 2026

Copy link
Copy Markdown
Member

Thanks for the fix, @aftabkh4n. Drag now fails with a clear error on Android 7 instead of reporting success, and it matches the clear_text approach from #40. Merging.

@Jeomon
Jeomon merged commit b3dabf9 into CursorTouch:master Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants