Skip to content

Commit

Permalink
Fix AA navigation restored started on the phone (patch)
Browse files Browse the repository at this point in the history
  • Loading branch information
vshcherb committed Nov 20, 2024
1 parent a85aad4 commit fa6b292
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions OsmAnd/src/net/osmand/plus/auto/NavigationSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -618,8 +618,9 @@ public void onAutoDriveEnabled() {
}
}
});
// Uncomment if navigating
// mNavigationManager.navigationStarted();
if (carNavigationShouldBeActive) {
navigationManager.navigationStarted();
}
} else {
this.navigationManager = null;
}
Expand All @@ -643,8 +644,8 @@ public void clearCarContext() {
public void startCarNavigation() {
if (navigationManager != null) {
navigationManager.navigationStarted();
carNavigationActive = true;
}
carNavigationShouldBeActive = true;
}

/**
Expand All @@ -660,7 +661,7 @@ public void stopCarNavigation() {
navigationScreen.stopTrip();
}
}
carNavigationActive = false;
carNavigationShouldBeActive = false;
navigationManager.navigationEnded();
}
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit fa6b292

Please sign in to comment.