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

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

Revert^2 "[Satellite] Input logging for the repository layer"

6ef29c50

Original commit message:
[Satellite] Input logging for the repository layer

Test: adb shell cmd statusbar echo -b DeviceBasedSatelliteInputLog:V
Test: after above command, grep for "DeviceBasedSatelliteRepo"
Bug: 311417356
Flag: ACONFIG com.android.internal.telephony.flags.oem_enabled_satellite_flag DEVELOPMENT

Change-Id: Ib0415397bcef72fd0f5a62108c35214556572fe6
parent 7cd20ff0
Loading
Loading
Loading
Loading
+26 −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.dagger

import com.android.systemui.statusbar.pipeline.satellite.data.DeviceBasedSatelliteRepository
import javax.inject.Qualifier

/** Detailed [DeviceBasedSatelliteRepository] logs */
@Qualifier
@MustBeDocumented
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
annotation class OemSatelliteInputLog
+7 −0
Original line number Diff line number Diff line
@@ -265,6 +265,13 @@ abstract class StatusBarPipelineModule {
            return factory.create("VerboseMobileViewLog", 100)
        }

        @Provides
        @SysUISingleton
        @OemSatelliteInputLog
        fun provideOemSatelliteInputLog(factory: LogBufferFactory): LogBuffer {
            return factory.create("DeviceBasedSatelliteInputLog", 32)
        }

        const val FIRST_MOBILE_SUB_SHOWING_NETWORK_TYPE_ICON =
            "FirstMobileSubShowingNetworkTypeIcon"
    }
+53 −4
Original line number Diff line number Diff line
@@ -26,6 +26,11 @@ import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCall
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.core.LogLevel
import com.android.systemui.log.core.MessageInitializer
import com.android.systemui.log.core.MessagePrinter
import com.android.systemui.statusbar.pipeline.dagger.OemSatelliteInputLog
import com.android.systemui.statusbar.pipeline.satellite.data.DeviceBasedSatelliteRepository
import com.android.systemui.statusbar.pipeline.satellite.data.prod.SatelliteSupport.Companion.whenSupported
import com.android.systemui.statusbar.pipeline.satellite.data.prod.SatelliteSupport.NotSupported
@@ -127,6 +132,7 @@ constructor(
    satelliteManagerOpt: Optional<SatelliteManager>,
    @Background private val bgDispatcher: CoroutineDispatcher,
    @Application private val scope: CoroutineScope,
    @OemSatelliteInputLog private val logBuffer: LogBuffer,
    private val systemClock: SystemClock,
) : DeviceBasedSatelliteRepository {

@@ -150,6 +156,11 @@ constructor(
                ensureMinUptime(systemClock, MIN_UPTIME)
                satelliteSupport.value = satelliteManager.checkSatelliteSupported()

                logBuffer.i(
                    { str1 = satelliteSupport.value.toString() },
                    { "Checked for system support. support=$str1" },
                )

                // We only need to check location availability if this mode is supported
                if (satelliteSupport.value is Supported) {
                    isSatelliteAllowedForCurrentLocation.subscriptionCount
@@ -164,6 +175,9 @@ constructor(
                                 * connection might cause more frequent checks.
                                 */
                                while (true) {
                                    logBuffer.i {
                                        "requestIsSatelliteCommunicationAllowedForCurrentLocation"
                                    }
                                    checkIsSatelliteAllowed()
                                    delay(POLLING_INTERVAL_MS)
                                }
@@ -172,6 +186,8 @@ constructor(
                }
            }
        } else {
            logBuffer.i { "Satellite manager is null" }

            satelliteSupport.value = NotSupported
        }
    }
@@ -186,6 +202,7 @@ constructor(
    private fun connectionStateFlow(sm: SupportedSatelliteManager): Flow<SatelliteConnectionState> =
        conflatedCallbackFlow {
                val cb = SatelliteModemStateCallback { state ->
                    logBuffer.i({ int1 = state }) { "onSatelliteModemStateChanged: state=$int1" }
                    trySend(SatelliteConnectionState.fromModemState(state))
                }

@@ -196,7 +213,7 @@ constructor(
                        sm.registerForSatelliteModemStateChanged(bgDispatcher.asExecutor(), cb)
                    registered = res == SATELLITE_RESULT_SUCCESS
                } catch (e: Exception) {
                    // Logging is in next commit
                    logBuffer.e("error registering for modem state", e)
                }

                awaitClose { if (registered) sm.unregisterForSatelliteModemStateChanged(cb) }
@@ -210,6 +227,9 @@ constructor(
    private fun signalStrengthFlow(sm: SupportedSatelliteManager) =
        conflatedCallbackFlow {
                val cb = NtnSignalStrengthCallback { signalStrength ->
                    logBuffer.i({ int1 = signalStrength.level }) {
                        "onNtnSignalStrengthChanged: level=$int1"
                    }
                    trySend(signalStrength.level)
                }

@@ -218,7 +238,7 @@ constructor(
                    sm.registerForNtnSignalStrengthChanged(bgDispatcher.asExecutor(), cb)
                    registered = true
                } catch (e: Exception) {
                    // Logging is in next commit
                    logBuffer.e("error registering for signal strength", e)
                }

                awaitClose { if (registered) sm.unregisterForNtnSignalStrengthChanged(cb) }
@@ -232,11 +252,15 @@ constructor(
                bgDispatcher.asExecutor(),
                object : OutcomeReceiver<Boolean, SatelliteManager.SatelliteException> {
                    override fun onError(e: SatelliteManager.SatelliteException) {
                        android.util.Log.e(TAG, "Found exception when checking for satellite: ", e)
                        logBuffer.e(
                            "Found exception when checking availability",
                            e,
                        )
                        isSatelliteAllowedForCurrentLocation.value = false
                    }

                    override fun onResult(allowed: Boolean) {
                        logBuffer.i { allowed.toString() }
                        isSatelliteAllowedForCurrentLocation.value = allowed
                    }
                }
@@ -258,6 +282,12 @@ constructor(
                    }

                    override fun onError(error: SatelliteManager.SatelliteException) {
                        logBuffer.e(
                            "Exception when checking for satellite support. " +
                                "Assuming it is not supported for this device.",
                            error,
                        )

                        // Assume that an error means it's not supported
                        continuation.resume(NotSupported)
                    }
@@ -265,7 +295,12 @@ constructor(

            try {
                requestIsSatelliteSupported(bgDispatcher.asExecutor(), cb)
            } catch (e: Exception) {
            } catch (error: Exception) {
                logBuffer.e(
                    "Exception when checking for satellite support. " +
                        "Assuming it is not supported for this device.",
                    error,
                )
                continuation.resume(NotSupported)
            }
        }
@@ -287,5 +322,19 @@ constructor(
                delay(timeTilMinUptime)
            }
        }

        /** A couple of convenience logging methods rather than a whole class */
        private fun LogBuffer.i(
            initializer: MessageInitializer = {},
            printer: MessagePrinter,
        ) = this.log(TAG, LogLevel.INFO, initializer, printer)

        private fun LogBuffer.e(message: String, exception: Throwable? = null) =
            this.log(
                tag = TAG,
                level = LogLevel.ERROR,
                message = message,
                exception = exception,
            )
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.telephony.satellite.SatelliteModemStateCallback
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.log.core.FakeLogBuffer
import com.android.systemui.statusbar.pipeline.satellite.data.prod.DeviceBasedSatelliteRepositoryImpl.Companion.MIN_UPTIME
import com.android.systemui.statusbar.pipeline.satellite.data.prod.DeviceBasedSatelliteRepositoryImpl.Companion.POLLING_INTERVAL_MS
import com.android.systemui.statusbar.pipeline.satellite.shared.model.SatelliteConnectionState
@@ -87,6 +88,7 @@ class DeviceBasedSatelliteRepositoryImplTest : SysuiTestCase() {
                    Optional.empty(),
                    dispatcher,
                    testScope.backgroundScope,
                    FakeLogBuffer.Factory.create(),
                    systemClock,
                )

@@ -419,6 +421,7 @@ class DeviceBasedSatelliteRepositoryImplTest : SysuiTestCase() {
                if (satMan != null) Optional.of(satMan) else Optional.empty(),
                dispatcher,
                testScope.backgroundScope,
                FakeLogBuffer.Factory.create(),
                systemClock,
            )
    }