updateRoute

fun updateRoute(newRoute: Route): Error?

Replace the current route with newRoute without ending the session.

The swap simulates a rerouting: rerouting listeners are notified, the instructions manager is reset, and notifyOnNewRoute will fire from the native layer once the new session is up. Apps typically call this from BetterRouteListener.onRemoteTrafficRouteFound after deciding the candidate is worth switching to.

Guards:

  • Returns NavigationErrorCodes.NOT_IN_GUIDANCE when the session is not actively guiding (any state other than SessionState.GUIDANCE, or while the better-route thread is being aborted).

  • Returns NavigationErrorCodes.UPDATE_ROUTE_REROUTING_IN_PROGRESS when a rerouting is currently underway (between notifyOnRerouteStartListeners and the matching notifyOnNewRoute).

  • Returns NavigationErrorCodes.START_FAILED when the native session swap throws.

Return

null on success, or an Error describing the rejection.