How senzhk/adbkeyboard works
Purpose and Entry Points
ADBKeyBoard is an Android input method (IME) for device automation. It accepts ADB-delivered broadcast intents and injects Unicode text, key events, editor actions, character code points, meta-key combinations, or clear-text operations into the currently focused editor. The runtime entry point is the IME service declared in keyboardservice/src/main/AndroidManifest.xml, implemented by keyboardservice/src/main/java/com/android/adbkeyboard/AdbIME.java.
Android IME Service Boundary
AdbIME is the central Android component: it runs under the Android input-method framework rather than as an app UI or network service. Once enabled and selected through adb shell ime, Android supplies it an InputConnection for the focused text field; this is the boundary through which broadcasts become edits in another application.
• keyboardservice/src/main/java/com/android/adbkeyboard/AdbIME.java
• keyboardservice/src/main/AndroidManifest.xml
• keyboardservice/src/main/res/xml/methods.xml
Broadcast Command Ingress
External automation invokes adb shell am broadcast with action names such as ADB_INPUT_TEXT, ADB_INPUT_B64, ADB_INPUT_CODE, ADB_EDITOR_CODE, ADB_INPUT_CHARS, and ADB_CLEAR_TEXT. The service receives and dispatches these intents, extracting string, integer, integer-array, and meta-key payloads. This public broadcast interface is the repository’s primary integration contract; callers may also be Android apps/services able to send broadcasts.
• keyboardservice/src/main/java/com/android/adbkeyboard/AdbIME.java
• keyboardservice/src/main/AndroidManifest.xml
Input Translation and Injection
The command dispatcher translates each payload type into Android IME operations:
• plain or Base64-decoded UTF-8 text is committed to the focused editor;
• numeric key codes and optional meta states become key events;
• Unicode code-point arrays are converted for character injection;
• editor-action codes trigger the target field’s action;
• clear requests remove current text.
The implementation must account for absent or invalid focused-editor connections, and relies on Android’s InputConnection, KeyEvent, and editor-action APIs rather than directly controlling target apps.
• keyboardservice/src/main/java/com/android/adbkeyboard/AdbIME.java
Minimal IME UI and Metadata
The keyboard has a minimal input-view resource, supporting its registration as a selectable virtual keyboard while its meaningful behavior is automation-driven broadcast handling. IME subtype/method metadata and user-visible service labels are Android resource-defined.
• keyboardservice/src/main/res/layout/view.xml
• keyboardservice/src/main/res/xml/methods.xml
• keyboardservice/src/main/res/values/strings.xml
Build, Packaging, and Runtime Infrastructure
This is a single Gradle Android module, keyboardservice, built into an installable debug APK. Gradle wrapper files provide reproducible local/CI builds; GitHub Actions runs Android build automation. The generated APK is installed via ADB onto a connected device or emulator, where Android system IME settings enable and select it.
• settings.gradle
• build.gradle
• keyboardservice/build.gradle
• .github/workflows/android.yml
External Dependencies and Deployment Model
There is no backend, database, or web surface. Material external dependencies are the Android framework, Android SDK/Gradle toolchain, and Android Debug Bridge (adb) for installation, IME selection, and broadcast delivery. ADBKeyboard.apk is a checked-in distributable artifact, while normal development packaging comes from the Gradle module.
• ADBKeyboard.apk
• keyboardservice/src/main/AndroidManifest.xml
• gradle/wrapper/gradle-wrapper.properties
Main entry points: AdbIME.java AdbIME service · build.gradle Gradle build · keyboardservice/build.gradle keyboardservice module · AndroidManifest.xml IME manifest
Components 15
Build & Packaging
- Gradle build · Builds the single Android module into a debug APK.
build.gradle - keyboardservice module
keyboardservice/build.gradle - GitHub Actions
.github/workflows/android.yml - Debug APK
ADBKeyboard.apk - Android SDK toolchain
Android IME
- IME manifest · Registers the input method service and broadcast-facing component.
keyboardservice/src/main/AndroidManifest.xml - IME method metadata
keyboardservice/src/main/res/xml/methods.xml - Minimal input view
keyboardservice/src/main/res/layout/view.xml - AdbIME service · Central dispatcher and injector running in Android's IME framework.
keyboardservice/src/main/java/com/android/adbkeyboard/AdbIME.java - Android IME framework · Supplies the active focused-editor connection.
- Focused editor · Receives committed text, key events, editor actions, and deletion.
Automation Integration
- ADB · Installs the APK, selects the IME, and sends broadcasts.
- Automation callers · ADB shell or Android apps/services issue public commands.
- Broadcast commands · ADB_INPUT_TEXT, Base64, code, chars, editor-action, and clear-text intents.
keyboardservice/src/main/java/com/android/adbkeyboard/AdbIME.java - Android IME settings · Enables and selects the installed input method.
Connections 16
- GitHub Actions → Gradle build: runs
- Gradle build → keyboardservice module: builds
- Gradle build → Android SDK toolchain: uses
- keyboardservice module → Debug APK: packages
- IME manifest → AdbIME service: declares
- IME method metadata → IME manifest: referenced by
- Minimal input view → AdbIME service: input view
- Android IME framework → AdbIME service: hosts
- Android IME framework → Focused editor: provides active
- Automation callers → Broadcast commands: issues
- ADB → Broadcast commands: delivers via am broadcast
- Broadcast commands → AdbIME service: dispatches to
- AdbIME service → Focused editor: commits text, keys, actions, clear
- ADB → Debug APK: installs
- ADB → Android IME settings: enables and selects
- Android IME settings → Android IME framework: activates IME