Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2bdd5d1 authored by Evan Laird's avatar Evan Laird Committed by Android (Google) Code Review
Browse files

Merge changes I6c70a99c,I04cb436c,I7898aa30 into main

* changes:
  [sb] parameterize the disambigation text
  [sb] Expose a top-level `shouldHomeStatusBarBeVisible` flow
  [mobile] Represent invalid subIds as null
parents ce27eff9 32e9ae16
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ class FakeHomeStatusBarViewModel(

    override val isHomeStatusBarAllowedByScene = MutableStateFlow(false)

    override val shouldHomeStatusBarBeVisible = MutableStateFlow(false)

    override val shouldShowOperatorNameView = MutableStateFlow(false)

    override val isClockVisible =
+92 −0
Original line number Diff line number Diff line
@@ -574,6 +574,98 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() {
            assertThat(latest).isFalse()
        }

    @Test
    fun shouldHomeStatusBarBeVisible_keyguardNotGone_noHun_false() =
        kosmos.runTest {
            // Do not transition from keyguard. i.e., we don't call transitionKeyguardToGone()

            // Nothing disabled
            fakeDisableFlagsRepository.disableFlags.value =
                DisableFlagsModel(DISABLE_NONE, DISABLE2_NONE)

            val latest by collectLastValue(underTest.shouldHomeStatusBarBeVisible)
            assertThat(latest).isFalse()
        }

    @Test
    fun shouldHomeStatusBarBeVisible_keyguardNotGone_hun_true() =
        kosmos.runTest {
            // Keyguard gone
            transitionKeyguardToGone()

            // Nothing disabled
            fakeDisableFlagsRepository.disableFlags.value =
                DisableFlagsModel(DISABLE_NONE, DISABLE2_NONE)

            // there is an active HUN
            headsUpNotificationRepository.setNotifications(
                UnconfinedFakeHeadsUpRowRepository(
                    key = "key",
                    pinnedStatus = MutableStateFlow(PinnedStatus.PinnedByUser),
                )
            )

            val latest by collectLastValue(underTest.shouldHomeStatusBarBeVisible)
            assertThat(latest).isTrue()
        }

    @Test
    fun shouldHomeStatusBarBeVisible_keyguardGone_noHun_notInCamera_true() =
        kosmos.runTest {
            // Keyguard gone
            transitionKeyguardToGone()

            // Nothing disabled
            fakeDisableFlagsRepository.disableFlags.value =
                DisableFlagsModel(DISABLE_NONE, DISABLE2_NONE)

            val latest by collectLastValue(underTest.shouldHomeStatusBarBeVisible)
            assertThat(latest).isTrue()
        }

    @Test
    fun shouldHomeStatusBarBeVisible_keyguardGone_hun_notInCamera_true() =
        kosmos.runTest {
            // Keyguard gone
            transitionKeyguardToGone()

            // Nothing disabled
            fakeDisableFlagsRepository.disableFlags.value =
                DisableFlagsModel(DISABLE_NONE, DISABLE2_NONE)

            // there is an active HUN
            headsUpNotificationRepository.setNotifications(
                UnconfinedFakeHeadsUpRowRepository(
                    key = "key",
                    pinnedStatus = MutableStateFlow(PinnedStatus.PinnedByUser),
                )
            )

            val latest by collectLastValue(underTest.shouldHomeStatusBarBeVisible)
            assertThat(latest).isTrue()
        }

    @Test
    fun shouldHomeStatusBarBeVisible_keyguardGone_noHun_inCamera_false() =
        kosmos.runTest {
            // Keyguard gone
            transitionKeyguardToGone()

            // Nothing disabled
            fakeDisableFlagsRepository.disableFlags.value =
                DisableFlagsModel(DISABLE_NONE, DISABLE2_NONE)

            fakeKeyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.OCCLUDED,
                testScope = testScope,
            )
            kosmos.keyguardInteractor.onCameraLaunchDetected(CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP)

            val latest by collectLastValue(underTest.shouldHomeStatusBarBeVisible)
            assertThat(latest).isFalse()
        }

    @Test
    fun isClockVisible_allowedByDisableFlags_visible() =
        kosmos.runTest {
+13 −4
Original line number Diff line number Diff line
@@ -39,14 +39,12 @@ class StatusBarOperatorNameViewModelTest : SysuiTestCase() {
        kosmos.runTest {
            val intr1 = fakeMobileIconsInteractor.getMobileConnectionInteractorForSubId(1)
            val intr2 = fakeMobileIconsInteractor.getMobileConnectionInteractorForSubId(2)
            val invalidIntr = fakeMobileIconsInteractor.getMobileConnectionInteractorForSubId(-1)

            // GIVEN default data subId is 1
            fakeMobileIconsInteractor.defaultDataSubId.value = 1

            intr1.carrierName.value = "Test Name 1"
            intr2.carrierName.value = "Test Name 2"
            invalidIntr.carrierName.value = "default network name"

            val latest by collectLastValue(underTest.operatorName)

@@ -56,8 +54,19 @@ class StatusBarOperatorNameViewModelTest : SysuiTestCase() {

            assertThat(latest).isEqualTo("Test Name 2")

            fakeMobileIconsInteractor.defaultDataSubId.value = -1
            fakeMobileIconsInteractor.defaultDataSubId.value = null

            assertThat(latest).isEqualTo("default network name")
            assertThat(latest).isNull()
        }

    @Test
    fun operatorName_noDefaultDataSubId_null() =
        kosmos.runTest {
            // GIVEN defaultDataSubId is null
            fakeMobileIconsInteractor.defaultDataSubId.value = null

            val latest by collectLastValue(underTest.operatorName)

            assertThat(latest).isNull()
        }
}
+3 −0
Original line number Diff line number Diff line
@@ -25,6 +25,9 @@ object StatusBarRootModernization {
    /** Aconfig flag for removing the fragment */
    const val FLAG_NAME = Flags.FLAG_STATUS_BAR_ROOT_MODERNIZATION

    /** Shows a "compose->bar" text in the status bar for debug purposes */
    const val SHOW_DISAMBIGUATION = false

    /** A token used for dependency declaration */
    val token: FlagToken
        get() = FlagToken(FLAG_NAME, isEnabled)
+5 −2
Original line number Diff line number Diff line
@@ -34,6 +34,9 @@ interface CarrierConfigRepository {
     */
    suspend fun startObservingCarrierConfigUpdates()

    /** Gets a cached [SystemUiCarrierConfig], or creates a new one which will track the defaults */
    fun getOrCreateConfigForSubId(subId: Int): SystemUiCarrierConfig
    /**
     * Gets a cached [SystemUiCarrierConfig], or creates a new one which will track the defaults. A
     * null [maybeSubId] will return the default carrier config.
     */
    fun getOrCreateConfigForSubId(maybeSubId: Int?): SystemUiCarrierConfig
}
Loading