Merge "[Sims Enhancement] update the sim's name after renaming sim" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
89963e81ff
@@ -219,24 +219,24 @@ fun SimsSectionImpl(
|
|||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
}
|
}
|
||||||
//TODO: Add the Restricted TwoTargetSwitchPreference in SPA
|
//TODO: Add the Restricted TwoTargetSwitchPreference in SPA
|
||||||
TwoTargetSwitchPreference(remember {
|
TwoTargetSwitchPreference(
|
||||||
object : SwitchPreferenceModel {
|
object : SwitchPreferenceModel {
|
||||||
override val title = subInfo.displayName.toString()
|
override val title = subInfo.displayName.toString()
|
||||||
override val summary = { subInfo.number }
|
override val summary = { subInfo.number }
|
||||||
override val checked = {
|
override val checked = {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
withContext(Dispatchers.Default) {
|
withContext(Dispatchers.Default) {
|
||||||
checked.value = subscriptionManager?.isSubscriptionEnabled(
|
checked.value = subscriptionManager?.isSubscriptionEnabled(
|
||||||
subInfo.subscriptionId)?:false
|
subInfo.subscriptionId)?:false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
checked.value
|
||||||
|
}
|
||||||
|
override val onCheckedChange = { newChecked: Boolean ->
|
||||||
|
startToggleSubscriptionDialog(context, subInfo, newChecked)
|
||||||
}
|
}
|
||||||
checked.value
|
|
||||||
}
|
}
|
||||||
override val onCheckedChange = { newChecked: Boolean ->
|
) {
|
||||||
startToggleSubscriptionDialog(context, subInfo, newChecked)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}) {
|
|
||||||
startMobileNetworkSettings(context, subInfo)
|
startMobileNetworkSettings(context, subInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -258,7 +258,7 @@ fun SimsSectionImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PrimarySimSectionImpl(
|
fun PrimarySimImpl(
|
||||||
subscriptionInfoList: List<SubscriptionInfo>,
|
subscriptionInfoList: List<SubscriptionInfo>,
|
||||||
callsSelectedId: MutableIntState,
|
callsSelectedId: MutableIntState,
|
||||||
textsSelectedId: MutableIntState,
|
textsSelectedId: MutableIntState,
|
||||||
@@ -323,10 +323,12 @@ fun PrimarySimSectionImpl(
|
|||||||
callsAndSmsList.add(item)
|
callsAndSmsList.add(item)
|
||||||
dataList.add(item)
|
dataList.add(item)
|
||||||
}
|
}
|
||||||
callsAndSmsList.add(ListPreferenceOption(
|
callsAndSmsList.add(
|
||||||
|
ListPreferenceOption(
|
||||||
id = SubscriptionManager.INVALID_SUBSCRIPTION_ID,
|
id = SubscriptionManager.INVALID_SUBSCRIPTION_ID,
|
||||||
text = stringResource(id = R.string.sim_calls_ask_first_prefs_title)
|
text = stringResource(id = R.string.sim_calls_ask_first_prefs_title)
|
||||||
))
|
)
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
// hide the primary sim
|
// hide the primary sim
|
||||||
state.value = false
|
state.value = false
|
||||||
@@ -341,33 +343,31 @@ fun PrimarySimSectionImpl(
|
|||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
Category(title = stringResource(id = R.string.primary_sim_title)) {
|
CreatePrimarySimListPreference(
|
||||||
CreatePrimarySimListPreference(
|
stringResource(id = R.string.primary_sim_calls_title),
|
||||||
stringResource(id = R.string.primary_sim_calls_title),
|
callsAndSmsList,
|
||||||
callsAndSmsList,
|
callsSelectedId,
|
||||||
callsSelectedId,
|
ImageVector.vectorResource(R.drawable.ic_phone),
|
||||||
ImageVector.vectorResource(R.drawable.ic_phone),
|
actionSetCalls
|
||||||
actionSetCalls
|
)
|
||||||
)
|
CreatePrimarySimListPreference(
|
||||||
CreatePrimarySimListPreference(
|
stringResource(id = R.string.primary_sim_texts_title),
|
||||||
stringResource(id = R.string.primary_sim_texts_title),
|
callsAndSmsList,
|
||||||
callsAndSmsList,
|
textsSelectedId,
|
||||||
textsSelectedId,
|
Icons.AutoMirrored.Outlined.Message,
|
||||||
Icons.AutoMirrored.Outlined.Message,
|
actionSetTexts
|
||||||
actionSetTexts
|
)
|
||||||
)
|
CreatePrimarySimListPreference(
|
||||||
CreatePrimarySimListPreference(
|
stringResource(id = R.string.mobile_data_settings_title),
|
||||||
stringResource(id = R.string.mobile_data_settings_title),
|
dataList,
|
||||||
dataList,
|
mobileDataSelectedId,
|
||||||
mobileDataSelectedId,
|
Icons.Outlined.DataUsage,
|
||||||
Icons.Outlined.DataUsage,
|
actionSetMobileData
|
||||||
actionSetMobileData
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
val autoDataTitle = stringResource(id = R.string.primary_sim_automatic_data_title)
|
val autoDataTitle = stringResource(id = R.string.primary_sim_automatic_data_title)
|
||||||
val autoDataSummary = stringResource(id = R.string.primary_sim_automatic_data_msg)
|
val autoDataSummary = stringResource(id = R.string.primary_sim_automatic_data_msg)
|
||||||
SwitchPreference(remember {
|
SwitchPreference(
|
||||||
object : SwitchPreferenceModel {
|
object : SwitchPreferenceModel {
|
||||||
override val title = autoDataTitle
|
override val title = autoDataTitle
|
||||||
override val summary = { autoDataSummary }
|
override val summary = { autoDataSummary }
|
||||||
@@ -375,6 +375,11 @@ fun PrimarySimSectionImpl(
|
|||||||
if (nonDds.intValue != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
if (nonDds.intValue != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
automaticDataChecked.value = getAutomaticData(telephonyManagerForNonDds)
|
automaticDataChecked.value = getAutomaticData(telephonyManagerForNonDds)
|
||||||
|
Log.d(
|
||||||
|
NetworkCellularGroupProvider.name,
|
||||||
|
"NonDds:${nonDds.intValue}" +
|
||||||
|
"getAutomaticData:${automaticDataChecked.value}"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
automaticDataChecked.value
|
automaticDataChecked.value
|
||||||
@@ -384,7 +389,26 @@ fun PrimarySimSectionImpl(
|
|||||||
actionSetAutoDataSwitch(it)
|
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
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,32 +466,42 @@ private fun showEuiccSettings(context: Context): Boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun setDefaultVoice(
|
suspend fun setDefaultVoice(
|
||||||
subscriptionManager: SubscriptionManager?,
|
subscriptionManager: SubscriptionManager?,
|
||||||
subId: Int): Unit = withContext(Dispatchers.Default) {
|
subId: Int
|
||||||
subscriptionManager?.setDefaultVoiceSubscriptionId(subId)
|
): Unit =
|
||||||
}
|
withContext(Dispatchers.Default) {
|
||||||
|
subscriptionManager?.setDefaultVoiceSubscriptionId(subId)
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun setDefaultSms(
|
suspend fun setDefaultSms(
|
||||||
subscriptionManager: SubscriptionManager?,
|
subscriptionManager: SubscriptionManager?,
|
||||||
subId: Int): Unit = withContext(Dispatchers.Default) {
|
subId: Int
|
||||||
subscriptionManager?.setDefaultSmsSubId(subId)
|
): Unit =
|
||||||
}
|
withContext(Dispatchers.Default) {
|
||||||
|
subscriptionManager?.setDefaultSmsSubId(subId)
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun setDefaultData(context: Context,
|
suspend fun setDefaultData(
|
||||||
subscriptionManager: SubscriptionManager?,
|
context: Context,
|
||||||
wifiPickerTrackerHelper: WifiPickerTrackerHelper?,
|
subscriptionManager: SubscriptionManager?,
|
||||||
subId: Int): Unit = withContext(Dispatchers.Default) {
|
wifiPickerTrackerHelper: WifiPickerTrackerHelper?,
|
||||||
subscriptionManager?.setDefaultDataSubId(subId)
|
subId: Int
|
||||||
MobileNetworkUtils.setMobileDataEnabled(
|
): Unit =
|
||||||
|
withContext(Dispatchers.Default) {
|
||||||
|
subscriptionManager?.setDefaultDataSubId(subId)
|
||||||
|
MobileNetworkUtils.setMobileDataEnabled(
|
||||||
context,
|
context,
|
||||||
subId,
|
subId,
|
||||||
true /* enabled */,
|
true /* enabled */,
|
||||||
true /* disableOtherSubscriptions */)
|
true /* disableOtherSubscriptions */
|
||||||
if (wifiPickerTrackerHelper != null
|
)
|
||||||
&& !wifiPickerTrackerHelper.isCarrierNetworkProvisionEnabled(subId)) {
|
if (wifiPickerTrackerHelper != null
|
||||||
wifiPickerTrackerHelper.setCarrierNetworkEnabled(true)
|
&& !wifiPickerTrackerHelper.isCarrierNetworkProvisionEnabled(subId)
|
||||||
|
) {
|
||||||
|
wifiPickerTrackerHelper.setCarrierNetworkEnabled(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
suspend fun getAutomaticData(telephonyManagerForNonDds: TelephonyManager?): Boolean =
|
suspend fun getAutomaticData(telephonyManagerForNonDds: TelephonyManager?): Boolean =
|
||||||
withContext(Dispatchers.Default) {
|
withContext(Dispatchers.Default) {
|
||||||
telephonyManagerForNonDds != null
|
telephonyManagerForNonDds != null
|
||||||
@@ -478,7 +512,7 @@ suspend fun getAutomaticData(telephonyManagerForNonDds: TelephonyManager?): Bool
|
|||||||
suspend fun setAutomaticData(telephonyManager: TelephonyManager?, newState: Boolean): Unit =
|
suspend fun setAutomaticData(telephonyManager: TelephonyManager?, newState: Boolean): Unit =
|
||||||
withContext(Dispatchers.Default) {
|
withContext(Dispatchers.Default) {
|
||||||
Log.d(
|
Log.d(
|
||||||
"NetworkCellularGroupProvider",
|
NetworkCellularGroupProvider.name,
|
||||||
"setAutomaticData: MOBILE_DATA_POLICY_AUTO_DATA_SWITCH as $newState"
|
"setAutomaticData: MOBILE_DATA_POLICY_AUTO_DATA_SWITCH as $newState"
|
||||||
)
|
)
|
||||||
telephonyManager?.setMobileDataPolicyEnabled(
|
telephonyManager?.setMobileDataPolicyEnabled(
|
||||||
|
@@ -24,7 +24,6 @@ import androidx.compose.material.icons.outlined.SignalCellularAlt
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.MutableIntState
|
import androidx.compose.runtime.MutableIntState
|
||||||
import androidx.compose.runtime.mutableIntStateOf
|
import androidx.compose.runtime.mutableIntStateOf
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
@@ -82,7 +81,7 @@ fun SimOnboardingPrimarySimImpl(
|
|||||||
callsSelectedId.intValue = onboardingService.targetPrimarySimCalls
|
callsSelectedId.intValue = onboardingService.targetPrimarySimCalls
|
||||||
textsSelectedId.intValue = onboardingService.targetPrimarySimTexts
|
textsSelectedId.intValue = onboardingService.targetPrimarySimTexts
|
||||||
mobileDataSelectedId.intValue = onboardingService.targetPrimarySimMobileData
|
mobileDataSelectedId.intValue = onboardingService.targetPrimarySimMobileData
|
||||||
PrimarySimSectionImpl(
|
PrimarySimImpl(
|
||||||
subscriptionInfoList = selectedSubscriptionInfoList,
|
subscriptionInfoList = selectedSubscriptionInfoList,
|
||||||
callsSelectedId = callsSelectedId,
|
callsSelectedId = callsSelectedId,
|
||||||
textsSelectedId = textsSelectedId,
|
textsSelectedId = textsSelectedId,
|
||||||
@@ -110,7 +109,7 @@ fun CreatePrimarySimListPreference(
|
|||||||
selectedId: MutableIntState,
|
selectedId: MutableIntState,
|
||||||
icon: ImageVector,
|
icon: ImageVector,
|
||||||
onIdSelected: (id: Int) -> Unit
|
onIdSelected: (id: Int) -> Unit
|
||||||
) = ListPreference(remember {
|
) = ListPreference(
|
||||||
object : ListPreferenceModel {
|
object : ListPreferenceModel {
|
||||||
override val title = title
|
override val title = title
|
||||||
override val options = list
|
override val options = list
|
||||||
@@ -119,5 +118,4 @@ fun CreatePrimarySimListPreference(
|
|||||||
override val icon = @Composable {
|
override val icon = @Composable {
|
||||||
SettingsIcon(icon)
|
SettingsIcon(icon)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
Reference in New Issue
Block a user