MSDKSession
Base Session class for MSDK-based Android Auto apps.
Handles all the generic session infrastructure that any MSDK client needs:
Session lifecycle (connect, start, stop, disconnect)
Phone state observation with deferred surface allocation
Loading state transitions (IDLE → STARTING → ONBOARDING → INITIALIZING → MAP_READY)
Car day/night mode: read from
CarContext.isDarkModewhen the session is created, started and re-opened (onNewIntent), and on every onCarConfigurationChangedPhone app launch when AA starts first
Screen navigation via AANavigationCoordinator with state machine validation
SurfaceCallback registration/unregistration
Phone state sync after map is ready
State Access
This class accesses Android Auto state through focused sub-holders:
connectionState (AAConnectionState): Connection lifecycle, phone state, callbacks
screenState (AAScreenStateHolder): Screen state, loading state, guidance session
mapState (AAMapState): The car's dark mode (read when the session is created, started and re-opened, and on car configuration changes)
Surface holder access (MapController, providers) remains via AndroidAutoSurfaceManager since AndroidAutoSurfaceHolder management is a separate concern.
What subclasses implement
createMainScreen: Root screen for the AA app
createSurfaceCallback: App-specific SurfaceCallback (with map rendering, overlays)
createScreenFactory: Factory for creating app-specific screens (search, route preview, navigation)
Screen Navigation
Phone-to-AA screen navigation is handled by AANavigationCoordinator which uses AAScreenFactory to create screens and AANavigationStateMachine to validate transitions. The subclass only provides the factory — the coordinator handles all push/pop logic and state tracking.
Lifecycle Flow
onCreate → read car dark mode → create coordinator → setAAConnected(true) → launch phone app → start observer
↓ (phone signals READY)
ensureInfrastructureReady → registerSurfaceCallback → MAP_READY
↓ (MapView ready)
syncToPhoneState (via coordinator) → push screens to match phone
↓ (user disconnects)
onDestroy → reset coordinator → cancel jobs → unregister callbacks → setAAConnected(false)See also
Functions
Records a change of the car's day/night mode in mapState.
Re-reads the car's day/night mode when the host re-opens this session.