Setup backup calling for new UI

Backup calling new handles by CrossSimCallingViewModel.
CrossSimCallingViewModel keep monitoring the active SIMs, and setup
backup calling if needed.

Fix: 340444839
Test: manual - SIMs
Test: manual - Mobile Settings
Test: unit test
Change-Id: I0a3451f1e8c3984b2348cf628fb1d91ce7aaecec
This commit is contained in:
Chaohui Wang
2024-05-23 16:24:41 +08:00
parent 5b0211ea75
commit 59a28a244c
11 changed files with 203 additions and 111 deletions

View File

@@ -20,8 +20,10 @@ import android.telephony.TelephonyManager
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.res.stringResource
import androidx.lifecycle.viewmodel.compose.viewModel
import com.android.settings.R
import com.android.settings.network.telephony.TelephonyRepository
import com.android.settings.network.telephony.wificalling.CrossSimCallingViewModel
import com.android.settingslib.spa.widget.preference.SwitchPreference
import com.android.settingslib.spa.widget.preference.SwitchPreferenceModel
import kotlinx.coroutines.Dispatchers
@@ -34,6 +36,7 @@ fun AutomaticDataSwitchingPreference(
) {
val autoDataSummary = stringResource(id = R.string.primary_sim_automatic_data_msg)
val coroutineScope = rememberCoroutineScope()
val crossSimCallingViewModel = viewModel<CrossSimCallingViewModel>() // handles backup calling
SwitchPreference(
object : SwitchPreferenceModel {
override val title = stringResource(id = R.string.primary_sim_automatic_data_title)
@@ -42,6 +45,7 @@ fun AutomaticDataSwitchingPreference(
override val onCheckedChange: (Boolean) -> Unit = { newEnabled ->
coroutineScope.launch(Dispatchers.Default) {
setAutoDataEnabled(newEnabled)
crossSimCallingViewModel.updateCrossSimCalling()
}
}
}
@@ -54,5 +58,4 @@ fun TelephonyRepository.setAutomaticData(subId: Int, newEnabled: Boolean) {
policy = TelephonyManager.MOBILE_DATA_POLICY_AUTO_DATA_SWITCH,
enabled = newEnabled,
)
//TODO: setup backup calling
}