From 736da0ca6cb043566ba92cfe1d8e50350d1df9f5 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Mon, 10 Feb 2025 14:51:51 +0100 Subject: [PATCH] Settings: Make SIM toggle unchangable when not supported Fixes: https://gitlab.com/LineageOS/issues/android/-/issues/8290 Change-Id: I2e566c24969708c31f607af2baad88b388bda74d --- src/com/android/settings/spa/network/SimsSection.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/spa/network/SimsSection.kt b/src/com/android/settings/spa/network/SimsSection.kt index cd1541fb4a1..d98129f6ab2 100644 --- a/src/com/android/settings/spa/network/SimsSection.kt +++ b/src/com/android/settings/spa/network/SimsSection.kt @@ -73,6 +73,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)) @@ -94,7 +99,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 {