Skip to content

Commit

Permalink
NN 132.5.0 (#7267)
Browse files Browse the repository at this point in the history
  • Loading branch information
VysotskiVadim authored Jun 15, 2023
1 parent d24331d commit 2a82243
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 34 deletions.
2 changes: 2 additions & 0 deletions changelog/unreleased/bugfixes/7267.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fixed redundant route alternatives request when a single primary route is set.
- Fixed lagging of enhanced location updates, i.e. when they're behind the real position, in tunnels.
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '132.3.0'
mapboxNavigatorVersion = '132.5.1'
}
println("Navigation Native version: " + mapboxNavigatorVersion)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@ internal class RouteAlternativesController constructor(
val isStopped = observers.isEmpty()
observers.add(routeAlternativesObserver)
if (isStopped) {
nativeRouteAlternativesController.addObserver(nativeObserver)
nativeRouteAlternativesController.addObserver2(nativeObserver)
nativeRouteAlternativesController.addObserver(oldObserver)
}
}

fun unregister(routeAlternativesObserver: NavigationRouteAlternativesObserver) {
observers.remove(routeAlternativesObserver)
if (observers.isEmpty()) {
nativeRouteAlternativesController.removeObserver(nativeObserver)
nativeRouteAlternativesController.removeObserver2(nativeObserver)
nativeRouteAlternativesController.removeObserver(oldObserver)
}
}

Expand Down Expand Up @@ -150,14 +152,23 @@ internal class RouteAlternativesController constructor(
return metadataMap[navigationRoute.id]
}

private val nativeObserver = object : com.mapbox.navigator.RouteAlternativesObserver {
// NN doesn't start route alternatives logic if we don't subscribe using old interface
// This problem is actual only for 2.13
private val oldObserver = object : com.mapbox.navigator.RouteAlternativesObserver {
override fun onRouteAlternativesChanged(
routeAlternatives: List<RouteAlternative>,
removed: List<RouteAlternative>
) { }
routeAlternatives: MutableList<RouteAlternative>,
removed: MutableList<RouteAlternative>
) {
}

override fun onOnlinePrimaryRouteAvailable(onlinePrimaryRoute: RouteInterface) {
}

override fun onOnlinePrimaryRouteAvailable(onlinePrimaryRoute: RouteInterface) {}
override fun onError(message: String) {
}
}

private val nativeObserver = object : com.mapbox.navigator.RouteAlternativesObserverSync {
override fun onRouteAlternativesUpdated(
onlinePrimaryRoute: RouteInterface?,
routeAlternatives: MutableList<RouteAlternative>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ class RouteAlternativesControllerTest {
routeAlternativesController.register(mockk<RouteAlternativesObserver>(relaxed = true))
routeAlternativesController.register(mockk<RouteAlternativesObserver>(relaxed = true))

verify(exactly = 1) { controllerInterface.addObserver(any()) }
verify(exactly = 0) { controllerInterface.removeObserver(any()) }
verify(exactly = 1) { controllerInterface.addObserver2(any()) }
verify(exactly = 0) { controllerInterface.removeObserver2(any()) }
}

@Test
fun `should removeObserver from nav-native interface when all observers are removed`() {
fun `should removeObserver2 from nav-native interface when all observers are removed`() {
val routeAlternativesController = createRouteAlternativesController()

val firstObserver: RouteAlternativesObserver = mockk(relaxed = true)
Expand All @@ -147,8 +147,8 @@ class RouteAlternativesControllerTest {
routeAlternativesController.unregister(firstObserver)
routeAlternativesController.unregister(secondObserver)

verify(exactly = 1) { controllerInterface.addObserver(any()) }
verify(exactly = 1) { controllerInterface.removeObserver(any()) }
verify(exactly = 1) { controllerInterface.addObserver2(any()) }
verify(exactly = 1) { controllerInterface.removeObserver2(any()) }
}

@Test
Expand All @@ -161,7 +161,7 @@ class RouteAlternativesControllerTest {
routeAlternativesController.register(secondObserver)
routeAlternativesController.unregisterAll()

verify(exactly = 1) { controllerInterface.addObserver(any()) }
verify(exactly = 1) { controllerInterface.addObserver2(any()) }
verify(exactly = 1) { controllerInterface.removeAllObservers() }
}

Expand All @@ -171,8 +171,8 @@ class RouteAlternativesControllerTest {
mockkStatic(RouteOptions::fromUrl)
every { RouteOptions.fromUrl(eq(genericURL)) } returns mockk()
val routeAlternativesController = createRouteAlternativesController()
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserver>()
every { controllerInterface.addObserver(capture(nativeObserver)) } just runs
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserverSync>()
every { controllerInterface.addObserver2(capture(nativeObserver)) } just runs
val routeProgress = mockk<RouteProgress>()
every { tripSession.getRouteProgress() } returns routeProgress

Expand Down Expand Up @@ -208,8 +208,8 @@ class RouteAlternativesControllerTest {
mockkStatic(RouteOptions::fromUrl)
every { RouteOptions.fromUrl(eq(genericURL)) } returns mockk()
val routeAlternativesController = createRouteAlternativesController()
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserver>()
every { controllerInterface.addObserver(capture(nativeObserver)) } just runs
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserverSync>()
every { controllerInterface.addObserver2(capture(nativeObserver)) } just runs
val routeProgress = mockk<RouteProgress>()
every { tripSession.getRouteProgress() } returns routeProgress

Expand Down Expand Up @@ -239,8 +239,8 @@ class RouteAlternativesControllerTest {
mockkStatic(RouteOptions::fromUrl)
every { RouteOptions.fromUrl(eq(genericURL)) } returns mockk()
val routeAlternativesController = createRouteAlternativesController()
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserver>()
every { controllerInterface.addObserver(capture(nativeObserver)) } just runs
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserverSync>()
every { controllerInterface.addObserver2(capture(nativeObserver)) } just runs
every { tripSession.getRouteProgress() } returns mockk {
every { navigationRoute } returns mockk {
every { routeOptions } returns mockk()
Expand Down Expand Up @@ -296,8 +296,8 @@ class RouteAlternativesControllerTest {
mockkStatic(RouteOptions::fromUrl)
every { RouteOptions.fromUrl(eq(genericURL)) } returns mockRouteOptions
val routeAlternativesController = createRouteAlternativesController()
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserver>()
every { controllerInterface.addObserver(capture(nativeObserver)) } just runs
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserverSync>()
every { controllerInterface.addObserver2(capture(nativeObserver)) } just runs
every { tripSession.getRouteProgress() } returns mockk()

val firstObserver: NavigationRouteAlternativesObserver = mockk(relaxed = true)
Expand Down Expand Up @@ -334,8 +334,8 @@ class RouteAlternativesControllerTest {
mockkStatic(RouteOptions::fromUrl)
every { RouteOptions.fromUrl(eq(genericURL)) } returns mockk()
val routeAlternativesController = createRouteAlternativesController()
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserver>()
every { controllerInterface.addObserver(capture(nativeObserver)) } just runs
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserverSync>()
every { controllerInterface.addObserver2(capture(nativeObserver)) } just runs
every { tripSession.getRouteProgress() } returns mockk()

val firstObserver: NavigationRouteAlternativesObserver = mockk(relaxed = true)
Expand Down Expand Up @@ -372,8 +372,8 @@ class RouteAlternativesControllerTest {
mockkStatic(RouteOptions::fromUrl)
every { RouteOptions.fromUrl(eq(genericURL)) } returns mockk()
val routeAlternativesController = createRouteAlternativesController()
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserver>()
every { controllerInterface.addObserver(capture(nativeObserver)) } just runs
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserverSync>()
every { controllerInterface.addObserver2(capture(nativeObserver)) } just runs
every { tripSession.getRouteProgress() } returns mockk()

val observer: NavigationRouteAlternativesObserver = mockk(relaxed = true)
Expand Down Expand Up @@ -423,8 +423,8 @@ class RouteAlternativesControllerTest {
mockkStatic(RouteOptions::fromUrl)
every { RouteOptions.fromUrl(eq(genericURL)) } returns mockk()
val routeAlternativesController = createRouteAlternativesController()
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserver>()
every { controllerInterface.addObserver(capture(nativeObserver)) } just runs
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserverSync>()
every { controllerInterface.addObserver2(capture(nativeObserver)) } just runs
every { tripSession.getRouteProgress() } returns mockk()

val observer: NavigationRouteAlternativesObserver = mockk(relaxed = true)
Expand Down Expand Up @@ -569,8 +569,8 @@ class RouteAlternativesControllerTest {
mockkStatic(RouteOptions::fromUrl)
every { RouteOptions.fromUrl(eq(genericURL)) } returns mockk()
val routeAlternativesController = createRouteAlternativesController()
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserver>()
every { controllerInterface.addObserver(capture(nativeObserver)) } just runs
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserverSync>()
every { controllerInterface.addObserver2(capture(nativeObserver)) } just runs
val routeProgress = mockk<RouteProgress>()
every { tripSession.getRouteProgress() } returns routeProgress

Expand Down Expand Up @@ -613,8 +613,8 @@ class RouteAlternativesControllerTest {
mockkStatic(RouteOptions::fromUrl)
every { RouteOptions.fromUrl(eq(genericURL)) } returns mockk()
val routeAlternativesController = createRouteAlternativesController()
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserver>()
every { controllerInterface.addObserver(capture(nativeObserver)) } just runs
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserverSync>()
every { controllerInterface.addObserver2(capture(nativeObserver)) } just runs
val routeProgress = mockk<RouteProgress>()
every { tripSession.getRouteProgress() } returns routeProgress

Expand Down Expand Up @@ -706,8 +706,8 @@ class RouteAlternativesControllerTest {
fun `metadata cleared on alternatives update from native observer`() =
coroutineRule.runBlockingTest {
val routeAlternativesController = createRouteAlternativesController()
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserver>()
every { controllerInterface.addObserver(capture(nativeObserver)) } just runs
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserverSync>()
every { controllerInterface.addObserver2(capture(nativeObserver)) } just runs
val routeProgress = mockk<RouteProgress>()
every { tripSession.getRouteProgress() } returns routeProgress
routeAlternativesController.register(
Expand Down

0 comments on commit 2a82243

Please sign in to comment.