fix(helper): report denied clipboard writes so text input can fall back - #159
Open
theworker02 wants to merge 1 commit into
Open
theworker02 wants to merge 1 commit into
theworker02 wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Some OEM builds restrict WRITE_CLIPBOARD to the foreground via AppOps and ClipboardService drops the write without throwing. Check the AppOps mode before writing so setClipboard returns false and the host falls back to ADBKeyboard instead of pasting nothing. Fixes google#127
theworker02
force-pushed
the
fix/127-clipboard-write-denied
branch
from
September 27, 2026 19:30
2373b46 to
08ccd79
Compare
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.
Fixes #127
Problem
GestureController.setClipboard()returnedtruewheneversetPrimaryClip()did not throw. On builds that restrictWRITE_CLIPBOARDto the foreground via AppOps (the reported OPPO PMT110 showsWRITE_CLIPBOARD: foreground),ClipboardServicedrops the write silently (op=30 result=false). The host then sentKEYCODE_PASTE, reported success, and never reached the ADBKeyboard fallback, so Chinese text was never entered.Change
GestureController.setClipboard()now checks theandroid:write_clipboardAppOps mode before writing:MODE_ALLOWED/MODE_DEFAULT: write as before.MODE_FOREGROUND: write only if the helper process importance is foreground or foreground-service; otherwise returnfalse.MODE_IGNORED/MODE_ERRORED: returnfalse.falseresult already makesAndroidAdbDriver.input_text()skip the paste and fall through to the ADBKeyboard broadcast and nativeinput text, so no host-side logic change is needed.test_android_input_text_falls_back_to_adbkeyboard_when_clipboard_rejected, which pins that a rejected clipboard write never sendsKEYCODE_PASTEand delivers the text viaADB_INPUT_B64.Testing
uv run pytest tests/unit/test_drivers.pypasses (6 tests).ruff format --checkandruff checkpass on the changed test file.minSdk 24(checkOpNoThrowbelow API 29,unsafeCheckOpNoThrowfrom API 29,ActivityManager.getMyMemoryState). A device check on a build withWRITE_CLIPBOARD: foregroundwould be appreciated.make testrun on Windows shows failures in unrelated agent/CLI tests.tests/unit/agents/flash/test_turn_index_snapshot.pyfails the same way on unmodifiedmain(see test(flash): mock VisualStepSummarizer in test_turn_index_snapshot for offline execution #32 / fix(tests): mock VisualStepSummarizer in test_turn_index_snapshot #35).