Locked means nothing to the instance; the lock is followed; no question by intent
CI / check (push) Canceled after 0s

Review M1, M2, M3, S1, S4, S5, S6 and the notes.

M1. While the phone is locked nothing goes to the instance from the sheet.
The controller asks the keyguard itself: ask() holds instead of asking,
the recording is not written down while it runs, and a question heard with
the instance's speech-to-text waits on the phone as a recording ("Question
heard", no words) to be written down and asked on unlock. me() and models()
wait for the unlock too; the microphone opens without them.

M2. The screen going off stops the microphone and the voice whatever the
lock says, and takes the conversation out of the last frame; found locked
(then, or on the way back) the controller drops the listening, stops
following the answer and ends the conversation. No answer is read aloud and
no conversation goes on over the lock. The screen stays on while speaking.

M3. AssistActivity is exported and believed its extras. A handed-over
question now waits in process memory (AssistHandOff) and the intent carries
a one-time ticket; ACTION_LISTEN, ACTION_CONTINUE, EXTRA_LISTEN, EXTRA_WAKE
and the ticket count only on an intent with the app's own mark (OwnIntents:
a random value kept in private storage, carried by the widget's and the
shortcuts' intents). Android's VOICE_COMMAND actions stay public.

S1 Recorder.stopNow() for close(). S4 the activity handles configuration
changes itself, take() runs once, a held question is saved. S5 a typed
question replaces the held one before the unlock is asked for, so one is
asked once. S6 the recogniser's "speech began" and loud level reach the
watch. Notes: no failure text over the lock, Share checks the model still
exists, USER_PRESENT re-reads the keyguard.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
HomerandClaude Fable 5.2 committed 2026-11-13 15:42:04 +00:00
1 parent a4a5c5dba1
commit 6540d160df
25 files changed
+582 -153

No files matched your search

@@ -4,8 +4,12 @@ import eu.llembas.android.api.LiveReply
import eu.llembas.android.api.ModelInfo
import eu.llembas.android.api.Step
import eu.llembas.android.api.Tail
import eu.llembas.android.assist.AssistActivity
import eu.llembas.android.assist.AssistController
import eu.llembas.android.assist.AssistHandOff
import eu.llembas.android.assist.AssistTurn
import eu.llembas.android.assist.AssistUiState
import eu.llembas.android.assist.Held
import eu.llembas.android.assist.LockedStart
import eu.llembas.android.assist.Opening
import eu.llembas.android.assist.Recorder
@@ -92,6 +96,50 @@ class AssistTest {
}
}
@Test
fun onlyTheAppsOwnIntentsAskForMoreThanTheSheet() {
val voiceButton = "android.intent.action.VOICE_COMMAND"
val handsFree = "android.speech.action.VOICE_SEARCH_HANDS_FREE"
// The app's own: the widget's microphone, the last chat, the session's "listen".
assertEquals(Opening.Listen, Opening.of(AssistActivity.ACTION_LISTEN, listenExtra = false, own = true))
assertEquals(Opening.Continue, Opening.of(AssistActivity.ACTION_CONTINUE, listenExtra = false, own = true))
assertEquals(Opening.Listen, Opening.of(null, listenExtra = true, own = true))
// The same from any other app: just the sheet.
assertEquals(Opening.Sheet, Opening.of(AssistActivity.ACTION_LISTEN, listenExtra = true, own = false))
assertEquals(Opening.Sheet, Opening.of(AssistActivity.ACTION_CONTINUE, listenExtra = false, own = false))
assertEquals(Opening.Sheet, Opening.of("android.intent.action.ASSIST", listenExtra = true, own = false))
// Android's own actions for a headset's button are anybody's, and listen.
assertEquals(Opening.Listen, Opening.of(voiceButton, listenExtra = false, own = false))
assertEquals(Opening.Listen, Opening.of(handsFree, listenExtra = false, own = false))
assertEquals(Opening.Sheet, Opening.of("android.intent.action.ASSIST", listenExtra = false, own = true))
}
@Test
fun aHandedOverQuestionIsTakenOnceAndOnlyWithItsTicket() {
val question = Held("How far is it to the next town?", null, spoken = true)
val ticket = AssistHandOff.leave(question)
// No ticket, a made-up one, one of another length: nothing.
assertEquals(null, AssistHandOff.take(null))
assertEquals(null, AssistHandOff.take("0".repeat(ticket.length)))
assertEquals(null, AssistHandOff.take(ticket.dropLast(1)))
// The ticket: the question, once.
assertTrue(AssistHandOff.take(ticket) === question)
assertEquals(null, AssistHandOff.take(ticket))
// A newer question takes the older one's place, and the older ticket is worth nothing.
val older = AssistHandOff.leave(question)
val newer = AssistHandOff.leave(Held("", ByteArray(4), spoken = true))
assertTrue(older != newer)
assertEquals(null, AssistHandOff.take(older))
assertTrue(AssistHandOff.take(newer)?.wav != null)
}
@Test
fun aQuestionWaitsAsWordsOrAsARecording() {
assertFalse(AssistUiState().held)
assertTrue(AssistUiState(waiting = "Why?").held)
assertTrue(AssistUiState(waitingRecording = true).held)
}
@Test
fun aVoiceReadsOnlyTheWords() {
val steps = listOf(
@@ -342,6 +342,9 @@ class ScreenShots {
shoot("22-assistant-locked-waiting", content = over(waiting, true))
shoot("22-assistant-locked-waiting", Phone.Small, fontScale = 1.5f, content = over(waiting, true))
shoot("22-assistant-locked-answered", content = over(Fakes.assistAnswered, true))
// Heard where the instance writes speech down: it waits as a recording, with no words.
shoot("22-assistant-locked-recording", content = over(Fakes.assistOpened.copy(waitingRecording = true), true))
shoot("22-assistant-locked-recording", Phone.Small, fontScale = 1.5f, content = over(Fakes.assistOpened.copy(waitingRecording = true), true))
shoot("23-assistant-offline", Phone.Small, content = over(Fakes.assistOffline, false))
shoot("24-assistant-conversation", content = over(Fakes.assistConversation, false))
shoot("24-assistant-conversation", Phone.Small, fontScale = 1.5f, content = over(Fakes.assistConversation, false))