App structure

Code is in android/app/src/main/java/app/assistant/. The app is two things: the WebView page (most screens) and native Kotlin screens and services. It uses no Google services.

Files

FileJob
MainActivity.ktHosts the page (assets/index.html) in a full-screen WebView. Gives it native things through NativeApp (46 bridge methods): server address and token, microphone, dictation, listening, vibration, dialogs, Back. Shows a rescue dialog if the page does not call pageReady() within 8 s.
AssistActivity.ktThe voice card (hold home or power, wake word, or from the app).
RingActivity.kt / RingService.ktFull-screen ringing card over the lock screen; the ring sound, louder over time, with vibration.
Alarms.ktCopies coming alarms and reminders into Android's alarm clock, so they ring with the app closed or offline. Syncs on open, after each turn, every 15 minutes, after a restart, and when one fires.
Notices.ktAssistant notices as phone notifications (normal, quiet, urgent channels).
NoticeStream.ktOne held-open GET /v1/events connection while location runs, for instant notices and fence changes.
CaptureService.ktListening: speech to text on the phone, uploads text chunks. See Phone capture.
PlaceWatch.ktListening is place by place: asks the server where the phone is after each location upload.
WakeService.ktListens for the wake word; opens the voice card.
Speech.ktSpeech to text on the phone. Audio never leaves the phone.
LocationService.ktLocation points every ~5 minutes. See Location.
Fences.ktAndroid's own proximity alerts for place reminders (no Google services).
HealthSync.ktDaily totals from Health Connect, one row per day to the server.
Detect.ktFinds parcels, bills and plans in notifications on the phone; sends only small items.
NotifyListener.ktForwards notifications of watched apps so automations can start on them.
PhoneActions.ktRuns the phone plugin's actions: dialer, text, open app, timer, alarm, directions.
PhotoText.ktReads text in photos on the phone (bundled ML Kit).
Woke.ktTells the server the user woke up, once a day, for the morning brief.
Unlock.ktRemembered phone: unlocks the account after a server restart.
Vault.ktKeeps the token encrypted with a Keystore key.
Updater.kt / InstallResult.kt / Replaced.ktSelf-update from your server.
Sfx.ktShort sound effects.
Tiles.ktQuick settings tiles (Chat, Talk).
VoiceGlow.ktThe edge glow of the voice screen.

The page

The page is one self-contained HTML file: server/examples/dummy-client/index.html, copied into android/app/src/main/assets/index.html. Today it has four tabs:

Home, Plan (Calendar, Alarms, Lists), Assistant (chat) and Settings (about 21 rows that open sub-pages). The redesign renames them Today, Plan, Chat and You, with the same view ids (Screens).

The server's rules call it a reference client: the backend never depends on it.

Bridge contract (frozen)

The page and the app talk through these names. Renaming one breaks the app silently. Change both sides in the same release. Safety for each call: Safety rules.

Page to app (NativeApp.*, also NA.*): 46 methods in MainActivity.Bridge.

alarmStatus captureState checkUpdate clearConfig forgetDevice getConfig haptic hasDictation healthState holdEnd holdStart installUpdate locationState notifyApps notifyState openAlarmSettings openAssistantSettings openNotifySettings openOverlaySettings openUrl pageReady phoneActions postNotice readPhoto saveConfig saveDevice setAutoUpdate setCapture setHealth setLocation setSfx setTheme setWake setupFix setupState sfx sfxEnabled shareText syncAlarms syncHealth syncNotify takeOauth talk unlockNow updateInfo voiceState

The page must also work in a plain browser with no NativeApp. Check a method exists before calling it.

pageReady: the page calls it as soon as its script starts, before any API call. If it does not come within 8 s, the app shows the rescue dialog. Nothing that can throw runs before it.

App to page (window.__*, called by MainActivity): __open __ready __captureChanged __updateChanged __locationChanged __voiceChanged __healthChanged __dictation __dictationState __oauthCheck __shared __photoText __setupChanged. Page-only, free to change: __acct __closeChatMenu __lost.

Open names (window.__open(name), allowed list OPEN_VIEWS in MainActivity, shortcuts in res/xml/shortcuts.xml): calendar alarms new-event new-alarm new-chat. lists works in the page only; add it to OPEN_VIEWS before a shortcut uses it.

Stored keys (localStorage). Renaming one resets a choice or loses data: lang lastUser noticeCursor oauth.provider opt.* outbox planTab setupSkipped startView theme thread titles weakUntil. planTab gains task; cal, alarm, list stay valid.

One file. The page is one HTML file with one <script> block. The release script copies that one file and checks the block parses. Splitting it breaks both.

Native colours

Native screens use the token names in res/values/colors.xml and res/values-night/colors.xml: page, card, line, text, mute, ink, on_ink, ok, warn, bad (today only page and icon_bg exist). MainActivity takes the window colour from page. The ringing and voice screens stay dark on purpose, but take bad, text and mute from the dark set.

Design rules for the page and native screens belong to Design.

What the app does on the phone

Permissions

From AndroidManifest.xml:

It is a share target (text and images) and can be the phone's assistant app.

Sound effects

The mp3 files in SOUND EFFECTS/ are copied into the Android app (res/raw, lower-case names) and played by the phone:

FileWhere it plays
Response:send.mp3You send a message in the chat
Error.mp3A turn fails, or a message could not be sent
aproval check.mp3The assistant asks for a yes (an approval card appears)
LiveModeStart.mp3 / LiveModeEnd.mp3The voice screen opens / closes
Live Loop.mp3A soft loop on the voice screen while it works on the answer (never while listening, so the microphone does not hear it)
Notifcation Freindly.mp3The sound of normal notices and quiet reminders (a new notification channel, because Android fixes a channel's sound when it is made)
ALARM REPEAT.mp3The ring sound of an alarm whose sound is default (it loops until stopped)

They are silent when the phone is on silent or vibrate. One switch, Settings > General > Sound effects. To change a sound, replace the file in the folder and run assistantx-app-release (copy it to the same name under AssistantX-Android/app/src/main/res/raw/).