1 /*
2  * Copyright (C) 2024 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.shade.carrier
18 
19 import com.android.keyguard.CarrierTextManager
20 import com.android.systemui.dagger.SysUISingleton
21 import com.android.systemui.log.LogBuffer
22 import com.android.systemui.log.core.LogLevel
23 import javax.inject.Inject
24 
25 /** Logger for [ShadeCarrierGroupController], mostly to try and solve b/341841138. */
26 @SysUISingleton
27 class ShadeCarrierGroupControllerLogger
28 @Inject
29 constructor(@ShadeCarrierGroupControllerLog val buffer: LogBuffer) {
30     /** De-structures the info object so that we don't have to generate new strings */
logHandleUpdateCarrierInfonull31     fun logHandleUpdateCarrierInfo(info: CarrierTextManager.CarrierTextCallbackInfo) {
32         buffer.log(
33             TAG,
34             LogLevel.VERBOSE,
35             {
36                 str1 = "${info.carrierText}"
37                 bool1 = info.anySimReady
38                 bool2 = info.airplaneMode
39             },
40             {
41                 "handleUpdateCarrierInfo: " +
42                     "result=(carrierText=$str1, anySimReady=$bool1, airplaneMode=$bool2)"
43             },
44         )
45     }
46 
logInvalidArrayLengthsnull47     fun logInvalidArrayLengths(numCarriers: Int, numSubs: Int) {
48         buffer.log(
49             TAG,
50             LogLevel.ERROR,
51             {
52                 int1 = numCarriers
53                 int2 = numSubs
54             },
55             { "┗ carriers.length != subIds.length. carriers.length=$int1 subs.length=$int2" },
56         )
57     }
58 
logUsingNoSimViewnull59     fun logUsingNoSimView(text: CharSequence) {
60         buffer.log(
61             TAG,
62             LogLevel.VERBOSE,
63             { str1 = "$text" },
64             { "┗ updating No SIM view with text=$str1" },
65         )
66     }
67 
logUsingSatelliteTextnull68     fun logUsingSatelliteText(text: CharSequence) {
69         buffer.log(
70             TAG,
71             LogLevel.VERBOSE,
72             { str1 = "$text" },
73             { "┗ updating No SIM view with satellite text=$str1" },
74         )
75     }
76 
logUsingSimViewsnull77     fun logUsingSimViews() {
78         buffer.log(TAG, LogLevel.VERBOSE, {}, { "┗ updating SIM views" })
79     }
80 
81     private companion object {
82         const val TAG = "SCGC"
83     }
84 }
85