Create WifiCallingRepository

Move Wi-Fi calling related feature into it.

Which simplifies the ImsMmTelRepository, so we can put more
ImsMmTelManager related features into ImsMmTelRepository in the future
cl.

Bug: 325414275
Test: manual - on Mobile Settings
Test: unit tests
Change-Id: I391f43cfa3a79e0c44865050c357ac54346c2fb1
This commit is contained in:
Chaohui Wang
2024-02-26 18:46:58 +08:00
parent 47905f7af8
commit b4ab4144aa
6 changed files with 184 additions and 84 deletions

View File

@@ -29,8 +29,7 @@ import androidx.lifecycle.repeatOnLifecycle
import androidx.preference.Preference
import androidx.preference.PreferenceScreen
import com.android.settings.R
import com.android.settings.network.telephony.ims.ImsMmTelRepository
import com.android.settings.network.telephony.ims.ImsMmTelRepositoryImpl
import com.android.settings.network.telephony.wificalling.WifiCallingRepository
import com.android.settingslib.spa.framework.util.collectLatestWithLifecycle
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
@@ -46,8 +45,8 @@ open class WifiCallingPreferenceController @JvmOverloads constructor(
context: Context,
key: String,
private val callStateFlowFactory: (subId: Int) -> Flow<Int> = context::callStateFlow,
private val imsMmTelRepositoryFactory: (subId: Int) -> ImsMmTelRepository = { subId ->
ImsMmTelRepositoryImpl(context, subId)
private val wifiCallingRepository: (subId: Int) -> WifiCallingRepository = { subId ->
WifiCallingRepository(context, subId)
},
) : TelephonyBasePreferenceController(context, key) {
@@ -123,7 +122,7 @@ open class WifiCallingPreferenceController @JvmOverloads constructor(
}
private fun getSummaryForWfcMode(): String {
val resId = when (imsMmTelRepositoryFactory(mSubId).getWiFiCallingMode()) {
val resId = when (wifiCallingRepository(mSubId).getWiFiCallingMode()) {
ImsMmTelManager.WIFI_MODE_WIFI_ONLY ->
com.android.internal.R.string.wfc_mode_wifi_only_summary