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

Commit dda80756 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB] Allow carrier merged conns to inflate signal strength - Kairos

A re-implementation of If250be73b3b86ac31237d4e11327c6233bc0221f but in
the Kairos pipeline.

Bug: 423686800
Flag: com.android.systemui.status_bar_inflate_carrier_merged
Flag: com.android.systemui.status_bar_mobile_icon_kairos
Test: atest CarrierMergedConnectionRepositoryKairosAdapterTest
Test: atest CarrierMergedConnectionRepositoryKairosTest

Test: With new flag on and Kairos on:
 (adb shell am broadcast -a com.android.systemui.demo -e command
network -e wifi carriermerged -e slot 2 -e level 4 -e numlevels 5 -e
inflate false) -> verify triangle with W+ displays with 4/4 bars filled
in (numlevels=5 means the level can be in range [0-4])
 (adb shell am broadcast -a com.android.systemui.demo -e command
network -e wifi carriermerged -e slot 2 -e level 4 -e numlevels 5 -e
inflate true) -> verify triangle with W+ displays with 5/5 bars filled
in

Test: With new flag off: Verify those same test cases, but that they all
show 4/4 bars filled in

Change-Id: Ib60d22310687efe78e9e880838113cde2fde80b0
parent c5be0e43
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -116,8 +116,7 @@ adb shell am broadcast -a com.android.systemui.demo -e command network -e mobile
Set the wifi level to max

```
adb shell am broadcast -a com.android.systemui.demo -e command network -e wifi
show -e level 4
adb shell am broadcast -a com.android.systemui.demo -e command network -e wifi show -e level 4
```

Set carrier merged to max
+1 −2
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import com.android.systemui.statusbar.pipeline.wifi.data.repository.fake
import com.android.systemui.statusbar.pipeline.wifi.data.repository.wifiRepository
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import org.junit.Ignore
import org.junit.runner.RunWith
import org.mockito.Mockito

@@ -35,7 +34,6 @@ import org.mockito.Mockito
@SmallTest
@RunWith(AndroidJUnit4::class)
@android.platform.test.annotations.EnabledOnRavenwood
@Ignore("b/423686800") // Re-enable once carrier merged inflation is implemented in Kairos
class CarrierMergedConnectionRepositoryKairosAdapterTest :
    CarrierMergedConnectionRepositoryTestBase() {

@@ -54,6 +52,7 @@ class CarrierMergedConnectionRepositoryKairosAdapterTest :
                            SUB_ID,
                            logger,
                            telephonyManager,
                            systemUiCarrierConfig,
                            kosmos.wifiRepository.fake,
                            isInEcmMode = stateOf(false),
                        )
+82 −0
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package com.android.systemui.statusbar.pipeline.mobile.data.repository.prod

import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.telephony.CarrierConfigManager.KEY_INFLATE_SIGNAL_STRENGTH_BOOL
import android.telephony.TelephonyManager
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
@@ -29,9 +32,13 @@ import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.log.table.logcatTableLogBuffer
import com.android.systemui.statusbar.pipeline.StatusBarInflateCarrierMerged
import com.android.systemui.statusbar.pipeline.mobile.data.model.DataConnectionState
import com.android.systemui.statusbar.pipeline.mobile.data.model.NetworkNameModel
import com.android.systemui.statusbar.pipeline.mobile.data.model.ResolvedNetworkType
import com.android.systemui.statusbar.pipeline.mobile.data.model.SystemUiCarrierConfig
import com.android.systemui.statusbar.pipeline.mobile.data.model.testCarrierConfig
import com.android.systemui.statusbar.pipeline.mobile.data.model.testCarrierConfigWithOverride
import com.android.systemui.statusbar.pipeline.shared.data.model.DataActivityModel
import com.android.systemui.statusbar.pipeline.wifi.data.repository.fakeWifiRepository
import com.android.systemui.statusbar.pipeline.wifi.data.repository.wifiRepository
@@ -50,11 +57,14 @@ import org.mockito.kotlin.stub
@android.platform.test.annotations.EnabledOnRavenwood
class CarrierMergedConnectionRepositoryKairosTest : SysuiTestCase() {

    private val systemUiCarrierConfig = SystemUiCarrierConfig(SUB_ID, testCarrierConfig())

    private val Kosmos.underTest by ActivatedKairosFixture {
        CarrierMergedConnectionRepositoryKairos(
            subId = SUB_ID,
            tableLogBuffer = logcatTableLogBuffer(this),
            telephonyManager = telephonyManager,
            systemUiCarrierConfig = systemUiCarrierConfig,
            wifiRepository = wifiRepository,
            isInEcmMode = stateOf(false),
        )
@@ -187,6 +197,78 @@ class CarrierMergedConnectionRepositoryKairosTest : SysuiTestCase() {
        assertThat(latest).isEqualTo(6)
    }

    @Test
    @EnableFlags(StatusBarInflateCarrierMerged.FLAG_NAME)
    fun numberOfLevels_comesFromCarrierMerged_andInflated() = runTest {
        val latest by underTest.numberOfLevels.collectLastValue()

        fakeWifiRepository.setWifiNetwork(
            WifiNetworkModel.CarrierMerged.of(
                subscriptionId = SUB_ID,
                level = 1,
                numberOfLevels = 6,
            )
        )
        systemUiCarrierConfig.processNewCarrierConfig(
            testCarrierConfigWithOverride(KEY_INFLATE_SIGNAL_STRENGTH_BOOL, true)
        )

        assertThat(latest).isEqualTo(7)
    }

    @Test
    @DisableFlags(StatusBarInflateCarrierMerged.FLAG_NAME)
    fun numberOfLevels_flagDisabled_ignoresInflated() = runTest {
        val latest by underTest.numberOfLevels.collectLastValue()

        fakeWifiRepository.setWifiNetwork(
            WifiNetworkModel.CarrierMerged.of(
                subscriptionId = SUB_ID,
                level = 1,
                numberOfLevels = 6,
            )
        )
        systemUiCarrierConfig.processNewCarrierConfig(
            testCarrierConfigWithOverride(KEY_INFLATE_SIGNAL_STRENGTH_BOOL, true)
        )

        assertThat(latest).isEqualTo(6)
    }

    @Test
    @DisableFlags(StatusBarInflateCarrierMerged.FLAG_NAME)
    fun inflateSignalStrength_flagDisabled_alwaysFalse() = runTest {
        val latest by underTest.inflateSignalStrength.collectLastValue()

        assertThat(latest).isEqualTo(false)

        systemUiCarrierConfig.processNewCarrierConfig(
            testCarrierConfigWithOverride(KEY_INFLATE_SIGNAL_STRENGTH_BOOL, true)
        )

        assertThat(latest).isEqualTo(false)
    }

    @Test
    @EnableFlags(StatusBarInflateCarrierMerged.FLAG_NAME)
    fun inflateSignalStrength_usesCarrierConfig() = runTest {
        val latest by underTest.inflateSignalStrength.collectLastValue()

        assertThat(latest).isEqualTo(false)

        systemUiCarrierConfig.processNewCarrierConfig(
            testCarrierConfigWithOverride(KEY_INFLATE_SIGNAL_STRENGTH_BOOL, true)
        )

        assertThat(latest).isEqualTo(true)

        systemUiCarrierConfig.processNewCarrierConfig(
            testCarrierConfigWithOverride(KEY_INFLATE_SIGNAL_STRENGTH_BOOL, false)
        )

        assertThat(latest).isEqualTo(false)
    }

    @Test
    fun dataEnabled_matchesWifiEnabled() = runTest {
        val latest by underTest.dataEnabled.collectLastValue()
+1 −0
Original line number Diff line number Diff line
@@ -522,6 +522,7 @@ class FullMobileConnectionRepositoryKairosTest : SysuiTestCase() {
                subId = SUB_ID,
                tableLogBuffer = mobileLogger,
                telephonyManager = telephonyManager,
                systemUiCarrierConfig = systemUiCarrierConfig,
                wifiRepository = wifiRepository,
                isInEcmMode = stateOf(false),
            )
+25 −0
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ package com.android.systemui.statusbar.pipeline.mobile.data.repository
import android.telephony.CellSignalStrength
import android.telephony.SubscriptionInfo
import android.telephony.TelephonyManager
import com.android.systemui.kairos.ExperimentalKairosApi
import com.android.systemui.kairos.State
import com.android.systemui.kairos.combine as kairosCombine
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.statusbar.pipeline.mobile.data.model.DataConnectionState
import com.android.systemui.statusbar.pipeline.mobile.data.model.NetworkNameModel
@@ -223,5 +226,27 @@ interface MobileConnectionRepository {
                }
                .stateIn(scope, SharingStarted.WhileSubscribed(), default.value)
        }

        /**
         * Automatically implements [MobileConnectionRepository.numberOfLevels] based on the
         * [inflateSignalStrength] value, but for Kairos states.
         *
         * @param default The default number of levels to use if [inflateSignalStrength] is false.
         */
        @ExperimentalKairosApi
        fun createNumberOfLevelsState(
            inflateSignalStrength: State<Boolean>,
            default: State<Int>,
        ): State<Int> {
            return kairosCombine(default, inflateSignalStrength) {
                defaultNumberOfLevels,
                shouldInflate ->
                if (shouldInflate) {
                    defaultNumberOfLevels + 1
                } else {
                    defaultNumberOfLevels
                }
            }
        }
    }
}
Loading