๐Ÿ“Š Data Model

March 29, 2026 ยท View on GitHub

โ† Back to README

AndroidCore is the centralized, static state store holding a live mirror of the Android device's system state. All telemetry from both the Logic Engine (JAR) and Feature Hub (APK) is parsed here. This document covers the state fields, JSON message protocol, and event types.


AndroidCore โ€” State Fields

Connection Status (Reactive)

These are ValueNotifier<bool> โ€” Flutter widgets can listen to them directly.

static final ValueNotifier<bool> jarConnected = ValueNotifier(false);
static final ValueNotifier<bool> apkConnected = ValueNotifier(false);
static final ValueNotifier<bool> allConnected  = ValueNotifier(false);

Battery State

FieldTypeSourceDescription
batteryPercentageintbattery_small, battery_updateCurrent level (0โ€“100)
batteryChargingboolbattery_small, battery_updateIs charging?
batteryPluggedintbattery_small, battery_updatePlug type int code
batterySaverboolbattery_small, battery_updateBattery saver mode active?
batteryTemperaturedoublebattery_updateยฐC
batteryVoltagedoublebattery_updateVolts
batteryCurrentMaintbattery_updateMilliamps (+ charging, - discharging)
batteryHealthStringbattery_update"Good", "Overheat", etc.
batteryTechnologyStringbattery_update"Li-ion", "Li-poly"
batteryPlugTypeStringbattery_update"USB", "AC", "Wireless", "None"

Volume State

FieldTypeDescription
volumeMusic / volumeMusicMaxintMedia volume (current / max)
volumeRing / volumeRingMaxintRingtone volume
volumeNotification / volumeNotificationMaxintNotification volume
volumeAlarm / volumeAlarmMaxintAlarm volume
volumeMusicAvailableboolStream controllable by current ringer mode
volumeRingAvailableboolStream controllable by current ringer mode
volumeNotificationAvailableboolStream controllable
volumeAlarmAvailableboolStream controllable

Device State Flags

FieldTypeDescription
wifiboolWi-Fi enabled
wifiNameStringConnected SSID
bluetoothboolBluetooth enabled
bluetoothNameStringConnected device name
mobileDataboolMobile data active
airplaneboolAirplane mode on
muteboolRinger muted
rotationLockboolAuto-rotate locked
locationboolLocation services on
torchboolFlashlight on

Permission Status

FieldTypeDescription
permissionLevelString"success", "warning", or "error"
permissionMessageStringHuman-readable status summary
permissionsDataMap<String, bool>Per-permission grant map
permissionTimestampintUnix ms timestamp of last report

JSON Message Protocol

All messages are JSON objects sent over TCP (from JAR) or WebSocket (from APK). The type field routes the message to the correct handler in updateFromMessage().

battery_small โ€” Realtime Battery Tick

Sent every ~1 second. Lightweight for frequent updates.

{
  "type": "battery_small",
  "percentage": 87,
  "charging": true,
  "plugged": 2,
  "battery_saver": false,
  "states": {
    "wifi": true,
    "bluetooth": false,
    "mobile_data": true,
    "airplane_mode": false,
    "mute": false,
    "rotation_lock": false,
    "location": true,
    "torch": false,
    "wifi_name": "HomeNetwork",
    "bluetooth_name": ""
  }
}

The states object is present on every message type. It's always parsed to keep device flags current.


battery_update โ€” Full Battery Snapshot

Sent on significant changes or at intervals. Contains full diagnostic data.

{
  "type": "battery_update",
  "battery": {
    "percentage": 87,
    "charging": true,
    "plugged": 2,
    "voltage": 4.2,
    "temperature": 29.5,
    "current_ma": -1200,
    "health": "Good",
    "technology": "Li-ion",
    "plug_type": "USB",
    "battery_saver": false
  }
}

volume_update โ€” All Audio Streams

Sent when any audio stream changes. Always includes all streams.

{
  "type": "volume_update",
  "streams": [
    { "stream_name": "music",        "current": 8,  "max": 15, "available": true  },
    { "stream_name": "ring",         "current": 4,  "max": 7,  "available": true  },
    { "stream_name": "notification", "current": 4,  "max": 7,  "available": true  },
    { "stream_name": "alarm",        "current": 6,  "max": 7,  "available": true  }
  ]
}

apk.permissions โ€” Runtime Permission Status

Sent on startup and when permissions change.

{
  "type": "apk.permissions",
  "level": "warning",
  "message": "Notification access is not granted. Some features will be limited.",
  "timestamp": 1711700000000,
  "data": {
    "READ_CONTACTS": true,
    "POST_NOTIFICATIONS": false,
    "BIND_NOTIFICATION_LISTENER_SERVICE": false,
    "RECORD_AUDIO": true
  }
}

Severity Levels:

LevelMeaning
"success"All required permissions granted
"warning"Some optional permissions missing โ€” partial functionality
"error"Critical permissions missing โ€” core features unavailable

Handshake Messages

MessageDirectionMeaning
{"type":"jar.hello"}JAR โ†’ WindowsLogic Engine TCP connection confirmed
{"type":"apk.hello"}APK โ†’ WindowsFeature Hub WebSocket connection confirmed

Update Flow

Incoming JSON message
        โ”‚
        โ–ผ
AndroidCore.updateFromMessage(msg)
        โ”‚
        โ”œโ”€ Parse "states" block โ†’ update device flags
        โ”‚
        โ””โ”€ Switch on "type":
                โ”œโ”€ battery_small  โ†’ quick battery fields
                โ”œโ”€ battery_update โ†’ full battery snapshot
                โ”œโ”€ volume_update  โ†’ all volume streams
                โ””โ”€ apk.permissions โ†’ permission map + level

Flutter UI reads AndroidCore fields directly
(ValueNotifier fields trigger reactive rebuilds)

โ† Back to README ยท Modules ยป ยท Reconnection ยป