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.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.SharedConnectivityInputLog
25 import com.android.systemui.statusbar.pipeline.shared.data.model.DefaultConnectionModel
26 import javax.inject.Inject
27 
28 /** Logs for connectivity-related inputs that are shared across wifi, mobile, etc. */
29 @SysUISingleton
30 class ConnectivityInputLogger
31 @Inject
32 constructor(
33     @SharedConnectivityInputLog private val buffer: LogBuffer,
34 ) {
logTuningChangednull35     fun logTuningChanged(tuningList: String?) {
36         buffer.log(TAG, LogLevel.DEBUG, { str1 = tuningList }, { "onTuningChanged: $str1" })
37     }
38 
logOnDefaultCapabilitiesChangednull39     fun logOnDefaultCapabilitiesChanged(
40         network: Network,
41         networkCapabilities: NetworkCapabilities,
42     ) {
43         LoggerHelper.logOnCapabilitiesChanged(
44             buffer,
45             TAG,
46             network,
47             networkCapabilities,
48             isDefaultNetworkCallback = true,
49         )
50     }
51 
logOnDefaultLostnull52     fun logOnDefaultLost(network: Network) {
53         LoggerHelper.logOnLost(buffer, TAG, network, isDefaultNetworkCallback = true)
54     }
55 
logDefaultConnectionsChangednull56     fun logDefaultConnectionsChanged(model: DefaultConnectionModel) {
57         buffer.log(
58             TAG,
59             LogLevel.DEBUG,
60             model::messageInitializer,
61             model::messagePrinter,
62         )
63     }
64 
logVcnSubscriptionIdnull65     fun logVcnSubscriptionId(subId: Int) {
66         buffer.log(TAG, LogLevel.DEBUG, { int1 = subId }, { "vcnSubId changed: $int1" })
67     }
68 }
69 
70 private const val TAG = "ConnectivityInputLogger"
71