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

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

Merge changes I450a5839,Ifa55ad81 into main

* changes:
  Revert^2 [Mobile] Make sure we +1 the reported level if INFLATE_SIGNAL_STRENGTH is true
  [Mobile] Wrap AccessibilityContentDescriptions in a static getter
parents 92e47456 5166fa4c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1673,6 +1673,8 @@
    <string name="accessibility_phone_two_bars">Phone two bars.</string>
    <!-- Content description of the phone signal when it is three bars for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_phone_three_bars">Phone three bars.</string>
    <!-- Content description of the phone signal when it is four bars for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_phone_four_bars">Phone four bars.</string>
    <!-- Content description of the phone signal when it is full for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_phone_signal_full">Phone signal full.</string>

+53 −0
Original line number Diff line number Diff line
@@ -33,6 +33,59 @@ public class AccessibilityContentDescriptions {
        R.string.accessibility_phone_signal_full
    };

    /**
     * @param level int in range [0-4] that describes the signal level
     * @return the appropriate content description for that signal strength, or 0 if the param is
     *         invalid
     */
    public static int getDescriptionForLevel(int level) {
        if (level > 4 || level < 0) {
            return 0;
        }

        return PHONE_SIGNAL_STRENGTH[level];
    }

    public static final int[] PHONE_SIGNAL_STRENGTH_INFLATED = {
            PHONE_SIGNAL_STRENGTH_NONE,
            R.string.accessibility_phone_one_bar,
            R.string.accessibility_phone_two_bars,
            R.string.accessibility_phone_three_bars,
            R.string.accessibility_phone_four_bars,
            R.string.accessibility_phone_signal_full
    };

    /**
     * @param level int in range [0-5] that describes the inflated signal level
     * @return the appropriate content description for that signal strength, or 0 if the param is
     *         invalid
     */
    public static int getDescriptionForInflatedLevel(int level) {
        if (level > 5 || level < 0) {
            return 0;
        }

        return PHONE_SIGNAL_STRENGTH_INFLATED[level];
    }

    /**
     * @param level int in range [0-5] that describes the inflated signal level
     * @param numberOfLevels one of (4, 5) that describes the default number of levels, or the
     *                       inflated number of levels. The level param should be relative to the
     *                       number of levels. This won't do any inflation.
     * @return the appropriate content description for that signal strength, or 0 if the param is
     *         invalid
     */
    public static int getDescriptionForLevel(int level, int numberOfLevels) {
        if (numberOfLevels == 5) {
            return getDescriptionForLevel(level);
        } else if (numberOfLevels == 6) {
            return getDescriptionForInflatedLevel(level);
        } else {
            return 0;
        }
    }

    public static final int[] DATA_CONNECTION_STRENGTH = {
        R.string.accessibility_no_data,
        R.string.accessibility_data_one_bar,
+3 −0
Original line number Diff line number Diff line
@@ -44,6 +44,9 @@ interface MobileConnectionRepository {
    /** The carrierId for this connection. See [TelephonyManager.getSimCarrierId] */
    val carrierId: StateFlow<Int>

    /** Reflects the value from the carrier config INFLATE_SIGNAL_STRENGTH for this connection */
    val inflateSignalStrength: StateFlow<Boolean>

    /**
     * The table log buffer created for this connection. Will have the name "MobileConnectionLog
     * [subId]"
+23 −4
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.systemui.statusbar.pipeline.wifi.data.repository.demo.model.F
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn

/**
@@ -67,6 +68,17 @@ class DemoMobileConnectionRepository(
            )
            .stateIn(scope, SharingStarted.WhileSubscribed(), _carrierId.value)

    private val _inflateSignalStrength: MutableStateFlow<Boolean> = MutableStateFlow(false)
    override val inflateSignalStrength =
        _inflateSignalStrength
            .logDiffsForTable(
                tableLogBuffer,
                columnPrefix = "",
                columnName = "inflate",
                _inflateSignalStrength.value
            )
            .stateIn(scope, SharingStarted.WhileSubscribed(), _inflateSignalStrength.value)

    private val _isEmergencyOnly = MutableStateFlow(false)
    override val isEmergencyOnly =
        _isEmergencyOnly
@@ -191,7 +203,16 @@ class DemoMobileConnectionRepository(
            .logDiffsForTable(tableLogBuffer, columnPrefix = "", _resolvedNetworkType.value)
            .stateIn(scope, SharingStarted.WhileSubscribed(), _resolvedNetworkType.value)

    override val numberOfLevels = MutableStateFlow(MobileConnectionRepository.DEFAULT_NUM_LEVELS)
    override val numberOfLevels =
        _inflateSignalStrength
            .map { shouldInflate ->
                if (shouldInflate) {
                    DEFAULT_NUM_LEVELS + 1
                } else {
                    DEFAULT_NUM_LEVELS
                }
            }
            .stateIn(scope, SharingStarted.WhileSubscribed(), DEFAULT_NUM_LEVELS)

    override val dataEnabled = MutableStateFlow(true)

@@ -226,8 +247,7 @@ class DemoMobileConnectionRepository(

        _carrierId.value = event.carrierId ?: INVALID_SUBSCRIPTION_ID

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

        cdmaRoaming.value = event.roaming
        _isRoaming.value = event.roaming
@@ -258,7 +278,6 @@ class DemoMobileConnectionRepository(
        carrierName.value = NetworkNameModel.SubscriptionDerived(CARRIER_MERGED_NAME)
        // TODO(b/276943904): is carrierId a thing with carrier merged networks?
        _carrierId.value = INVALID_SUBSCRIPTION_ID
        numberOfLevels.value = event.numberOfLevels
        cdmaRoaming.value = false
        _primaryLevel.value = event.level
        _cdmaLevel.value = event.level
+1 −0
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ class CarrierMergedConnectionRepository(

    override val isRoaming = MutableStateFlow(false).asStateFlow()
    override val carrierId = MutableStateFlow(INVALID_SUBSCRIPTION_ID).asStateFlow()
    override val inflateSignalStrength = MutableStateFlow(false).asStateFlow()
    override val isEmergencyOnly = MutableStateFlow(false).asStateFlow()
    override val operatorAlphaShort = MutableStateFlow(null).asStateFlow()
    override val isInService = MutableStateFlow(true).asStateFlow()
Loading