Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit fad7515a authored by LuK1337's avatar LuK1337
Browse files

fixup! Settings: Make SIM toggle unchangable when not supported

BP4A uses MobileNetworkMainSwitchPreference instead of
MobileNetworkSwitchController.

Change-Id: Ib29b4c5ec7dbf90b52551da300b9060dcadafe82
parent c3106657
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -67,7 +67,16 @@ class MobileNetworkMainSwitchPreference(
    override val disableWidgetOnCheckedChanged: Boolean
        get() = false

    override fun isAvailable(context: Context): Boolean = true
    override fun isAvailable(context: Context): Boolean {
        val subInfo =
            subscriptionRepository.getSelectableSubscriptionInfoList().firstOrNull {
                it.subscriptionId == subId
            } ?: return false
        // For eSIM, we always want the toggle. If telephony stack support disabling a pSIM
        // directly, we show the toggle.
        return subInfo.isEmbedded ||
            context.requireSubscriptionManager().canDisablePhysicalSubscription()
    }

    override fun tags(context: Context) = arrayOf(KEY_MOBILE_DATA)