mapbox / mapbox-navigation-android-examples

Other
53 stars 46 forks source link

Sync the car and app #144

Closed kmadsen closed 2 years ago

kmadsen commented 2 years ago

Testing this out because there are new functions available to sync NavigationView with MapboxCarApp

kmadsen commented 2 years ago

Calling these functions one after another will not update the state to active guidance. Need a way to pause before addListener

navigationView.api.startActiveGuidance()
navigationView.addListener(appListener)
2022-09-16 17:27:47.166 onAttached CarAppSyncComponent
2022-09-16 17:27:47.167 onAttached car
2022-09-16 17:28:23.388 onAttached app
2022-09-16 17:28:23.388 navigationView.api.startActiveGuidance()
2022-09-16 17:28:23.389 updateCarAppState onFreeDrive

EDIT: this is fixed with

val routes = MapboxNavigationApp.current()!!.getNavigationRoutes()
navigationView.api.startActiveGuidance(routes)
navigationView.addListener(appListener)
Zayankovsky commented 2 years ago

Synchronization doesn't work for me in the following scenario:

  1. Launch the app on a phone and start a trip.
  2. Launch Android Auto app.
  3. I expect that Android Auto app will immediately transition to Active Navigation state, but instead the trip is canceled.
kmadsen commented 2 years ago

Synchronization doesn't work for me in the following scenario:

Launch the app on a phone and start a trip. Launch Android Auto app. I expect that Android Auto app will immediately transition to Active Navigation state, but instead the trip is canceled.

Yeah nice catch. Not sure why the NavigationView is emitting that it is in free drive 👀

    private val appListener = object : NavigationViewListener() {
        override fun onFreeDrive() {
            logI(LOG_TAG, "updateCarAppState onFreeDrive")
            MapboxCarApp.updateCarAppState(FreeDriveState)
        }

EDIT: Ok found it, it's in the MainCarSession example. When enabling the trip session

kmadsen commented 2 years ago

Ok Replay is not supported yet to share between dropin and AA. We'll need a public api for that feature as well

kmadsen commented 2 years ago

Actually, synchronization doesn't work in a much simpler scenario:

Thanks for finding! A big issue to supporting this logic in the example is there are no unit tests to keep track of these issues