mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
fix(sidecar): close the soft keyboard after typing on android
This commit is contained in:
1 parent
11f72a722a
commit
276c05ac84
1 file changed
+17
@@ -779,6 +779,22 @@ internal fun typeChunks(
|
|||||||
return typed
|
return typed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dismissSoftKeyboard closes an open IME, and issues nothing when none is open.
|
||||||
|
//
|
||||||
|
// The keyboard is its own window over the bottom of the app, and the hierarchy
|
||||||
|
// carries only what is visible to the user, so every app node under it is
|
||||||
|
// absent from the tree the picker enumerates targets from. Typing raises it, so
|
||||||
|
// an IME left open hides a form's submit control for as long as the fuzzer
|
||||||
|
// keeps typing into that form, which is a state it cannot type its way out of.
|
||||||
|
//
|
||||||
|
// The mInputShown guard is load-bearing rather than an optimisation: BACK is
|
||||||
|
// what closes an open IME, and BACK with no IME open navigates out of the
|
||||||
|
// screen, so an unguarded dismissal would make every InputText a back press.
|
||||||
|
internal fun dismissSoftKeyboard(shell: (String) -> String) {
|
||||||
|
if (!shell("dumpsys input_method").contains("mInputShown=true")) return
|
||||||
|
shell("input keyevent 4")
|
||||||
|
}
|
||||||
|
|
||||||
// resumedActivityPackage matches a "package/activity" component, mirroring the
|
// resumedActivityPackage matches a "package/activity" component, mirroring the
|
||||||
// Go scope guard's regex so both read the same dumpsys wording.
|
// Go scope guard's regex so both read the same dumpsys wording.
|
||||||
private val resumedActivityPackage =
|
private val resumedActivityPackage =
|
||||||
@@ -885,6 +901,7 @@ class MaestroDriverBackend(private val serial: String?) : DriverBackend {
|
|||||||
} else {
|
} else {
|
||||||
driver.inputText(text)
|
driver.inputText(text)
|
||||||
}
|
}
|
||||||
|
dismissSoftKeyboard { dadb.shell(it).allOutput }
|
||||||
}
|
}
|
||||||
|
|
||||||
// typeShellSafe types shell-safe ASCII through adb `input text` in chunks,
|
// typeShellSafe types shell-safe ASCII through adb `input text` in chunks,
|
||||||
|
|||||||
Reference in new issue
Block a user