ITADN

Bug: -keyboard command prepends placeholder/hint text to input on v1.1.0

#57Closedquanru 创建于 2026-04-01
Q
quanrucommented
## Description When using `yadb -keyboard 'text'` on v1.1.0, some apps' input fields have the placeholder/hint text prepended to the actual input. This worked correctly in v1.0.0. ## Steps to Reproduce 1. Open X/Twitter Android app → tap compose new post 2. The compose field shows placeholder "有什么新鲜事?" (What's happening?) 3. Run: `adb shell "app_process -Djava.class.path=/data/local/tmp/yadb /data/local/tmp com.ysbing.yadb.Main -keyboard 'hello world'"` 4. **Expected**: Field contains `hello world` 5. **Actual**: Field contains `有什么新鲜事?hello world` — the placeholder is prepended ## Root Cause The commit `f2ca1f0a` ("refactor: optimize keyboard text input and clear logic using Accessibility API") changed the input method from clipboard+paste to Accessibility API. In `Keyboard.java` `setTextByAccessibility()`: ```java CharSequence current = focused.getText(); finalDoc = (current != null ? current.toString() : "") + text; ``` The issue is that `AccessibilityNodeInfo.getText()` returns the **hint/placeholder text** for custom views (like X/Twitter's compose field) that expose hint text to accessibility services for screen readers. The code then concatenates the placeholder with the new text. In v1.0.0, the clipboard+Ctrl+V approach never read existing field content, so the placeholder was correctly handled by the app's own InputConnection logic. ## Suggested Fix In `setTextByAccessibility()`, check if the node is showing hint text before reading `getText()`: ```java CharSequence current = focused.getText(); // On API 26+, check if the text is actually a hint (placeholder) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && focused.isShowingHintText()) { current = null; // Ignore hint text } finalDoc = (current != null ? current.toString() : "") + text; ``` Or alternatively, don't append to existing text at all — just set the new text directly, which matches the behavior of the v1.0.0 clipboard approach. ## Environment - Android devices: tested on multiple devices - Apps affected: X/Twitter (likely any app with custom placeholder implementation) - yadb v1.0.0: works correctly - yadb v1.1.0: bug present
关闭于 2026-04-01 0 条评论