VideoCalling UI adds the init value

Bug: 367696228
Test: atest VideoCallingPreferenceControllerTest
Flag: EXEMPT bugfix
Change-Id: I1a1de9e3174a9211be619c96c104607f831b51a2
This commit is contained in:
songferngwang
2024-10-03 13:49:56 +00:00
parent 1955144ffc
commit 8e6bc6f289
2 changed files with 57 additions and 8 deletions

View File

@@ -44,12 +44,12 @@ constructor(
context: Context,
key: String,
private val callStateRepository: CallStateRepository = CallStateRepository(context),
private val videoCallingRepository: VideoCallingRepository = VideoCallingRepository(context),
) : TogglePreferenceController(context, key), On4gLteUpdateListener {
private var subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID
private var preference: TwoStatePreference? = null
private var callingPreferenceCategoryController: CallingPreferenceCategoryController? = null
private val repository = VideoCallingRepository(context)
private var videoCallEditable = false
private var isInCall = false
@@ -71,14 +71,18 @@ constructor(
override fun displayPreference(screen: PreferenceScreen) {
super.displayPreference(screen)
preference = screen.findPreference(preferenceKey)
Log.d(TAG, "init ui")
preference?.isVisible = false
callingPreferenceCategoryController?.updateChildVisible(preferenceKey, false)
}
override fun onViewCreated(viewLifecycleOwner: LifecycleOwner) {
repository.isVideoCallReadyFlow(subId).collectLatestWithLifecycle(viewLifecycleOwner) {
isReady ->
preference?.isVisible = isReady
callingPreferenceCategoryController?.updateChildVisible(preferenceKey, isReady)
}
videoCallingRepository.isVideoCallReadyFlow(subId)
.collectLatestWithLifecycle(viewLifecycleOwner) { isReady ->
Log.d(TAG, "isVideoCallReadyFlow: update visible")
preference?.isVisible = isReady
callingPreferenceCategoryController?.updateChildVisible(preferenceKey, isReady)
}
callStateRepository.callStateFlow(subId).collectLatestWithLifecycle(viewLifecycleOwner) {
callState ->
isInCall = callState != TelephonyManager.CALL_STATE_IDLE
@@ -129,10 +133,10 @@ constructor(
class VideoCallingSearchItem(private val context: Context) :
MobileNetworkSettingsSearchItem {
private val repository = VideoCallingRepository(context)
private val videoCallingRepository = VideoCallingRepository(context)
private fun isAvailable(subId: Int): Boolean = runBlocking {
repository.isVideoCallReadyFlow(subId).first()
videoCallingRepository.isVideoCallReadyFlow(subId).first()
}
override fun getSearchResult(subId: Int): MobileNetworkSettingsSearchResult? {