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

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

Merge "[SB] Allow carrier merged connections to inflate their signal strength" into main

parents 7f40afe3 84603d66
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -473,6 +473,16 @@ flag {
    }
}

flag {
    name: "status_bar_inflate_carrier_merged"
    namespace: "systemui"
    description: "Allow the status bar to inflate the levels of the carrier merged connection"
    bug: "423686800"
    metadata {
      purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "icon_refresh_2025"
    namespace: "systemui"
+8 −1
Original line number Diff line number Diff line
@@ -33,9 +33,11 @@ Commands are sent as string extras with key ```command``` (required). Possible v
| ```network```        |                            |                  | Control the RSSI display
|                      | ```airplane```             |                  | ```show``` to show icon, any other value to hide
|                      | ```fully```                |                  | Sets MCS state to fully connected (```true```, ```false```)
|                      | ```wifi```                 |                  | ```show``` to show icon, any other value to hide
|                      | ```wifi```                 |                  | ```show``` to show icon, ```carriermerged``` to show a carrier merged (W+) connection, any other value to hide
|                      |                            | ```level```      | Sets wifi level (null or 0-4)
|                      |                            | ```hotspot```    | Sets the wifi to be from an Instant Hotspot. Values: ```none```, ```unknown```, ```phone```, ```tablet```, ```laptop```, ```watch```, ```auto```. (See `DemoModeWifiDataSource.kt`.)
|                      |                            | ```numlevels```  | Sets the default maximum number of levels (typically 5)
|                      |                            | ```inflate```    | True if numlevels should be increased by 1 (represents a carrier configuration)
|                      | ```mobile```               |                  | ```show``` to show icon, any other value to hide
|                      |                            | ```datatype```   | Values: ```1x```, ```3g```, ```4g```, ```e```, ```g```, ```h```, ```lte```, ```roam```, any other value to hide
|                      |                            | ```level```      | Sets mobile signal strength level (null or 0-4)
@@ -93,6 +95,11 @@ adb shell am broadcast -a com.android.systemui.demo -e command network -e wifi
show -e level 4
```

Set carrier merged to max

```
adb shell am broadcast -a com.android.systemui.demo -e command network -e wifi carriermerged -e slot 3 -e level 4 -e numlevels 5
```

Show the satellite icon

+4 −12
Original line number Diff line number Diff line
@@ -312,12 +312,7 @@ class DemoMobileConnectionsRepositoryTest : SysuiTestCase() {
            assertThat(latest).hasSize(1)

            fakeWifiEventFlow.value =
                FakeWifiEventModel.Wifi(
                    level = 1,
                    activity = 0,
                    ssid = null,
                    validated = true,
                )
                FakeWifiEventModel.Wifi(level = 1, activity = 0, ssid = null, validated = true)

            assertThat(latest).isEmpty()

@@ -376,12 +371,7 @@ class DemoMobileConnectionsRepositoryTest : SysuiTestCase() {

            // WHEN the carrier merged is removed
            fakeWifiEventFlow.value =
                FakeWifiEventModel.Wifi(
                    level = 4,
                    activity = 0,
                    ssid = null,
                    validated = true,
                )
                FakeWifiEventModel.Wifi(level = 4, activity = 0, ssid = null, validated = true)

            // THEN the subId=3 connection goes back to the mobile information
            connection = connections!!.find { it.subId == 3 }!!
@@ -629,11 +619,13 @@ fun validCarrierMergedEvent(
    subId: Int = 1,
    level: Int = 1,
    numberOfLevels: Int = 4,
    inflateSignalStrength: Boolean = false,
    activity: Int = DATA_ACTIVITY_NONE,
): FakeWifiEventModel.CarrierMerged =
    FakeWifiEventModel.CarrierMerged(
        subscriptionId = subId,
        level = level,
        numberOfLevels = numberOfLevels,
        inflateSignalStrength = inflateSignalStrength,
        activity = activity,
    )
+2 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ 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

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

+85 −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
@@ -27,9 +30,13 @@ import com.android.systemui.kosmos.runTest
import com.android.systemui.kosmos.testScope
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.mobile.data.repository.MobileConnectionRepository
import com.android.systemui.statusbar.pipeline.shared.data.model.DataActivityModel
import com.android.systemui.statusbar.pipeline.wifi.data.repository.fake
@@ -52,6 +59,7 @@ class CarrierMergedConnectionRepositoryTest : CarrierMergedConnectionRepositoryT
            SUB_ID,
            logger,
            telephonyManager,
            systemUiCarrierConfig,
            bgContext = kosmos.backgroundCoroutineContext,
            scope = kosmos.testScope.backgroundScope,
            kosmos.wifiRepository.fake,
@@ -66,6 +74,7 @@ abstract class CarrierMergedConnectionRepositoryTestBase : SysuiTestCase() {

    protected val logger = logcatTableLogBuffer(kosmos, "CarrierMergedConnectionRepositoryTest")
    protected val telephonyManager = mock<TelephonyManager>()
    protected val systemUiCarrierConfig = SystemUiCarrierConfig(SUB_ID, testCarrierConfig())

    abstract fun recreateRepo(): MobileConnectionRepository

@@ -199,6 +208,82 @@ abstract class CarrierMergedConnectionRepositoryTestBase : SysuiTestCase() {
            assertThat(latest).isEqualTo(6)
        }

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

            wifiRepository.fake.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() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.numberOfLevels)

            wifiRepository.fake.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() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.inflateSignalStrength)

            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() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.inflateSignalStrength)

            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() =
        kosmos.runTest {
Loading