AAMapState

Focused state holder for Android Auto map display state.

This class manages all state related to the Android Auto map rendering, camera behavior, and user interaction with the map surface:

  • Camera following: Whether the map auto-centers on GPS position

  • Split screen: Whether the AA display shows a side panel

  • Vehicle position: Horizontal center of the visible area for vehicle icon placement

  • Day/night: The car head unit's day/night mode, the user's day/night choice (AADayNightMode), and the mode the map is drawn in, which combines the two (isMapDark)

  • Zoom: Delegated zoom handlers (routed through SurfaceCallback for live camera state)

  • MapView reattach: Callback for re-attaching MapView after Navigation session restart

Why Zoom Is Delegated

The zoom buttons in NavigationScreen only have access to MapController, whose zoomIn()/zoomOut() methods use a stale ViewModel center during guidance tracking (the MSDK moves the camera directly without updating the ViewModel).

By routing zoom through the SurfaceCallback (which has access to the live aaMapView), we can read the actual camera position via getCurrentMapState() and apply zoom at the correct location using MapController.centerOn().

Thread Safety

  • StateFlow for all reactive state (inherently thread-safe)

  • @Volatile for zoomHandler and zoomToRectHandler (set from main thread, may be invoked from binder thread)

See also

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Public read-only StateFlow of the user's day/night mode choice for the Android Auto map.

Link copied to clipboard

Public read-only StateFlow of the camera following state.

Link copied to clipboard
val isCarDarkMode: StateFlow<Boolean>

Public read-only StateFlow of the car's dark mode state.

Link copied to clipboard
val isSplitScreen: StateFlow<Boolean>

Public read-only StateFlow of the split screen state.

Link copied to clipboard

Emits whether the Android Auto map is drawn dark (isMapDark): the current value on collection, then each time it changes — when the car switches between day and night under AADayNightMode.AUTO, or when the user changes dayNightMode.

Link copied to clipboard

Public read-only StateFlow of the visible area horizontal center fraction.

Functions

Link copied to clipboard
fun handleZoom(zoomIn: Boolean)

Handles a zoom operation by delegating to the registered zoom handler.

Link copied to clipboard

Fits the AA MapView camera to a geographic bounding box within the visible screen area.

Link copied to clipboard

Whether the Android Auto map is drawn dark now: the user's dayNightMode applied to the car's isCarDarkMode — see AADayNightMode.isMapDark.

Link copied to clipboard

Requests the Android Auto MapView to be re-attached to Navigation.

Link copied to clipboard

Sets the camera following state.

Link copied to clipboard
fun setCarDarkMode(isDark: Boolean)

Sets the car's dark mode state.

Link copied to clipboard

Sets the user's day/night mode choice for the Android Auto map.

Link copied to clipboard
fun setReattachMapViewCallback(callback: () -> Unit?)

Sets the callback for MapView re-attachment.

Link copied to clipboard
fun setSplitScreen(splitScreen: Boolean)

Sets the split screen state.

Link copied to clipboard

Sets the horizontal center of the visible area as a fraction of the full surface.

Link copied to clipboard
fun setZoomHandler(handler: (Boolean) -> Unit?)

Sets the callback for handling zoom operations on the AA MapView.

Link copied to clipboard
fun setZoomToRectHandler(handler: (GeoRect) -> Unit?)

Sets the callback for fitting the AA MapView camera to a geographic bounding box.