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 ) { logOnServiceStateChangednull39 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 logOnSignalStrengthsChangednull56 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 logOnDataConnectionStateChangednull68 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 logOnDataActivitynull81 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 logOnCarrierNetworkChangenull93 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 logOnDisplayInfoChangednull105 fun logOnDisplayInfoChanged(displayInfo: TelephonyDisplayInfo, subId: Int) { 106 buffer.log( 107 TAG, 108 LogLevel.INFO, 109 { 110 int1 = subId 111 str1 = displayInfo.toString() 112 }, 113 { "onDisplayInfoChanged: subId=$int1 displayInfo=$str1" }, 114 ) 115 } 116 logCarrierConfigChangednull117 fun logCarrierConfigChanged(subId: Int) { 118 buffer.log( 119 TAG, 120 LogLevel.INFO, 121 { int1 = subId }, 122 { "onCarrierConfigChanged: subId=$int1" }, 123 ) 124 } 125 logOnDataEnabledChangednull126 fun logOnDataEnabledChanged(enabled: Boolean, subId: Int) { 127 buffer.log( 128 TAG, 129 LogLevel.INFO, 130 { 131 int1 = subId 132 bool1 = enabled 133 }, 134 { "onDataEnabledChanged: subId=$int1 enabled=$bool1" }, 135 ) 136 } 137 logActionCarrierConfigChangednull138 fun logActionCarrierConfigChanged() { 139 buffer.log(TAG, LogLevel.INFO, {}, { "Intent received: ACTION_CARRIER_CONFIG_CHANGED" }) 140 } 141 logDefaultDataSubRatConfignull142 fun logDefaultDataSubRatConfig(config: MobileMappings.Config) { 143 buffer.log( 144 TAG, 145 LogLevel.INFO, 146 { str1 = config.toString() }, 147 { "defaultDataSubRatConfig: $str1" } 148 ) 149 } 150 logDefaultMobileIconMappingnull151 fun logDefaultMobileIconMapping(mapping: Map<String, SignalIcon.MobileIconGroup>) { 152 buffer.log( 153 TAG, 154 LogLevel.INFO, 155 { str1 = mapping.toString() }, 156 { "defaultMobileIconMapping: $str1" } 157 ) 158 } 159 logDefaultMobileIconGroupnull160 fun logDefaultMobileIconGroup(group: SignalIcon.MobileIconGroup) { 161 buffer.log(TAG, LogLevel.INFO, { str1 = group.name }, { "defaultMobileIconGroup: $str1" }) 162 } 163 logOnSubscriptionsChangednull164 fun logOnSubscriptionsChanged() { 165 buffer.log(TAG, LogLevel.INFO, {}, { "onSubscriptionsChanged" }) 166 } 167 logServiceProvidersUpdatedBroadcastnull168 fun logServiceProvidersUpdatedBroadcast(intent: Intent) { 169 val showSpn = intent.getBooleanExtra(TelephonyManager.EXTRA_SHOW_SPN, false) 170 val spn = intent.getStringExtra(TelephonyManager.EXTRA_DATA_SPN) 171 val showPlmn = intent.getBooleanExtra(TelephonyManager.EXTRA_SHOW_PLMN, false) 172 val plmn = intent.getStringExtra(TelephonyManager.EXTRA_PLMN) 173 174 buffer.log( 175 TAG, 176 LogLevel.INFO, 177 { 178 bool1 = showSpn 179 str1 = spn 180 bool2 = showPlmn 181 str2 = plmn 182 }, 183 { 184 "Intent: ACTION_SERVICE_PROVIDERS_UPDATED." + 185 " showSpn=$bool1 spn=$str1 showPlmn=$bool2 plmn=$str2" 186 } 187 ) 188 } 189 } 190 191 private const val TAG = "MobileInputLog" 192