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

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

Merge changes from topic "cherrypicker-L99700030003921781:N71800030062077718" into 24D1-dev

* changes:
  [Sat] Add device-based emergency calls only state to satellie icon
  [Sb][Mobile] Listen for service states via broadcast for subId = -1
parents fdd773d7 c46f4339
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -53,6 +53,27 @@ constructor(
        )
    }

    fun logTopLevelServiceStateBroadcastEmergencyOnly(subId: Int, serviceState: ServiceState) {
        buffer.log(
            TAG,
            LogLevel.INFO,
            {
                int1 = subId
                bool1 = serviceState.isEmergencyOnly
            },
            { "ACTION_SERVICE_STATE for subId=$int1. ServiceState.isEmergencyOnly=$bool1" }
        )
    }

    fun logTopLevelServiceStateBroadcastMissingExtras(subId: Int) {
        buffer.log(
            TAG,
            LogLevel.INFO,
            { int1 = subId },
            { "ACTION_SERVICE_STATE for subId=$int1. Intent is missing extras. Ignoring" }
        )
    }

    fun logOnSignalStrengthsChanged(signalStrength: SignalStrength, subId: Int) {
        buffer.log(
            TAG,
+31 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.statusbar.pipeline.mobile.data.model

import android.telephony.ServiceState

/**
 * Simplified representation of a [ServiceState] for use in SystemUI. Add any fields that we need to
 * extract from service state here for consumption downstream
 */
data class ServiceStateModel(val isEmergencyOnly: Boolean) {
    companion object {
        fun fromServiceState(serviceState: ServiceState): ServiceStateModel {
            return ServiceStateModel(isEmergencyOnly = serviceState.isEmergencyOnly)
        }
    }
}
+14 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.telephony.SubscriptionManager
import com.android.settingslib.SignalIcon.MobileIconGroup
import com.android.settingslib.mobile.MobileMappings
import com.android.settingslib.mobile.MobileMappings.Config
import com.android.systemui.statusbar.pipeline.mobile.data.model.ServiceStateModel
import com.android.systemui.statusbar.pipeline.mobile.data.model.SubscriptionModel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
@@ -91,6 +92,19 @@ interface MobileConnectionsRepository {
    /** Fallback [MobileIconGroup] in the case where there is no icon in the mapping */
    val defaultMobileIconGroup: Flow<MobileIconGroup>

    /**
     * [deviceServiceState] is equivalent to the last [Intent.ACTION_SERVICE_STATE] broadcast with a
     * subscriptionId of -1 (aka [SubscriptionManager.INVALID_SUBSCRIPTION_ID]).
     *
     * While each [MobileConnectionsRepository] listens for the service state of each subscription,
     * there is potentially a service state associated with the device itself. This value can be
     * used to calculate e.g., the emergency calling capability of the device (as opposed to the
     * emergency calling capability of an individual mobile connection)
     *
     * Note: this is a [StateFlow] using an eager sharing strategy.
     */
    val deviceServiceState: StateFlow<ServiceStateModel?>

    /**
     * If any active SIM on the device is in
     * [android.telephony.TelephonyManager.SIM_STATE_PIN_REQUIRED] or
+10 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.demomode.DemoMode
import com.android.systemui.demomode.DemoModeController
import com.android.systemui.statusbar.pipeline.mobile.data.model.ServiceStateModel
import com.android.systemui.statusbar.pipeline.mobile.data.model.SubscriptionModel
import com.android.systemui.statusbar.pipeline.mobile.data.repository.demo.DemoMobileConnectionsRepository
import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.MobileConnectionsRepositoryImpl
@@ -151,6 +152,15 @@ constructor(
    override val defaultMobileIconGroup: Flow<SignalIcon.MobileIconGroup> =
        activeRepo.flatMapLatest { it.defaultMobileIconGroup }

    override val deviceServiceState: StateFlow<ServiceStateModel?> =
        activeRepo
            .flatMapLatest { it.deviceServiceState }
            .stateIn(
                scope,
                SharingStarted.WhileSubscribed(),
                realRepository.deviceServiceState.value
            )

    override val isAnySimSecure: Flow<Boolean> = activeRepo.flatMapLatest { it.isAnySimSecure }
    override fun getIsAnySimSecure(): Boolean = activeRepo.value.getIsAnySimSecure()

+4 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.log.table.TableLogBufferFactory
import com.android.systemui.statusbar.pipeline.mobile.data.model.ResolvedNetworkType
import com.android.systemui.statusbar.pipeline.mobile.data.model.ResolvedNetworkType.DefaultNetworkType
import com.android.systemui.statusbar.pipeline.mobile.data.model.ServiceStateModel
import com.android.systemui.statusbar.pipeline.mobile.data.model.SubscriptionModel
import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionRepository
import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionsRepository
@@ -136,6 +137,9 @@ constructor(

    override val defaultMobileIconGroup = flowOf(TelephonyIcons.THREE_G)

    // TODO(b/339023069): demo command for device-based connectivity state
    override val deviceServiceState: StateFlow<ServiceStateModel?> = MutableStateFlow(null)

    override val isAnySimSecure: Flow<Boolean> = flowOf(getIsAnySimSecure())
    override fun getIsAnySimSecure(): Boolean = false

Loading