feat: introduce routing status tracking for approved roads and telemetry batch queue limits

This commit is contained in:
Hamza-Ayed
2026-09-19 12:34:26 +03:00
parent a8470eb76c
commit 91e9e71ce4
9 changed files with 234 additions and 129 deletions
@@ -67,8 +67,7 @@ class NavigationCubit extends Cubit<NavigationState> {
CarPlatformBridge.ensureInitialized();
await ttsService.init();
// Initialize 3-second telemetry tracking & 2-minute batch uploads
TelemetryTrackingService.instance.initialize();
// The tracking session begins only once the user starts navigation.
TelemetryTrackingService.instance.checkPeriodicUpdates();
// Load saved vehicle & search preferences
@@ -289,16 +288,6 @@ class NavigationCubit extends Cubit<NavigationState> {
_startMovementInterpolation(newLoc, heading);
}
// Continuous 3-second telemetry sampling with stationary filtering and 2-minute batching
TelemetryTrackingService.instance.recordPosition(
latitude: newLoc.latitude,
longitude: newLoc.longitude,
speedKmH: speedKmH,
heading: heading,
elevation: alt,
remainingDistance: state.remainingDistance,
);
// Proactively move camera on first acquired GPS lock (only when style is loaded)
if (!_hasInitiallyCenteredCamera && mapController != null && _isMapStyleLoaded) {
_hasInitiallyCenteredCamera = true;
@@ -310,6 +299,15 @@ class NavigationCubit extends Cubit<NavigationState> {
}
if (state.isNavigating) {
// Navigation-only telemetry: sampled every 3 seconds and sent as a batch every 2 minutes.
TelemetryTrackingService.instance.recordPosition(
latitude: newLoc.latitude,
longitude: newLoc.longitude,
speedKmH: speedKmH,
heading: heading,
elevation: alt,
remainingDistance: state.remainingDistance,
);
_processActiveNavigationTick(newLoc, speedKmH, heading);
}
}
@@ -718,6 +716,7 @@ class NavigationCubit extends Cubit<NavigationState> {
return;
}
final route = state.currentRoute!;
TelemetryTrackingService.instance.initialize();
final steps = route.steps;
print("🧭 [NavigationCubit] Starting navigation along route: ${route.formattedDistance}, ETA ${route.formattedDuration}, ${steps.length} steps");
@@ -774,7 +773,8 @@ class NavigationCubit extends Cubit<NavigationState> {
void stopNavigation() {
print("🛑 [NavigationCubit] stopNavigation triggered.");
TelemetryTrackingService.instance.flush(repository: repository);
// Stop the two-minute timer and send the final in-memory batch.
TelemetryTrackingService.instance.dispose(repository: repository);
_movementInterpolationTimer?.cancel();
_movementInterpolationTimer = null;
ttsService.stop();