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

Commit 89963e81 authored by SongFerng Wang's avatar SongFerng Wang Committed by Android (Google) Code Review
Browse files

Merge "[Sims Enhancement] update the sim's name after renaming sim" into main

parents 3f52a6c4 a70f208d
Loading
Loading
Loading
Loading
+96 −62
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ fun SimsSectionImpl(
            mutableStateOf(false)
        }
        //TODO: Add the Restricted TwoTargetSwitchPreference in SPA
        TwoTargetSwitchPreference(remember {
        TwoTargetSwitchPreference(
                object : SwitchPreferenceModel {
                    override val title = subInfo.displayName.toString()
                    override val summary = { subInfo.number }
@@ -236,7 +236,7 @@ fun SimsSectionImpl(
                        startToggleSubscriptionDialog(context, subInfo, newChecked)
                    }
                }
        }) {
        ) {
            startMobileNetworkSettings(context, subInfo)
        }
    }
@@ -258,7 +258,7 @@ fun SimsSectionImpl(
}

@Composable
fun PrimarySimSectionImpl(
fun PrimarySimImpl(
    subscriptionInfoList: List<SubscriptionInfo>,
    callsSelectedId: MutableIntState,
    textsSelectedId: MutableIntState,
@@ -323,10 +323,12 @@ fun PrimarySimSectionImpl(
            callsAndSmsList.add(item)
            dataList.add(item)
        }
        callsAndSmsList.add(ListPreferenceOption(
        callsAndSmsList.add(
            ListPreferenceOption(
                id = SubscriptionManager.INVALID_SUBSCRIPTION_ID,
                text = stringResource(id = R.string.sim_calls_ask_first_prefs_title)
        ))
            )
        )
    } else {
        // hide the primary sim
        state.value = false
@@ -341,7 +343,6 @@ fun PrimarySimSectionImpl(
            mutableStateOf(false)
        }

        Category(title = stringResource(id = R.string.primary_sim_title)) {
        CreatePrimarySimListPreference(
            stringResource(id = R.string.primary_sim_calls_title),
            callsAndSmsList,
@@ -363,11 +364,10 @@ fun PrimarySimSectionImpl(
            Icons.Outlined.DataUsage,
            actionSetMobileData
        )
        }

        val autoDataTitle = stringResource(id = R.string.primary_sim_automatic_data_title)
        val autoDataSummary = stringResource(id = R.string.primary_sim_automatic_data_msg)
        SwitchPreference(remember {
        SwitchPreference(
            object : SwitchPreferenceModel {
                override val title = autoDataTitle
                override val summary = { autoDataSummary }
@@ -375,6 +375,11 @@ fun PrimarySimSectionImpl(
                    if (nonDds.intValue != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
                        coroutineScope.launch {
                            automaticDataChecked.value = getAutomaticData(telephonyManagerForNonDds)
                            Log.d(
                                NetworkCellularGroupProvider.name,
                                "NonDds:${nonDds.intValue}" +
                                    "getAutomaticData:${automaticDataChecked.value}"
                            )
                        }
                    }
                    automaticDataChecked.value
@@ -384,7 +389,26 @@ fun PrimarySimSectionImpl(
                    actionSetAutoDataSwitch(it)
                }
            }
        })
        )
    }
}

@Composable
fun PrimarySimSectionImpl(
    subscriptionInfoList: List<SubscriptionInfo>,
    callsSelectedId: MutableIntState,
    textsSelectedId: MutableIntState,
    mobileDataSelectedId: MutableIntState,
    nonDds: MutableIntState,
) {
    Category(title = stringResource(id = R.string.primary_sim_title)) {
        PrimarySimImpl(
            subscriptionInfoList,
            callsSelectedId,
            textsSelectedId,
            mobileDataSelectedId,
            nonDds
        )
    }
}

@@ -443,31 +467,41 @@ private fun showEuiccSettings(context: Context): Boolean {

suspend fun setDefaultVoice(
    subscriptionManager: SubscriptionManager?,
        subId: Int): Unit = withContext(Dispatchers.Default) {
    subId: Int
): Unit =
    withContext(Dispatchers.Default) {
        subscriptionManager?.setDefaultVoiceSubscriptionId(subId)
    }

suspend fun setDefaultSms(
    subscriptionManager: SubscriptionManager?,
        subId: Int): Unit = withContext(Dispatchers.Default) {
    subId: Int
): Unit =
    withContext(Dispatchers.Default) {
        subscriptionManager?.setDefaultSmsSubId(subId)
    }

suspend fun setDefaultData(context: Context,
suspend fun setDefaultData(
    context: Context,
    subscriptionManager: SubscriptionManager?,
    wifiPickerTrackerHelper: WifiPickerTrackerHelper?,
                                   subId: Int): Unit = withContext(Dispatchers.Default) {
    subId: Int
): Unit =
    withContext(Dispatchers.Default) {
        subscriptionManager?.setDefaultDataSubId(subId)
        MobileNetworkUtils.setMobileDataEnabled(
            context,
            subId,
            true /* enabled */,
            true /* disableOtherSubscriptions */)
            true /* disableOtherSubscriptions */
        )
        if (wifiPickerTrackerHelper != null
            && !wifiPickerTrackerHelper.isCarrierNetworkProvisionEnabled(subId)) {
            && !wifiPickerTrackerHelper.isCarrierNetworkProvisionEnabled(subId)
        ) {
            wifiPickerTrackerHelper.setCarrierNetworkEnabled(true)
        }
    }

suspend fun getAutomaticData(telephonyManagerForNonDds: TelephonyManager?): Boolean =
    withContext(Dispatchers.Default) {
        telephonyManagerForNonDds != null
@@ -478,7 +512,7 @@ suspend fun getAutomaticData(telephonyManagerForNonDds: TelephonyManager?): Bool
suspend fun setAutomaticData(telephonyManager: TelephonyManager?, newState: Boolean): Unit =
    withContext(Dispatchers.Default) {
        Log.d(
            "NetworkCellularGroupProvider",
            NetworkCellularGroupProvider.name,
            "setAutomaticData: MOBILE_DATA_POLICY_AUTO_DATA_SWITCH as $newState"
        )
        telephonyManager?.setMobileDataPolicyEnabled(
+2 −4
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import androidx.compose.material.icons.outlined.SignalCellularAlt
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableIntState
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
@@ -82,7 +81,7 @@ fun SimOnboardingPrimarySimImpl(
        callsSelectedId.intValue = onboardingService.targetPrimarySimCalls
        textsSelectedId.intValue = onboardingService.targetPrimarySimTexts
        mobileDataSelectedId.intValue = onboardingService.targetPrimarySimMobileData
        PrimarySimSectionImpl(
        PrimarySimImpl(
            subscriptionInfoList = selectedSubscriptionInfoList,
            callsSelectedId = callsSelectedId,
            textsSelectedId = textsSelectedId,
@@ -110,7 +109,7 @@ fun CreatePrimarySimListPreference(
        selectedId: MutableIntState,
        icon: ImageVector,
        onIdSelected: (id: Int) -> Unit
) = ListPreference(remember {
) = ListPreference(
    object : ListPreferenceModel {
        override val title = title
        override val options = list
@@ -119,5 +118,4 @@ fun CreatePrimarySimListPreference(
        override val icon = @Composable {
            SettingsIcon(icon)
        }
    }
})
 No newline at end of file