mapbox / mapbox/mapbox-navigation-android

Exposing return value of onStartCommand() of NavigationNotificationService

Open
#5,115 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

jira-sync-complete
Dominant language
Kotlin
Stars
651
Forks
321
PR merge metrics
No merged PRs in 30d

Description

We are experiencing a problem with `NavigationNotificationService` when the user revokes location permissions.

The `NavigationNotificationService` is stopped because the user revokes the location permissions while the SDK is running. Then, after I try to use the app again (after the service has restarted) it sometimes crashes because of the service already running

The `NavigationNotificationService` is restarting itself after it's killed by the system. I've noticed that's because you're using the START_STICKY flag for the service. I know that this flag is useful in some cases but in our scenario it is causing us some trouble

Would it be an option to expose the return value of `onStartCommand()`? Or would it be an option to allow the service to restart only if required permissions are given?

Please also see:

https://github.com/mapbox/mapbox-navigation-android/blob/main/libnavigation-core/src/main/java/com/mapbox/navigation/core/trip/service/NavigationNotificationService.kt#L38

**Android API:**30
**Mapbox Navigation SDK version:** latest

### Steps to trigger behavior

1. Run navigation app that uses the Mapbox Nav SDK
2. Revoke location permissions
3. Use the app with revoked permissions

### Expected behavior

Service should not restart if the location permissions are insufficient.

### Actual behavior
NavigationNotificationService restarts automatically, independent of missing permissions.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with libnavigation-core/src/main/java/com/mapbox/navigation/core/trip/service/NavigationNotificationService.kt at line 38, then reproduce the listed steps on Android API 30 by revoking location permissions. Trace the service restart behavior and verify that NavigationNotificationService does not restart when the required permissions are missing.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.