From 2fde58e3c66d6d2b6c28f571fc0fc7375d85d4c7 Mon Sep 17 00:00:00 2001 From: Dzina Dybouskaya Date: Fri, 7 Jul 2023 17:59:04 +0300 Subject: [PATCH 1/8] tmp --- gradle/dependencies.gradle | 2 +- .../instrumentation_tests/core/EvOfflineTest.kt | 11 ++++++++--- .../navigation/navigator/internal/NavigatorLoader.kt | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 6cd8b499b5c..c5eaf12c87b 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 = 'av-NN-843-fix-1-SNAPSHOT' } 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..24e0dd1cf79 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 @@ -3,6 +3,7 @@ package com.mapbox.navigation.instrumentation_tests.core import android.location.Location import android.util.Log import com.mapbox.api.directions.v5.DirectionsCriteria +import com.mapbox.common.ReachabilityFactory import com.mapbox.navigation.base.route.NavigationRoute import com.mapbox.navigation.base.route.RouterOrigin import com.mapbox.navigation.base.trip.model.RouteProgress @@ -67,9 +68,9 @@ class EvOfflineTest : BaseCoreNoCleanUpTest() { } @Test - @Ignore("NN-843") +// @Ignore("NN-843") fun startNavigationOfflineThenSwitchToOnlineRouteWhenInternetAppears() = sdkTest( - timeout = INCREASED_TIMEOUT_BECAUSE_OF_REAL_ROUTING_TILES_USAGE + timeout = 160000 ) { val originalTestRoute = setupBerlinEvRoute() withMapboxNavigationAndOfflineTilesForRegion( @@ -158,7 +159,7 @@ class EvOfflineTest : BaseCoreNoCleanUpTest() { @Test fun offlineOnlineSwitchWhenOnlineRouteIsTheSameAsCurrentOfflineWithSimpleObserver() = sdkTest( - timeout = INCREASED_TIMEOUT_BECAUSE_OF_REAL_ROUTING_TILES_USAGE + timeout = 160000 ) { val evBerlinTestRoute = EvRoutesProvider.getBerlinEvRoute( context, @@ -178,6 +179,10 @@ class EvOfflineTest : BaseCoreNoCleanUpTest() { navigation.registerRouteAlternativesObserver( SimpleAlternativesObserverFromDocumentation(navigation) ) + ReachabilityFactory.reachability(null).addListener { + println("[TestNetwork3] listener triggered with status: $it") + } + navigation.startTripSession() stayOnPosition( evBerlinTestRoute.origin.latitude(), 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..f15ea306bca 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 @@ -59,7 +59,7 @@ object NavigatorLoader { config, cache, historyRecorderComposite, - router, + null, ) val graphAccessor = GraphAccessor(cache) val roadObjectMatcher = RoadObjectMatcher(cache) From a3cbaab54949e5db511eba0b0d214058fcc3976c Mon Sep 17 00:00:00 2001 From: VysotskiVadim Date: Fri, 7 Jul 2023 17:14:41 +0200 Subject: [PATCH 2/8] cleanup --- .../instrumentation_tests/core/EvOfflineTest.kt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) 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 24e0dd1cf79..9be62fa6e05 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 @@ -3,7 +3,6 @@ package com.mapbox.navigation.instrumentation_tests.core import android.location.Location import android.util.Log import com.mapbox.api.directions.v5.DirectionsCriteria -import com.mapbox.common.ReachabilityFactory import com.mapbox.navigation.base.route.NavigationRoute import com.mapbox.navigation.base.route.RouterOrigin import com.mapbox.navigation.base.trip.model.RouteProgress @@ -35,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 @@ -68,9 +66,8 @@ class EvOfflineTest : BaseCoreNoCleanUpTest() { } @Test -// @Ignore("NN-843") fun startNavigationOfflineThenSwitchToOnlineRouteWhenInternetAppears() = sdkTest( - timeout = 160000 + timeout = INCREASED_TIMEOUT_BECAUSE_OF_REAL_ROUTING_TILES_USAGE ) { val originalTestRoute = setupBerlinEvRoute() withMapboxNavigationAndOfflineTilesForRegion( @@ -179,9 +176,6 @@ class EvOfflineTest : BaseCoreNoCleanUpTest() { navigation.registerRouteAlternativesObserver( SimpleAlternativesObserverFromDocumentation(navigation) ) - ReachabilityFactory.reachability(null).addListener { - println("[TestNetwork3] listener triggered with status: $it") - } navigation.startTripSession() stayOnPosition( From d1e773595b604eb7c74eb513a348ebbc0f0425d3 Mon Sep 17 00:00:00 2001 From: VysotskiVadim Date: Fri, 7 Jul 2023 17:15:29 +0200 Subject: [PATCH 3/8] allow snaphot repo temprary --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 069f28c88d0..9f4737f0634 100644 --- a/build.gradle +++ b/build.gradle @@ -64,7 +64,7 @@ allprojects { // we allow access to snapshots repo if ALLOW_SNAPSHOT_REPOSITORY is set, what means we are running on CI // with Navigation Native forced to be some snapshot version // if you need to use snapshots while development, just set `addSnapshotsRepo` to true manually - def addSnapshotsRepo = project.hasProperty('ALLOW_SNAPSHOT_REPOSITORY') ? project.property('ALLOW_SNAPSHOT_REPOSITORY') : (System.getenv("ALLOW_SNAPSHOT_REPOSITORY")?.toBoolean() ?: false) + def addSnapshotsRepo = true//project.hasProperty('ALLOW_SNAPSHOT_REPOSITORY') ? project.property('ALLOW_SNAPSHOT_REPOSITORY') : (System.getenv("ALLOW_SNAPSHOT_REPOSITORY")?.toBoolean() ?: false) if (addSnapshotsRepo) { println("Snapshot repository reference added.") maven { From 125aff0eebc804dc4aee4d150e2d9a758e6f01ca Mon Sep 17 00:00:00 2001 From: VysotskiVadim Date: Fri, 7 Jul 2023 17:17:28 +0200 Subject: [PATCH 4/8] return timeout back --- .../navigation/instrumentation_tests/core/EvOfflineTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9be62fa6e05..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 @@ -156,7 +156,7 @@ class EvOfflineTest : BaseCoreNoCleanUpTest() { @Test fun offlineOnlineSwitchWhenOnlineRouteIsTheSameAsCurrentOfflineWithSimpleObserver() = sdkTest( - timeout = 160000 + timeout = INCREASED_TIMEOUT_BECAUSE_OF_REAL_ROUTING_TILES_USAGE ) { val evBerlinTestRoute = EvRoutesProvider.getBerlinEvRoute( context, From 05af89f79218075c5e873c7ec725e56b265705e1 Mon Sep 17 00:00:00 2001 From: VysotskiVadim Date: Fri, 7 Jul 2023 18:18:26 +0200 Subject: [PATCH 5/8] pass null as native router only if default router is used --- .../java/com/mapbox/navigation/core/MapboxNavigation.kt | 6 +++++- .../mapbox/navigation/core/NavigationComponentProvider.kt | 2 +- .../navigation/navigator/internal/MapboxNativeNavigator.kt | 4 +--- .../navigator/internal/MapboxNativeNavigatorImpl.kt | 4 +--- .../mapbox/navigation/navigator/internal/NavigatorLoader.kt | 6 ++---- 5 files changed, 10 insertions(+), 12 deletions(-) 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/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 f15ea306bca..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,14 +52,14 @@ object NavigatorLoader { config: ConfigHandle, historyRecorderComposite: HistoryRecorderHandle?, tilesConfig: TilesConfig, - router: RouterInterface, + router: RouterInterface?, ): NativeComponents { val cache = CacheFactory.build(tilesConfig, config, historyRecorderComposite) val navigator = Navigator( config, cache, historyRecorderComposite, - null, + router, ) val graphAccessor = GraphAccessor(cache) val roadObjectMatcher = RoadObjectMatcher(cache) @@ -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, ) } From e14c164a7780c57550570c78eed5f1643e501414 Mon Sep 17 00:00:00 2001 From: VysotskiVadim Date: Fri, 7 Jul 2023 18:27:36 +0200 Subject: [PATCH 6/8] fixed unit tests --- .../mapbox/navigation/route/internal/RouterWrapperTests.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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(), ) } From cc24d7a97321144c7c34f7c1eeb9b8d123cd94cd Mon Sep 17 00:00:00 2001 From: VysotskiVadim Date: Fri, 7 Jul 2023 18:36:08 +0200 Subject: [PATCH 7/8] added known issue --- changelog/unreleased/issues/changes.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/unreleased/issues/changes.md 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. From 76ea5a41cde21b6d8626d60134071fb523fc578c Mon Sep 17 00:00:00 2001 From: dzmitryfomchyn Date: Fri, 7 Jul 2023 21:34:59 +0200 Subject: [PATCH 8/8] Bump NN to 143.0.0 --- build.gradle | 2 +- gradle/dependencies.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 9f4737f0634..069f28c88d0 100644 --- a/build.gradle +++ b/build.gradle @@ -64,7 +64,7 @@ allprojects { // we allow access to snapshots repo if ALLOW_SNAPSHOT_REPOSITORY is set, what means we are running on CI // with Navigation Native forced to be some snapshot version // if you need to use snapshots while development, just set `addSnapshotsRepo` to true manually - def addSnapshotsRepo = true//project.hasProperty('ALLOW_SNAPSHOT_REPOSITORY') ? project.property('ALLOW_SNAPSHOT_REPOSITORY') : (System.getenv("ALLOW_SNAPSHOT_REPOSITORY")?.toBoolean() ?: false) + def addSnapshotsRepo = project.hasProperty('ALLOW_SNAPSHOT_REPOSITORY') ? project.property('ALLOW_SNAPSHOT_REPOSITORY') : (System.getenv("ALLOW_SNAPSHOT_REPOSITORY")?.toBoolean() ?: false) if (addSnapshotsRepo) { println("Snapshot repository reference added.") maven { diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index c5eaf12c87b..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 = 'av-NN-843-fix-1-SNAPSHOT' + mapboxNavigatorVersion = '143.0.0' } println("Navigation Native version: " + mapboxNavigatorVersion)