From fa6b292168c373ee4456ad3e50bdd42d300f8fc3 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Wed, 20 Nov 2024 18:02:33 +0100 Subject: [PATCH] Fix AA navigation restored started on the phone (patch) --- .../osmand/plus/auto/NavigationSession.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/auto/NavigationSession.java b/OsmAnd/src/net/osmand/plus/auto/NavigationSession.java index 773312d1f1a..67f9d34483e 100644 --- a/OsmAnd/src/net/osmand/plus/auto/NavigationSession.java +++ b/OsmAnd/src/net/osmand/plus/auto/NavigationSession.java @@ -129,7 +129,7 @@ public class NavigationSession extends Session implements NavigationListener, Os private CarContext carContext; private NavigationManager navigationManager; - private boolean carNavigationActive; + private boolean carNavigationShouldBeActive; // it could set true before init navigationManager private TripHelper tripHelper; NavigationSession() { @@ -433,7 +433,7 @@ public void startNavigationScreen() { } getCarContext().getCarService(ScreenManager.class).push(navigationScreen); // navigation already started - if (routingHelper.isFollowingMode() && routingHelper.isRouteCalculated() && !carNavigationActive) { + if (routingHelper.isFollowingMode() && routingHelper.isRouteCalculated() && !carNavigationShouldBeActive) { startCarNavigation(); } } @@ -618,8 +618,9 @@ public void onAutoDriveEnabled() { } } }); - // Uncomment if navigating - // mNavigationManager.navigationStarted(); + if (carNavigationShouldBeActive) { + navigationManager.navigationStarted(); + } } else { this.navigationManager = null; } @@ -643,8 +644,8 @@ public void clearCarContext() { public void startCarNavigation() { if (navigationManager != null) { navigationManager.navigationStarted(); - carNavigationActive = true; } + carNavigationShouldBeActive = true; } /** @@ -660,7 +661,7 @@ public void stopCarNavigation() { navigationScreen.stopTrip(); } } - carNavigationActive = false; + carNavigationShouldBeActive = false; navigationManager.navigationEnded(); } } @@ -670,7 +671,7 @@ public void stopCarNavigation() { public void updateCarNavigation(Location currentLocation) { OsmandApplication app = getApp(); TripHelper tripHelper = this.tripHelper; - if (carNavigationActive && navigationManager != null && tripHelper != null + if (carNavigationShouldBeActive && navigationManager != null && tripHelper != null && routingHelper.isRouteCalculated() && routingHelper.isFollowingMode()) { NavigationSession carNavigationSession = app.getCarNavigationSession(); if (carNavigationSession != null) { @@ -704,10 +705,6 @@ public void updateCarNavigation(Location currentLocation) { } } - public boolean isCarNavigationActive() { - return carNavigationActive; - } - private void checkAppInitialization(@NonNull RestoreNavigationHelper restoreNavigationHelper) { OsmandApplication app = getApp(); if (app.isApplicationInitializing()) {