Reapply "Create CallStateRepository.isInCallFlow"

This reverts commit 93e4c65d3d.

Fixed the test by cherry-pick change
I7a3d27cb53c930a56ab0f0896b545807bf4f9dc0.

Bug: 336209156
Test: manual - on MobileNetworkSwitchController
Test: atest SubscriptionInfoListViewModelTest
Change-Id: Id606d6ee90acd8a98de706d8533fed0aac96bff4
This commit is contained in:
Chaohui Wang
2024-04-30 12:31:59 +08:00
parent f97e76bc3f
commit 7bbd8fa4e3
8 changed files with 217 additions and 37 deletions

View File

@@ -23,10 +23,8 @@ import android.telephony.TelephonyManager
import androidx.lifecycle.LifecycleOwner
import androidx.preference.Preference
import androidx.preference.PreferenceScreen
import com.android.settings.R
import com.android.settings.core.BasePreferenceController
import com.android.settings.network.SubscriptionUtil
import com.android.settings.network.telephony.MobileNetworkUtils
import com.android.settingslib.spa.framework.util.collectLatestWithLifecycle
/** This controls a preference allowing the user to delete the profile for an eSIM. */
@@ -57,9 +55,10 @@ class DeleteSimProfilePreferenceController(context: Context, preferenceKey: Stri
}
override fun onViewCreated(viewLifecycleOwner: LifecycleOwner) {
mContext.callStateFlow(subscriptionId).collectLatestWithLifecycle(viewLifecycleOwner) {
preference.isEnabled = (it == TelephonyManager.CALL_STATE_IDLE)
}
CallStateRepository(mContext).callStateFlow(subscriptionId)
.collectLatestWithLifecycle(viewLifecycleOwner) {
preference.isEnabled = (it == TelephonyManager.CALL_STATE_IDLE)
}
}
override fun handlePreferenceTreeClick(preference: Preference): Boolean {