Skip to content

Commit 4032da4

Browse files
author
Łukasz Paczos
committed
fixed an issue where a alternatives or refresh update could interrupt a reroute
1 parent 8dab187 commit 4032da4

15 files changed

Lines changed: 10489 additions & 91 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Mapbox welcomes participation and contributions from everyone.
1111
- Updated the `MapboxRestAreaApi` logic to load a SAPA map only if the upcoming rest stop is at the current step of the route leg. [#6695](https://github.com/mapbox/mapbox-navigation-android/pull/6695)
1212
- Fixed an issue where `MapboxRerouteController` could deliver a delayed interruption state notifications. Now, the interruption state is always delivered synchronously, as soon as it's available. [#6718](https://github.com/mapbox/mapbox-navigation-android/pull/6718)
1313
- Fixed the `NavigationView` issue where route arrows are being rendered above navigation puck after device rotation. [#6747](https://github.com/mapbox/mapbox-navigation-android/pull/6747)
14+
- Fixed an issue where a refresh of the routes or a change in alternatives that occurred while user was off-route would call `RerouteController#interrupt` and interrupt the potentially ongoing reroute process without recovery. [#6719](https://github.com/mapbox/mapbox-navigation-android/pull/6719)
1415

1516
## Mapbox Navigation SDK 2.9.5 - 13 December, 2022
1617
### Changelog

instrumentation-tests/src/androidTest/java/com/mapbox/navigation/instrumentation_tests/core/CoreRerouteTest.kt

Lines changed: 270 additions & 41 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.mapbox.navigation.instrumentation_tests.utils.assertions
2+
3+
import com.mapbox.navigation.core.reroute.NavigationRerouteController
4+
import com.mapbox.navigation.core.reroute.RerouteState
5+
import com.mapbox.navigation.testing.ui.assertions.ValueTransitionAssertion
6+
7+
class RerouteStateTransitionAssertion(
8+
rerouteController: NavigationRerouteController,
9+
expectedBlock: ValueTransitionAssertion<RerouteState>.() -> Unit
10+
) : ValueTransitionAssertion<RerouteState>(expectedBlock) {
11+
init {
12+
rerouteController.registerRerouteStateObserver { state ->
13+
onNewValue(state)
14+
}
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
package com.mapbox.navigation.instrumentation_tests.utils.assertions
22

3-
import com.mapbox.navigation.base.trip.model.RouteProgress
43
import com.mapbox.navigation.base.trip.model.RouteProgressState
54
import com.mapbox.navigation.core.MapboxNavigation
6-
import com.mapbox.navigation.core.trip.session.RouteProgressObserver
75
import com.mapbox.navigation.testing.ui.assertions.ValueTransitionAssertion
86

97
class RouteProgressStateTransitionAssertion(
108
mapboxNavigation: MapboxNavigation,
119
expectedBlock: ValueTransitionAssertion<RouteProgressState>.() -> Unit
1210
) : ValueTransitionAssertion<RouteProgressState>(expectedBlock) {
1311
init {
14-
mapboxNavigation.registerRouteProgressObserver(
15-
object : RouteProgressObserver {
16-
override fun onRouteProgressChanged(routeProgress: RouteProgress) {
17-
onNewValue(routeProgress.currentState)
18-
}
19-
}
20-
)
12+
mapboxNavigation.registerRouteProgressObserver { routeProgress ->
13+
onNewValue(routeProgress.currentState)
14+
}
2115
}
2216
}

instrumentation-tests/src/androidTest/java/com/mapbox/navigation/instrumentation_tests/utils/location/MockLocationReplayer.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ class MockLocationReplayerRule(mockLocationUpdatesRule: MockLocationUpdatesRule)
7070
play()
7171
}
7272
}
73+
74+
fun stopAndClearEvents() {
75+
mapboxReplayer?.run {
76+
stop()
77+
clearEvents()
78+
}
79+
}
7380
}
7481

7582
fun Location.setUpLocation(event: ReplayEventUpdateLocation) {

instrumentation-tests/src/androidTest/java/com/mapbox/navigation/instrumentation_tests/utils/routes/RoutesProvider.kt

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ object RoutesProvider {
8080
fun dc_short_with_alternative(context: Context): MockRoute {
8181
val jsonResponse = readRawFileText(context, R.raw.route_response_dc_short_with_alternative)
8282
val coordinates = listOf(
83-
Point.fromLngLat(-77.033991, 38.891121),
84-
Point.fromLngLat(-77.030023, 38.895433)
83+
Point.fromLngLat(-77.033625, 38.891164),
84+
Point.fromLngLat(-77.03002, 38.895453)
8585
)
8686
return MockRoute(
8787
jsonResponse,
@@ -98,6 +98,28 @@ object RoutesProvider {
9898
)
9999
}
100100

101+
fun dc_short_with_alternative_reroute(context: Context): MockRoute {
102+
val jsonResponse =
103+
readRawFileText(context, R.raw.route_response_dc_short_with_alternative_reroute)
104+
val coordinates = listOf(
105+
Point.fromLngLat(-77.036178, 38.892106),
106+
Point.fromLngLat(-77.03002, 38.895453)
107+
)
108+
return MockRoute(
109+
jsonResponse,
110+
DirectionsResponse.fromJson(jsonResponse),
111+
listOf(
112+
MockDirectionsRequestHandler(
113+
profile = DirectionsCriteria.PROFILE_DRIVING_TRAFFIC,
114+
jsonResponse = jsonResponse,
115+
expectedCoordinates = coordinates,
116+
)
117+
),
118+
coordinates,
119+
emptyList()
120+
)
121+
}
122+
101123
fun dc_very_short_two_legs(context: Context): MockRoute {
102124
val jsonResponse = readRawFileText(context, R.raw.route_response_dc_very_short_two_legs)
103125
val coordinates = listOf(

instrumentation-tests/src/main/res/raw/route_response_dc_short_with_alternative.json

Lines changed: 3073 additions & 1 deletion
Large diffs are not rendered by default.
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
{
2+
"code": "Ok",
3+
"route": {
4+
"legs": [
5+
{
6+
"annotation": {
7+
"maxspeed": [
8+
{
9+
"speed": 40,
10+
"unit": "km/h"
11+
},
12+
{
13+
"speed": 40,
14+
"unit": "km/h"
15+
},
16+
{
17+
"speed": 40,
18+
"unit": "km/h"
19+
},
20+
{
21+
"speed": 40,
22+
"unit": "km/h"
23+
},
24+
{
25+
"speed": 40,
26+
"unit": "km/h"
27+
},
28+
{
29+
"speed": 40,
30+
"unit": "km/h"
31+
},
32+
{
33+
"speed": 40,
34+
"unit": "km/h"
35+
},
36+
{
37+
"speed": 40,
38+
"unit": "km/h"
39+
},
40+
{
41+
"speed": 40,
42+
"unit": "km/h"
43+
},
44+
{
45+
"speed": 40,
46+
"unit": "km/h"
47+
},
48+
{
49+
"speed": 40,
50+
"unit": "km/h"
51+
},
52+
{
53+
"speed": 40,
54+
"unit": "km/h"
55+
},
56+
{
57+
"speed": 40,
58+
"unit": "km/h"
59+
},
60+
{
61+
"speed": 40,
62+
"unit": "km/h"
63+
},
64+
{
65+
"speed": 40,
66+
"unit": "km/h"
67+
},
68+
{
69+
"speed": 40,
70+
"unit": "km/h"
71+
},
72+
{
73+
"speed": 40,
74+
"unit": "km/h"
75+
},
76+
{
77+
"speed": 40,
78+
"unit": "km/h"
79+
},
80+
{
81+
"speed": 40,
82+
"unit": "km/h"
83+
},
84+
{
85+
"speed": 40,
86+
"unit": "km/h"
87+
},
88+
{
89+
"speed": 40,
90+
"unit": "km/h"
91+
},
92+
{
93+
"speed": 40,
94+
"unit": "km/h"
95+
},
96+
{
97+
"speed": 40,
98+
"unit": "km/h"
99+
},
100+
{
101+
"speed": 40,
102+
"unit": "km/h"
103+
},
104+
{
105+
"speed": 40,
106+
"unit": "km/h"
107+
}
108+
],
109+
"congestion_numeric": [
110+
0,
111+
0,
112+
0,
113+
0,
114+
0,
115+
0,
116+
0,
117+
0,
118+
0,
119+
0,
120+
0,
121+
0,
122+
0,
123+
0,
124+
0,
125+
null,
126+
null,
127+
null,
128+
null,
129+
null,
130+
null,
131+
null,
132+
null,
133+
null,
134+
null
135+
],
136+
"speed": [
137+
5.8,
138+
5.8,
139+
5.9,
140+
5.9,
141+
5.8,
142+
6,
143+
5.8,
144+
5.8,
145+
5.8,
146+
5.8,
147+
5.9,
148+
6,
149+
7.4,
150+
7.2,
151+
7.4,
152+
5.7,
153+
5.9,
154+
5.9,
155+
5.9,
156+
5.6,
157+
5.8,
158+
4.2,
159+
4.2,
160+
4.2,
161+
4.2
162+
],
163+
"distance": [
164+
8.3,
165+
8.8,
166+
34.3,
167+
34.1,
168+
19,
169+
16.4,
170+
44.1,
171+
45.9,
172+
143.3,
173+
77,
174+
36.2,
175+
10.3,
176+
14.4,
177+
114.1,
178+
16.4,
179+
17.5,
180+
46.2,
181+
24.5,
182+
4.9,
183+
7.7,
184+
7,
185+
36.9,
186+
6.3,
187+
10.2,
188+
6.3
189+
],
190+
"duration": [
191+
1.42,
192+
1.514,
193+
5.848,
194+
5.81,
195+
3.265,
196+
4.762,
197+
7.573,
198+
7.876,
199+
24.514,
200+
13.2,
201+
6.171,
202+
1.722,
203+
5.574,
204+
15.793,
205+
2.223,
206+
5.093,
207+
7.893,
208+
4.134,
209+
0.837,
210+
1.4,
211+
1.207,
212+
8.818,
213+
1.51,
214+
2.437,
215+
1.509
216+
]
217+
}
218+
}
219+
]
220+
}
221+
}

0 commit comments

Comments
 (0)