feat: add device authentication, place gates support, and PiP navigation features
This commit is contained in:
@@ -13,6 +13,7 @@ import '../../../core/services/car_platform_bridge.dart';
|
||||
import '../../../core/services/connectivity_service.dart';
|
||||
import '../../../core/services/location_service.dart';
|
||||
import '../../../core/services/pip_service.dart';
|
||||
import '../../../core/services/telemetry_tracking_service.dart';
|
||||
import '../../../core/services/tts_service.dart';
|
||||
import '../../../core/services/vehicle_icon_generator.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -36,8 +37,6 @@ class NavigationCubit extends Cubit<NavigationState> {
|
||||
DateTime? _offRouteStartTime;
|
||||
bool _isRerouting = false;
|
||||
int _lastTraveledIndexInFullRoute = 0;
|
||||
DateTime? _lastTelemetrySent;
|
||||
final String _driverId = 'driver_${DateTime.now().millisecondsSinceEpoch % 100000}';
|
||||
|
||||
NavigationCubit({
|
||||
required this.repository,
|
||||
@@ -68,6 +67,10 @@ class NavigationCubit extends Cubit<NavigationState> {
|
||||
CarPlatformBridge.ensureInitialized();
|
||||
await ttsService.init();
|
||||
|
||||
// Initialize 3-second telemetry tracking & 2-minute batch uploads
|
||||
TelemetryTrackingService.instance.initialize();
|
||||
TelemetryTrackingService.instance.checkPeriodicUpdates();
|
||||
|
||||
// Load saved vehicle & search preferences
|
||||
try {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
@@ -286,20 +289,15 @@ class NavigationCubit extends Cubit<NavigationState> {
|
||||
_startMovementInterpolation(newLoc, heading);
|
||||
}
|
||||
|
||||
// Periodic driver telemetry stream (every 5 seconds)
|
||||
final now = DateTime.now();
|
||||
if (_lastTelemetrySent == null || now.difference(_lastTelemetrySent!).inSeconds >= 5) {
|
||||
_lastTelemetrySent = now;
|
||||
repository.sendDriverTelemetry(
|
||||
driverId: _driverId,
|
||||
latitude: newLoc.latitude,
|
||||
longitude: newLoc.longitude,
|
||||
speed: speedKmH,
|
||||
heading: heading,
|
||||
elevation: alt,
|
||||
distance: state.remainingDistance,
|
||||
);
|
||||
}
|
||||
// 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) {
|
||||
@@ -776,6 +774,7 @@ class NavigationCubit extends Cubit<NavigationState> {
|
||||
|
||||
void stopNavigation() {
|
||||
print("🛑 [NavigationCubit] stopNavigation triggered.");
|
||||
TelemetryTrackingService.instance.flush(repository: repository);
|
||||
_movementInterpolationTimer?.cancel();
|
||||
_movementInterpolationTimer = null;
|
||||
ttsService.stop();
|
||||
@@ -1277,6 +1276,7 @@ class NavigationCubit extends Cubit<NavigationState> {
|
||||
_connectivitySub?.cancel();
|
||||
_searchDebounce?.cancel();
|
||||
ttsService.stop();
|
||||
TelemetryTrackingService.instance.dispose(repository: repository);
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user