Loading src/com/android/settings/network/telephony/VideoCallingPreferenceController.kt +14 −7 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ constructor( private var subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID private var preference: TwoStatePreference? = null private var callingPreferenceCategoryController: CallingPreferenceCategoryController? = null private var isVisible = false private var videoCallEditable = false private var isInCall = false Loading @@ -66,21 +66,26 @@ constructor( } // Availability is controlled in onViewCreated() and VideoCallingSearchItem. override fun getAvailabilityStatus() = AVAILABLE override fun getAvailabilityStatus() = if (isVisible) AVAILABLE else CONDITIONALLY_UNAVAILABLE override fun displayPreference(screen: PreferenceScreen) { super.displayPreference(screen) preference = screen.findPreference(preferenceKey) Log.d(TAG, "init ui") preference?.isVisible = false callingPreferenceCategoryController?.updateChildVisible(preferenceKey, false) Log.d( TAG, "displayPreference: isVisible: $isVisible, videoCallEditable: $videoCallEditable" ) } override fun onViewCreated(viewLifecycleOwner: LifecycleOwner) { videoCallingRepository.isVideoCallReadyFlow(subId) .collectLatestWithLifecycle(viewLifecycleOwner) { isReady -> Log.d(TAG, "isVideoCallReadyFlow: update visible") preference?.isVisible = isReady Log.d(TAG, "isVideoCallReadyFlow: update visible: $isReady") isVisible = isReady preference?.let{ it.isVisible = isVisible updateState(it) } callingPreferenceCategoryController?.updateChildVisible(preferenceKey, isReady) } callStateRepository.callStateFlow(subId).collectLatestWithLifecycle(viewLifecycleOwner) { Loading @@ -92,8 +97,10 @@ constructor( override fun updateState(preference: Preference) { super.updateState(preference) videoCallEditable = queryVoLteState(subId).isEnabledByUser && queryImsState(subId).isAllowUserControl Log.d(TAG, "updateState: update videoCallEditable: $videoCallEditable") updatePreference() } Loading tests/spa_unit/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.kt +22 −1 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ class VideoCallingPreferenceControllerTest { } @Test fun onViewCreated_videoCallIsNotReady_isShown() = runBlocking { fun onViewCreated_videoCallIsReady_isShown() = runBlocking { mockVideoCallingRepository.stub { on { isVideoCallReadyFlow(SUB_ID) } doReturn flowOf(true) } Loading @@ -109,6 +109,27 @@ class VideoCallingPreferenceControllerTest { assertThat(preference.isVisible).isTrue() } @Test fun onViewCreated_videoCallIsReady_enabledAndChecked() = runBlocking { mockVideoCallingRepository.stub { on { isVideoCallReadyFlow(SUB_ID) } doReturn flowOf(true) } mockVtQueryImsState.stub { on { isEnabledByUser } doReturn true on { isAllowUserControl } doReturn true } mockQueryVoLteState.stub { on { isEnabledByUser } doReturn true } mockCallStateRepository.stub { on { callStateFlow(SUB_ID) } doReturn flowOf(TelephonyManager.CALL_STATE_IDLE) } controller.onViewCreated(TestLifecycleOwner()) delay(100) assertThat(preference.isEnabled).isTrue() assertThat(preference.isChecked).isTrue() } @Test fun updateState_4gLteOff_disabledAndUnchecked() { mockQueryVoLteState.stub { on { isEnabledByUser } doReturn false } Loading Loading
src/com/android/settings/network/telephony/VideoCallingPreferenceController.kt +14 −7 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ constructor( private var subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID private var preference: TwoStatePreference? = null private var callingPreferenceCategoryController: CallingPreferenceCategoryController? = null private var isVisible = false private var videoCallEditable = false private var isInCall = false Loading @@ -66,21 +66,26 @@ constructor( } // Availability is controlled in onViewCreated() and VideoCallingSearchItem. override fun getAvailabilityStatus() = AVAILABLE override fun getAvailabilityStatus() = if (isVisible) AVAILABLE else CONDITIONALLY_UNAVAILABLE override fun displayPreference(screen: PreferenceScreen) { super.displayPreference(screen) preference = screen.findPreference(preferenceKey) Log.d(TAG, "init ui") preference?.isVisible = false callingPreferenceCategoryController?.updateChildVisible(preferenceKey, false) Log.d( TAG, "displayPreference: isVisible: $isVisible, videoCallEditable: $videoCallEditable" ) } override fun onViewCreated(viewLifecycleOwner: LifecycleOwner) { videoCallingRepository.isVideoCallReadyFlow(subId) .collectLatestWithLifecycle(viewLifecycleOwner) { isReady -> Log.d(TAG, "isVideoCallReadyFlow: update visible") preference?.isVisible = isReady Log.d(TAG, "isVideoCallReadyFlow: update visible: $isReady") isVisible = isReady preference?.let{ it.isVisible = isVisible updateState(it) } callingPreferenceCategoryController?.updateChildVisible(preferenceKey, isReady) } callStateRepository.callStateFlow(subId).collectLatestWithLifecycle(viewLifecycleOwner) { Loading @@ -92,8 +97,10 @@ constructor( override fun updateState(preference: Preference) { super.updateState(preference) videoCallEditable = queryVoLteState(subId).isEnabledByUser && queryImsState(subId).isAllowUserControl Log.d(TAG, "updateState: update videoCallEditable: $videoCallEditable") updatePreference() } Loading
tests/spa_unit/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.kt +22 −1 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ class VideoCallingPreferenceControllerTest { } @Test fun onViewCreated_videoCallIsNotReady_isShown() = runBlocking { fun onViewCreated_videoCallIsReady_isShown() = runBlocking { mockVideoCallingRepository.stub { on { isVideoCallReadyFlow(SUB_ID) } doReturn flowOf(true) } Loading @@ -109,6 +109,27 @@ class VideoCallingPreferenceControllerTest { assertThat(preference.isVisible).isTrue() } @Test fun onViewCreated_videoCallIsReady_enabledAndChecked() = runBlocking { mockVideoCallingRepository.stub { on { isVideoCallReadyFlow(SUB_ID) } doReturn flowOf(true) } mockVtQueryImsState.stub { on { isEnabledByUser } doReturn true on { isAllowUserControl } doReturn true } mockQueryVoLteState.stub { on { isEnabledByUser } doReturn true } mockCallStateRepository.stub { on { callStateFlow(SUB_ID) } doReturn flowOf(TelephonyManager.CALL_STATE_IDLE) } controller.onViewCreated(TestLifecycleOwner()) delay(100) assertThat(preference.isEnabled).isTrue() assertThat(preference.isChecked).isTrue() } @Test fun updateState_4gLteOff_disabledAndUnchecked() { mockQueryVoLteState.stub { on { isEnabledByUser } doReturn false } Loading