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

Commit 0ac59e16 authored by Evan Laird's avatar Evan Laird
Browse files

[Mobile] Use CellSignalStrength.getNumSignalStrengthLevels

The existing mobile pipeline was mistakenly using a const val `4` for
the default number of levels. It should have been defined as `5`,
representing the levels 0-4 discretely.

This change configures the MobileConnectionRepository DEFAULT_NUM_LEVELS
to be defined in the same way as the old MobileSignalController.

Test: tests in pipeline/mobile
Test: manual via demo mode:
Test: adb shell am broadcast -a com.android.systemui.demo -e command network -e mobile show -e inflate true -e level 1
Fixes: 299689440
Flag: NONE
Change-Id: I26e52afdc09f126a9aba8d89af819c84e020fa1c
(cherry picked from commit 963a9fc8)
parent 0cdf6dea
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

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.log.table.TableLogBuffer
@@ -133,6 +134,6 @@ interface MobileConnectionRepository {

    companion object {
        /** The default number of levels to use for [numberOfLevels]. */
        const val DEFAULT_NUM_LEVELS = 4
        val DEFAULT_NUM_LEVELS = CellSignalStrength.getNumSignalStrengthLevels()
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.systemui.statusbar.pipeline.mobile.data.model.DataConnectionS
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.repository.MobileConnectionRepository
import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionRepository.Companion.DEFAULT_NUM_LEVELS
import com.android.systemui.statusbar.pipeline.mobile.data.repository.demo.model.FakeNetworkEventModel
import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.FullMobileConnectionRepository.Companion.COL_CARRIER_ID
import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.FullMobileConnectionRepository.Companion.COL_CARRIER_NETWORK_CHANGE
@@ -207,6 +208,9 @@ class DemoMobileConnectionRepository(

        _carrierId.value = event.carrierId ?: INVALID_SUBSCRIPTION_ID

        numberOfLevels.value =
            if (event.inflateStrength) DEFAULT_NUM_LEVELS + 1 else DEFAULT_NUM_LEVELS

        cdmaRoaming.value = event.roaming
        _isRoaming.value = event.roaming
        // TODO(b/261029387): not yet supported
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ constructor(
        val dataType = getString("datatype")?.toDataType()
        val slot = getString("slot")?.toInt()
        val carrierId = getString("carrierid")?.toInt()
        val inflateStrength = getString("inflate")?.toBoolean()
        val inflateStrength = getString("inflate").toBoolean()
        val activity = getString("activity")?.toActivity()
        val carrierNetworkChange = getString("carriernetworkchange") == "show"
        val roaming = getString("roam") == "show"
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ sealed interface FakeNetworkEventModel {
        // Null means the default (chosen by the repository)
        val subId: Int?,
        val carrierId: Int?,
        val inflateStrength: Boolean?,
        val inflateStrength: Boolean = false,
        @DataActivityType val activity: Int?,
        val carrierNetworkChange: Boolean,
        val roaming: Boolean,
+1 −6
Original line number Diff line number Diff line
@@ -271,12 +271,7 @@ class MobileIconInteractorImpl(
            }
            .stateIn(scope, SharingStarted.WhileSubscribed(), 0)

    private val numberOfLevels: StateFlow<Int> =
        connectionRepository.numberOfLevels.stateIn(
            scope,
            SharingStarted.WhileSubscribed(),
            connectionRepository.numberOfLevels.value,
        )
    private val numberOfLevels: StateFlow<Int> = connectionRepository.numberOfLevels

    override val isDataConnected: StateFlow<Boolean> =
        connectionRepository.dataConnectionState
Loading