From eb5a236170c304d4469990514cc3601aa5bc3d78 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Wed, 24 Jun 2026 08:36:41 +0300 Subject: [PATCH] Improved detection if SIM card is available --- .../kotlin/com/tutpro/baresip/BaresipService.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index c7b97b1c..f8709a94 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -2229,8 +2229,19 @@ class BaresipService: Service() { account.telProvider = "" val mobileUa = UserAgent(0L, account) val isAirplaneModeOn = Settings.Global.getInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0) != 0 - mobileUa.status = if (isAirplaneModeOn) R.drawable.circle_white else circleGreen.getValue(colorblind) - updateMobileStatus() + val sm = getSystemService(TELEPHONY_SUBSCRIPTION_SERVICE) as android.telephony.SubscriptionManager + val hasActiveSubscription = if (checkSelfPermission(android.Manifest.permission.READ_PHONE_STATE) == + PackageManager.PERMISSION_GRANTED) + !sm.activeSubscriptionInfoList.isNullOrEmpty() + else + false + mobileUa.status = if (isAirplaneModeOn) + R.drawable.circle_white + else if (hasActiveSubscription) + circleGreen.getValue(colorblind) + else + circleRed.getValue(colorblind) + updateMobileStatus(mobileUa.status) val updatedUas = uas.value.toMutableList() updatedUas.add(mobileUa)