From 0c9e4792a380a74c96632e15bbaeb4d41a8910b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Paczos?= Date: Thu, 8 Dec 2022 13:22:31 +0100 Subject: [PATCH] block until deprecated MapboxNavigation#resetTripSession() finishes --- .../mapbox/navigation/core/MapboxNavigation.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 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 84f78b05499..bbe5103059c 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 @@ -143,6 +143,7 @@ import kotlinx.coroutines.cancel import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.ReceiveChannel import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import java.lang.reflect.Field @@ -645,10 +646,18 @@ class MapboxNavigation @VisibleForTesting internal constructor( * navigation simulation, or before resetting location to not real (simulated) * position without recreation of [MapboxNavigation]. */ - @Deprecated(message = "use a function withe the callback instead") + @Deprecated(message = "use the overload with the callback instead") fun resetTripSession() { - resetTripSession { - // no-op + // using a blocking function to keep parity with the original implementation so that + // Nav Native is fully done with the reset when this function returns + runBlocking { + logD(LOG_CATEGORY) { + "Resetting trip session" + } + navigator.resetRideSession() + logI(LOG_CATEGORY) { + "Trip session reset" + } } }