Wake word that loads and says its state; three APKs; display per spec 3.7.0

Assistant: the wake word as it is now (model copied by stream per version,
greeting x name, generated pieces, boost and threshold by sensitivity, one
WakeState, WakeListener, the test row) and notification summaries in the
notifications build only. Design: the two flavour dimensions and the
self-updater's own-kind rule. Installing: the three files and why.
Working-notes: the variants, the asset and runCatching trap, locale numbers.
Release-checklist: the wake word and installing.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
HomerandClaude Fable 5.2 committed 2026-11-12 10:15:34 +00:00
1 parent 9cd5e4b999
commit de270b1f91
5 files changed
+113 -25

No files matched your search

+57 -12
@@ -86,10 +86,18 @@ a card waiting, or nothing said (the usual silence rules). With a Bluetooth head
microphone; a wired headset's is the default anyway.
**Notification summaries** (Settings › Assistant › *Notification summaries*, off; plus Android's
notification access, which only the person can give). `LembasNotificationListener` keeps
nothing; `NotificationReader.read` takes what is up when a question asks -- the *Summarise my
notifications* chip, or a question naming them (`assist_notifications_phrases`) -- and nothing
while the phone is locked. They go with that one question as "My notifications:" text.
notification access, which only the person can give) -- **in the `notifications` build only**.
`LembasNotificationListener` keeps nothing; `NotificationAccess.read` takes what is up when a
question asks -- the *Summarise my notifications* chip, or a question naming them
(`assist_notifications_phrases`) -- and nothing while the phone is locked. They go with that one
question as "My notifications:" text (`NotificationReader.asText`, in every build).
The listener and its manifest entry live in `src/notifications/` alone. The standard builds
(`src/standard/`) have a `NotificationAccess` that can do nothing and declare no listener and no
permission of it: Google Play Protect blocks installing an app from outside the Play Store that
can read notifications, and it blocked 1.0.0-beta.7. Settings there says which build has the
feature and why. `scripts/check-apk.sh` checks the built files, in CI and before a release is
published.
**Open in app** continues the same chat in the app. A reply waiting on a card (an approval or a
question) says to open it in the app: the sheet does not answer cards.
@@ -121,17 +129,54 @@ what Settings › Assistant › *Wake word* turns on (off by default).
CI and the release workflow run it before Gradle.
- **`full` only.** The `fdroid` flavour has a stub (`src/fdroid/.../wake/Engine.kt`,
`AVAILABLE = false`) and Settings says why: F-Droid builds every library from source, and
sherpa-onnx is not built from source here yet. ABIs in `full`: arm64-v8a, armeabi-v7a, x86_64.
- **Phrases**: four English ones (`WakePhrases`), spelled in the model's BPE pieces with its
`bpe.model` (sentencepiece, offline) -- the phone has no tokenizer, and a free phrase was not
measured. Not tuned on a phone: the engine's default threshold (0.25) and score (1.5).
sherpa-onnx is not built from source here yet. ABIs: arm64-v8a and armeabi-v7a in a release;
a debug build adds x86_64 for the emulator. Of the AAR's libraries only `libsherpa-onnx-jni.so`
and `libonnxruntime.so` are packaged (the C and C++ API libraries are for other callers).
- **The model is copied out of the APK by stream** (`unpackWakeModel`), once per model version
(`assets/wakeword/version`, a hash of the pinned files written by the fetch script), into the
app's no-backup files. `AssetManager.openFd` works only for an asset stored uncompressed, and
1.0.0-beta.7 used it on compressed ones: the engine never loaded on any phone, silently. The
`.onnx` assets are stored now as well (`noCompress`), and CI checks the APK.
- **A phrase is a greeting and a name**: Hey / OK / Hello, then Assistant / Computer / Google or an
ordinary name (`WakeWords`, default "Hey Assistant"). Only words the model was trained to hear:
"Hey Lembas" had to be repeated until it happened to land, because Lembas is no word of the
model's. Settings saves `greeting_name`; an id that is no phrase any more reads as the default.
- **The token pieces are generated**, never typed: `scripts/fetch-wakeword.py` also takes the
model's `bpe.model` from the same pinned archive (to `build/wakeword/`, not into the APK), and
`scripts/gen-wake-phrases.py` (sentencepiece, pinned in `scripts/wake-requirements.txt`) writes
`wake/WakeWords.kt`. CI checks the committed table against the tokenizer, and `WakeWordsTest`
every piece against `tokens.txt`. "OK" is spelled OKAY, one piece, as the model's speech was
transcribed. A name with four or more single-letter pieces is dropped (Elizabeth, Benjamin).
- **The engine ends the process on a piece it does not know** (`exit(-1)` in its keyword
encoder), so `checkKeywords` checks every keywords line against `tokens.txt` first.
- **Boost and threshold** go on each keywords line (`:boost #threshold`, sherpa-onnx's syntax),
from Settings › Wake word › *Sensitivity*: Low 1.0 / 0.35, Normal 1.5 / 0.25, High 2.0 / 0.15,
and 0.05 stricter for a phrase of fewer than five pieces. The threshold is the least average
probability of the heard pieces (0.25 is the engine's default, 0.35 its documentation's
stricter example); `numTrailingBlanks` is the engine's own 1. Starting values, not yet tuned
on phones.
- **One state, shown** (`WakeState` in `WakeStatus.state`): Off, Starting, Listening(phrase),
Paused(why), Failed(why, detail). The service writes it; its notification (`wakeNotification`,
written from the state in one place), Settings' row and "Test the wake word" read it. A start
never posts a phrase by default: 1.0.0-beta.7 posted "Listening for Hey Lembas" on every app
open, whatever was chosen and whether or not anything listened.
- **`WakeListener`** is the loop apart from Android (tested on the JVM with a fake engine and
microphone): an engine that does not load, a microphone that does not start or stops, are
`Failed` with the reason, logged (`LLeMbasWake`), retried after 2 s, 5 s, 15 s, 1 min, then
every 5 min. A new plan cancels and joins the old loop before the engine is released. Five
seconds of exact zeros is `Paused(Silent)`: Android hands a background app silence while
another app has the microphone, or its switch is off.
- **`WakeWordService`** (`foregroundServiceType="microphone"`, notification up the whole time,
with Stop): 16 kHz audio to the engine in memory, nothing kept or sent. Pauses while the sheet
is up (`AssistPresence`, counted by the session and the activity), in battery saver, and with
the screen off unless *Only while the screen is on* is off. On the word: the sheet opens
listening through `LembasAssistService.current.showSession` when LLeMbas is the assistant
(Android lets the bound voice-interaction service do that from the background), else as an
activity, else a "tap to ask" notification.
the screen off unless *Only while the screen is on* is off. It is not started without the
microphone permission (the state says so), and the app looks again each time it comes to the
screen. On the word: the sheet opens listening through
`LembasAssistService.current.showSession` when LLeMbas is the assistant (Android lets the
bound voice-interaction service do that from the background), else as an activity, else a
"tap to ask" notification.
- **Test the wake word** (Settings): for ten seconds a heard phrase is counted
(`WakeStatus.heardInTrial`) instead of opening the assistant. A deadline, not a switch.
- **Android's rules**: a microphone service starts only from the app on screen and never at
boot -- `WakeBootReceiver` posts "tap to listen again", and the app restarts a service the
phone stopped whenever it opens. Settings links the battery-optimisation page and names
+13 -4
@@ -177,10 +177,19 @@ holds the offered list, the `values-*` folders and the locale config equal.
## Distribution
`full`: a signed APK on the GitHub and forge Releases, which updates itself from
`llembas.eu/android/latest.json` -- SHA-256 checked, signer checked, then Android's installer.
`fdroid`: the same app without the updater, for F-Droid (metadata and a reproducible build are
later). The release key lives in the CI secrets, never in the repository.
Two flavour dimensions, three APKs of one application id and one key. `distribution`: `full`
(updates itself, wake-word engine) or `fdroid` (neither; F-Droid updates it and builds from
source). `reading`: `standard` (no notification listener in the manifest at all) or
`notifications` (the listener, for notification summaries). The variants are `fullStandard`
(`llembas-android-<version>.apk`), `fullNotifications` (`…-notifications.apk`) and
`fdroidStandard` (`…-fdroid.apk`); there is no F-Droid build with the listener.
The full builds update themselves from `llembas.eu/android/latest.json` -- SHA-256 checked,
signer checked, then Android's installer -- and only to their own kind: the standard build takes
`url` and `sha256`, the notifications build the optional `notifications: {url, sha256}`, and
without one it installs nothing and says to take the file from the release page (it would
otherwise lose its listener without a word). The release key lives in the CI secrets, never in
the repository.
**The update check** (`update/ReleaseCheck.kt`, both flavours) reads the repository's public
releases from `api.github.com` over plain HTTPS: no Google service, no account, nothing sent but
+18 -8
@@ -1,12 +1,21 @@
# Installing and updating
LLeMbas for Android is not on Google Play. Each release on GitHub carries two APKs, signed with
the same key:
LLeMbas for Android is not on Google Play. Each release on GitHub carries three APKs of the one
app, signed with the same key:
| File | What |
|---|---|
| `llembas-android-<version>.apk` | The **full** build. It can install a newer release of itself. |
| `llembas-android-<version>-fdroid.apk` | The **F-Droid** build: the same app without the self-installer, for the F-Droid repository. |
| `llembas-android-<version>.apk` | The **standard** build, the one to install. It can install a newer release of itself, and has the wake word. |
| `llembas-android-<version>-notifications.apk` | The same, plus a notification listener, for **notification summaries** ("summarise my notifications"). |
| `llembas-android-<version>-fdroid.apk` | The **F-Droid** build: no self-installer and no wake-word engine, for the F-Droid repository. |
**Why notification summaries are a separate file.** Google Play Protect blocks installing an app
from outside the Play Store that can read notifications (it is one of the things it looks for in
an unknown app). So the standard build declares no notification listener at all, and Settings ›
Assistant › *Notification summaries* says where they went. The `-notifications` build is the same
app with the same signature: it installs over the standard one as an ordinary update, and back,
with nothing lost. Installing it may need Play Protect's own "install anyway", which is yours to
decide.
Releases: <https://github.com/LLeMbas/LLeMbas-Android/releases>. A version with `-beta.N` is a
test version, marked as a pre-release.
@@ -27,14 +36,15 @@ GitHub releases. To follow LLeMbas for Android with it:
1. **Add app**, and give it the repository's address:
`https://github.com/LLeMbas/LLeMbas-Android`
2. For betas, turn on **Include prereleases**. Leave it off to get releases only.
3. Each release has two APKs. To take the full build, not the F-Droid one, set
3. Each release has three APKs. To take the standard build, set
**Filter APKs by regular expression** to:
```
^llembas-android-[0-9.]+(-beta\.[0-9]+)?\.apk$
```
(For the F-Droid build instead: `-fdroid\.apk$`.)
(For the build with notification summaries instead: `-notifications\.apk$`; for the F-Droid
build: `-fdroid\.apk$`.)
4. **Add**, then install.
Obtainium checks on its own schedule, so the app's own *Look for new versions* can stay off.
Switching between the full and the F-Droid build needs no reinstall: both are signed with the
same key and share the application id.
Switching between the three builds needs no reinstall: all are signed with the same key and
share the application id.
+9 -1
@@ -28,6 +28,14 @@ the tag.
14. **Offline**: airplane mode in a chat -- send says the instance cannot be reached and the
message stays in the composer; back online, the stream picks up by itself.
15. **The wake word** (standard build): turn it on; the notification says *Listening for* your
phrase, not another; **Test the wake word** says *Heard it* when you say it; close the app
and say it: the assistant opens. Change the phrase: the notification follows. Take the
microphone permission away in the system's settings and open the app: it says so, and does
not close.
16. **Installing**: the standard APK installs without Play Protect blocking it; the
`-notifications` APK installs over it and Settings then offers notification summaries.
The test builds from `dev` (CI's `llembas-android-debug-N` artifact) are the way to walk this
list before a tag: they install beside a released app and over each other. A `-beta.N` tag is
list before a tag: they install beside a released app and over each other (the plain one, `-notifications` and `-fdroid`). A `-beta.N` tag is
published on GitHub as a pre-release by `release.yml` itself.
+16
@@ -122,6 +122,22 @@ design change, before a phone.
permitted within comments"), so no `--` dash in a layout's or the manifest's comments. CI run 61.
- **The wake-word engine is not in the repository.** `scripts/fetch-wakeword.py` fetches it
(hash-pinned) before Gradle; a local `full` build without it fails on the missing AAR.
- **Three variants, not two flavours**: `fullStandard`, `fullNotifications`, `fdroidStandard`
(`assembleFullStandardDebug`, `testFullStandardDebugUnitTest`, …). Only `src/notifications/`
may declare or contain the notification listener; `scripts/check-apk.sh` fails CI and a
release otherwise. See Design › Distribution.
- **An asset the native engine opens must not depend on how the APK stores it.**
`AssetManager.openFd` throws on a compressed asset; copy by stream. And **never
`runCatching { … }.getOrNull()` around something whose failure a person needs to see**: the
wake word did not work on any phone for a whole beta because of that pair.
- **The wake phrases' pieces are generated** (`scripts/gen-wake-phrases.py`, needs the
`sentencepiece` pinned in `scripts/wake-requirements.txt`, in a venv). A piece the model does
not know ends the process inside the engine; CI checks the table twice.
- **A number in a keywords line or a duration is formatted with `Locale.ROOT`**; the phone's
locale would write a decimal comma. A number a person reads (`localeNumber`) is the opposite:
the phone's format, and `Locale.ROOT` there means the spec's plain format for the tests.
- **Display follows the harness spec** (`display.md`, 3.7.0): `api/Display.kt` has the title cut,
the call states and duration, the end line of a stopped or failed reply, and locale numbers.
- **Phone actions drive OsmAnd through `osmand.api://` URIs only.** Its AIDL API's classes are
GPLv3 (the OsmAnd repository); copying them would change this app's licence.
- **A UI string that names another UI string's words** (`phone_actions_line` says "Do it") must