Skip to content

Commit 2b876a3

Browse files
dzinadVysotskiVadimDzmitryFomchyn
authored
NN-843 (#7349)
* tmp * cleanup * allow snaphot repo temprary * return timeout back * pass null as native router only if default router is used * fixed unit tests * added known issue * Bump NN to 143.0.0 --------- Co-authored-by: VysotskiVadim <[email protected]> Co-authored-by: dzmitryfomchyn <[email protected]>
1 parent 67163a6 commit 2b876a3

File tree

9 files changed

+13
-18
lines changed

9 files changed

+13
-18
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

gradle/dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ext {
1313
// version which we should use in this build
1414
def mapboxNavigatorVersion = System.getenv("FORCE_MAPBOX_NAVIGATION_NATIVE_VERSION")
1515
if (mapboxNavigatorVersion == null || mapboxNavigatorVersion == '') {
16-
mapboxNavigatorVersion = '142.0.0'
16+
mapboxNavigatorVersion = '143.0.0'
1717
}
1818
println("Navigation Native version: " + mapboxNavigatorVersion)
1919

instrumentation-tests/src/androidTest/java/com/mapbox/navigation/instrumentation_tests/core/EvOfflineTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import kotlinx.coroutines.flow.first
3434
import org.junit.Assert.assertEquals
3535
import org.junit.Assert.assertNull
3636
import org.junit.Assert.assertTrue
37-
import org.junit.Ignore
3837
import org.junit.Rule
3938
import org.junit.Test
4039

@@ -67,7 +66,6 @@ class EvOfflineTest : BaseCoreNoCleanUpTest() {
6766
}
6867

6968
@Test
70-
@Ignore("NN-843")
7169
fun startNavigationOfflineThenSwitchToOnlineRouteWhenInternetAppears() = sdkTest(
7270
timeout = INCREASED_TIMEOUT_BECAUSE_OF_REAL_ROUTING_TILES_USAGE
7371
) {
@@ -178,6 +176,7 @@ class EvOfflineTest : BaseCoreNoCleanUpTest() {
178176
navigation.registerRouteAlternativesObserver(
179177
SimpleAlternativesObserverFromDocumentation(navigation)
180178
)
179+
181180
navigation.startTripSession()
182181
stayOnPosition(
183182
evBerlinTestRoute.origin.latitude(),

libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,11 @@ class MapboxNavigation @VisibleForTesting internal constructor(
471471
),
472472
navigationOptions.accessToken ?: "",
473473
if (moduleRouter.isInternalImplementation()) {
474-
nativeRouter
474+
// We pass null to let NN know that default router is used and it can rely
475+
// on implementation details in some cases like offline-online switch.
476+
// Meanwhile platform SDK uses its own instance of native router for
477+
// route requests
478+
null
475479
} else {
476480
RouterInterfaceAdapter(moduleRouter, ::getNavigationRoutes)
477481
},

libnavigation-core/src/main/java/com/mapbox/navigation/core/NavigationComponentProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ internal object NavigationComponentProvider {
4242
historyRecorderComposite: HistoryRecorderHandle?,
4343
tilesConfig: TilesConfig,
4444
accessToken: String,
45-
router: RouterInterface,
45+
router: RouterInterface?,
4646
): MapboxNativeNavigator = MapboxNativeNavigatorImpl.create(
4747
config,
4848
historyRecorderComposite,

libnavigation-router/src/test/java/com/mapbox/navigation/route/internal/RouterWrapperTests.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import com.mapbox.navigation.base.route.RouterCallback
1717
import com.mapbox.navigation.base.route.RouterFailure
1818
import com.mapbox.navigation.base.route.RouterOrigin.Offboard
1919
import com.mapbox.navigation.base.route.RouterOrigin.Onboard
20-
import com.mapbox.navigation.navigator.internal.MapboxNativeNavigator
2120
import com.mapbox.navigation.navigator.internal.mapToRoutingMode
2221
import com.mapbox.navigation.route.internal.util.ACCESS_TOKEN_QUERY_PARAM
2322
import com.mapbox.navigation.route.internal.util.TestRouteFixtures
@@ -74,7 +73,6 @@ class RouterWrapperTests {
7473
var coroutineRule = MainCoroutineRule()
7574

7675
private lateinit var routerWrapper: RouterWrapper
77-
private val mapboxNativeNavigator: MapboxNativeNavigator = mockk(relaxed = true)
7876
private val router: RouterInterface = mockk(relaxed = true)
7977
private val accessToken = "pk.123"
8078
private val route: DirectionsRoute = mockk(relaxed = true)
@@ -145,7 +143,6 @@ class RouterWrapperTests {
145143
every { ThreadController.IODispatcher } returns coroutineRule.testDispatcher
146144
every { ThreadController.DefaultDispatcher } returns coroutineRule.testDispatcher
147145

148-
every { mapboxNativeNavigator.router } returns router
149146
every { router.getRoute(any(), any(), capture(getRouteSlot)) } returns 0L
150147
every { router.getRouteRefresh(any(), capture(refreshRouteSlot)) } returns 0L
151148

@@ -155,7 +152,7 @@ class RouterWrapperTests {
155152

156153
routerWrapper = RouterWrapper(
157154
accessToken,
158-
mapboxNativeNavigator.router,
155+
router,
159156
ThreadController(),
160157
)
161158
}

libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/MapboxNativeNavigator.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ interface MapboxNativeNavigator {
4242
historyRecorderComposite: HistoryRecorderHandle?,
4343
tilesConfig: TilesConfig,
4444
accessToken: String,
45-
router: RouterInterface,
45+
router: RouterInterface?,
4646
): MapboxNativeNavigator
4747

4848
/**
@@ -192,6 +192,4 @@ interface MapboxNativeNavigator {
192192
val roadObjectMatcher: RoadObjectMatcher?
193193

194194
val experimental: Experimental
195-
196-
val router: RouterInterface
197195
}

libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/MapboxNativeNavigatorImpl.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ object MapboxNativeNavigatorImpl : MapboxNativeNavigator {
6666
override var roadObjectsStore: RoadObjectsStore? = null
6767
override lateinit var experimental: Experimental
6868
override lateinit var cache: CacheHandle
69-
override lateinit var router: RouterInterface
7069
override lateinit var routeAlternativesController: RouteAlternativesControllerInterface
7170
private val nativeNavigatorRecreationObservers =
7271
CopyOnWriteArraySet<NativeNavigatorRecreationObserver>()
@@ -83,7 +82,7 @@ object MapboxNativeNavigatorImpl : MapboxNativeNavigator {
8382
historyRecorderComposite: HistoryRecorderHandle?,
8483
tilesConfig: TilesConfig,
8584
accessToken: String,
86-
router: RouterInterface,
85+
router: RouterInterface?,
8786
): MapboxNativeNavigator {
8887
navigator?.shutdown()
8988

@@ -99,7 +98,6 @@ object MapboxNativeNavigatorImpl : MapboxNativeNavigator {
9998
roadObjectsStore = nativeComponents.navigator.roadObjectStore()
10099
experimental = nativeComponents.navigator.experimental
101100
cache = nativeComponents.cache
102-
this.router = nativeComponents.router
103101
routeAlternativesController = nativeComponents.routeAlternativesController
104102
this.accessToken = accessToken
105103
return this

libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/NavigatorLoader.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ object NavigatorLoader {
5252
config: ConfigHandle,
5353
historyRecorderComposite: HistoryRecorderHandle?,
5454
tilesConfig: TilesConfig,
55-
router: RouterInterface,
55+
router: RouterInterface?,
5656
): NativeComponents {
5757
val cache = CacheFactory.build(tilesConfig, config, historyRecorderComposite)
5858
val navigator = Navigator(
@@ -69,7 +69,6 @@ object NavigatorLoader {
6969
graphAccessor,
7070
cache,
7171
roadObjectMatcher,
72-
router,
7372
navigator.routeAlternativesController,
7473
)
7574
}
@@ -149,7 +148,6 @@ object NavigatorLoader {
149148
val graphAccessor: GraphAccessor,
150149
val cache: CacheHandle,
151150
val roadObjectMatcher: RoadObjectMatcher,
152-
val router: RouterInterface,
153151
val routeAlternativesController: RouteAlternativesControllerInterface,
154152
)
155153
}

0 commit comments

Comments
 (0)