MSDKSession

abstract class MSDKSession : Session

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.isDarkMode when the session is created, started and re-opened (onNewIntent), and on every onCarConfigurationChanged

  • Phone 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:

Surface holder access (MapController, providers) remains via AndroidAutoSurfaceManager since AndroidAutoSurfaceHolder management is a separate concern.

What subclasses implement

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

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val carContext: @NonNull CarContext
Link copied to clipboard
open val lifecycle: @NonNull Lifecycle

Functions

Link copied to clipboard
open override fun onCarConfigurationChanged(newConfiguration: Configuration)

Records a change of the car's day/night mode in mapState.

Link copied to clipboard
open override fun onCreateScreen(intent: Intent): Screen
Link copied to clipboard
open override fun onNewIntent(intent: Intent)

Re-reads the car's day/night mode when the host re-opens this session.

Link copied to clipboard
open fun setCarContextInternal(carContext: @NonNull CarContext)
Link copied to clipboard
open fun setLifecycleRegistryInternal(registry: @NonNull LifecycleRegistry)