fix: inputText searches non-overlay windows for focused input field
Same rootInActiveWindow issue as getCurrentPackage - the overlay window was being searched instead of the actual foreground app. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c839b0d658
commit
aa83f448f9
1 changed files with 9 additions and 2 deletions
|
|
@ -66,8 +66,15 @@ class DeviceController {
|
|||
|
||||
suspend fun inputText(text: String): Boolean {
|
||||
val svc = service ?: return false
|
||||
val focusedNode = svc.rootInActiveWindow?.findFocus(AccessibilityNodeInfo.FOCUS_INPUT)
|
||||
?: return false
|
||||
val ownPackage = svc.packageName
|
||||
// Search non-overlay windows for the focused input field
|
||||
val focusedNode = svc.windows
|
||||
.filter { it.type == android.view.accessibility.AccessibilityWindowInfo.TYPE_APPLICATION }
|
||||
.firstNotNullOfOrNull { win ->
|
||||
val root = win.root ?: return@firstNotNullOfOrNull null
|
||||
if (root.packageName?.toString() == ownPackage) return@firstNotNullOfOrNull null
|
||||
root.findFocus(AccessibilityNodeInfo.FOCUS_INPUT)
|
||||
} ?: return false
|
||||
val args = Bundle().apply {
|
||||
putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, text)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue