# senzhk/adbkeyboard architecture

> Architecture diagram of the GitHub repository senzhk/adbkeyboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/senzhk/adbkeyboard
- Repository: https://github.com/senzhk/adbkeyboard

## Overview

#### 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: [`keyboardservice/src/main/java/com/android/adbkeyboard/AdbIME.java`](https://github.com/senzhk/adbkeyboard/blob/master/keyboardservice/src/main/java/com/android/adbkeyboard/AdbIME.java) (AdbIME service), [`build.gradle`](https://github.com/senzhk/adbkeyboard/blob/master/build.gradle) (Gradle build), [`keyboardservice/build.gradle`](https://github.com/senzhk/adbkeyboard/blob/master/keyboardservice/build.gradle) (keyboardservice module), [`keyboardservice/src/main/AndroidManifest.xml`](https://github.com/senzhk/adbkeyboard/blob/master/keyboardservice/src/main/AndroidManifest.xml) (IME manifest)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Build &amp; Packaging"]
  node_gradle["Gradle build<br/>build system<br/>[build.gradle]"]
  node_module["keyboardservice module<br/>Android module<br/>[build.gradle]"]
  node_ci["GitHub Actions<br/>CI workflow<br/>[android.yml]"]
  node_apk["Debug APK<br/>installable artifact<br/>[ADBKeyboard.apk]"]
  node_androidsdk["Android SDK toolchain<br/>external toolchain"]
end

subgraph group_ime["Android IME"]
  node_manifest["IME manifest<br/>Android declaration"]
  node_metadata["IME method metadata<br/>IME metadata<br/>[methods.xml]"]
  node_imeui["Minimal input view<br/>IME layout<br/>[view.xml]"]
  node_adbime{{"AdbIME service<br/>InputMethodService<br/>[AdbIME.java]"}}
  node_framework["Android IME framework<br/>platform runtime"]
  node_connection["Focused editor<br/>InputConnection target"]
end

subgraph group_integration["Automation Integration"]
  node_adb["ADB<br/>device bridge"]
  node_callers["Automation callers<br/>broadcast clients"]
  node_broadcasts["Broadcast commands<br/>integration contract<br/>[AdbIME.java]"]
  node_settings["Android IME settings<br/>system configuration"]
end

node_ci -->|"runs"| node_gradle
node_gradle -->|"builds"| node_module
node_gradle -->|"uses"| node_androidsdk
node_module -->|"packages"| node_apk
node_manifest -->|"declares"| node_adbime
node_metadata -->|"referenced by"| node_manifest
node_imeui -->|"input view"| node_adbime
node_framework -->|"hosts"| node_adbime
node_framework -->|"provides active"| node_connection
node_callers -->|"issues"| node_broadcasts
node_adb -->|"delivers via am broadcast"| node_broadcasts
node_broadcasts -->|"dispatches to"| node_adbime
node_adbime -->|"commits text, keys, actions, clear"| node_connection
node_adb -->|"installs"| node_apk
node_adb -->|"enables and selects"| node_settings
node_settings -->|"activates IME"| node_framework

click node_gradle "https://github.com/senzhk/adbkeyboard/blob/master/build.gradle"
click node_module "https://github.com/senzhk/adbkeyboard/blob/master/keyboardservice/build.gradle"
click node_ci "https://github.com/senzhk/adbkeyboard/blob/master/.github/workflows/android.yml"
click node_apk "https://github.com/senzhk/adbkeyboard/blob/master/ADBKeyboard.apk"
click node_manifest "https://github.com/senzhk/adbkeyboard/blob/master/keyboardservice/src/main/AndroidManifest.xml"
click node_metadata "https://github.com/senzhk/adbkeyboard/blob/master/keyboardservice/src/main/res/xml/methods.xml"
click node_imeui "https://github.com/senzhk/adbkeyboard/blob/master/keyboardservice/src/main/res/layout/view.xml"
click node_adbime "https://github.com/senzhk/adbkeyboard/blob/master/keyboardservice/src/main/java/com/android/adbkeyboard/AdbIME.java"
click node_broadcasts "https://github.com/senzhk/adbkeyboard/blob/master/keyboardservice/src/main/java/com/android/adbkeyboard/AdbIME.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_gradle,node_module,node_ci,node_apk,node_androidsdk toneBlue
class node_manifest,node_metadata,node_imeui,node_adbime,node_framework,node_connection toneAmber
class node_adb,node_callers,node_broadcasts,node_settings toneMint
```

## Components

### Build & Packaging

- [Gradle build](https://github.com/senzhk/adbkeyboard/blob/master/build.gradle): build system · Builds the single Android module into a debug APK. · `build.gradle`
- [keyboardservice module](https://github.com/senzhk/adbkeyboard/blob/master/keyboardservice/build.gradle): Android module · `keyboardservice/build.gradle`
- [GitHub Actions](https://github.com/senzhk/adbkeyboard/blob/master/.github/workflows/android.yml): CI workflow · `.github/workflows/android.yml`
- [Debug APK](https://github.com/senzhk/adbkeyboard/blob/master/ADBKeyboard.apk): installable artifact · `ADBKeyboard.apk`
- **Android SDK toolchain**: external toolchain

### Android IME

- [IME manifest](https://github.com/senzhk/adbkeyboard/blob/master/keyboardservice/src/main/AndroidManifest.xml): Android declaration · Registers the input method service and broadcast-facing component. · `keyboardservice/src/main/AndroidManifest.xml`
- [IME method metadata](https://github.com/senzhk/adbkeyboard/blob/master/keyboardservice/src/main/res/xml/methods.xml): IME metadata · `keyboardservice/src/main/res/xml/methods.xml`
- [Minimal input view](https://github.com/senzhk/adbkeyboard/blob/master/keyboardservice/src/main/res/layout/view.xml): IME layout · `keyboardservice/src/main/res/layout/view.xml`
- [AdbIME service](https://github.com/senzhk/adbkeyboard/blob/master/keyboardservice/src/main/java/com/android/adbkeyboard/AdbIME.java): InputMethodService · Central dispatcher and injector running in Android's IME framework. · `keyboardservice/src/main/java/com/android/adbkeyboard/AdbIME.java`
- **Android IME framework**: platform runtime · Supplies the active focused-editor connection.
- **Focused editor**: InputConnection target · Receives committed text, key events, editor actions, and deletion.

### Automation Integration

- **ADB**: device bridge · Installs the APK, selects the IME, and sends broadcasts.
- **Automation callers**: broadcast clients · ADB shell or Android apps/services issue public commands.
- [Broadcast commands](https://github.com/senzhk/adbkeyboard/blob/master/keyboardservice/src/main/java/com/android/adbkeyboard/AdbIME.java): integration contract · ADB_INPUT_TEXT, Base64, code, chars, editor-action, and clear-text intents. · `keyboardservice/src/main/java/com/android/adbkeyboard/AdbIME.java`
- **Android IME settings**: system configuration · Enables and selects the installed input method.

## Connections

- 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
