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

Commit 3b18f643 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov Committed by Android (Google) Code Review
Browse files

Merge changes Ib60d2231,I03ee5334 into main

* changes:
  [SB] Allow carrier merged conns to inflate signal strength - Kairos
  [Kairos] Use repo for all fields in MobileConnectionRepoKairosAdapter
parents cdfbe009 dda80756
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
+2 −9
Original line number Diff line number Diff line
@@ -23,13 +23,10 @@ import com.android.systemui.kairos.ExperimentalKairosApi
import com.android.systemui.kairos.launchKairosNetwork
import com.android.systemui.kairos.stateOf
import com.android.systemui.kosmos.testScope
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.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

@@ -37,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() {

@@ -56,15 +52,12 @@ class CarrierMergedConnectionRepositoryKairosAdapterTest :
                            SUB_ID,
                            logger,
                            telephonyManager,
                            systemUiCarrierConfig,
                            kosmos.wifiRepository.fake,
                            isInEcmMode = stateOf(false),
                        )
                    }
                    adapter =
                        MobileConnectionRepositoryKairosAdapter(
                            repo,
                            SystemUiCarrierConfig(SUB_ID, testCarrierConfig()),
                        )
                    adapter = MobileConnectionRepositoryKairosAdapter(repo)
                    Unit
                }
            }
+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