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
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ class MapboxNavigation @VisibleForTesting internal constructor(
fun stopTripSession() {
runIfNotDestroyed {
latestLegIndex = tripSession.getRouteProgress()?.currentLegProgress?.legIndex
tripSession.stop()
tripSession.stop(true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understood from your discussion with @averkhaturau in the NN PR, it would only be true if we haven't arrived yet, right? If so, there's no such check here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of the cancelled : bool parameter here is that routing session cancel is not a complete opposite to routing complete. E.g. User may finish the route but navigator will not detect it because the user parks on another side of the building / fence, etc. But actual session is successfully complete and the User shows it by pressing thumb up. From other side, session may be detected is finished by mistake, e.g. wrong map-matching, target point where is impossible to stop, etc., and the user will actually cancel the session.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

Expand Down Expand Up @@ -1216,7 +1216,7 @@ class MapboxNavigation @VisibleForTesting internal constructor(
billingController.onDestroy()
directionsSession.shutdown()
directionsSession.unregisterAllRoutesObservers()
tripSession.stop()
tripSession.stop(true)
tripSession.unregisterAllLocationObservers()
tripSession.unregisterAllRouteProgressObservers()
tripSession.unregisterAllOffRouteObservers()
Expand Down Expand Up @@ -2010,7 +2010,7 @@ class MapboxNavigation @VisibleForTesting internal constructor(
channel,
{ notificationAction ->
when (notificationAction) {
NotificationAction.END_NAVIGATION -> tripSession.stop()
NotificationAction.END_NAVIGATION -> tripSession.stop(true)
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ internal class MapboxTripSession(
override fun start(withTripService: Boolean, withReplayEnabled: Boolean) {
if (state != TripSessionState.STARTED) {
navigator.addNavigatorObserver(navigatorObserver)
navigator.startTripSession()
if (withTripService) {
tripService.startService()
}
Expand Down Expand Up @@ -359,10 +360,11 @@ internal class MapboxTripSession(
/**
* Stop MapboxTripSession
*/
override fun stop() {
override fun stop(canceled: Boolean) {
if (state == TripSessionState.STOPPED) {
return
}
navigator.stopTripSession(canceled)
navigator.removeNavigatorObserver(navigatorObserver)
tripService.stopService()
tripSessionLocationEngine.stopLocationUpdates()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal interface TripSession {
fun getState(): TripSessionState

fun start(withTripService: Boolean, withReplayEnabled: Boolean = false)
fun stop()
fun stop(canceled: Boolean)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You always invoke it with true...

fun isRunningWithForegroundService(): Boolean

fun registerLocationObserver(locationObserver: LocationObserver)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ internal class MapboxNavigationTest : MapboxNavigationBaseTest() {
createMapboxNavigation()
mapboxNavigation.onDestroy()

verify(exactly = 1) { tripSession.stop() }
verify(exactly = 1) { tripSession.stop(true) }
}

@Test
Expand Down Expand Up @@ -425,7 +425,7 @@ internal class MapboxNavigationTest : MapboxNavigationBaseTest() {
mapboxNavigation.onDestroy()

verifyOrder {
tripSession.stop()
tripSession.stop(true)
MapboxNavigationTelemetry.destroy(mapboxNavigation)
}
}
Expand Down Expand Up @@ -1289,7 +1289,7 @@ internal class MapboxNavigationTest : MapboxNavigationBaseTest() {
withTripService = true,
withReplayEnabled = false
)
tripSession.stop()
tripSession.stop(true)
tripSession.unregisterAllStateObservers()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ class MapboxTripSessionNoSetupTest {
)

tripSession.start(false)
tripSession.stop()
tripSession.stop(true)
testLocationEngine.updateLocation(createLocation())

assertNull(tripSession.getRawLocation())
Expand Down
Loading