fix(android): read the location callback's answer as nullable
The fresh-fix request declared its callback parameter as non-null, but LocationManager answers with null when no provider has a fix. Kotlin's generated check threw on the main executor before the fallback could run, so the crash escaped PhoneStatusWorker's catch and killed the process when the app came to the foreground. The callback takes Location? now. A null answer resumes the coroutine with null, which currentFix already treats as no fix and answers with lastKnownFix. assembleDebug passes; a status run on the emulator completed without the process dying.
This commit is contained in:
1 parent
4710f783c7
commit
30b5e0f721
1 file changed
+5
-1
@@ -113,7 +113,11 @@ object PhoneSensors {
|
|||||||
settled.set(true)
|
settled.set(true)
|
||||||
signal.cancel()
|
signal.cancel()
|
||||||
}
|
}
|
||||||
val callback = androidx.core.util.Consumer<Location> { location ->
|
// The parameter is nullable on purpose: the provider
|
||||||
|
// calls this with null when it has no fix. Typed
|
||||||
|
// non-null, Kotlin's parameter check threw on the main
|
||||||
|
// thread before this body ran, killing the process.
|
||||||
|
val callback = androidx.core.util.Consumer<Location?> { location ->
|
||||||
// The timeout abandons this coroutine but not the
|
// The timeout abandons this coroutine but not the
|
||||||
// callback: a late answer must not resume it twice.
|
// callback: a late answer must not resume it twice.
|
||||||
// A null answer is the provider's "no fix", which
|
// A null answer is the provider's "no fix", which
|
||||||
|
|||||||
Reference in new issue
Block a user