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
Properties
Public read-only StateFlow of the user's day/night mode choice for the Android Auto map.
Public read-only StateFlow of the camera following state.
Public read-only StateFlow of the car's dark mode state.
Public read-only StateFlow of the split screen state.
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.
Public read-only StateFlow of the visible area horizontal center fraction.
Functions
Handles a zoom operation by delegating to the registered zoom handler.
Fits the AA MapView camera to a geographic bounding box within the visible screen area.
Whether the Android Auto map is drawn dark now: the user's dayNightMode applied to the car's isCarDarkMode — see AADayNightMode.isMapDark.
Requests the Android Auto MapView to be re-attached to Navigation.
Sets the camera following state.
Sets the car's dark mode state.
Sets the user's day/night mode choice for the Android Auto map.
Sets the callback for MapView re-attachment.
Sets the split screen state.
Sets the horizontal center of the visible area as a fraction of the full surface.
Sets the callback for handling zoom operations on the AA MapView.
Sets the callback for fitting the AA MapView camera to a geographic bounding box.