๐งฉ Modules Reference
March 29, 2026 ยท View on GitHub
โ Back to README
Complete reference for all internal Windows-side modules. Covers each module's role, its public API, and how it fits into the overall system. All modules are singletons unless noted otherwise.
Module Map
AppManager โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Orchestrates full init sequence
โ
โโโบ AdbProvider โโโโโโโโโโโโโโโโโโโโโโโ All ADB command execution
โโโบ JarManager โโโโโโโโโโโโโโโโโโโโโโโโ JAR lifecycle + event stream
โ โโโบ JarServer โโโโโโโโโโโโโโโโโ TCP listener (JAR connects here)
โโโบ ApkServer โโโโโโโโโโโโโโโโโโโโโโโโโ WS listener (APK connects here)
โโโบ MediaDataManager โโโโโโโโโโโโโโโโโโ WS listener (media events)
โโโบ NotificationDataManager โโโโโโโโโโโ WS listener (notification events)
โโโบ ReconnectionManager โโโโโโโโโโโโโโโ Post-boot connection monitoring
โโโบ AndroidCore โโโโโโโโโโโโโโโ Shared real-time state store
AdbProvider
Role: The single source of truth for all ADB command execution. Every interaction with the connected Android device goes through this module.
Resolved Paths (validated at first use)
| Property | Points To |
|---|---|
adbPath | Bundled adb.exe in the installation directory |
apkPath | Bundled AndroidDex.apk |
jarPath | Bundled androiddex.jar |
All paths throw a user-friendly exception (not a file path dump) if the file is missing.
Key Methods
| Method | Description |
|---|---|
startAdbBlocking() | Runs adb start-server; throws on failure |
connectBlocking() | Runs adb connect [device] + sets up adb reverse on all ports |
getDevices() โ List<String> | Parses adb devices output; returns serial/IP list |
pushJar(localPath) โ AdbResult | adb push jar /data/local/tmp/ |
killJar() | adb shell kill the existing JAR process by PID |
startJarRuntime() โ Process | adb shell app_process โ returns the running process handle |
isPackageInstalled(pkg) โ bool | adb shell pm list packages | grep pkg |
installApk(path) โ AdbResult | adb install -r path |
startServerService(pkg) โ AdbResult | adb shell am start-foreground-service |
run(args) โ AdbResult | Generic ADB runner โ wraps any argument list |
runOnDevice(args) โ AdbResult | Like run() but prepends the device selector (-d or -s id) |
AdbResult
class AdbResult {
final bool success; // exitCode == 0
final String output; // stdout + stderr combined
}
AppManager
Role: Master orchestrator for the full initialization sequence. Owns the Stream<AppEvent> that drives the APP progress bar in the boot screen.
State
| Field | Type | Meaning |
|---|---|---|
_busy | bool | Prevents concurrent initializeSystem() calls |
Key Methods
| Method | Description |
|---|---|
initializeSystem() | Full 11-step boot sequence; emits AppEvent for each step |
startExtendedServices() | Activates Media + Notification channels after handshakes |
Event Stream
Each AppEvent carries:
AppEvent { String message, double progress, bool isError }
The boot screen's APP bar listens to this stream and updates _appProgress / _appLabel reactively.
JarManager
Role: Manages the entire Logic Engine lifecycle โ from local file validation through device upload, process launch, and runtime monitoring. Exposes its own Stream<JarEvent> for the JAR progress bar.
State
| Field | Type | Meaning |
|---|---|---|
_process | Process? | Handle to the running JAR adb shell process |
jarReady | Completer<void> | Completes when jar.hello handshake arrives |
Key Methods
| Method | Description |
|---|---|
startJar() | Full 7-step deploy: stop โ kill โ locate โ push โ launch โ monitor |
stopJar() | Kills _process if running |
resetJarReady() | Replaces jarReady with a fresh Completer before a retry |
markHandshakeComplete() | Called by AppManager after jar.hello โ pushes JAR bar to 1.0 |
Event Stream
JarEvent { String message, double progress, bool isError }
JarServer
Role: ServerSocket that listens for the Logic Engine's TCP connect-back.
Message Routing
Message type | Action |
|---|---|
jar.hello | Completes JarManager.jarReady ยท sets AndroidCore.jarConnected = true |
| Any other JSON | Passed to AndroidCore.updateFromMessage() |
ApkServer
Role: WebSocket server that the Kotlin APK connects back to.
State
| Field | Type | Meaning |
|---|---|---|
apkReady | Completer<void> | Completes when apk.hello arrives |
Message Routing
Message type | Action |
|---|---|
apk.hello | Completes apkReady ยท sets AndroidCore.apkConnected = true |
battery_small | AndroidCore.updateFromMessage() โ battery quick-update |
battery_update | AndroidCore.updateFromMessage() โ full battery snapshot |
volume_update | AndroidCore.updateFromMessage() โ all volume streams |
apk.permissions | AndroidCore.updateFromMessage() โ permission status |
DeviceManager
Role: Singleton holding which ADB device to target. All ADB commands use DeviceManager.instance.adbArgs when building their argument lists.
State
| Field | Meaning |
|---|---|
_deviceId | Current target: "-d" (USB), "ip:port" (Wi-Fi), or a USB serial |
_needsDeviceSelection | true โ boot flow must show the picker dialog before starting |
Key Methods
| Method | Description |
|---|---|
setFromArgs(args) | Parses CLI args; calls autoDetect() if empty |
autoDetect() | getDevices() โ picks 1 auto, or sets needsDeviceSelection |
selectDevice(id) | Called from dialog: maps serial โ -d, IP โ ip:port |
adbArgs โ List<String> | Returns ['-d'] or ['-s', _deviceId] |
โ See Device Manager for the full dialog flow.
ReconnectionManager
Role: Monitors connection health after a successful boot. Orchestrates multi-phase auto-recovery when a disconnection is detected.
Complete documentation in Reconnection System.
AndroidCore
Role: Centralized static state store. All telemetry from both the JAR and APK is parsed here. The Flutter UI reads directly from these fields.
Connection Notifiers (reactive)
static final ValueNotifier<bool> jarConnected = ValueNotifier(false);
static final ValueNotifier<bool> apkConnected = ValueNotifier(false);
static final ValueNotifier<bool> allConnected = ValueNotifier(false);
Complete field reference in Data Model.
ScrcpyVideoManager / ScrcpyAudioManager
Role: Manages the scrcpy streaming process for individual Android app windows. Each app window has its own scrcpy process embedded via Win32 SetParent.
WindowManager
Role: Win32 window lifecycle manager. Handles creation, destruction, resize, focus, and Z-ordering of embedded Android app windows.
WindowThumbnailService
Role: Captures thumbnail frames of embedded windows for the Recents / Task View panel.
โ Back to README ยท Boot Flow ยป ยท Reconnection ยป