diff --git a/Assistant.md b/Assistant.md index 505b322..5895549 100644 --- a/Assistant.md +++ b/Assistant.md @@ -42,33 +42,70 @@ handed over by the session, or just the sheet; `onNewIntent` takes a second pres ## Over the lock screen -`AssistActivity` is `setShowWhenLocked`; what it does when the phone is locked is `lockedStart()` -(tested): +**While the phone is locked nothing goes to the instance and nothing of the account is shown or +spoken.** `AssistController` asks the keyguard itself (its `locked` function), so the rule holds +whoever calls it: + +- `ask()` does not ask: it holds the question (`hold`, `Held`) until `unlocked()`. +- With Voice input › LLeMbas the recording is not written down while it runs + (`writeDownAsSaid` skips), the end is found by the level alone (`EndOfSpeech`), and the + finished recording waits **on the phone** (`AssistUiState.waitingRecording`): the sheet says + *Question heard*, with no words, and **Unlock to send**. `unlocked()` sends it to be written + down and asks it. It is kept in memory only. +- With Voice input › Phone the phone's recogniser writes it down; the words are shown while + they wait (`AssistUiState.waiting`). Where that recogniser sends the recording is its own + business, as always. +- `/api/v2/me` and the model list are asked for on unlock (`loadRemote`); the microphone opens + without them (`loadLocal` only). +- The sheet draws no turns, no model chip, no last chat and no failure text while locked; no + answer is read aloud (`speak`) and a spoken conversation does not go on. + +`AssistActivity` is `setShowWhenLocked`; what it does when opened over the lock is +`lockedStart()` (tested): | Opened | Locked behaviour | |---|---| -| to listen -- the wake word, a headset's button -- with the microphone allowed | **Listen**: the sheet stays up and listens (`AssistController.listenOverLock`). What it hears is *held* (`AssistUiState.waiting`), shown as the person's own question with **Unlock to send**, and Android is asked to unlock at once (`requestDismissKeyguard`: a face or a fingerprint is enough). If nobody unlocks, the sheet stays as it is | +| to listen -- the wake word, a headset's button -- with the microphone allowed | **Listen**: the sheet stays up and listens; what it hears is held, and Android is asked to unlock at once (`requestDismissKeyguard`: a face or a fingerprint is enough). If nobody unlocks, the sheet stays as it is | | with a question handed over by the session | **Hold**: the same, without listening | | anything else (the plain sheet, the last chat, the microphone's permission prompt) | **Unlock**: Android is asked to unlock first, and the sheet goes if that is turned down | -The question is asked when the phone is unlocked -- by the dismiss request, or by the person -(`ACTION_USER_PRESENT`). Nothing is asked, and no answer shown or spoken, before: a conversation -that was on the sheet when the phone locked is replaced by one fixed line. The screen is kept on -while it listens or works, and a sheet over the lock screen goes when the screen goes off. +The held question is asked when the phone is unlocked -- Android's answer to the request, the +person's own unlock (`ACTION_USER_PRESENT`), or the sheet coming back -- once, and only when the +keyguard itself says so. A question typed over the lock screen takes the place of one that +waited. The screen is kept on while the sheet listens, works or speaks. -With the instance's speech-to-text, listening over the lock screen sends the recording to the -instance to be written down (the person's own words come back); with Voice input › Phone it -stays with the phone's recogniser. +**The phone locking while the sheet is up.** `ACTION_SCREEN_OFF` stops the microphone and the +voice whatever the lock says yet (`screenOff`), blanks the sheet for the picture Android keeps +of it, and finishes a sheet that was over the lock screen. Found locked then or on the way back +(`onStart`), `lockedNow` also stops following the answer. The assistant's own sheet (the +session) is hidden by Android when the screen goes off, and its controller has the same rule. + +**Who may ask what of the activity** (`OwnIntents.kt`). It is exported, because Android's +`ACTION_ASSIST` and the headset actions must reach it -- so any app can start it with any +extras. Therefore: + +- a question never travels in an intent. The session leaves it in the app's memory + (`AssistHandOff.leave`) and the intent carries a one-time ticket (`EXTRA_HANDOFF`); +- `ACTION_LISTEN`, `ACTION_CONTINUE`, `EXTRA_LISTEN`, `EXTRA_WAKE` and the ticket count only on + an intent with the app's own mark (`OwnIntents.own` / `isOwn`: a random value made once, kept + in private storage, carried inside the widget's `PendingIntent`s and the shortcuts, which no + other app can read). Without it they are just the sheet. `AskWidget.refresh` at start gives a + widget placed by an older version its marked buttons; +- `VOICE_COMMAND` and `VOICE_SEARCH_HANDS_FREE` are Android's and open it listening for + anybody: over the lock that records on the phone and sends nothing. + +The activity handles configuration changes itself (`configChanges`), runs `take()` once, and +saves a held question's words across being made again; a held recording is not saved. The wake word with the screen off used to show the sheet for a moment only: a locked phone took the "ask to unlock first" path, and `onDismissCancelled` -- which is what Android answers when -nobody unlocks -- finished the activity. The assistant's own sheet (the session, screen on and -locked) listens over the lock screen too and hands what it heard to the activity (`EXTRA_SPOKEN`). +nobody unlocks -- finished the activity. **Not done: an answer over the lock screen.** A wake word from across the room gets its question heard and then waits for the unlock. Answering aloud without unlocking would be a setting of its own (off by default, voice only, nothing drawn), since it lets anyone near the -phone use the account. +phone use the account. **Also not covered:** `LembasRecognitionService`, the system recogniser +other apps get, sends its recording to the instance whenever an app asks it to, locked or not. ## The sheet @@ -101,9 +138,12 @@ means to speak listens (above). before the microphone heard anything above the room). When to stop is `EndOfSpeech` (`assist/EndOfSpeech.kt`, tested with level sequences), fed the microphone's level (RMS) every 100 ms. No level is absolute: the **noise floor** is the quietest level of the last two - seconds, taken at once when it falls and slowly when it rises. Speech begins when the level is - over about twice the floor in three of the last eight ticks; a pause is back within 1.6 times - of it. A pause of 1.5 s after speech sends it; nothing said gives up after 5 s and sends + seconds, taken at once when it falls and slowly, in calm moments only, when it rises (so a + voice does not lift it under itself; a first sound louder than any room is a guess until a + dip or a calm moment shows the room). Speech begins when the level is over about twice the + floor in three of the last eight ticks, or stays above the floor for a second without being + steady (listening that begins mid-sentence); a pause is back within 1.6 times of it, and an + exact zero after sound -- a headset that gates its noise -- is a pause too. A pause of 1.5 s after speech sends it; nothing said gives up after 5 s and sends nothing (a speech-to-text model asked to write down silence invents a sentence, so its words count as speech only when the microphone heard something above the room); the same words for 4.5 s end it; and never past 60 s. Known limits: sound that is not steady (music, a @@ -117,8 +157,9 @@ means to speak listens (above). for `android.speech.RecognitionService`). No Google library is linked; a phone with none says so in Settings. If the instance has no speech-to-text, the phone's is used. It is asked for the same 1.5 s pause (`EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS`, a hint not - every recogniser takes) and watched (`phoneWatch`): no words in 8 s gives up, the same words - for 4.5 s asks it to stop, and one that does not answer has its words taken as they are. + every recogniser takes) and watched (`phoneWatch`): no words and no sign of speech (its + "speech began", a loud level) for 8 s gives up, the same words for 4.5 s in quiet asks it to + stop, and one that does not answer has its words taken as they are. `LembasRecognitionService` (what other apps get as the system's recogniser) ends by `EndOfSpeech` too, within its 15 s limit. diff --git a/Release-checklist.md b/Release-checklist.md index e79abe5..d4569a0 100644 --- a/Release-checklist.md +++ b/Release-checklist.md @@ -18,9 +18,14 @@ the tag. ask by voice; the answer is read aloud; Include screen sends the screen's text. 8. **Lock screen**: open the assistant while locked -- nothing from the account shows; sending asks to unlock. With the wake word listening with the screen off: lock the phone, say the - phrase -- the screen comes on, the sheet **stays** and listens; ask something: your question - is shown with *Unlock to send*, and it is sent (and answered) once you unlock; leave it, and - the sheet is gone when the screen goes off. + phrase -- the screen comes on, the sheet **stays** and listens; ask something. With Voice + input › LLeMbas it says *Question heard* (no words) and **Unlock to send**, and the + instance's log shows **no request** until you unlock; then it is written down, asked and + answered. With Voice input › Phone your words are shown while they wait. Leave it, and the + sheet is gone when the screen goes off. Unlocked: ask by voice and press the power button + while it listens, and again while the answer is read aloud -- the microphone and the voice + stop, and nothing of the conversation is on the lock screen. Turn the phone while a question + waits: it still waits, and is asked once. 9. **The tile and the shortcut** open the sheet. 10. **Both themes**, and the narrowest phone at hand: nothing runs off the screen. 11. **Attach**: take a photo, choose photos, choose a file; each arrives on the web page with the