AAScreenStateHolder
Focused state holder for Android Auto screen state and loading lifecycle.
This class manages the state related to which screen is active on Android Auto, the loading/initialization lifecycle, and current guidance session information:
Screen state: Which AA screen is currently displayed (AndroidAutoScreenState)
Loading state: Initialization progress with multi-level guard logic (AndroidAutoLoadingState)
Phone equivalent state: What AA screen the phone's current state maps to (for sync on reconnect)
Guidance session: Current destination and demo mode (for mid-session AA sync)
Loading State Guards
The setLoadingState method contains critical guard logic to prevent state downgrades:
AndroidAutoLoadingState.MAP_READY cannot be downgraded to loading states
AndroidAutoLoadingState.LICENSE_REQUIRED cannot be overridden by initialization states
AndroidAutoLoadingState.ONBOARDING_REQUIRED persists until the phone transitions past onboarding
These guards provide defense-in-depth against race conditions where stale phone state re-emissions trigger loading state changes after the map is already rendering.
Cross-Holder Dependency
When the AA screen state changes, the phone app needs to be notified via PhoneAppCallback.onAAScreenStateChanged(). Since the callback is owned by AAConnectionState, this holder accepts an onAAScreenStateChanged lambda that the orchestrator wires to the connection state's callback.
Thread Safety
@Volatile for loadingState (written from GL thread, read from main thread)
@Volatile for stateListener (set from main thread, read from GL thread)
StateFlow for reactive state (inherently thread-safe)
Parameters
Optional lambda called when the AA screen state changes (for notifying PhoneAppCallback). Defaults to null for standalone use and testing.
See also
Properties
Functions
Clears the current guidance session state.
Gets the current AA screen state.
Gets the current guidance destination title.
Gets the current loading state.
Gets the phone's equivalent AA screen state.
Gets whether the current guidance session is in demo mode.
Resets the AA screen state to DISCONNECTED.
Resets the loading state to IDLE.
Sets the current Android Auto screen state.
Sets the current guidance session state.
Sets the current loading state and notifies the listener.
Sets the phone's equivalent AA screen state.
Registers a listener to be notified of loading state changes.