From 970a8f60258a2ae2c8f4b9528a37808dda45fcc1 Mon Sep 17 00:00:00 2001 From: Caitlin Shkuratov Date: Thu, 4 May 2023 19:36:38 +0000 Subject: [PATCH] [SB Refactor] Use the calculated mobileIsDefault for failed connection. This is not directly related to b/225902574 but I noticed it while looking at that issue. In the case where carrier merged comes through a WIFI connection, it would never show the ! because mobileIsDefault=false. However, the carrier merged connection could be non-validated, in which case we *should* show the ! (but wouldn't right now). This CL updates the `isDefaultConnectionFailed` calculation to also show the ! if carrier merged is default and not validated. It does this by using the interactor's interally calculated `mobileIsDefault` flow, which includes carrier merged (as opposed to the repo's `mobileIsDefault` flow, which does not include carrier merged). Bug: 225902574 Test: atest MobileIconsInteractorTest Change-Id: Ic79cc1755a67400de067a51abcf654b1294b7fe1 --- .../domain/interactor/MobileIconsInteractor.kt | 2 +- .../interactor/MobileIconsInteractorTest.kt | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractor.kt index eec91a0bca825..e1ffae01be032 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractor.kt @@ -259,7 +259,7 @@ constructor( */ override val isDefaultConnectionFailed: StateFlow = combine( - mobileConnectionsRepo.mobileIsDefault, + mobileIsDefault, mobileConnectionsRepo.defaultConnectionIsValidated, forcingCellularValidation, ) { mobileIsDefault, defaultConnectionIsValidated, forcingCellularValidation -> diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractorTest.kt index 6e1ab58db56d2..1c219da09e276 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractorTest.kt @@ -361,6 +361,21 @@ class MobileIconsInteractorTest : SysuiTestCase() { job.cancel() } + @Test + fun failedConnection_carrierMergedDefault_notValidated_failed() = + testScope.runTest { + var latest: Boolean? = null + val job = underTest.isDefaultConnectionFailed.onEach { latest = it }.launchIn(this) + + connectionsRepository.hasCarrierMergedConnection.value = true + connectionsRepository.defaultConnectionIsValidated.value = false + yield() + + assertThat(latest).isTrue() + + job.cancel() + } + /** Regression test for b/275076959. */ @Test fun failedConnection_dataSwitchInSameGroup_notFailed() =