Loading packages/SystemUI/src/com/android/systemui/log/table/Diffable.kt +22 −0 Original line number Original line Diff line number Diff line Loading @@ -78,3 +78,25 @@ fun <T : Diffable<T>> Flow<T>.logDiffsForTable( newVal newVal } } } } /** * Each time the boolean flow is updated with a new value that's different from the previous value, * logs the new value to the given [tableLogBuffer]. */ fun Flow<Boolean>.logDiffsForTable( tableLogBuffer: TableLogBuffer, columnPrefix: String, columnName: String, initialValue: Boolean, ): Flow<Boolean> { val initialValueFun = { tableLogBuffer.logChange(columnPrefix, columnName, initialValue) initialValue } return this.pairwiseBy(initialValueFun) { prevVal, newVal: Boolean -> if (prevVal != newVal) { tableLogBuffer.logChange(columnPrefix, columnName, newVal) } newVal } } packages/SystemUI/src/com/android/systemui/log/table/TableLogBuffer.kt +5 −0 Original line number Original line Diff line number Diff line Loading @@ -127,6 +127,11 @@ class TableLogBuffer( rowInitializer(row) rowInitializer(row) } } /** Logs a boolean change. */ fun logChange(prefix: String, columnName: String, value: Boolean) { logChange(systemClock.currentTimeMillis(), prefix, columnName, value) } // Keep these individual [logChange] methods private (don't let clients give us their own // Keep these individual [logChange] methods private (don't let clients give us their own // timestamps.) // timestamps.) Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/airplane/data/repository/AirplaneModeRepository.kt +10 −4 Original line number Original line Diff line number Diff line Loading @@ -23,9 +23,10 @@ import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCall import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.log.table.TableLogBuffer import com.android.systemui.log.table.logDiffsForTable import com.android.systemui.qs.SettingObserver import com.android.systemui.qs.SettingObserver import com.android.systemui.statusbar.pipeline.shared.ConnectivityPipelineLogger import com.android.systemui.statusbar.pipeline.dagger.AirplaneTableLog import com.android.systemui.statusbar.pipeline.shared.ConnectivityPipelineLogger.Companion.logInputChange import com.android.systemui.util.settings.GlobalSettings import com.android.systemui.util.settings.GlobalSettings import javax.inject.Inject import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope Loading Loading @@ -58,7 +59,7 @@ class AirplaneModeRepositoryImpl constructor( constructor( @Background private val bgHandler: Handler, @Background private val bgHandler: Handler, private val globalSettings: GlobalSettings, private val globalSettings: GlobalSettings, logger: ConnectivityPipelineLogger, @AirplaneTableLog logger: TableLogBuffer, @Application scope: CoroutineScope, @Application scope: CoroutineScope, ) : AirplaneModeRepository { ) : AirplaneModeRepository { // TODO(b/254848912): Replace this with a generic SettingObserver coroutine once we have it. // TODO(b/254848912): Replace this with a generic SettingObserver coroutine once we have it. Loading @@ -82,7 +83,12 @@ constructor( awaitClose { observer.isListening = false } awaitClose { observer.isListening = false } } } .distinctUntilChanged() .distinctUntilChanged() .logInputChange(logger, "isAirplaneMode") .logDiffsForTable( logger, columnPrefix = "", columnName = "isAirplaneMode", initialValue = false ) .stateIn( .stateIn( scope, scope, started = SharingStarted.WhileSubscribed(), started = SharingStarted.WhileSubscribed(), Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/AirplaneTableLog.kt 0 → 100644 +25 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2022 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 /** Airplane mode logs in table format. */ @Qualifier @MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.RUNTIME) annotation class AirplaneTableLog packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/StatusBarPipelineModule.kt +8 −0 Original line number Original line Diff line number Diff line Loading @@ -71,5 +71,13 @@ abstract class StatusBarPipelineModule { fun provideWifiTableLogBuffer(factory: TableLogBufferFactory): TableLogBuffer { fun provideWifiTableLogBuffer(factory: TableLogBufferFactory): TableLogBuffer { return factory.create("WifiTableLog", 100) return factory.create("WifiTableLog", 100) } } @JvmStatic @Provides @SysUISingleton @AirplaneTableLog fun provideAirplaneTableLogBuffer(factory: TableLogBufferFactory): TableLogBuffer { return factory.create("AirplaneTableLog", 30) } } } } } Loading
packages/SystemUI/src/com/android/systemui/log/table/Diffable.kt +22 −0 Original line number Original line Diff line number Diff line Loading @@ -78,3 +78,25 @@ fun <T : Diffable<T>> Flow<T>.logDiffsForTable( newVal newVal } } } } /** * Each time the boolean flow is updated with a new value that's different from the previous value, * logs the new value to the given [tableLogBuffer]. */ fun Flow<Boolean>.logDiffsForTable( tableLogBuffer: TableLogBuffer, columnPrefix: String, columnName: String, initialValue: Boolean, ): Flow<Boolean> { val initialValueFun = { tableLogBuffer.logChange(columnPrefix, columnName, initialValue) initialValue } return this.pairwiseBy(initialValueFun) { prevVal, newVal: Boolean -> if (prevVal != newVal) { tableLogBuffer.logChange(columnPrefix, columnName, newVal) } newVal } }
packages/SystemUI/src/com/android/systemui/log/table/TableLogBuffer.kt +5 −0 Original line number Original line Diff line number Diff line Loading @@ -127,6 +127,11 @@ class TableLogBuffer( rowInitializer(row) rowInitializer(row) } } /** Logs a boolean change. */ fun logChange(prefix: String, columnName: String, value: Boolean) { logChange(systemClock.currentTimeMillis(), prefix, columnName, value) } // Keep these individual [logChange] methods private (don't let clients give us their own // Keep these individual [logChange] methods private (don't let clients give us their own // timestamps.) // timestamps.) Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/airplane/data/repository/AirplaneModeRepository.kt +10 −4 Original line number Original line Diff line number Diff line Loading @@ -23,9 +23,10 @@ import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCall import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.log.table.TableLogBuffer import com.android.systemui.log.table.logDiffsForTable import com.android.systemui.qs.SettingObserver import com.android.systemui.qs.SettingObserver import com.android.systemui.statusbar.pipeline.shared.ConnectivityPipelineLogger import com.android.systemui.statusbar.pipeline.dagger.AirplaneTableLog import com.android.systemui.statusbar.pipeline.shared.ConnectivityPipelineLogger.Companion.logInputChange import com.android.systemui.util.settings.GlobalSettings import com.android.systemui.util.settings.GlobalSettings import javax.inject.Inject import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope Loading Loading @@ -58,7 +59,7 @@ class AirplaneModeRepositoryImpl constructor( constructor( @Background private val bgHandler: Handler, @Background private val bgHandler: Handler, private val globalSettings: GlobalSettings, private val globalSettings: GlobalSettings, logger: ConnectivityPipelineLogger, @AirplaneTableLog logger: TableLogBuffer, @Application scope: CoroutineScope, @Application scope: CoroutineScope, ) : AirplaneModeRepository { ) : AirplaneModeRepository { // TODO(b/254848912): Replace this with a generic SettingObserver coroutine once we have it. // TODO(b/254848912): Replace this with a generic SettingObserver coroutine once we have it. Loading @@ -82,7 +83,12 @@ constructor( awaitClose { observer.isListening = false } awaitClose { observer.isListening = false } } } .distinctUntilChanged() .distinctUntilChanged() .logInputChange(logger, "isAirplaneMode") .logDiffsForTable( logger, columnPrefix = "", columnName = "isAirplaneMode", initialValue = false ) .stateIn( .stateIn( scope, scope, started = SharingStarted.WhileSubscribed(), started = SharingStarted.WhileSubscribed(), Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/AirplaneTableLog.kt 0 → 100644 +25 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2022 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 /** Airplane mode logs in table format. */ @Qualifier @MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.RUNTIME) annotation class AirplaneTableLog
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/dagger/StatusBarPipelineModule.kt +8 −0 Original line number Original line Diff line number Diff line Loading @@ -71,5 +71,13 @@ abstract class StatusBarPipelineModule { fun provideWifiTableLogBuffer(factory: TableLogBufferFactory): TableLogBuffer { fun provideWifiTableLogBuffer(factory: TableLogBufferFactory): TableLogBuffer { return factory.create("WifiTableLog", 100) return factory.create("WifiTableLog", 100) } } @JvmStatic @Provides @SysUISingleton @AirplaneTableLog fun provideAirplaneTableLogBuffer(factory: TableLogBufferFactory): TableLogBuffer { return factory.create("AirplaneTableLog", 30) } } } } }