Improved detection if SIM card is available
This commit is contained in:
@ -2229,8 +2229,19 @@ class BaresipService: Service() {
|
|||||||
account.telProvider = ""
|
account.telProvider = ""
|
||||||
val mobileUa = UserAgent(0L, account)
|
val mobileUa = UserAgent(0L, account)
|
||||||
val isAirplaneModeOn = Settings.Global.getInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0) != 0
|
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)
|
val sm = getSystemService(TELEPHONY_SUBSCRIPTION_SERVICE) as android.telephony.SubscriptionManager
|
||||||
updateMobileStatus()
|
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()
|
val updatedUas = uas.value.toMutableList()
|
||||||
updatedUas.add(mobileUa)
|
updatedUas.add(mobileUa)
|
||||||
|
|||||||
Reference in New Issue
Block a user