Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ workflows:
branches:
only:
- main
- /^tarigo.*/
- release:
filters:
tags:
Expand Down Expand Up @@ -650,4 +651,4 @@ jobs:
- publish-artifacts:
artifact-type: "core"
- publish-artifacts:
artifact-type: "ui"
artifact-type: "ui"
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,46 @@

Mapbox welcomes participation and contributions from everyone.

## Mapbox Navigation SDK 2.1.1 - December 13, 2021

For details on how v2 differs from v1 and guidance on migrating from v1 of the Mapbox Navigation SDK for Android to the v2 public preview, see [2.0 Navigation SDK Migration Guide](https://github.com/mapbox/mapbox-navigation-android/wiki/2.0-Navigation-SDK-Migration-Guide).

### Changelog
#### Bug fixes and improvements
- Fixed billing issue when upgrading Mapbox Maps SDK from v9 to v10. [#5263](https://github.com/mapbox/mapbox-navigation-android/pull/5263)
- Fixed notification appearance on Android 12. [#5159](https://github.com/mapbox/mapbox-navigation-android/pull/5159)

### Mapbox dependencies
This release depends on, and has been tested with, the following Mapbox dependencies:
- Mapbox Maps SDK `v10.0.2` ([release notes](https://github.com/mapbox/mapbox-maps-android/releases/tag/android-v10.0.2))
- Mapbox Navigation Native `v79.0.3`
- Mapbox Core Common `v20.0.3`
- Mapbox Java `v6.1.0` ([release notes](https://github.com/mapbox/mapbox-java/releases/tag/v6.1.0))
- Mapbox Android Core `v5.0.0`
- Mapbox Android Telemetry `v8.1.0`

## Mapbox Navigation SDK 2.1.0 - December 2, 2021
Mapbox Navigation SDK v2.1.0 was released prematurely with an unresolved billing issue. We deleted this version from the Maven repository and we’re preparing the v2.1.1 release with additional fixes.

We strongly recommend not to release your application with v2.1.0. More information will be available in [this announcement](https://github.com/mapbox/mapbox-navigation-android/discussions/5213).

## Mapbox Navigation SDK 2.1.0-rc.2 - November 18, 2021

For details on how v2 differs from v1 and guidance on migrating from v1 of the Mapbox Navigation SDK for Android to the v2 public preview, see [2.0 Navigation SDK Migration Guide](https://github.com/mapbox/mapbox-navigation-android/wiki/2.0-Navigation-SDK-Migration-Guide).

### Changelog
#### Bug fixes and improvements
- Trigger RouteAlternativesObserver on main thread. [#5120](https://github.com/mapbox/mapbox-navigation-android/pull/5120)

### Mapbox dependencies
This release depends on, and has been tested with, the following Mapbox dependencies:
- Mapbox Maps SDK `v10.0.0` ([release notes](https://github.com/mapbox/mapbox-maps-android/releases/tag/android-v10.0.0))
- Mapbox Navigation Native `v79.0.3`
- Mapbox Core Common `v20.0.0`
- Mapbox Java `v6.1.0` ([release notes](https://github.com/mapbox/mapbox-java/releases/tag/v6.1.0))
- Mapbox Android Core `v5.0.0`
- Mapbox Android Telemetry `v8.1.0`

## Mapbox Navigation SDK 2.1.0-rc.1 - October 28, 2021

For details on how v2 differs from v1 and guidance on migrating from v1 of the Mapbox Navigation SDK for Android to the v2 public preview, see [2.0 Navigation SDK Migration Guide](https://github.com/mapbox/mapbox-navigation-android/wiki/2.0-Navigation-SDK-Migration-Guide).
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,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 = System.getenv("ALLOW_SNAPSHOT_REPOSITORY")?.toBoolean() ?: false
def addSnapshotsRepo = true //System.getenv("ALLOW_SNAPSHOT_REPOSITORY")?.toBoolean() ?: false
if (addSnapshotsRepo) {
println("Snapshot repository reference added.")
maven {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=mapbox
POM_DEVELOPER_NAME=Mapbox

POM_SNAPSHOT_VERSION_NAME=2.1.0-SNAPSHOT
POM_SNAPSHOT_VERSION_NAME=2.1.1-test-core-telemetry-SNAPSHOT

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
Expand Down
6 changes: 3 additions & 3 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ ext {
// version which we should use in this build
def mapboxNavigatorVersion = System.getenv("FORCE_MAPBOX_NAVIGATION_NATIVE_VERSION")
if (mapboxNavigatorVersion == null || mapboxNavigatorVersion == '') {
mapboxNavigatorVersion = '79.0.2'
mapboxNavigatorVersion = '79.0.3'
}
println("Navigation Native version: " + mapboxNavigatorVersion)

version = [
mapboxMapSdk : '10.0.0',
mapboxMapSdk : '10.1.2-test-core-telemetry-SNAPSHOT',
mapboxSdkServices : '6.1.0',
mapboxEvents : '8.1.0',
mapboxCore : '5.0.0',
mapboxNavigator : "${mapboxNavigatorVersion}",
mapboxCommonNative : '20.0.0',
mapboxCommonNative : '20.1.1-b1dc6ad813d20bd73288a64e9344c260484fe2ff-SNAPSHOT',
mapboxCrashMonitor : '2.0.0',
mapboxAnnotationPlugin : '0.8.0',
mapboxBaseAndroid : '0.5.0',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class RouteAlternativesTest : BaseTest<EmptyTestActivity>(EmptyTestActivity::cla
Espresso.onIdle()
}
firstAlternative.unregister()
assertTrue(firstAlternative.calledOnMainThread)

runOnMainSync {
val countDownLatch = CountDownLatch(1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mapbox.navigation.instrumentation_tests.utils.idling

import android.os.Looper
import androidx.test.espresso.IdlingResource
import com.mapbox.api.directions.v5.models.DirectionsRoute
import com.mapbox.navigation.base.route.RouterOrigin
Expand All @@ -24,6 +25,7 @@ class RouteAlternativesIdlingResource(
private set
var alternatives: List<DirectionsRoute>? = null
private set
var calledOnMainThread = true

private var callback: IdlingResource.ResourceCallback? = null

Expand All @@ -47,6 +49,11 @@ class RouteAlternativesIdlingResource(
alternatives: List<DirectionsRoute>,
routerOrigin: RouterOrigin
) {
// Verify this happens on the main thread.
if (Looper.myLooper() != Looper.getMainLooper()) {
calledOnMainThread = false
}

mapboxNavigation.unregisterRouteAlternativesObserver(this)
this.routeProgress = routeProgress
this.alternatives = alternatives
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.mapbox.navigation.base.metrics

import androidx.annotation.StringDef
import com.google.gson.Gson
import com.mapbox.bindgen.Value

/**
* An interface with types of metrics events that the SDK would send via Telemetry
Expand Down Expand Up @@ -39,6 +40,13 @@ interface MetricEvent {
* @return String
*/
fun toJson(gson: Gson): String

/**
* Present [MetricEvent] as [Value]
*
* @return Value
*/
fun toValue(): Value
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ class MapboxNavigation @VisibleForTesting internal constructor(
routeAlternativesController = RouteAlternativesControllerProvider.create(
navigationOptions.routeAlternativesOptions,
navigator,
tripSession
tripSession,
threadController,
)
routeRefreshController = RouteRefreshControllerProvider.createRouteRefreshController(
navigationOptions.routeRefreshOptions,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
package com.mapbox.navigation.core.routealternatives

import com.mapbox.api.directions.v5.models.DirectionsRoute
import com.mapbox.base.common.logger.model.Message
import com.mapbox.base.common.logger.model.Tag
import com.mapbox.navigation.base.internal.utils.parseDirectionsResponse
import com.mapbox.navigation.base.route.RouteAlternativesOptions
import com.mapbox.navigation.base.route.RouterOrigin
import com.mapbox.navigation.base.trip.model.RouteProgress
import com.mapbox.navigation.core.trip.session.TripSession
import com.mapbox.navigation.navigator.internal.MapboxNativeNavigator
import com.mapbox.navigation.utils.internal.ThreadController
import com.mapbox.navigation.utils.internal.logI
import com.mapbox.navigator.RouteAlternative
import kotlinx.coroutines.cancelChildren
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import java.util.concurrent.CopyOnWriteArraySet

internal class RouteAlternativesController constructor(
private val options: RouteAlternativesOptions,
private val navigator: MapboxNativeNavigator,
private val tripSession: TripSession
private val tripSession: TripSession,
private val threadController: ThreadController
) {

private val mainJobControl by lazy { threadController.getMainScopeAndRootJob() }

private val nativeRouteAlternativesController = navigator.createRouteAlternativesController()
.apply {
setRouteAlternativesOptions(
Expand All @@ -44,6 +51,7 @@ internal class RouteAlternativesController constructor(
observers.remove(routeAlternativesObserver)
if (observers.isEmpty()) {
nativeRouteAlternativesController.removeObserver(nativeObserver)
mainJobControl.job.cancelChildren()
}
}

Expand All @@ -58,36 +66,44 @@ internal class RouteAlternativesController constructor(

private val nativeObserver = object : com.mapbox.navigator.RouteAlternativesObserver {
override fun onRouteAlternativesChanged(
routeAlternatives: List<com.mapbox.navigator.RouteAlternative>
routeAlternatives: List<RouteAlternative>
): List<Int> {
val routeProgress = tripSession.getRouteProgress()
?: return emptyList()

// Map the alternatives from nav-native, add the existing RouteOptions.
onRouteAlternativesChanged(routeProgress, routeAlternatives)

// This is supposed to be able to filter alternatives. If we want to provide
// a mechanism to let downstream developers edit the routes - we should remove
// the call to directionsSession.setRoutes
return emptyList()
}
}

// TODO make async
val alternatives: List<DirectionsRoute> = runBlocking {
routeAlternatives.map { routeAlternative ->
private fun onRouteAlternativesChanged(
routeProgress: RouteProgress,
routeAlternatives: List<RouteAlternative>
) {
// Map the alternatives from nav-native, add the existing RouteOptions.
val alternatives = runBlocking {
routeAlternatives
.map { routeAlternative ->
parseDirectionsResponse(
routeAlternative.route,
routeProgress.route.routeOptions()
) {
logI(TAG, Message("Response metadata: $it"))
}.first()
}
}
}

mainJobControl.scope.launch {
// Notify the listeners.
// TODO https://github.com/mapbox/mapbox-navigation-native/issues/4409
// There is no way to determine if the route was Onboard or Offboard
observers.forEach {
it.onRouteAlternatives(routeProgress, alternatives, RouterOrigin.Onboard)
}

// This is supposed to be able to filter alternatives. If we want to provide
// a mechanism to let downstream developers edit the routes - we should remove
// the call to directionsSession.setRoutes
return emptyList()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ package com.mapbox.navigation.core.routealternatives
import com.mapbox.navigation.base.route.RouteAlternativesOptions
import com.mapbox.navigation.core.trip.session.TripSession
import com.mapbox.navigation.navigator.internal.MapboxNativeNavigator
import com.mapbox.navigation.utils.internal.ThreadController

internal object RouteAlternativesControllerProvider {

fun create(
options: RouteAlternativesOptions,
navigator: MapboxNativeNavigator,
tripSession: TripSession
tripSession: TripSession,
threadController: ThreadController
) = RouteAlternativesController(
options,
navigator,
tripSession
tripSession,
threadController
)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mapbox.navigation.core.routeoptions

import com.mapbox.api.directions.v5.DirectionsCriteria
import com.mapbox.api.directions.v5.models.Bearing
import com.mapbox.api.directions.v5.models.RouteOptions
import com.mapbox.base.common.logger.model.Message
Expand Down Expand Up @@ -134,16 +135,22 @@ class RouteOptionsUpdater {
coordinatesList.size - remainingWaypoints - 1
)
)
.layersList(
mutableListOf(locationMatcherResult.zLevel).apply {
val legacyLayerList = routeOptions.layersList()
if (legacyLayerList != null) {
addAll(legacyLayerList.takeLast(remainingWaypoints))
} else {
repeat(remainingWaypoints) { add(null) }
}
}

if (
routeOptions.profile() == DirectionsCriteria.PROFILE_DRIVING ||
routeOptions.profile() == DirectionsCriteria.PROFILE_DRIVING_TRAFFIC
) {
optionsBuilder.layersList(
mutableListOf(locationMatcherResult.zLevel).apply {
val legacyLayerList = routeOptions.layersList()
if (legacyLayerList != null) {
addAll(legacyLayerList.takeLast(remainingWaypoints))
} else {
repeat(remainingWaypoints) { add(null) }
}
)
}
)
}

optionsBuilder.arriveBy(null)
Expand Down
Loading