setLoadingState
Sets the current loading state and notifies the listener.
Called primarily by MSDKSession's phoneState observer to update the loading state as the phone app progresses through initialization. MSDKSurfaceCallback sets MAP_READY when a car MapView becomes ready, and ERROR when the car map cannot be built.
MAP_READY Protection
Once the loading state reaches AndroidAutoLoadingState.MAP_READY, it must NOT be downgraded back to a loading/initialization state. MAP_READY lasts until the session ends (AndroidAutoLoadingState.IDLE), or until one of the other states listed below replaces it, including while the host takes the map surface away: the root screen keeps its map template, which is what brings the surface back.
This guard provides defense-in-depth against race conditions where a stale phone state re-emission triggers a loading state change after the map is already rendering.
AndroidAutoLoadingState.IDLE (session ended), AndroidAutoLoadingState.ERROR, AndroidAutoLoadingState.ONBOARDING_REQUIRED (e.g., map data deleted while AA is connected), and AndroidAutoLoadingState.LICENSE_REQUIRED (license check failed on reconnect) are allowed to override MAP_READY.
LICENSE_REQUIRED Protection
Similarly, once the loading state reaches AndroidAutoLoadingState.LICENSE_REQUIRED, it must NOT be overridden by initialization states. LICENSE_REQUIRED is a definitive state set by the phone app when the license does not include Android Auto features.
Only AndroidAutoLoadingState.IDLE (session ended) and AndroidAutoLoadingState.ERROR can override LICENSE_REQUIRED.
ONBOARDING_REQUIRED Protection
Similarly, once the loading state reaches AndroidAutoLoadingState.ONBOARDING_REQUIRED, it must NOT be overridden by initialization states. ONBOARDING_REQUIRED is set when the user hasn't completed onboarding yet. It must persist until the phone transitions past onboarding (INITIALIZING_MAPS, MAP_READY) or a definitive state is reached (LICENSE_REQUIRED, ERROR).
Only AndroidAutoLoadingState.IDLE (session ended), AndroidAutoLoadingState.INITIALIZING_MAPS (past onboarding), AndroidAutoLoadingState.MAP_READY (past onboarding), AndroidAutoLoadingState.LICENSE_REQUIRED (license checked after onboarding), AndroidAutoLoadingState.ERROR, and ONBOARDING_REQUIRED itself can override ONBOARDING_REQUIRED.
ERROR Is Not Protected
Any state can override AndroidAutoLoadingState.ERROR, and MAP_READY must be able to: a car MapView that becomes ready after an error brings the map back. While the session lives, the SDK does not write IDLE over it: it writes IDLE only when the session ends.
Listener Failures
The listener (setStateListener) is notified synchronously, once the state is set. An exception it throws, such as the HostException of a Screen.invalidate() whose call to the host fails, is logged and not propagated: the new state stands, and the caller's own work is not cut short.
Parameters
The new loading state