-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make SharedApp backwards compatible and removable #6303
Conversation
80d1dd4
to
1ecfb3f
Compare
Codecov Report
@@ Coverage Diff @@
## main #6303 +/- ##
=========================================
Coverage 68.89% 68.89%
Complexity 4454 4454
=========================================
Files 668 668
Lines 26688 26688
Branches 3147 3147
=========================================
Hits 18387 18387
Misses 7093 7093
Partials 1208 1208 |
EDIT: solution was to register the instrumentation test ran into this
|
f5a607e
to
d98d130
Compare
libnavui-androidauto/src/main/java/com/mapbox/androidauto/MapboxCarApp.kt
Outdated
Show resolved
Hide resolved
d98d130
to
5b1eb0d
Compare
EDIT: actually i'm not finding more changes to make here so will leave it opn |
5b1eb0d
to
9c502e1
Compare
9c502e1
to
50ad972
Compare
@@ -109,7 +109,7 @@ class NavigationView @JvmOverloads constructor( | |||
keepScreenOn = true | |||
captureSystemBarsInsets() | |||
|
|||
SharedApp.setup(context.applicationContext as Application) | |||
MapboxNavigationApp.registerObserver(SharedApp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should be changing how SharedApp
is integrated with NavigationView
. Instead, we should leave SharedApp.setup(Application)
call here and move MapboxNavigationApp.registerObserver(SharedApp)
call inside SharedApp.setup
method.
Registering SharedApp
as MapboxNavigationObserver
is an implementation detail that should be hidden from the public.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the point that SharedApp
is still internal, but what we will want is a public version of SharedApp
and then it can register an internal MapboxNavigationObserver
object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should setup(Application)
be required though? The application context is passed to NavigationOptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the application context
requirement to get early access to the Context
before MapboxNavigation
and NavigationOptions
are initialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why does SharedApp
need the early access to the Context
. Everything that uses the context would be better to get it from MapboxNavigationObserver
After applying the fix from this PR I am getting crash when opening "Default NavigationView" activity 2x in QA-Test-App: E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mapbox.navigation.qa_test_app, PID: 4971
java.lang.IllegalStateException: There are multiple DataStores active for the same file: /data/user/0/com.mapbox.navigation.qa_test_app/files/datastore/mapbox_navigation_preferences.preferences_pb. You should either maintain your DataStore as a singleton or confirm that there is no two DataStore's active on the same file (by confirming that the scope is cancelled).
at androidx.datastore.core.SingleProcessDataStore$file$2.invoke(SingleProcessDataStore.kt:168)
at androidx.datastore.core.SingleProcessDataStore$file$2.invoke(SingleProcessDataStore.kt:163)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at androidx.datastore.core.SingleProcessDataStore.getFile(SingleProcessDataStore.kt:163)
at androidx.datastore.core.SingleProcessDataStore.readData(SingleProcessDataStore.kt:380)
at androidx.datastore.core.SingleProcessDataStore.readDataOrHandleCorruption(SingleProcessDataStore.kt:359)
at androidx.datastore.core.SingleProcessDataStore.readAndInit(SingleProcessDataStore.kt:322)
at androidx.datastore.core.SingleProcessDataStore.readAndInitOrPropagateFailure(SingleProcessDataStore.kt:311)
at androidx.datastore.core.SingleProcessDataStore.handleRead(SingleProcessDataStore.kt:261)
at androidx.datastore.core.SingleProcessDataStore.access$handleRead(SingleProcessDataStore.kt:76)
at androidx.datastore.core.SingleProcessDataStore$actor$3.invokeSuspend(SingleProcessDataStore.kt:239)
at androidx.datastore.core.SingleProcessDataStore$actor$3.invoke(Unknown Source:8)
at androidx.datastore.core.SingleProcessDataStore$actor$3.invoke(Unknown Source:4)
at androidx.datastore.core.SimpleActor$offer$2.invokeSuspend(SimpleActor.kt:122)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665) |
After some more discussion, An initiative to install components with a public api is better served by the component installer For android auto, we're looking for something along these lines #6304 where we can |
Closing this one because we're planning on removing |
Description
Resolves #6253
There is an incompatibility with
SharedApp
where it can only be setup once and it is the only opportunity to specify custom services https://github.com/mapbox/mapbox-navigation-android/pull/6213/files#r964971123Every time the
SharedApp.setup
function changes it will break compatibility with anything that uses it. Converting theSharedApp
to aMapboxNavigationObserver
to resolve it and removing customizability so it can stay backwards compatible.On the topic of, creating custom services like
MapboxAudioGuidance
. We should be discussing public api options for how to do so, that way theSharedApp
will not break compatibility with AA. Am also considering that custom services can be swapped withMapboxNavigationApp.unregisterObserver
andMapboxNavigationApp.registerObserver
, which are going to be forever backwards compatible and they are public.There is no public interface for declaring custom services so it should be removed from this
SharedApp.setup
function.