diff --git a/changelog/unreleased/issues/changes.md b/changelog/unreleased/issues/changes.md new file mode 100644 index 00000000000..cae78202471 --- /dev/null +++ b/changelog/unreleased/issues/changes.md @@ -0,0 +1 @@ +- In case an app provides custom `Router` implementation to Nav SDK, the Nav SDK doesn't trigger `NavigationRouteAlternativesObserver` with online alternatives when current route is offline. diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 6cd8b499b5c..31856e0c21e 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -13,7 +13,7 @@ ext { // version which we should use in this build def mapboxNavigatorVersion = System.getenv("FORCE_MAPBOX_NAVIGATION_NATIVE_VERSION") if (mapboxNavigatorVersion == null || mapboxNavigatorVersion == '') { - mapboxNavigatorVersion = '142.0.0' + mapboxNavigatorVersion = '143.0.0' } println("Navigation Native version: " + mapboxNavigatorVersion) diff --git a/instrumentation-tests/src/androidTest/java/com/mapbox/navigation/instrumentation_tests/core/EvOfflineTest.kt b/instrumentation-tests/src/androidTest/java/com/mapbox/navigation/instrumentation_tests/core/EvOfflineTest.kt index f82f0ac60a5..a8f42b7162e 100644 --- a/instrumentation-tests/src/androidTest/java/com/mapbox/navigation/instrumentation_tests/core/EvOfflineTest.kt +++ b/instrumentation-tests/src/androidTest/java/com/mapbox/navigation/instrumentation_tests/core/EvOfflineTest.kt @@ -34,7 +34,6 @@ import kotlinx.coroutines.flow.first import org.junit.Assert.assertEquals import org.junit.Assert.assertNull import org.junit.Assert.assertTrue -import org.junit.Ignore import org.junit.Rule import org.junit.Test @@ -67,7 +66,6 @@ class EvOfflineTest : BaseCoreNoCleanUpTest() { } @Test - @Ignore("NN-843") fun startNavigationOfflineThenSwitchToOnlineRouteWhenInternetAppears() = sdkTest( timeout = INCREASED_TIMEOUT_BECAUSE_OF_REAL_ROUTING_TILES_USAGE ) { @@ -178,6 +176,7 @@ class EvOfflineTest : BaseCoreNoCleanUpTest() { navigation.registerRouteAlternativesObserver( SimpleAlternativesObserverFromDocumentation(navigation) ) + navigation.startTripSession() stayOnPosition( evBerlinTestRoute.origin.latitude(), diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt index 33a83f078e3..89326fc2879 100644 --- a/libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt @@ -471,7 +471,11 @@ class MapboxNavigation @VisibleForTesting internal constructor( ), navigationOptions.accessToken ?: "", if (moduleRouter.isInternalImplementation()) { - nativeRouter + // We pass null to let NN know that default router is used and it can rely + // on implementation details in some cases like offline-online switch. + // Meanwhile platform SDK uses its own instance of native router for + // route requests + null } else { RouterInterfaceAdapter(moduleRouter, ::getNavigationRoutes) }, diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/NavigationComponentProvider.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/NavigationComponentProvider.kt index dbeb5aaefc1..b2bf602682f 100644 --- a/libnavigation-core/src/main/java/com/mapbox/navigation/core/NavigationComponentProvider.kt +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/NavigationComponentProvider.kt @@ -42,7 +42,7 @@ internal object NavigationComponentProvider { historyRecorderComposite: HistoryRecorderHandle?, tilesConfig: TilesConfig, accessToken: String, - router: RouterInterface, + router: RouterInterface?, ): MapboxNativeNavigator = MapboxNativeNavigatorImpl.create( config, historyRecorderComposite, diff --git a/libnavigation-router/src/test/java/com/mapbox/navigation/route/internal/RouterWrapperTests.kt b/libnavigation-router/src/test/java/com/mapbox/navigation/route/internal/RouterWrapperTests.kt index 92179337367..e70528345fc 100644 --- a/libnavigation-router/src/test/java/com/mapbox/navigation/route/internal/RouterWrapperTests.kt +++ b/libnavigation-router/src/test/java/com/mapbox/navigation/route/internal/RouterWrapperTests.kt @@ -17,7 +17,6 @@ import com.mapbox.navigation.base.route.RouterCallback import com.mapbox.navigation.base.route.RouterFailure import com.mapbox.navigation.base.route.RouterOrigin.Offboard import com.mapbox.navigation.base.route.RouterOrigin.Onboard -import com.mapbox.navigation.navigator.internal.MapboxNativeNavigator import com.mapbox.navigation.navigator.internal.mapToRoutingMode import com.mapbox.navigation.route.internal.util.ACCESS_TOKEN_QUERY_PARAM import com.mapbox.navigation.route.internal.util.TestRouteFixtures @@ -74,7 +73,6 @@ class RouterWrapperTests { var coroutineRule = MainCoroutineRule() private lateinit var routerWrapper: RouterWrapper - private val mapboxNativeNavigator: MapboxNativeNavigator = mockk(relaxed = true) private val router: RouterInterface = mockk(relaxed = true) private val accessToken = "pk.123" private val route: DirectionsRoute = mockk(relaxed = true) @@ -145,7 +143,6 @@ class RouterWrapperTests { every { ThreadController.IODispatcher } returns coroutineRule.testDispatcher every { ThreadController.DefaultDispatcher } returns coroutineRule.testDispatcher - every { mapboxNativeNavigator.router } returns router every { router.getRoute(any(), any(), capture(getRouteSlot)) } returns 0L every { router.getRouteRefresh(any(), capture(refreshRouteSlot)) } returns 0L @@ -155,7 +152,7 @@ class RouterWrapperTests { routerWrapper = RouterWrapper( accessToken, - mapboxNativeNavigator.router, + router, ThreadController(), ) } diff --git a/libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/MapboxNativeNavigator.kt b/libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/MapboxNativeNavigator.kt index 06b1245d9cc..95beec77f0f 100644 --- a/libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/MapboxNativeNavigator.kt +++ b/libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/MapboxNativeNavigator.kt @@ -42,7 +42,7 @@ interface MapboxNativeNavigator { historyRecorderComposite: HistoryRecorderHandle?, tilesConfig: TilesConfig, accessToken: String, - router: RouterInterface, + router: RouterInterface?, ): MapboxNativeNavigator /** @@ -192,6 +192,4 @@ interface MapboxNativeNavigator { val roadObjectMatcher: RoadObjectMatcher? val experimental: Experimental - - val router: RouterInterface } diff --git a/libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/MapboxNativeNavigatorImpl.kt b/libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/MapboxNativeNavigatorImpl.kt index 7eb61dbdfad..8269d3fa3eb 100644 --- a/libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/MapboxNativeNavigatorImpl.kt +++ b/libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/MapboxNativeNavigatorImpl.kt @@ -66,7 +66,6 @@ object MapboxNativeNavigatorImpl : MapboxNativeNavigator { override var roadObjectsStore: RoadObjectsStore? = null override lateinit var experimental: Experimental override lateinit var cache: CacheHandle - override lateinit var router: RouterInterface override lateinit var routeAlternativesController: RouteAlternativesControllerInterface private val nativeNavigatorRecreationObservers = CopyOnWriteArraySet() @@ -83,7 +82,7 @@ object MapboxNativeNavigatorImpl : MapboxNativeNavigator { historyRecorderComposite: HistoryRecorderHandle?, tilesConfig: TilesConfig, accessToken: String, - router: RouterInterface, + router: RouterInterface?, ): MapboxNativeNavigator { navigator?.shutdown() @@ -99,7 +98,6 @@ object MapboxNativeNavigatorImpl : MapboxNativeNavigator { roadObjectsStore = nativeComponents.navigator.roadObjectStore() experimental = nativeComponents.navigator.experimental cache = nativeComponents.cache - this.router = nativeComponents.router routeAlternativesController = nativeComponents.routeAlternativesController this.accessToken = accessToken return this diff --git a/libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/NavigatorLoader.kt b/libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/NavigatorLoader.kt index aec20a8879f..57454a80bf6 100644 --- a/libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/NavigatorLoader.kt +++ b/libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/NavigatorLoader.kt @@ -52,7 +52,7 @@ object NavigatorLoader { config: ConfigHandle, historyRecorderComposite: HistoryRecorderHandle?, tilesConfig: TilesConfig, - router: RouterInterface, + router: RouterInterface?, ): NativeComponents { val cache = CacheFactory.build(tilesConfig, config, historyRecorderComposite) val navigator = Navigator( @@ -69,7 +69,6 @@ object NavigatorLoader { graphAccessor, cache, roadObjectMatcher, - router, navigator.routeAlternativesController, ) } @@ -149,7 +148,6 @@ object NavigatorLoader { val graphAccessor: GraphAccessor, val cache: CacheHandle, val roadObjectMatcher: RoadObjectMatcher, - val router: RouterInterface, val routeAlternativesController: RouteAlternativesControllerInterface, ) }