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)

  • Dark mode detection via 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 → setAAConnected(true) → create coordinator → 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)
Link copied to clipboard
open override fun onCreateScreen(intent: Intent): Screen
Link copied to clipboard
open fun onNewIntent(intent: @NonNull Intent)
Link copied to clipboard
open fun setCarContextInternal(carContext: @NonNull CarContext)
Link copied to clipboard
open fun setLifecycleRegistryInternal(registry: @NonNull LifecycleRegistry)