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

Commit ab89efaa authored by Evan Laird's avatar Evan Laird
Browse files

[sat] Table log buffers

We have been in need of more granular, rolling table log buffers in
order to dig into bug reports more easily.

Test: tests in satellite/
Flag: NONE logging
Bug: 359356088
Change-Id: Iec2e1d4e05b58f49d9bb41aaa885a74661117dc2
parent e30e313e
Loading
Loading
Loading
Loading
+24 −0
Original line number Original line 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.dagger

import javax.inject.Qualifier

@Qualifier
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
annotation class DeviceBasedSatelliteTableLog
+7 −0
Original line number Original line Diff line number Diff line
@@ -239,6 +239,13 @@ abstract class StatusBarPipelineModule {
            return factory.create("VerboseDeviceBasedSatelliteInputLog", 200)
            return factory.create("VerboseDeviceBasedSatelliteInputLog", 200)
        }
        }


        @Provides
        @SysUISingleton
        @DeviceBasedSatelliteTableLog
        fun provideDeviceBasedSatelliteTableLog(factory: TableLogBufferFactory): TableLogBuffer {
            return factory.create("DeviceBasedSatelliteTableLog", 200)
        }

        const val FIRST_MOBILE_SUB_SHOWING_NETWORK_TYPE_ICON =
        const val FIRST_MOBILE_SUB_SHOWING_NETWORK_TYPE_ICON =
            "FirstMobileSubShowingNetworkTypeIcon"
            "FirstMobileSubShowingNetworkTypeIcon"
    }
    }
+9 −1
Original line number Original line Diff line number Diff line
@@ -385,7 +385,15 @@ constructor(
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)


    override val isDeviceInEmergencyCallsOnlyMode: Flow<Boolean> =
    override val isDeviceInEmergencyCallsOnlyMode: Flow<Boolean> =
        mobileConnectionsRepo.deviceServiceState.map { it?.isEmergencyOnly ?: false }
        mobileConnectionsRepo.deviceServiceState
            .map { it?.isEmergencyOnly ?: false }
            .distinctUntilChanged()
            .logDiffsForTable(
                tableLogger,
                columnPrefix = LOGGING_PREFIX,
                columnName = "deviceEmergencyOnly",
                initialValue = false,
            )


    /** Vends out new [MobileIconInteractor] for a particular subId */
    /** Vends out new [MobileIconInteractor] for a particular subId */
    override fun getMobileConnectionInteractorForSubId(subId: Int): MobileIconInteractor =
    override fun getMobileConnectionInteractorForSubId(subId: Int): MobileIconInteractor =
+60 −13
Original line number Original line Diff line number Diff line
@@ -21,7 +21,10 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.core.LogLevel
import com.android.systemui.log.core.LogLevel
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.log.table.logDiffsForTable
import com.android.systemui.statusbar.pipeline.dagger.DeviceBasedSatelliteInputLog
import com.android.systemui.statusbar.pipeline.dagger.DeviceBasedSatelliteInputLog
import com.android.systemui.statusbar.pipeline.dagger.DeviceBasedSatelliteTableLog
import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.MobileIconsInteractor
import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.MobileIconsInteractor
import com.android.systemui.statusbar.pipeline.satellite.data.DeviceBasedSatelliteRepository
import com.android.systemui.statusbar.pipeline.satellite.data.DeviceBasedSatelliteRepository
import com.android.systemui.statusbar.pipeline.satellite.shared.model.SatelliteConnectionState
import com.android.systemui.statusbar.pipeline.satellite.shared.model.SatelliteConnectionState
@@ -33,6 +36,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.map
@@ -47,6 +51,7 @@ constructor(
    wifiInteractor: WifiInteractor,
    wifiInteractor: WifiInteractor,
    @Application scope: CoroutineScope,
    @Application scope: CoroutineScope,
    @DeviceBasedSatelliteInputLog private val logBuffer: LogBuffer,
    @DeviceBasedSatelliteInputLog private val logBuffer: LogBuffer,
    @DeviceBasedSatelliteTableLog private val tableLog: TableLogBuffer,
) {
) {
    /** Must be observed by any UI showing Satellite iconography */
    /** Must be observed by any UI showing Satellite iconography */
    val isSatelliteAllowed =
    val isSatelliteAllowed =
@@ -55,6 +60,13 @@ constructor(
            } else {
            } else {
                flowOf(false)
                flowOf(false)
            }
            }
            .distinctUntilChanged()
            .logDiffsForTable(
                tableLog,
                columnPrefix = "",
                columnName = COL_ALLOWED,
                initialValue = false,
            )
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)


    /** See [SatelliteConnectionState] for relevant states */
    /** See [SatelliteConnectionState] for relevant states */
@@ -65,6 +77,12 @@ constructor(


                flowOf(SatelliteConnectionState.Off)
                flowOf(SatelliteConnectionState.Off)
            }
            }
            .distinctUntilChanged()
            .logDiffsForTable(
                tableLog,
                columnPrefix = "",
                initialValue = SatelliteConnectionState.Off,
            )
            .stateIn(scope, SharingStarted.WhileSubscribed(), SatelliteConnectionState.Off)
            .stateIn(scope, SharingStarted.WhileSubscribed(), SatelliteConnectionState.Off)


    /** 0-4 description of the connection strength */
    /** 0-4 description of the connection strength */
@@ -74,6 +92,13 @@ constructor(
            } else {
            } else {
                flowOf(0)
                flowOf(0)
            }
            }
            .distinctUntilChanged()
            .logDiffsForTable(
                tableLog,
                columnPrefix = "",
                columnName = COL_LEVEL,
                initialValue = 0,
            )
            .stateIn(scope, SharingStarted.WhileSubscribed(), 0)
            .stateIn(scope, SharingStarted.WhileSubscribed(), 0)


    val isSatelliteProvisioned = repo.isSatelliteProvisioned
    val isSatelliteProvisioned = repo.isSatelliteProvisioned
@@ -82,7 +107,8 @@ constructor(
        wifiInteractor.wifiNetwork.map { it is WifiNetworkModel.Active }
        wifiInteractor.wifiNetwork.map { it is WifiNetworkModel.Active }


    private val allConnectionsOos =
    private val allConnectionsOos =
        iconsInteractor.icons.aggregateOver(
        iconsInteractor.icons
            .aggregateOver(
                selector = { intr ->
                selector = { intr ->
                    combine(intr.isInService, intr.isEmergencyOnly, intr.isNonTerrestrial) {
                    combine(intr.isInService, intr.isEmergencyOnly, intr.isNonTerrestrial) {
                        isInService,
                        isInService,
@@ -95,6 +121,13 @@ constructor(
            ) { isOosAndNotEmergencyAndNotSatellite ->
            ) { isOosAndNotEmergencyAndNotSatellite ->
                isOosAndNotEmergencyAndNotSatellite.all { it }
                isOosAndNotEmergencyAndNotSatellite.all { it }
            }
            }
            .distinctUntilChanged()
            .logDiffsForTable(
                tableLog,
                columnPrefix = "",
                columnName = COL_ALL_OOS,
                initialValue = true,
            )


    /** When all connections are considered OOS, satellite connectivity is potentially valid */
    /** When all connections are considered OOS, satellite connectivity is potentially valid */
    val areAllConnectionsOutOfService =
    val areAllConnectionsOutOfService =
@@ -122,10 +155,24 @@ constructor(
            } else {
            } else {
                flowOf(false)
                flowOf(false)
            }
            }
            .distinctUntilChanged()
            .logDiffsForTable(
                tableLog,
                columnPrefix = "",
                columnName = COL_FULL_OOS,
                initialValue = true,
            )
            .stateIn(scope, SharingStarted.WhileSubscribed(), true)
            .stateIn(scope, SharingStarted.WhileSubscribed(), true)


    companion object {
    companion object {
        const val TAG = "DeviceBasedSatelliteInteractor"
        const val TAG = "DeviceBasedSatelliteInteractor"

        const val COL_LEVEL = "level"
        const val COL_ALL_OOS = "allConnsOOS"
        const val COL_ALLOWED = "allowed"
        // Going to try to optimize for not using too much width on the table here. This information
        // can be ascertained by checking for the device emergency only in the mobile logs as well
        const val COL_FULL_OOS = "allOosAndNoEmer"
    }
    }
}
}


+11 −1
Original line number Original line Diff line number Diff line
@@ -26,8 +26,10 @@ import android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_NOT_CO
import android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_OFF
import android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_OFF
import android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_UNAVAILABLE
import android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_UNAVAILABLE
import android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_UNKNOWN
import android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_UNKNOWN
import com.android.systemui.log.table.Diffable
import com.android.systemui.log.table.TableRowLogger


enum class SatelliteConnectionState {
enum class SatelliteConnectionState : Diffable<SatelliteConnectionState> {
    // State is unknown or undefined
    // State is unknown or undefined
    Unknown,
    Unknown,
    // Radio is off
    // Radio is off
@@ -37,7 +39,15 @@ enum class SatelliteConnectionState {
    // Radio is connected, aka satellite is available for use
    // Radio is connected, aka satellite is available for use
    Connected;
    Connected;


    override fun logDiffs(prevVal: SatelliteConnectionState, row: TableRowLogger) {
        if (prevVal != this) {
            row.logChange(COL_CONNECTION_STATE, name)
        }
    }

    companion object {
    companion object {
        const val COL_CONNECTION_STATE = "connState"

        // TODO(b/316635648): validate these states. We don't need the level of granularity that
        // TODO(b/316635648): validate these states. We don't need the level of granularity that
        //  SatelliteManager gives us.
        //  SatelliteManager gives us.
        fun fromModemState(@SatelliteManager.SatelliteModemState modemState: Int) =
        fun fromModemState(@SatelliteManager.SatelliteModemState modemState: Int) =
Loading