1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.statusbar.pipeline.wifi.shared 18 19 import android.net.Network 20 import android.net.NetworkCapabilities 21 import com.android.systemui.dagger.SysUISingleton 22 import com.android.systemui.log.LogBuffer 23 import com.android.systemui.log.core.LogLevel 24 import com.android.systemui.statusbar.pipeline.dagger.WifiInputLog 25 import com.android.systemui.statusbar.pipeline.shared.LoggerHelper 26 import javax.inject.Inject 27 28 /** 29 * Logger for all the wifi-related inputs (intents, callbacks, etc.) that the wifi repo receives. 30 */ 31 @SysUISingleton 32 class WifiInputLogger 33 @Inject 34 constructor( 35 @WifiInputLog val buffer: LogBuffer, 36 ) { 37 fun logOnCapabilitiesChanged( 38 network: Network, 39 networkCapabilities: NetworkCapabilities, 40 isDefaultNetworkCallback: Boolean, 41 ) { 42 LoggerHelper.logOnCapabilitiesChanged( 43 buffer, 44 TAG, 45 network, 46 networkCapabilities, 47 isDefaultNetworkCallback, 48 ) 49 } 50 51 fun logOnLost(network: Network, isDefaultNetworkCallback: Boolean) { 52 LoggerHelper.logOnLost(buffer, TAG, network, isDefaultNetworkCallback) 53 } 54 55 fun logIntent(intentName: String) { 56 buffer.log(TAG, LogLevel.DEBUG, { str1 = intentName }, { "Intent received: $str1" }) 57 } 58 59 fun logActivity(activity: String) { 60 buffer.log(TAG, LogLevel.DEBUG, { str1 = activity }, { "Activity: $str1" }) 61 } 62 63 fun logScanResults() = buffer.log(TAG, LogLevel.DEBUG, {}, { "onScanResultsAvailable" }) 64 } 65 66 private const val TAG = "WifiInputLog" 67