From 30b5e0f7219a16d676f2117a18124b5557b417da Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Wed, 2 Dec 2026 11:39:55 +0100 Subject: [PATCH] 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. --- .../src/main/java/rs/rhema/phone/sensors/PhoneSensors.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/java/rs/rhema/phone/sensors/PhoneSensors.kt b/android/app/src/main/java/rs/rhema/phone/sensors/PhoneSensors.kt index a3ccf61..2a9f5c9 100644 --- a/android/app/src/main/java/rs/rhema/phone/sensors/PhoneSensors.kt +++ b/android/app/src/main/java/rs/rhema/phone/sensors/PhoneSensors.kt @@ -113,7 +113,11 @@ object PhoneSensors { settled.set(true) signal.cancel() } - val callback = androidx.core.util.Consumer { 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 -> // The timeout abandons this coroutine but not the // callback: a late answer must not resume it twice. // A null answer is the provider's "no fix", which