๐Ÿงฉ 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)

PropertyPoints To
adbPathBundled adb.exe in the installation directory
apkPathBundled AndroidDex.apk
jarPathBundled androiddex.jar

All paths throw a user-friendly exception (not a file path dump) if the file is missing.

Key Methods

MethodDescription
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) โ†’ AdbResultadb push jar /data/local/tmp/
killJar()adb shell kill the existing JAR process by PID
startJarRuntime() โ†’ Processadb shell app_process โ€” returns the running process handle
isPackageInstalled(pkg) โ†’ booladb shell pm list packages | grep pkg
installApk(path) โ†’ AdbResultadb install -r path
startServerService(pkg) โ†’ AdbResultadb shell am start-foreground-service
run(args) โ†’ AdbResultGeneric ADB runner โ€” wraps any argument list
runOnDevice(args) โ†’ AdbResultLike 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

FieldTypeMeaning
_busyboolPrevents concurrent initializeSystem() calls

Key Methods

MethodDescription
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

FieldTypeMeaning
_processProcess?Handle to the running JAR adb shell process
jarReadyCompleter<void>Completes when jar.hello handshake arrives

Key Methods

MethodDescription
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 typeAction
jar.helloCompletes JarManager.jarReady ยท sets AndroidCore.jarConnected = true
Any other JSONPassed to AndroidCore.updateFromMessage()

ApkServer

Role: WebSocket server that the Kotlin APK connects back to.

State

FieldTypeMeaning
apkReadyCompleter<void>Completes when apk.hello arrives

Message Routing

Message typeAction
apk.helloCompletes apkReady ยท sets AndroidCore.apkConnected = true
battery_smallAndroidCore.updateFromMessage() โ†’ battery quick-update
battery_updateAndroidCore.updateFromMessage() โ†’ full battery snapshot
volume_updateAndroidCore.updateFromMessage() โ†’ all volume streams
apk.permissionsAndroidCore.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

FieldMeaning
_deviceIdCurrent target: "-d" (USB), "ip:port" (Wi-Fi), or a USB serial
_needsDeviceSelectiontrue โ†’ boot flow must show the picker dialog before starting

Key Methods

MethodDescription
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 ยป