From 77e4c37914044d36c82b065329a52731fd7f5dc9 Mon Sep 17 00:00:00 2001 From: Martin Bilka Date: Sat, 18 Jul 2026 22:34:26 +0200 Subject: [PATCH] Fix crash when calling back a missed call with a stale SIM handle Intent.hasExtra(EXTRA_PHONE_ACCOUNT_HANDLE) only confirms the key is present, not that the parcelable resolves to a non-null value. When the handle points to a SIM slot that's present but inactive/locked, getParcelableExtra() can return null and the !! throws an NPE. Extract the extra defensively and fall back to the existing options (saved custom SIM, default outgoing account, SIM selector dialog) instead of crashing. Fixes #134 Fixes #473 --- CHANGELOG.md | 4 ++++ .../main/kotlin/org/fossify/phone/extensions/CallExt.kt | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7375ee44d..3a507644d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Fixed crash when tapping "Call back" on a missed call notification when the phone account handle from the intent no longer resolves (e.g. an inactive/locked SIM) ([#134], [#473]) ## [1.11.1] - 2026-02-01 ### Changed @@ -243,6 +245,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#118]: https://github.com/FossifyOrg/Phone/issues/118 [#125]: https://github.com/FossifyOrg/Phone/issues/125 [#133]: https://github.com/FossifyOrg/Phone/issues/133 +[#134]: https://github.com/FossifyOrg/Phone/issues/134 [#139]: https://github.com/FossifyOrg/Phone/issues/139 [#146]: https://github.com/FossifyOrg/Phone/issues/146 [#147]: https://github.com/FossifyOrg/Phone/issues/147 @@ -260,6 +263,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#359]: https://github.com/FossifyOrg/Phone/issues/359 [#378]: https://github.com/FossifyOrg/Phone/issues/378 [#389]: https://github.com/FossifyOrg/Phone/issues/389 +[#473]: https://github.com/FossifyOrg/Phone/issues/473 [#526]: https://github.com/FossifyOrg/Phone/issues/526 [#535]: https://github.com/FossifyOrg/Phone/issues/535 [#543]: https://github.com/FossifyOrg/Phone/issues/543 diff --git a/app/src/main/kotlin/org/fossify/phone/extensions/CallExt.kt b/app/src/main/kotlin/org/fossify/phone/extensions/CallExt.kt index f2dc9aca3..49a5a1cea 100644 --- a/app/src/main/kotlin/org/fossify/phone/extensions/CallExt.kt +++ b/app/src/main/kotlin/org/fossify/phone/extensions/CallExt.kt @@ -106,12 +106,11 @@ fun SimpleActivity.getHandleToUse( if (it) { val defaultHandle = telecomManager.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL) + // hasExtra() can be true with a null parcelable (e.g. locked SIM); extract safely and fall through. + val intentHandle = intent?.getParcelableExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE) when { forceSimSelector -> showSelectSimDialog(phoneNumber, callback) - intent?.hasExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE) == true -> { - callback(intent.getParcelableExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE)!!) - } - + intentHandle != null -> callback(intentHandle) config.getCustomSIM(phoneNumber) != null -> { callback(config.getCustomSIM(phoneNumber)) }