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.net.Network 20 import android.net.NetworkCapabilities 21 import android.telephony.ServiceState 22 import android.telephony.SignalStrength 23 import android.telephony.TelephonyDisplayInfo 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.plugins.log.LogBuffer 28 import com.android.systemui.plugins.log.LogLevel 29 import com.android.systemui.statusbar.pipeline.dagger.MobileInputLog 30 import com.android.systemui.statusbar.pipeline.shared.LoggerHelper 31 import javax.inject.Inject 32 33 /** Logs for inputs into the mobile pipeline. */ 34 @SysUISingleton 35 class MobileInputLogger 36 @Inject 37 constructor( 38 @MobileInputLog private val buffer: LogBuffer, 39 ) { logOnCapabilitiesChangednull40 fun logOnCapabilitiesChanged( 41 network: Network, 42 networkCapabilities: NetworkCapabilities, 43 isDefaultNetworkCallback: Boolean, 44 ) { 45 LoggerHelper.logOnCapabilitiesChanged( 46 buffer, 47 TAG, 48 network, 49 networkCapabilities, 50 isDefaultNetworkCallback, 51 ) 52 } 53 logOnLostnull54 fun logOnLost(network: Network, isDefaultNetworkCallback: Boolean) { 55 LoggerHelper.logOnLost(buffer, TAG, network, isDefaultNetworkCallback) 56 } 57 logOnServiceStateChangednull58 fun logOnServiceStateChanged(serviceState: ServiceState, subId: Int) { 59 buffer.log( 60 TAG, 61 LogLevel.INFO, 62 { 63 int1 = subId 64 bool1 = serviceState.isEmergencyOnly 65 bool2 = serviceState.roaming 66 str1 = serviceState.operatorAlphaShort 67 }, 68 { 69 "onServiceStateChanged: subId=$int1 emergencyOnly=$bool1 roaming=$bool2" + 70 " operator=$str1" 71 } 72 ) 73 } 74 logOnSignalStrengthsChangednull75 fun logOnSignalStrengthsChanged(signalStrength: SignalStrength, subId: Int) { 76 buffer.log( 77 TAG, 78 LogLevel.INFO, 79 { 80 int1 = subId 81 str1 = signalStrength.toString() 82 }, 83 { "onSignalStrengthsChanged: subId=$int1 strengths=$str1" } 84 ) 85 } 86 logOnDataConnectionStateChangednull87 fun logOnDataConnectionStateChanged(dataState: Int, networkType: Int, subId: Int) { 88 buffer.log( 89 TAG, 90 LogLevel.INFO, 91 { 92 int1 = subId 93 int2 = dataState 94 str1 = networkType.toString() 95 }, 96 { "onDataConnectionStateChanged: subId=$int1 dataState=$int2 networkType=$str1" }, 97 ) 98 } 99 logOnDataActivitynull100 fun logOnDataActivity(direction: Int, subId: Int) { 101 buffer.log( 102 TAG, 103 LogLevel.INFO, 104 { 105 int1 = subId 106 int2 = direction 107 }, 108 { "onDataActivity: subId=$int1 direction=$int2" }, 109 ) 110 } 111 logOnCarrierNetworkChangenull112 fun logOnCarrierNetworkChange(active: Boolean, subId: Int) { 113 buffer.log( 114 TAG, 115 LogLevel.INFO, 116 { 117 int1 = subId 118 bool1 = active 119 }, 120 { "onCarrierNetworkChange: subId=$int1 active=$bool1" }, 121 ) 122 } 123 logOnDisplayInfoChangednull124 fun logOnDisplayInfoChanged(displayInfo: TelephonyDisplayInfo, subId: Int) { 125 buffer.log( 126 TAG, 127 LogLevel.INFO, 128 { 129 int1 = subId 130 str1 = displayInfo.toString() 131 }, 132 { "onDisplayInfoChanged: subId=$int1 displayInfo=$str1" }, 133 ) 134 } 135 logCarrierConfigChangednull136 fun logCarrierConfigChanged(subId: Int) { 137 buffer.log( 138 TAG, 139 LogLevel.INFO, 140 { int1 = subId }, 141 { "onCarrierConfigChanged: subId=$int1" }, 142 ) 143 } 144 logOnDataEnabledChangednull145 fun logOnDataEnabledChanged(enabled: Boolean, subId: Int) { 146 buffer.log( 147 TAG, 148 LogLevel.INFO, 149 { 150 int1 = subId 151 bool1 = enabled 152 }, 153 { "onDataEnabledChanged: subId=$int1 enabled=$bool1" }, 154 ) 155 } 156 logActionCarrierConfigChangednull157 fun logActionCarrierConfigChanged() { 158 buffer.log(TAG, LogLevel.INFO, {}, { "Intent received: ACTION_CARRIER_CONFIG_CHANGED" }) 159 } 160 logDefaultDataSubRatConfignull161 fun logDefaultDataSubRatConfig(config: MobileMappings.Config) { 162 buffer.log( 163 TAG, 164 LogLevel.INFO, 165 { str1 = config.toString() }, 166 { "defaultDataSubRatConfig: $str1" } 167 ) 168 } 169 logDefaultMobileIconMappingnull170 fun logDefaultMobileIconMapping(mapping: Map<String, SignalIcon.MobileIconGroup>) { 171 buffer.log( 172 TAG, 173 LogLevel.INFO, 174 { str1 = mapping.toString() }, 175 { "defaultMobileIconMapping: $str1" } 176 ) 177 } 178 logDefaultMobileIconGroupnull179 fun logDefaultMobileIconGroup(group: SignalIcon.MobileIconGroup) { 180 buffer.log(TAG, LogLevel.INFO, { str1 = group.name }, { "defaultMobileIconGroup: $str1" }) 181 } 182 logOnSubscriptionsChangednull183 fun logOnSubscriptionsChanged() { 184 buffer.log(TAG, LogLevel.INFO, {}, { "onSubscriptionsChanged" }) 185 } 186 } 187 188 private const val TAG = "MobileInputLog" 189