Settings: Make SIM toggle unchangable when not supported

Fixes: https://gitlab.com/LineageOS/issues/android/-/issues/8290
Change-Id: I2e566c24969708c31f607af2baad88b388bda74d
This commit is contained in:
LuK1337 2025-02-10 14:51:51 +01:00 committed by Michael Bestas
parent 3df966cc65
commit 97c93a7017
No known key found for this signature in database

View file

@ -69,6 +69,11 @@ private fun SimPreference(subInfo: SubscriptionInfo) {
SubscriptionRepository(context).isSubscriptionEnabledFlow(subInfo.subscriptionId)
}.collectAsStateWithLifecycle(initialValue = false)
val phoneNumber = phoneNumber(subInfo)
val canDisablePhysicalSubscription by remember {
flow {
emit(SubscriptionRepository(context).canDisablePhysicalSubscription())
}
}.collectAsStateWithLifecycle(initialValue = false)
val isConvertedPsim by remember(subInfo) {
flow {
emit(SubscriptionUtil.isConvertedPsimSubscription(subInfo))
@ -90,7 +95,10 @@ private fun SimPreference(subInfo: SubscriptionInfo) {
}
}
override val icon = @Composable { SimIcon(subInfo.isEmbedded) }
override val changeable = { isActivationChangeable && !isConvertedPsim }
override val changeable = {
(subInfo.isEmbedded || canDisablePhysicalSubscription)
&& isActivationChangeable && !isConvertedPsim
}
override val checked = { checked.value }
override val onCheckedChange: (Boolean) -> Unit = { newChecked ->
coroutineScope.launch {