Android Assistant Intents
Relevant source files
The following files were used as context for generating this wiki page:
- android/app/src/main/kotlin/app/cogwheel/conduit/AssistantLaunch.kt
- android/app/src/test/kotlin/app/cogwheel/conduit/AssistantLaunchTest.kt
- android/app/src/main/AndroidManifest.xml
- android/app/src/test/kotlin/app/cogwheel/conduit/AssistantComponentsTest.kt
- android/app/src/main/res/layout/assistant_overlay.xml
- README.md
Android Assistant Intents enable the application to integrate with system-level voice interaction and intent-based triggering. This system allows users to launch specific application features, such as new chats or voice calls, directly from the Android Assistant or home screen widgets.
The module manages the transition from Android system intents to internal Dart actions, ensuring that user requests are captured, queued, and executed correctly when the application engine is ready.
Sources: README.md:109-110, android/app/src/main/kotlin/app/cogwheel/conduit/AssistantLaunch.kt:1-10
Core Service Architecture
The application registers several specialized services in the AndroidManifest.xml to handle voice interaction and speech recognition. These services are identified by specific intent filters and metadata.
Voice Interaction Services
- ConduitVoiceInteractionSessionService: Handles the actual voice interaction session. It requires the
BIND_VOICE_INTERACTIONpermission. - ConduitAssistSessionService: Manages the assistant session context.
- ConduitRecognitionService: Provides a custom implementation of the Android
RecognitionServicefor speech-to-text functionality.
Sources: android/app/src/main/AndroidManifest.xml:74-106, android/app/src/test/kotlin/app/cogwheel/conduit/AssistantComponentsTest.kt:33-40
The diagram shows the relationship between Android system services and the Conduit specific implementations.
Sources: android/app/src/test/kotlin/app/cogwheel/conduit/AssistantComponentsTest.kt:33-55
Assistant Launch Logic
The AssistantLaunchAction class extracts specific instructions from incoming Intents. It uses boolean extras to determine if the user wants to start a new chat or a voice call.
Intent Extraction Process
When an Intent is processed via AssistantLaunchAction.take(intent):
- It checks for
EXTRA_START_NEW_CHATorEXTRA_START_VOICE_CALL. - It identifies if the composer should be focused via
EXTRA_FOCUS_COMPOSER. - Once extracted, the extras are removed from the Intent to prevent re-triggering the same action (e.g., during activity recreation or launches from history).
Sources: android/app/src/main/kotlin/app/cogwheel/conduit/AssistantLaunch.kt:34-70, android/app/src/test/kotlin/app/cogwheel/conduit/AssistantLaunchTest.kt:29-45
Launch Configuration Options
| Intent Extra | Action Method | Description |
|---|---|---|
EXTRA_START_NEW_CHAT | startNewChat | Triggers the creation of a new chat session. |
EXTRA_START_VOICE_CALL | startVoiceCall | Immediately initiates a voice-call mode. |
EXTRA_FOCUS_COMPOSER | N/A | If true, focuses the input area for immediate typing. |
Sources: android/app/src/main/kotlin/app/cogwheel/conduit/AssistantLaunch.kt:12-25, android/app/src/test/kotlin/app/cogwheel/conduit/AssistantLaunchTest.kt:14-27
Action Queuing and Data Flow
Because the Android Activity might start before the Flutter/Dart engine is ready to receive commands, the system uses an AssistantLaunchQueue.
- Offer: When an Intent arrives, the extracted
AssistantLaunchActionis offered to the queue. - Wait/Forward: If Dart is not yet listening, the queue holds the latest request. If Dart is already listening, the request is returned immediately for processing.
- Consumption: When Dart starts listening (via
startListening()), it receives any pending action.
Sources: android/app/src/main/kotlin/app/cogwheel/conduit/AssistantLaunch.kt:72-100, android/app/src/test/kotlin/app/cogwheel/conduit/AssistantLaunchTest.kt:53-70
This flowchart illustrates how intents are safely transitioned to the Dart environment, ensuring no actions are lost or replayed.
Sources: android/app/src/main/kotlin/app/cogwheel/conduit/AssistantLaunch.kt:72-100, android/app/src/test/kotlin/app/cogwheel/conduit/AssistantLaunchTest.kt:47-80
User Interface Integration
The Assistant feature includes a specific overlay layout (assistant_overlay.xml) that provides quick actions for the user when the assistant is invoked over other content.
Overlay Components
- btn_summarize: A button providing a "Summarize page" action.
- btn_ask_about: A button providing an "Ask about page" action.
- input_area: A text view labeled "Ask Conduit" that acts as a trigger for text input.
- btn_voice: A dedicated frame for launching voice-based interaction.
Sources: android/app/src/main/res/layout/assistant_overlay.xml:19-106
Summary
The Android Assistant Intents system provides a bridge between the Android OS and the Conduit application. It ensures that system triggers—whether from voice commands, widgets, or "Ask Conduit" text processing—are correctly translated into application actions. By utilizing a managed queue and intent-clearing logic, the system prevents duplicate actions while ensuring responsiveness during application cold starts.