GuidanceProvider
Interface for providing navigation guidance data to Android Auto.
This interface abstracts the guidance functionality needed by the Android Auto module, allowing it to display turn-by-turn navigation without depending on the phone app's specific implementation (e.g., GuidanceViewModel from navigating_presentation).
Architecture
This interface follows the same pattern as MapController:
┌─────────────────────────────────────────────────────────────────────┐
│ androidauto │
│ GuidanceProvider (this interface) │
│ - Base interface with StateFlow and control methods │
└─────────────────────────────────────────────────────────────────────┘
▲
│ extends
┌─────────────────────────────────────────────────────────────────────┐
│ android_auto (app module) │
│ GuidanceProviderWithViewModel │
│ - Extended interface with getGuidanceViewModel() │
└─────────────────────────────────────────────────────────────────────┘
▲
│ implements
┌─────────────────────────────────────────────────────────────────────┐
│ app │
│ GuidanceProviderAdapter │
│ - Wraps GuidanceViewModel │
│ - Converts GuidanceState → AAGuidanceState │
│ - Converts Bitmap → ByteArray │
└─────────────────────────────────────────────────────────────────────┘State Flow
The guidanceState StateFlow provides real-time navigation updates:
Maneuver icons and instructions
Distance and duration to destination
ETA and speed information
Audio mute state
Control Methods
Control methods allow Android Auto to trigger navigation actions:
startNavigation: Begin turn-by-turn guidance
stopNavigation: End the current navigation session
toggleMute: Toggle voice guidance on/off
recenter: Recenter the map on the current position
Usage
Android Auto screens access the provider via AndroidAutoSurfaceHolder:
val provider = AndroidAutoSurfaceManager.getHolder().getGuidanceProvider()
if (provider != null) {
scope.launch {
provider.guidanceState.collect { state ->
// Update NavigationTemplate with new state
}
}
}