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.log.LogBuffer
22 import com.android.systemui.log.core.LogLevel
23 
24 /** Helper object for logs that are shared between wifi and mobile. */
25 object LoggerHelper {
logOnCapabilitiesChangednull26     fun logOnCapabilitiesChanged(
27         buffer: LogBuffer,
28         tag: String,
29         network: Network,
30         networkCapabilities: NetworkCapabilities,
31         isDefaultNetworkCallback: Boolean,
32     ) {
33         buffer.log(
34             tag,
35             LogLevel.INFO,
36             {
37                 bool1 = isDefaultNetworkCallback
38                 int1 = network.getNetId()
39                 str1 = networkCapabilities.toString()
40             },
41             { "on${if (bool1) "Default" else ""}CapabilitiesChanged: net=$int1 capabilities=$str1" }
42         )
43     }
44 
logOnLostnull45     fun logOnLost(
46         buffer: LogBuffer,
47         tag: String,
48         network: Network,
49         isDefaultNetworkCallback: Boolean,
50     ) {
51         buffer.log(
52             tag,
53             LogLevel.INFO,
54             {
55                 int1 = network.getNetId()
56                 bool1 = isDefaultNetworkCallback
57             },
58             { "on${if (bool1) "Default" else ""}Lost: net=$int1" }
59         )
60     }
61 }
62