diff --git a/build.gradle b/build.gradle index 069f28c88d0..6c79ac19914 100644 --- a/build.gradle +++ b/build.gradle @@ -64,7 +64,8 @@ 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 = project.hasProperty('ALLOW_SNAPSHOT_REPOSITORY') ? project.property('ALLOW_SNAPSHOT_REPOSITORY') : (System.getenv("ALLOW_SNAPSHOT_REPOSITORY")?.toBoolean() ?: false) + def addSnapshotsRepo = true if (addSnapshotsRepo) { println("Snapshot repository reference added.") maven { diff --git a/examples/src/main/java/com/mapbox/navigation/examples/core/MapboxNavigationActivity.kt b/examples/src/main/java/com/mapbox/navigation/examples/core/MapboxNavigationActivity.kt index 90fb2a46b42..a5537e7ad71 100644 --- a/examples/src/main/java/com/mapbox/navigation/examples/core/MapboxNavigationActivity.kt +++ b/examples/src/main/java/com/mapbox/navigation/examples/core/MapboxNavigationActivity.kt @@ -38,6 +38,7 @@ import com.mapbox.navigation.core.MapboxNavigationProvider import com.mapbox.navigation.core.adasis.AdasisConfig import com.mapbox.navigation.core.directions.session.RoutesObserver import com.mapbox.navigation.core.formatter.MapboxDistanceFormatter +import com.mapbox.navigation.core.replay.route.ReplayRouteSession import com.mapbox.navigation.core.trip.session.LocationMatcherResult import com.mapbox.navigation.core.trip.session.LocationObserver import com.mapbox.navigation.core.trip.session.NavigationSessionStateObserver @@ -271,6 +272,7 @@ class MapboxNavigationActivity : AppCompatActivity() { logD("sessionId=${mapboxNavigation.getNavigationSessionState().sessionId}", LOG_CATEGORY) } + @OptIn(ExperimentalPreviewMapboxNavigationAPI::class) @SuppressLint("MissingPermission") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -432,6 +434,7 @@ class MapboxNavigationActivity : AppCompatActivity() { // start the trip session to being receiving location updates in free drive // and later when a route is set, also receiving route progress updates mapboxNavigation.startTripSession() + ReplayRouteSession().onAttached(mapboxNavigation) } @OptIn(ExperimentalPreviewMapboxNavigationAPI::class) @@ -442,8 +445,9 @@ class MapboxNavigationActivity : AppCompatActivity() { mapboxNavigation.registerRouteProgressObserver(routeProgressObserver) mapboxNavigation.registerLocationObserver(locationObserver) mapboxNavigation.registerVoiceInstructionsObserver(voiceInstructionsObserver) - mapboxNavigation.setAdasisMessageCallback(AdasisConfig.Builder().build()) { message -> + mapboxNavigation.setAdasisMessageCallback(AdasisConfig.Builder().build()) { message, context -> Log.d("AdasisTest.", "Adasis message: $message") + Log.d("AdasisTest.", "Context: $context") } } diff --git a/gradle/artifact-settings.gradle b/gradle/artifact-settings.gradle index 265023dc4ab..75e8b1a08ff 100644 --- a/gradle/artifact-settings.gradle +++ b/gradle/artifact-settings.gradle @@ -12,9 +12,10 @@ ext { mapboxArtifactLicenseUrl = 'https://www.mapbox.com/legal/tos/' snapshot = project.hasProperty("snapshot") ? project.property("snapshot").toBoolean() : false releaseTagPrefix = project.hasProperty('RELEASE_TAG_PREFIX') ? project.property('RELEASE_TAG_PREFIX') : 'v' - versionName = getVersionName() + versionName = '2.18.0-adas-preview-10-SNAPSHOT' } +// latest is 2.18.0-adas-preview-10-SNAPSHOT def getVersionName() { if (project.hasProperty('VERSION_NAME')) { return project.property('VERSION_NAME') diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index c914a4a5079..1c82d636156 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 = '182.0.0' + mapboxNavigatorVersion = 'nio-adas-lpo-flatbuffers-vectors-11-SNAPSHOT' } println("Navigation Native version: " + mapboxNavigatorVersion) def androidXWorkManagerVersion = project.hasProperty('WORK_MANAGER_VERSION') ? project.property('WORK_MANAGER_VERSION') : '2.7.0' diff --git a/libnavigation-core/api/current.txt b/libnavigation-core/api/current.txt index c02a388667e..91815874972 100644 --- a/libnavigation-core/api/current.txt +++ b/libnavigation-core/api/current.txt @@ -201,7 +201,7 @@ package com.mapbox.navigation.core { package com.mapbox.navigation.core.adasis { @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public fun interface ADASISv2MessageCallback { - method public void onMessage(java.util.List messageBuffer); + method public void onMessage(java.util.List messageBuffer, com.mapbox.navigation.core.adasis.AdasisMessageContext context); } @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class AdasisConfig { @@ -294,6 +294,11 @@ package com.mapbox.navigation.core.adasis { field public static final com.mapbox.navigation.core.adasis.AdasisMessageBinaryFormat.FlatBuffers INSTANCE; } + public final class AdasisMessageContext { + method public Long? getPositionMonotonicTimestampNanoseconds(); + property public final Long? positionMonotonicTimestampNanoseconds; + } + @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class EdgeAdasAttributes { method public java.util.List getCurvatures(); method public java.util.List getSlopes(); 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 08ef74ea990..b8b3ea9e9d6 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 @@ -46,6 +46,7 @@ import com.mapbox.navigation.base.trip.notification.TripNotificationInterceptor import com.mapbox.navigation.core.accounts.BillingController import com.mapbox.navigation.core.adasis.ADASISv2MessageCallback import com.mapbox.navigation.core.adasis.AdasisConfig +import com.mapbox.navigation.core.adasis.AdasisMessageContext import com.mapbox.navigation.core.arrival.ArrivalController import com.mapbox.navigation.core.arrival.ArrivalObserver import com.mapbox.navigation.core.arrival.ArrivalProgressObserver @@ -2006,8 +2007,8 @@ class MapboxNavigation @VisibleForTesting internal constructor( @ExperimentalPreviewMapboxNavigationAPI fun setAdasisMessageCallback(adasisConfig: AdasisConfig, callback: ADASISv2MessageCallback) { navigator.setAdasisMessageCallback( - { message -> - callback.onMessage(message) + { message, context -> + callback.onMessage(message, AdasisMessageContext.fromNative(context)) }, adasisConfig.toNativeAdasisConfig() ) diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ADASISv2MessageCallback.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ADASISv2MessageCallback.kt index 99ff6630cf9..5b1ed5458c9 100644 --- a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ADASISv2MessageCallback.kt +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ADASISv2MessageCallback.kt @@ -11,6 +11,7 @@ fun interface ADASISv2MessageCallback { /** * Called when ADASIS message is available * @param messageBuffer Message buffer in format specified via [AdasisConfigDataSending.messageBinaryFormat] + * @param context Message context. For details see [AdasisMessageContext] docs */ - fun onMessage(messageBuffer: List) + fun onMessage(messageBuffer: List, context: AdasisMessageContext) } diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisMessageContext.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisMessageContext.kt new file mode 100644 index 00000000000..f52143123e7 --- /dev/null +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisMessageContext.kt @@ -0,0 +1,51 @@ +package com.mapbox.navigation.core.adasis + +/** + * Context of an adasis message. + * + * @param positionMonotonicTimestampNanoseconds the monotonic time of a position message within a message batch. + * This time is determined based on the monotonic time of the previous location and the lookAhead time. + * If the lookAhead is set to 0, then the positionMonotonicTimestampNanoseconds will be the monotonic time + * of the last location update. + */ +class AdasisMessageContext internal constructor( + val positionMonotonicTimestampNanoseconds: Long?, +) { + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as AdasisMessageContext + + if (positionMonotonicTimestampNanoseconds != other.positionMonotonicTimestampNanoseconds) return false + + return true + } + + override fun hashCode(): Int { + return positionMonotonicTimestampNanoseconds.hashCode() + } + + override fun toString(): String { + return "AdasisMessageContext(positionMonotonicTimestampNanoseconds=$positionMonotonicTimestampNanoseconds)" + } + + /** + * Temporary method to track NN changes. When NN adds a property to their object, + * this method's compilation will fail. + * In that case conversion both from and to native object should be adjusted. + */ + private fun toNative(): com.mapbox.navigator.AdasisMessageContext { + return com.mapbox.navigator.AdasisMessageContext(this.positionMonotonicTimestampNanoseconds) + } + + internal companion object { + + fun fromNative( + nativeContext: com.mapbox.navigator.AdasisMessageContext + ): AdasisMessageContext { + return AdasisMessageContext(nativeContext.positionMessageTimestamp) + } + } +}