1 /* 2 * Copyright (C) 2022 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.mobile.data 18 19 import android.content.Intent 20 import android.telephony.ServiceState 21 import android.telephony.SignalStrength 22 import android.telephony.TelephonyDisplayInfo 23 import android.telephony.TelephonyManager 24 import com.android.settingslib.SignalIcon 25 import com.android.settingslib.mobile.MobileMappings 26 import com.android.systemui.dagger.SysUISingleton 27 import com.android.systemui.log.LogBuffer 28 import com.android.systemui.log.core.LogLevel 29 import com.android.systemui.statusbar.pipeline.dagger.MobileInputLog 30 import javax.inject.Inject 31 32 /** Logs for inputs into the mobile pipeline. */ 33 @SysUISingleton 34 class MobileInputLogger 35 @Inject 36 constructor( 37 @MobileInputLog private val buffer: LogBuffer, 38 ) { 39 fun logOnServiceStateChanged(serviceState: ServiceState, subId: Int) { 40 buffer.log( 41 TAG, 42 LogLevel.INFO, 43 { 44 int1 = subId 45 bool1 = serviceState.isEmergencyOnly 46 bool2 = serviceState.roaming 47 str1 = serviceState.operatorAlphaShort 48 }, 49 { 50 "onServiceStateChanged: subId=$int1 emergencyOnly=$bool1 roaming=$bool2" + 51 " operator=$str1" 52 } 53 ) 54 } 55 56 fun logOnSignalStrengthsChanged(signalStrength: SignalStrength, subId: Int) { 57 buffer.log( 58 TAG, 59 LogLevel.INFO, 60 { 61 int1 = subId 62 str1 = signalStrength.toString() 63 }, 64 { "onSignalStrengthsChanged: subId=$int1 strengths=$str1" } 65 ) 66 } 67 68 fun logOnDataConnectionStateChanged(dataState: Int, networkType: Int, subId: Int) { 69 buffer.log( 70 TAG, 71 LogLevel.INFO, 72 { 73 int1 = subId 74 int2 = dataState 75 str1 = networkType.toString() 76 }, 77 { "onDataConnectionStateChanged: subId=$int1 dataState=$int2 networkType=$str1" }, 78 ) 79 } 80 81 fun logOnDataActivity(direction: Int, subId: Int) { 82 buffer.log( 83 TAG, 84 LogLevel.INFO, 85 { 86 int1 = subId 87 int2 = direction 88 }, 89 { "onDataActivity: subId=$int1 direction=$int2" }, 90 ) 91 } 92 93 fun logOnCarrierNetworkChange(active: Boolean, subId: Int) { 94 buffer.log( 95 TAG, 96 LogLevel.INFO, 97 { 98 int1 = subId 99 bool1 = active 100 }, 101 { "onCarrierNetworkChange: subId=$int1 active=$bool1" }, 102 ) 103 } 104 105 fun logOnDisplayInfoChanged(displayInfo: TelephonyDisplayInfo, subId: Int) { 106 buffer.log( 107 TAG, 108 LogLevel.INFO, 109 { 110 int1 = subId 111 str1 = displayInfo.toString() 112 bool1 = displayInfo.isRoaming 113 }, 114 { "onDisplayInfoChanged: subId=$int1 displayInfo=$str1 isRoaming=$bool1" }, 115 ) 116 } 117 118 fun logCarrierConfigChanged(subId: Int) { 119 buffer.log( 120 TAG, 121 LogLevel.INFO, 122 { int1 = subId }, 123 { "onCarrierConfigChanged: subId=$int1" }, 124 ) 125 } 126 127 fun logOnDataEnabledChanged(enabled: Boolean, subId: Int) { 128 buffer.log( 129 TAG, 130 LogLevel.INFO, 131 { 132 int1 = subId 133 bool1 = enabled 134 }, 135 { "onDataEnabledChanged: subId=$int1 enabled=$bool1" }, 136 ) 137 } 138 139 fun logActionCarrierConfigChanged() { 140 buffer.log(TAG, LogLevel.INFO, {}, { "Intent received: ACTION_CARRIER_CONFIG_CHANGED" }) 141 } 142 143 fun logDefaultDataSubRatConfig(config: MobileMappings.Config) { 144 buffer.log( 145 TAG, 146 LogLevel.INFO, 147 { str1 = config.toString() }, 148 { "defaultDataSubRatConfig: $str1" } 149 ) 150 } 151 152 fun logDefaultMobileIconMapping(mapping: Map<String, SignalIcon.MobileIconGroup>) { 153 buffer.log( 154 TAG, 155 LogLevel.INFO, 156 { str1 = mapping.toString() }, 157 { "defaultMobileIconMapping: $str1" } 158 ) 159 } 160 161 fun logDefaultMobileIconGroup(group: SignalIcon.MobileIconGroup) { 162 buffer.log(TAG, LogLevel.INFO, { str1 = group.name }, { "defaultMobileIconGroup: $str1" }) 163 } 164 165 fun logOnSubscriptionsChanged() { 166 buffer.log(TAG, LogLevel.INFO, {}, { "onSubscriptionsChanged" }) 167 } 168 169 fun logServiceProvidersUpdatedBroadcast(intent: Intent) { 170 val showSpn = intent.getBooleanExtra(TelephonyManager.EXTRA_SHOW_SPN, false) 171 val spn = intent.getStringExtra(TelephonyManager.EXTRA_DATA_SPN) 172 val showPlmn = intent.getBooleanExtra(TelephonyManager.EXTRA_SHOW_PLMN, false) 173 val plmn = intent.getStringExtra(TelephonyManager.EXTRA_PLMN) 174 175 buffer.log( 176 TAG, 177 LogLevel.INFO, 178 { 179 bool1 = showSpn 180 str1 = spn 181 bool2 = showPlmn 182 str2 = plmn 183 }, 184 { 185 "Intent: ACTION_SERVICE_PROVIDERS_UPDATED." + 186 " showSpn=$bool1 spn=$str1 showPlmn=$bool2 plmn=$str2" 187 } 188 ) 189 } 190 } 191 192 private const val TAG = "MobileInputLog" 193