Loading src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt +96 −62 Original line number Diff line number Diff line Loading @@ -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 } Loading @@ -236,7 +236,7 @@ fun SimsSectionImpl( startToggleSubscriptionDialog(context, subInfo, newChecked) } } }) { ) { startMobileNetworkSettings(context, subInfo) } } Loading @@ -258,7 +258,7 @@ fun SimsSectionImpl( } @Composable fun PrimarySimSectionImpl( fun PrimarySimImpl( subscriptionInfoList: List<SubscriptionInfo>, callsSelectedId: MutableIntState, textsSelectedId: MutableIntState, Loading Loading @@ -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 Loading @@ -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, Loading @@ -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 } Loading @@ -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 Loading @@ -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 ) } } Loading Loading @@ -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 Loading @@ -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( Loading src/com/android/settings/spa/network/SimOnboardingPrimarySim.kt +2 −4 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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, Loading Loading @@ -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 Loading @@ -119,5 +118,4 @@ fun CreatePrimarySimListPreference( override val icon = @Composable { SettingsIcon(icon) } } }) No newline at end of file Loading
src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt +96 −62 Original line number Diff line number Diff line Loading @@ -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 } Loading @@ -236,7 +236,7 @@ fun SimsSectionImpl( startToggleSubscriptionDialog(context, subInfo, newChecked) } } }) { ) { startMobileNetworkSettings(context, subInfo) } } Loading @@ -258,7 +258,7 @@ fun SimsSectionImpl( } @Composable fun PrimarySimSectionImpl( fun PrimarySimImpl( subscriptionInfoList: List<SubscriptionInfo>, callsSelectedId: MutableIntState, textsSelectedId: MutableIntState, Loading Loading @@ -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 Loading @@ -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, Loading @@ -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 } Loading @@ -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 Loading @@ -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 ) } } Loading Loading @@ -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 Loading @@ -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( Loading
src/com/android/settings/spa/network/SimOnboardingPrimarySim.kt +2 −4 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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, Loading Loading @@ -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 Loading @@ -119,5 +118,4 @@ fun CreatePrimarySimListPreference( override val icon = @Composable { SettingsIcon(icon) } } }) No newline at end of file