Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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 | package com.android.systemui.statusbar.policy; |
| 17 | |
Hall Liu | 5a95a70 | 2020-01-06 19:04:10 -0800 | [diff] [blame] | 18 | import static android.telephony.AccessNetworkConstants.TRANSPORT_TYPE_WWAN; |
| 19 | import static android.telephony.NetworkRegistrationInfo.DOMAIN_PS; |
| 20 | |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 21 | import android.content.Context; |
| 22 | import android.content.Intent; |
Jason Monk | 0288de0 | 2017-02-23 14:48:05 -0500 | [diff] [blame] | 23 | import android.database.ContentObserver; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 24 | import android.net.NetworkCapabilities; |
Jason Monk | 0288de0 | 2017-02-23 14:48:05 -0500 | [diff] [blame] | 25 | import android.os.Handler; |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 26 | import android.os.Looper; |
Bill Lin | 767c0db | 2019-08-15 20:42:06 +0800 | [diff] [blame] | 27 | import android.os.Message; |
Jason Monk | 0288de0 | 2017-02-23 14:48:05 -0500 | [diff] [blame] | 28 | import android.provider.Settings.Global; |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 29 | import android.telephony.Annotation; |
Jayachandran C | 7803cfa | 2020-01-21 15:01:12 -0800 | [diff] [blame] | 30 | import android.telephony.CdmaEriInformation; |
Jayachandran C | a6f9b6d | 2019-11-07 17:26:02 -0800 | [diff] [blame] | 31 | import android.telephony.CellSignalStrength; |
| 32 | import android.telephony.CellSignalStrengthCdma; |
Jack Yu | e27d3fd | 2019-03-15 14:49:53 -0700 | [diff] [blame] | 33 | import android.telephony.NetworkRegistrationInfo; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 34 | import android.telephony.PhoneStateListener; |
| 35 | import android.telephony.ServiceState; |
| 36 | import android.telephony.SignalStrength; |
| 37 | import android.telephony.SubscriptionInfo; |
| 38 | import android.telephony.SubscriptionManager; |
| 39 | import android.telephony.TelephonyManager; |
Jason Monk | 93fb68f | 2015-07-20 11:43:56 -0400 | [diff] [blame] | 40 | import android.text.TextUtils; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 41 | import android.util.Log; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 42 | |
| 43 | import com.android.internal.annotations.VisibleForTesting; |
SongFerngWang | 8cfb4d5 | 2018-08-21 18:04:29 +0800 | [diff] [blame] | 44 | import com.android.settingslib.Utils; |
Gus Prevas | ab33679 | 2018-11-14 13:52:20 -0500 | [diff] [blame] | 45 | import com.android.settingslib.graph.SignalDrawable; |
Antony Sargent | c026de3 | 2019-05-21 16:29:04 -0700 | [diff] [blame] | 46 | import com.android.settingslib.net.SignalStrengthUtil; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 47 | import com.android.systemui.R; |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 48 | import com.android.systemui.statusbar.policy.NetworkController.IconState; |
Jason Monk | e06b065 | 2016-03-02 16:35:27 -0500 | [diff] [blame] | 49 | import com.android.systemui.statusbar.policy.NetworkController.SignalCallback; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 50 | import com.android.systemui.statusbar.policy.NetworkControllerImpl.Config; |
Jason Monk | c6cc626 | 2015-06-11 11:10:15 -0400 | [diff] [blame] | 51 | import com.android.systemui.statusbar.policy.NetworkControllerImpl.SubscriptionDefaults; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 52 | |
| 53 | import java.io.PrintWriter; |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 54 | import java.util.BitSet; |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 55 | import java.util.HashMap; |
Jayachandran C | a6f9b6d | 2019-11-07 17:26:02 -0800 | [diff] [blame] | 56 | import java.util.List; |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 57 | import java.util.Map; |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 58 | import java.util.Objects; |
| 59 | import java.util.concurrent.Executor; |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 60 | import java.util.regex.Matcher; |
| 61 | import java.util.regex.Pattern; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 62 | |
| 63 | |
| 64 | public class MobileSignalController extends SignalController< |
| 65 | MobileSignalController.MobileState, MobileSignalController.MobileIconGroup> { |
Bill Lin | 767c0db | 2019-08-15 20:42:06 +0800 | [diff] [blame] | 66 | |
| 67 | // The message to display Nr5G icon gracfully by CarrierConfig timeout |
| 68 | private static final int MSG_DISPLAY_GRACE = 1; |
| 69 | |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 70 | private final TelephonyManager mPhone; |
Jason Monk | c6cc626 | 2015-06-11 11:10:15 -0400 | [diff] [blame] | 71 | private final SubscriptionDefaults mDefaults; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 72 | private final String mNetworkNameDefault; |
| 73 | private final String mNetworkNameSeparator; |
Jason Monk | 0288de0 | 2017-02-23 14:48:05 -0500 | [diff] [blame] | 74 | private final ContentObserver mObserver; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 75 | @VisibleForTesting |
| 76 | final PhoneStateListener mPhoneStateListener; |
| 77 | // Save entire info for logging, we only use the id. |
Jason Monk | 66845a3 | 2015-08-03 11:09:41 -0400 | [diff] [blame] | 78 | final SubscriptionInfo mSubscriptionInfo; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 79 | |
| 80 | // @VisibleForDemoMode |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 81 | final Map<String, MobileIconGroup> mNetworkToIconLookup; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 82 | |
| 83 | // Since some pieces of the phone state are interdependent we store it locally, |
| 84 | // this could potentially become part of MobileState for simplification/complication |
| 85 | // of code. |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 86 | private int mDataNetType = TelephonyManager.NETWORK_TYPE_UNKNOWN; |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 87 | private boolean mCA = false; |
| 88 | private boolean mCAPlus = false; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 89 | private int mDataState = TelephonyManager.DATA_DISCONNECTED; |
| 90 | private ServiceState mServiceState; |
| 91 | private SignalStrength mSignalStrength; |
| 92 | private MobileIconGroup mDefaultIcons; |
| 93 | private Config mConfig; |
Bill Lin | 767c0db | 2019-08-15 20:42:06 +0800 | [diff] [blame] | 94 | private final Handler mDisplayGraceHandler; |
andychou | b935e68 | 2019-04-11 23:40:49 +0800 | [diff] [blame] | 95 | @VisibleForTesting |
| 96 | boolean mInflateSignalStrengths = false; |
Bill Lin | 767c0db | 2019-08-15 20:42:06 +0800 | [diff] [blame] | 97 | @VisibleForTesting |
| 98 | boolean mIsShowingIconGracefully = false; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 99 | |
| 100 | // TODO: Reduce number of vars passed in, if we have the NetworkController, probably don't |
| 101 | // need listener lists anymore. |
| 102 | public MobileSignalController(Context context, Config config, boolean hasMobileData, |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 103 | TelephonyManager phone, CallbackHandler callbackHandler, |
Jason Monk | c6cc626 | 2015-06-11 11:10:15 -0400 | [diff] [blame] | 104 | NetworkControllerImpl networkController, SubscriptionInfo info, |
| 105 | SubscriptionDefaults defaults, Looper receiverLooper) { |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 106 | super("MobileSignalController(" + info.getSubscriptionId() + ")", context, |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 107 | NetworkCapabilities.TRANSPORT_CELLULAR, callbackHandler, |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 108 | networkController); |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 109 | mNetworkToIconLookup = new HashMap<>(); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 110 | mConfig = config; |
| 111 | mPhone = phone; |
Jason Monk | c6cc626 | 2015-06-11 11:10:15 -0400 | [diff] [blame] | 112 | mDefaults = defaults; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 113 | mSubscriptionInfo = info; |
Jayachandran C | ff50c8e | 2019-10-30 16:41:59 -0700 | [diff] [blame] | 114 | mPhoneStateListener = new MobilePhoneStateListener((new Handler(receiverLooper))::post); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 115 | mNetworkNameSeparator = getStringIfExists(R.string.status_bar_network_name_separator); |
| 116 | mNetworkNameDefault = getStringIfExists( |
| 117 | com.android.internal.R.string.lockscreen_carrier_default); |
| 118 | |
| 119 | mapIconSets(); |
| 120 | |
Jason Monk | 00aa9d4 | 2015-08-10 10:12:02 -0400 | [diff] [blame] | 121 | String networkName = info.getCarrierName() != null ? info.getCarrierName().toString() |
| 122 | : mNetworkNameDefault; |
| 123 | mLastState.networkName = mCurrentState.networkName = networkName; |
| 124 | mLastState.networkNameData = mCurrentState.networkNameData = networkName; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 125 | mLastState.enabled = mCurrentState.enabled = hasMobileData; |
| 126 | mLastState.iconGroup = mCurrentState.iconGroup = mDefaultIcons; |
| 127 | // Get initial data sim state. |
| 128 | updateDataSim(); |
Jason Monk | 0288de0 | 2017-02-23 14:48:05 -0500 | [diff] [blame] | 129 | mObserver = new ContentObserver(new Handler(receiverLooper)) { |
| 130 | @Override |
| 131 | public void onChange(boolean selfChange) { |
| 132 | updateTelephony(); |
| 133 | } |
| 134 | }; |
Bill Lin | 767c0db | 2019-08-15 20:42:06 +0800 | [diff] [blame] | 135 | |
| 136 | mDisplayGraceHandler = new Handler(receiverLooper) { |
| 137 | @Override |
| 138 | public void handleMessage(Message msg) { |
| 139 | if (msg.what == MSG_DISPLAY_GRACE) { |
| 140 | mIsShowingIconGracefully = false; |
| 141 | updateTelephony(); |
| 142 | } |
| 143 | } |
| 144 | }; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | public void setConfiguration(Config config) { |
| 148 | mConfig = config; |
andychou | 9e39628 | 2019-04-10 20:49:06 +0800 | [diff] [blame] | 149 | updateInflateSignalStrength(); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 150 | mapIconSets(); |
| 151 | updateTelephony(); |
| 152 | } |
| 153 | |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 154 | public int getDataContentDescription() { |
| 155 | return getIcons().mDataContentDescription; |
| 156 | } |
| 157 | |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 158 | public void setAirplaneMode(boolean airplaneMode) { |
| 159 | mCurrentState.airplaneMode = airplaneMode; |
| 160 | notifyListenersIfNecessary(); |
| 161 | } |
| 162 | |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 163 | public void setUserSetupComplete(boolean userSetup) { |
| 164 | mCurrentState.userSetup = userSetup; |
| 165 | notifyListenersIfNecessary(); |
| 166 | } |
| 167 | |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 168 | @Override |
| 169 | public void updateConnectivity(BitSet connectedTransports, BitSet validatedTransports) { |
| 170 | boolean isValidated = validatedTransports.get(mTransportType); |
| 171 | mCurrentState.isDefault = connectedTransports.get(mTransportType); |
| 172 | // Only show this as not having connectivity if we are default. |
| 173 | mCurrentState.inetCondition = (isValidated || !mCurrentState.isDefault) ? 1 : 0; |
| 174 | notifyListenersIfNecessary(); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 175 | } |
| 176 | |
Andrew Flynn | a478d70 | 2015-04-14 23:33:45 -0400 | [diff] [blame] | 177 | public void setCarrierNetworkChangeMode(boolean carrierNetworkChangeMode) { |
| 178 | mCurrentState.carrierNetworkChangeMode = carrierNetworkChangeMode; |
Andrew Flynn | 2fdbe12 | 2015-06-01 16:34:21 -0400 | [diff] [blame] | 179 | updateTelephony(); |
Andrew Flynn | a478d70 | 2015-04-14 23:33:45 -0400 | [diff] [blame] | 180 | } |
| 181 | |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 182 | /** |
| 183 | * Start listening for phone state changes. |
| 184 | */ |
| 185 | public void registerListener() { |
| 186 | mPhone.listen(mPhoneStateListener, |
| 187 | PhoneStateListener.LISTEN_SERVICE_STATE |
| 188 | | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS |
| 189 | | PhoneStateListener.LISTEN_CALL_STATE |
| 190 | | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE |
Andrew Flynn | a478d70 | 2015-04-14 23:33:45 -0400 | [diff] [blame] | 191 | | PhoneStateListener.LISTEN_DATA_ACTIVITY |
Fabian Kozynski | aaf7897 | 2019-07-08 10:02:08 -0400 | [diff] [blame] | 192 | | PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE |
| 193 | | PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE); |
Jason Monk | 0288de0 | 2017-02-23 14:48:05 -0500 | [diff] [blame] | 194 | mContext.getContentResolver().registerContentObserver(Global.getUriFor(Global.MOBILE_DATA), |
| 195 | true, mObserver); |
| 196 | mContext.getContentResolver().registerContentObserver(Global.getUriFor( |
| 197 | Global.MOBILE_DATA + mSubscriptionInfo.getSubscriptionId()), |
| 198 | true, mObserver); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | /** |
| 202 | * Stop listening for phone state changes. |
| 203 | */ |
| 204 | public void unregisterListener() { |
| 205 | mPhone.listen(mPhoneStateListener, 0); |
Jason Monk | 0288de0 | 2017-02-23 14:48:05 -0500 | [diff] [blame] | 206 | mContext.getContentResolver().unregisterContentObserver(mObserver); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | /** |
| 210 | * Produce a mapping of data network types to icon groups for simple and quick use in |
| 211 | * updateTelephony. |
| 212 | */ |
| 213 | private void mapIconSets() { |
| 214 | mNetworkToIconLookup.clear(); |
| 215 | |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 216 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EVDO_0), |
| 217 | TelephonyIcons.THREE_G); |
| 218 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EVDO_A), |
| 219 | TelephonyIcons.THREE_G); |
| 220 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EVDO_B), |
| 221 | TelephonyIcons.THREE_G); |
| 222 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EHRPD), |
| 223 | TelephonyIcons.THREE_G); |
| 224 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_UMTS), |
| 225 | TelephonyIcons.THREE_G); |
| 226 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_TD_SCDMA), |
| 227 | TelephonyIcons.THREE_G); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 228 | |
| 229 | if (!mConfig.showAtLeast3G) { |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 230 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_UNKNOWN), |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 231 | TelephonyIcons.UNKNOWN); |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 232 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EDGE), |
| 233 | TelephonyIcons.E); |
| 234 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_CDMA), |
| 235 | TelephonyIcons.ONE_X); |
| 236 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_1xRTT), |
| 237 | TelephonyIcons.ONE_X); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 238 | |
| 239 | mDefaultIcons = TelephonyIcons.G; |
| 240 | } else { |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 241 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_UNKNOWN), |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 242 | TelephonyIcons.THREE_G); |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 243 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_EDGE), |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 244 | TelephonyIcons.THREE_G); |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 245 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_CDMA), |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 246 | TelephonyIcons.THREE_G); |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 247 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_1xRTT), |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 248 | TelephonyIcons.THREE_G); |
| 249 | mDefaultIcons = TelephonyIcons.THREE_G; |
| 250 | } |
| 251 | |
| 252 | MobileIconGroup hGroup = TelephonyIcons.THREE_G; |
Amin Shaikh | f5830ca | 2018-03-09 14:06:50 -0500 | [diff] [blame] | 253 | MobileIconGroup hPlusGroup = TelephonyIcons.THREE_G; |
vagdevi | 3f2b9a5 | 2019-08-09 09:45:14 -0700 | [diff] [blame] | 254 | if (mConfig.show4gFor3g) { |
| 255 | hGroup = TelephonyIcons.FOUR_G; |
| 256 | hPlusGroup = TelephonyIcons.FOUR_G; |
| 257 | } else if (mConfig.hspaDataDistinguishable) { |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 258 | hGroup = TelephonyIcons.H; |
Amin Shaikh | f5830ca | 2018-03-09 14:06:50 -0500 | [diff] [blame] | 259 | hPlusGroup = TelephonyIcons.H_PLUS; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 260 | } |
vagdevi | 3f2b9a5 | 2019-08-09 09:45:14 -0700 | [diff] [blame] | 261 | |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 262 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_HSDPA), hGroup); |
| 263 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_HSUPA), hGroup); |
| 264 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_HSPA), hGroup); |
| 265 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_HSPAP), hPlusGroup); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 266 | |
| 267 | if (mConfig.show4gForLte) { |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 268 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_LTE), |
| 269 | TelephonyIcons.FOUR_G); |
Robert Greenwalt | 37d34ba | 2016-07-27 14:54:34 -0700 | [diff] [blame] | 270 | if (mConfig.hideLtePlus) { |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 271 | mNetworkToIconLookup.put(toIconKeyCA(TelephonyManager.NETWORK_TYPE_LTE), |
Robert Greenwalt | 37d34ba | 2016-07-27 14:54:34 -0700 | [diff] [blame] | 272 | TelephonyIcons.FOUR_G); |
| 273 | } else { |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 274 | mNetworkToIconLookup.put(toIconKeyCA(TelephonyManager.NETWORK_TYPE_LTE), |
Robert Greenwalt | 37d34ba | 2016-07-27 14:54:34 -0700 | [diff] [blame] | 275 | TelephonyIcons.FOUR_G_PLUS); |
| 276 | } |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 277 | } else { |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 278 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_LTE), |
| 279 | TelephonyIcons.LTE); |
Robert Greenwalt | 37d34ba | 2016-07-27 14:54:34 -0700 | [diff] [blame] | 280 | if (mConfig.hideLtePlus) { |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 281 | mNetworkToIconLookup.put(toIconKeyCA(TelephonyManager.NETWORK_TYPE_LTE), |
Robert Greenwalt | 37d34ba | 2016-07-27 14:54:34 -0700 | [diff] [blame] | 282 | TelephonyIcons.LTE); |
| 283 | } else { |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 284 | mNetworkToIconLookup.put(toIconKeyCA(TelephonyManager.NETWORK_TYPE_LTE), |
Robert Greenwalt | 37d34ba | 2016-07-27 14:54:34 -0700 | [diff] [blame] | 285 | TelephonyIcons.LTE_PLUS); |
| 286 | } |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 287 | } |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 288 | mNetworkToIconLookup.put(toIconKeyCAPlus(TelephonyManager.NETWORK_TYPE_LTE), |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 289 | TelephonyIcons.LTE_CA_5G_E); |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 290 | mNetworkToIconLookup.put(toIconKey(TelephonyManager.NETWORK_TYPE_IWLAN), |
| 291 | TelephonyIcons.WFC); |
| 292 | } |
| 293 | |
| 294 | private String getIconKey() { |
| 295 | if (mCA) { |
| 296 | return toIconKeyCA(mDataNetType); |
| 297 | } else if (mCAPlus) { |
| 298 | return toIconKeyCAPlus(mDataNetType); |
| 299 | } else { |
| 300 | return toIconKey(mDataNetType); |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | // Some specific carriers have 5GE network which is special CA network. |
| 305 | private String toIconKeyCAPlus(@Annotation.NetworkType int networkType) { |
| 306 | return toIconKeyCA(networkType) + "_Plus"; |
| 307 | } |
| 308 | |
| 309 | private String toIconKeyCA(@Annotation.NetworkType int networkType) { |
| 310 | return toIconKey(networkType) + "_CA"; |
| 311 | } |
| 312 | |
| 313 | private String toIconKey(@Annotation.NetworkType int networkType) { |
| 314 | return Integer.toString(networkType); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 315 | } |
| 316 | |
andychou | 9e39628 | 2019-04-10 20:49:06 +0800 | [diff] [blame] | 317 | private void updateInflateSignalStrength() { |
Antony Sargent | c026de3 | 2019-05-21 16:29:04 -0700 | [diff] [blame] | 318 | mInflateSignalStrengths = SignalStrengthUtil.shouldInflateSignalStrength(mContext, |
| 319 | mSubscriptionInfo.getSubscriptionId()); |
andychou | 9e39628 | 2019-04-10 20:49:06 +0800 | [diff] [blame] | 320 | } |
| 321 | |
Jason Monk | 48edc0c | 2017-04-10 15:01:27 -0400 | [diff] [blame] | 322 | private int getNumLevels() { |
andychou | 9e39628 | 2019-04-10 20:49:06 +0800 | [diff] [blame] | 323 | if (mInflateSignalStrengths) { |
Jason Monk | 43c14d1 | 2017-06-22 11:20:04 -0400 | [diff] [blame] | 324 | return SignalStrength.NUM_SIGNAL_STRENGTH_BINS + 1; |
| 325 | } |
Jason Monk | 48edc0c | 2017-04-10 15:01:27 -0400 | [diff] [blame] | 326 | return SignalStrength.NUM_SIGNAL_STRENGTH_BINS; |
| 327 | } |
| 328 | |
| 329 | @Override |
| 330 | public int getCurrentIconId() { |
| 331 | if (mCurrentState.iconGroup == TelephonyIcons.CARRIER_NETWORK_CHANGE) { |
| 332 | return SignalDrawable.getCarrierChangeState(getNumLevels()); |
| 333 | } else if (mCurrentState.connected) { |
Jason Monk | 43c14d1 | 2017-06-22 11:20:04 -0400 | [diff] [blame] | 334 | int level = mCurrentState.level; |
andychou | 9e39628 | 2019-04-10 20:49:06 +0800 | [diff] [blame] | 335 | if (mInflateSignalStrengths) { |
Jason Monk | 43c14d1 | 2017-06-22 11:20:04 -0400 | [diff] [blame] | 336 | level++; |
| 337 | } |
Amin Shaikh | af4c193 | 2018-03-08 10:29:56 -0500 | [diff] [blame] | 338 | boolean dataDisabled = mCurrentState.userSetup |
Fabian Kozynski | c7bc84b | 2019-03-11 13:57:31 -0400 | [diff] [blame] | 339 | && (mCurrentState.iconGroup == TelephonyIcons.DATA_DISABLED |
Evan Laird | 2ea99c1 | 2019-09-19 16:52:58 -0400 | [diff] [blame] | 340 | || (mCurrentState.iconGroup == TelephonyIcons.NOT_DEFAULT_DATA |
| 341 | && mCurrentState.defaultDataOff)); |
Amin Shaikh | af4c193 | 2018-03-08 10:29:56 -0500 | [diff] [blame] | 342 | boolean noInternet = mCurrentState.inetCondition == 0; |
| 343 | boolean cutOut = dataDisabled || noInternet; |
| 344 | return SignalDrawable.getState(level, getNumLevels(), cutOut); |
Jason Monk | 48edc0c | 2017-04-10 15:01:27 -0400 | [diff] [blame] | 345 | } else if (mCurrentState.enabled) { |
| 346 | return SignalDrawable.getEmptyState(getNumLevels()); |
| 347 | } else { |
| 348 | return 0; |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | @Override |
Jason Monk | 01df36f | 2017-06-07 13:02:47 -0400 | [diff] [blame] | 353 | public int getQsCurrentIconId() { |
| 354 | return getCurrentIconId(); |
| 355 | } |
| 356 | |
| 357 | @Override |
Jason Monk | e06b065 | 2016-03-02 16:35:27 -0500 | [diff] [blame] | 358 | public void notifyListeners(SignalCallback callback) { |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 359 | MobileIconGroup icons = getIcons(); |
| 360 | |
| 361 | String contentDescription = getStringIfExists(getContentDescription()); |
| 362 | String dataContentDescription = getStringIfExists(icons.mDataContentDescription); |
Amin Shaikh | 43ad7fe | 2018-03-05 14:34:44 -0500 | [diff] [blame] | 363 | if (mCurrentState.inetCondition == 0) { |
| 364 | dataContentDescription = mContext.getString(R.string.data_connection_no_internet); |
| 365 | } |
Fabian Kozynski | c7bc84b | 2019-03-11 13:57:31 -0400 | [diff] [blame] | 366 | final boolean dataDisabled = (mCurrentState.iconGroup == TelephonyIcons.DATA_DISABLED |
Evan Laird | 2ea99c1 | 2019-09-19 16:52:58 -0400 | [diff] [blame] | 367 | || (mCurrentState.iconGroup == TelephonyIcons.NOT_DEFAULT_DATA)) |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 368 | && mCurrentState.userSetup; |
Jeff Davidson | 5c7daaf | 2015-01-27 16:24:32 -0800 | [diff] [blame] | 369 | |
Jason Monk | 0f0de13 | 2016-12-19 15:36:13 -0500 | [diff] [blame] | 370 | // Show icon in QS when we are connected or data is disabled. |
Jason Monk | 7e6c83c | 2017-04-26 14:35:24 -0400 | [diff] [blame] | 371 | boolean showDataIcon = mCurrentState.dataConnected || dataDisabled; |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 372 | IconState statusIcon = new IconState(mCurrentState.enabled && !mCurrentState.airplaneMode, |
| 373 | getCurrentIconId(), contentDescription); |
| 374 | |
Jason Monk | 7e6c83c | 2017-04-26 14:35:24 -0400 | [diff] [blame] | 375 | int qsTypeIcon = 0; |
| 376 | IconState qsIcon = null; |
| 377 | String description = null; |
| 378 | // Only send data sim callbacks to QS. |
| 379 | if (mCurrentState.dataSim) { |
Evan Laird | 9dcd322 | 2017-12-04 14:31:48 -0500 | [diff] [blame] | 380 | qsTypeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.mQsDataType : 0; |
Jason Monk | 7e6c83c | 2017-04-26 14:35:24 -0400 | [diff] [blame] | 381 | qsIcon = new IconState(mCurrentState.enabled |
Jason Monk | 01df36f | 2017-06-07 13:02:47 -0400 | [diff] [blame] | 382 | && !mCurrentState.isEmergency, getQsCurrentIconId(), contentDescription); |
Jason Monk | 7e6c83c | 2017-04-26 14:35:24 -0400 | [diff] [blame] | 383 | description = mCurrentState.isEmergency ? null : mCurrentState.networkName; |
| 384 | } |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 385 | boolean activityIn = mCurrentState.dataConnected |
Jason Monk | 0288de0 | 2017-02-23 14:48:05 -0500 | [diff] [blame] | 386 | && !mCurrentState.carrierNetworkChangeMode |
| 387 | && mCurrentState.activityIn; |
Jason Monk | 07b75fe | 2015-05-14 16:47:03 -0400 | [diff] [blame] | 388 | boolean activityOut = mCurrentState.dataConnected |
Jason Monk | 0288de0 | 2017-02-23 14:48:05 -0500 | [diff] [blame] | 389 | && !mCurrentState.carrierNetworkChangeMode |
| 390 | && mCurrentState.activityOut; |
Jason Monk | 0f0de13 | 2016-12-19 15:36:13 -0500 | [diff] [blame] | 391 | showDataIcon &= mCurrentState.isDefault || dataDisabled; |
Wenting Xiong | 63364fe | 2017-02-07 19:12:27 +0800 | [diff] [blame] | 392 | int typeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.mDataType : 0; |
Jason Monk | 7e6c83c | 2017-04-26 14:35:24 -0400 | [diff] [blame] | 393 | callback.setMobileDataIndicators(statusIcon, qsIcon, typeIcon, qsTypeIcon, |
| 394 | activityIn, activityOut, dataContentDescription, description, icons.mIsWide, |
| 395 | mSubscriptionInfo.getSubscriptionId(), mCurrentState.roaming); |
Andrew Flynn | a478d70 | 2015-04-14 23:33:45 -0400 | [diff] [blame] | 396 | } |
| 397 | |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 398 | @Override |
| 399 | protected MobileState cleanState() { |
| 400 | return new MobileState(); |
| 401 | } |
| 402 | |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 403 | private boolean isCdma() { |
| 404 | return (mSignalStrength != null) && !mSignalStrength.isGsm(); |
| 405 | } |
| 406 | |
| 407 | public boolean isEmergencyOnly() { |
| 408 | return (mServiceState != null && mServiceState.isEmergencyOnly()); |
| 409 | } |
| 410 | |
| 411 | private boolean isRoaming() { |
Shishir Agrawal | 7ef5b88 | 2017-06-26 12:06:03 -0700 | [diff] [blame] | 412 | // During a carrier change, roaming indications need to be supressed. |
| 413 | if (isCarrierNetworkChangeActive()) { |
| 414 | return false; |
| 415 | } |
Jason Monk | e153198 | 2017-09-05 11:20:30 -0400 | [diff] [blame] | 416 | if (isCdma() && mServiceState != null) { |
Jayachandran C | 7803cfa | 2020-01-21 15:01:12 -0800 | [diff] [blame] | 417 | final int iconMode = mPhone.getCdmaEriInformation().getEriIconMode(); |
| 418 | return mPhone.getCdmaEriInformation().getEriIconIndex() != CdmaEriInformation.ERI_OFF |
| 419 | && (iconMode == CdmaEriInformation.ERI_ICON_MODE_NORMAL |
| 420 | || iconMode == CdmaEriInformation.ERI_ICON_MODE_FLASH); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 421 | } else { |
| 422 | return mServiceState != null && mServiceState.getRoaming(); |
| 423 | } |
| 424 | } |
| 425 | |
Andrew Flynn | a478d70 | 2015-04-14 23:33:45 -0400 | [diff] [blame] | 426 | private boolean isCarrierNetworkChangeActive() { |
Andrew Flynn | 55fc800 | 2015-05-29 08:33:46 -0400 | [diff] [blame] | 427 | return mCurrentState.carrierNetworkChangeMode; |
Andrew Flynn | a478d70 | 2015-04-14 23:33:45 -0400 | [diff] [blame] | 428 | } |
| 429 | |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 430 | public void handleBroadcast(Intent intent) { |
| 431 | String action = intent.getAction(); |
Meng Wang | 57f5655 | 2020-01-17 16:58:40 -0800 | [diff] [blame] | 432 | if (action.equals(TelephonyManager.ACTION_SERVICE_PROVIDERS_UPDATED)) { |
| 433 | updateNetworkName(intent.getBooleanExtra(TelephonyManager.EXTRA_SHOW_SPN, false), |
| 434 | intent.getStringExtra(TelephonyManager.EXTRA_SPN), |
| 435 | intent.getStringExtra(TelephonyManager.EXTRA_DATA_SPN), |
| 436 | intent.getBooleanExtra(TelephonyManager.EXTRA_SHOW_PLMN, false), |
| 437 | intent.getStringExtra(TelephonyManager.EXTRA_PLMN)); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 438 | notifyListenersIfNecessary(); |
Jayachandran C | 041e769 | 2019-12-20 16:20:02 -0800 | [diff] [blame] | 439 | } else if (action.equals(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED)) { |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 440 | updateDataSim(); |
Jason Monk | 8fcab35 | 2015-06-29 10:57:00 -0400 | [diff] [blame] | 441 | notifyListenersIfNecessary(); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 442 | } |
| 443 | } |
| 444 | |
| 445 | private void updateDataSim() { |
Fabian Kozynski | ccde55d | 2019-06-26 10:06:09 -0400 | [diff] [blame] | 446 | int activeDataSubId = mDefaults.getActiveDataSubId(); |
| 447 | if (SubscriptionManager.isValidSubscriptionId(activeDataSubId)) { |
| 448 | mCurrentState.dataSim = activeDataSubId == mSubscriptionInfo.getSubscriptionId(); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 449 | } else { |
| 450 | // There doesn't seem to be a data sim selected, however if |
| 451 | // there isn't a MobileSignalController with dataSim set, then |
| 452 | // QS won't get any callbacks and will be blank. Instead |
| 453 | // lets just assume we are the data sim (which will basically |
| 454 | // show one at random) in QS until one is selected. The user |
| 455 | // should pick one soon after, so we shouldn't be in this state |
| 456 | // for long. |
| 457 | mCurrentState.dataSim = true; |
| 458 | } |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 459 | } |
| 460 | |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 461 | private boolean isCarrierSpecificDataIcon() { |
| 462 | if (mConfig.patternOfCarrierSpecificDataIcon == null |
| 463 | || mConfig.patternOfCarrierSpecificDataIcon.length() == 0) { |
| 464 | return false; |
| 465 | } |
| 466 | |
| 467 | Pattern stringPattern = Pattern.compile(mConfig.patternOfCarrierSpecificDataIcon); |
| 468 | String[] operatorNames = new String[]{mServiceState.getOperatorAlphaLongRaw(), |
| 469 | mServiceState.getOperatorAlphaShortRaw()}; |
| 470 | for (String opName : operatorNames) { |
| 471 | if (!TextUtils.isEmpty(opName)) { |
| 472 | Matcher matcher = stringPattern.matcher(opName); |
| 473 | if (matcher.find()) { |
| 474 | return true; |
| 475 | } |
| 476 | } |
| 477 | } |
| 478 | return false; |
| 479 | } |
| 480 | |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 481 | /** |
| 482 | * Updates the network's name based on incoming spn and plmn. |
| 483 | */ |
Pavel Zhamaitsiak | 5504d39 | 2015-03-27 09:24:47 -0700 | [diff] [blame] | 484 | void updateNetworkName(boolean showSpn, String spn, String dataSpn, |
| 485 | boolean showPlmn, String plmn) { |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 486 | if (CHATTY) { |
Pavel Zhamaitsiak | 5504d39 | 2015-03-27 09:24:47 -0700 | [diff] [blame] | 487 | Log.d("CarrierLabel", "updateNetworkName showSpn=" + showSpn |
| 488 | + " spn=" + spn + " dataSpn=" + dataSpn |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 489 | + " showPlmn=" + showPlmn + " plmn=" + plmn); |
| 490 | } |
| 491 | StringBuilder str = new StringBuilder(); |
Pavel Zhamaitsiak | 5504d39 | 2015-03-27 09:24:47 -0700 | [diff] [blame] | 492 | StringBuilder strData = new StringBuilder(); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 493 | if (showPlmn && plmn != null) { |
| 494 | str.append(plmn); |
Pavel Zhamaitsiak | 5504d39 | 2015-03-27 09:24:47 -0700 | [diff] [blame] | 495 | strData.append(plmn); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 496 | } |
| 497 | if (showSpn && spn != null) { |
| 498 | if (str.length() != 0) { |
| 499 | str.append(mNetworkNameSeparator); |
| 500 | } |
| 501 | str.append(spn); |
| 502 | } |
| 503 | if (str.length() != 0) { |
| 504 | mCurrentState.networkName = str.toString(); |
| 505 | } else { |
| 506 | mCurrentState.networkName = mNetworkNameDefault; |
| 507 | } |
Pavel Zhamaitsiak | 5504d39 | 2015-03-27 09:24:47 -0700 | [diff] [blame] | 508 | if (showSpn && dataSpn != null) { |
| 509 | if (strData.length() != 0) { |
| 510 | strData.append(mNetworkNameSeparator); |
| 511 | } |
| 512 | strData.append(dataSpn); |
| 513 | } |
| 514 | if (strData.length() != 0) { |
| 515 | mCurrentState.networkNameData = strData.toString(); |
| 516 | } else { |
| 517 | mCurrentState.networkNameData = mNetworkNameDefault; |
| 518 | } |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | /** |
Jayachandran C | a6f9b6d | 2019-11-07 17:26:02 -0800 | [diff] [blame] | 522 | * Extracts the CellSignalStrengthCdma from SignalStrength then returns the level |
| 523 | */ |
| 524 | private final int getCdmaLevel() { |
| 525 | List<CellSignalStrengthCdma> signalStrengthCdma = |
| 526 | mSignalStrength.getCellSignalStrengths(CellSignalStrengthCdma.class); |
| 527 | if (!signalStrengthCdma.isEmpty()) { |
| 528 | return signalStrengthCdma.get(0).getLevel(); |
| 529 | } |
| 530 | return CellSignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN; |
| 531 | } |
| 532 | |
| 533 | /** |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 534 | * Updates the current state based on mServiceState, mSignalStrength, mDataNetType, |
| 535 | * mDataState, and mSimState. It should be called any time one of these is updated. |
| 536 | * This will call listeners if necessary. |
| 537 | */ |
| 538 | private final void updateTelephony() { |
| 539 | if (DEBUG) { |
SongFerngWang | 8cfb4d5 | 2018-08-21 18:04:29 +0800 | [diff] [blame] | 540 | Log.d(mTag, "updateTelephonySignalStrength: hasService=" + |
| 541 | Utils.isInService(mServiceState) + " ss=" + mSignalStrength); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 542 | } |
Evan Laird | 2ea99c1 | 2019-09-19 16:52:58 -0400 | [diff] [blame] | 543 | checkDefaultData(); |
SongFerngWang | 8cfb4d5 | 2018-08-21 18:04:29 +0800 | [diff] [blame] | 544 | mCurrentState.connected = Utils.isInService(mServiceState) |
| 545 | && mSignalStrength != null; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 546 | if (mCurrentState.connected) { |
| 547 | if (!mSignalStrength.isGsm() && mConfig.alwaysShowCdmaRssi) { |
Jayachandran C | a6f9b6d | 2019-11-07 17:26:02 -0800 | [diff] [blame] | 548 | mCurrentState.level = getCdmaLevel(); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 549 | } else { |
| 550 | mCurrentState.level = mSignalStrength.getLevel(); |
| 551 | } |
| 552 | } |
Pengquan Meng | a62d32b | 2018-12-06 17:38:38 -0800 | [diff] [blame] | 553 | |
| 554 | // When the device is camped on a 5G Non-Standalone network, the data network type is still |
| 555 | // LTE. In this case, we first check which 5G icon should be shown. |
| 556 | MobileIconGroup nr5GIconGroup = getNr5GIconGroup(); |
Bill Lin | 767c0db | 2019-08-15 20:42:06 +0800 | [diff] [blame] | 557 | if (mConfig.nrIconDisplayGracePeriodMs > 0) { |
| 558 | nr5GIconGroup = adjustNr5GIconGroupByDisplayGraceTime(nr5GIconGroup); |
| 559 | } |
| 560 | |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 561 | String iconKey = getIconKey(); |
Pengquan Meng | a62d32b | 2018-12-06 17:38:38 -0800 | [diff] [blame] | 562 | if (nr5GIconGroup != null) { |
| 563 | mCurrentState.iconGroup = nr5GIconGroup; |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 564 | } else if (mNetworkToIconLookup.get(iconKey) != null) { |
| 565 | mCurrentState.iconGroup = mNetworkToIconLookup.get(iconKey); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 566 | } else { |
| 567 | mCurrentState.iconGroup = mDefaultIcons; |
| 568 | } |
| 569 | mCurrentState.dataConnected = mCurrentState.connected |
Jason Monk | 7e6c83c | 2017-04-26 14:35:24 -0400 | [diff] [blame] | 570 | && mDataState == TelephonyManager.DATA_CONNECTED; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 571 | |
Jason Monk | 0f0de13 | 2016-12-19 15:36:13 -0500 | [diff] [blame] | 572 | mCurrentState.roaming = isRoaming(); |
Andrew Flynn | a478d70 | 2015-04-14 23:33:45 -0400 | [diff] [blame] | 573 | if (isCarrierNetworkChangeActive()) { |
| 574 | mCurrentState.iconGroup = TelephonyIcons.CARRIER_NETWORK_CHANGE; |
Wenting Xiong | 63364fe | 2017-02-07 19:12:27 +0800 | [diff] [blame] | 575 | } else if (isDataDisabled() && !mConfig.alwaysShowDataRatIcon) { |
Fabian Kozynski | c7bc84b | 2019-03-11 13:57:31 -0400 | [diff] [blame] | 576 | if (mSubscriptionInfo.getSubscriptionId() |
| 577 | != mDefaults.getDefaultDataSubId()) { |
| 578 | mCurrentState.iconGroup = TelephonyIcons.NOT_DEFAULT_DATA; |
| 579 | } else { |
| 580 | mCurrentState.iconGroup = TelephonyIcons.DATA_DISABLED; |
| 581 | } |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 582 | } |
| 583 | if (isEmergencyOnly() != mCurrentState.isEmergency) { |
| 584 | mCurrentState.isEmergency = isEmergencyOnly(); |
| 585 | mNetworkController.recalculateEmergency(); |
| 586 | } |
| 587 | // Fill in the network name if we think we have it. |
Fabian Kozynski | a909199 | 2019-03-25 11:08:32 -0400 | [diff] [blame] | 588 | if (mCurrentState.networkName.equals(mNetworkNameDefault) && mServiceState != null |
Jason Monk | 93fb68f | 2015-07-20 11:43:56 -0400 | [diff] [blame] | 589 | && !TextUtils.isEmpty(mServiceState.getOperatorAlphaShort())) { |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 590 | mCurrentState.networkName = mServiceState.getOperatorAlphaShort(); |
| 591 | } |
Fabian Kozynski | a909199 | 2019-03-25 11:08:32 -0400 | [diff] [blame] | 592 | // If this is the data subscription, update the currentState data name |
| 593 | if (mCurrentState.networkNameData.equals(mNetworkNameDefault) && mServiceState != null |
| 594 | && mCurrentState.dataSim |
SongFerngWang | 2b1ea8d | 2019-11-20 02:11:09 +0800 | [diff] [blame] | 595 | && !TextUtils.isEmpty(mServiceState.getOperatorAlphaShort())) { |
| 596 | mCurrentState.networkNameData = mServiceState.getOperatorAlphaShort(); |
Fabian Kozynski | a909199 | 2019-03-25 11:08:32 -0400 | [diff] [blame] | 597 | } |
Andrew Flynn | a478d70 | 2015-04-14 23:33:45 -0400 | [diff] [blame] | 598 | |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 599 | notifyListenersIfNecessary(); |
| 600 | } |
| 601 | |
Evan Laird | 2ea99c1 | 2019-09-19 16:52:58 -0400 | [diff] [blame] | 602 | /** |
| 603 | * If we are controlling the NOT_DEFAULT_DATA icon, check the status of the other one |
| 604 | */ |
| 605 | private void checkDefaultData() { |
| 606 | if (mCurrentState.iconGroup != TelephonyIcons.NOT_DEFAULT_DATA) { |
| 607 | mCurrentState.defaultDataOff = false; |
| 608 | return; |
| 609 | } |
| 610 | |
| 611 | mCurrentState.defaultDataOff = mNetworkController.isDataControllerDisabled(); |
| 612 | } |
| 613 | |
| 614 | void onMobileDataChanged() { |
| 615 | checkDefaultData(); |
| 616 | notifyListenersIfNecessary(); |
| 617 | } |
| 618 | |
Pengquan Meng | a62d32b | 2018-12-06 17:38:38 -0800 | [diff] [blame] | 619 | private MobileIconGroup getNr5GIconGroup() { |
| 620 | if (mServiceState == null) return null; |
| 621 | |
Jack Yu | 20d7140 | 2019-03-16 23:00:35 -0700 | [diff] [blame] | 622 | int nrState = mServiceState.getNrState(); |
| 623 | if (nrState == NetworkRegistrationInfo.NR_STATE_CONNECTED) { |
Pengquan Meng | a62d32b | 2018-12-06 17:38:38 -0800 | [diff] [blame] | 624 | // Check if the NR 5G is using millimeter wave and the icon is config. |
| 625 | if (mServiceState.getNrFrequencyRange() == ServiceState.FREQUENCY_RANGE_MMWAVE) { |
| 626 | if (mConfig.nr5GIconMap.containsKey(Config.NR_CONNECTED_MMWAVE)) { |
| 627 | return mConfig.nr5GIconMap.get(Config.NR_CONNECTED_MMWAVE); |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | // If NR 5G is not using millimeter wave or there is no icon for millimeter wave, we |
| 632 | // check the normal 5G icon. |
| 633 | if (mConfig.nr5GIconMap.containsKey(Config.NR_CONNECTED)) { |
| 634 | return mConfig.nr5GIconMap.get(Config.NR_CONNECTED); |
| 635 | } |
Jack Yu | 20d7140 | 2019-03-16 23:00:35 -0700 | [diff] [blame] | 636 | } else if (nrState == NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED) { |
SongFerngWang | 52dada7 | 2019-08-14 16:59:29 +0800 | [diff] [blame] | 637 | if (mCurrentState.activityDormant) { |
| 638 | if (mConfig.nr5GIconMap.containsKey(Config.NR_NOT_RESTRICTED_RRC_IDLE)) { |
| 639 | return mConfig.nr5GIconMap.get(Config.NR_NOT_RESTRICTED_RRC_IDLE); |
| 640 | } |
| 641 | } else { |
| 642 | if (mConfig.nr5GIconMap.containsKey(Config.NR_NOT_RESTRICTED_RRC_CON)) { |
| 643 | return mConfig.nr5GIconMap.get(Config.NR_NOT_RESTRICTED_RRC_CON); |
| 644 | } |
Pengquan Meng | a62d32b | 2018-12-06 17:38:38 -0800 | [diff] [blame] | 645 | } |
Jack Yu | 20d7140 | 2019-03-16 23:00:35 -0700 | [diff] [blame] | 646 | } else if (nrState == NetworkRegistrationInfo.NR_STATE_RESTRICTED) { |
Pengquan Meng | a62d32b | 2018-12-06 17:38:38 -0800 | [diff] [blame] | 647 | if (mConfig.nr5GIconMap.containsKey(Config.NR_RESTRICTED)) { |
| 648 | return mConfig.nr5GIconMap.get(Config.NR_RESTRICTED); |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | return null; |
| 653 | } |
| 654 | |
Bill Lin | 767c0db | 2019-08-15 20:42:06 +0800 | [diff] [blame] | 655 | /** |
| 656 | * The function to adjust MobileIconGroup depend on CarrierConfig's time |
| 657 | * nextIconGroup == null imply next state could be 2G/3G/4G/4G+ |
| 658 | * nextIconGroup != null imply next state will be 5G/5G+ |
| 659 | * Flag : mIsShowingIconGracefully |
| 660 | * --------------------------------------------------------------------------------- |
| 661 | * | Last state | Current state | Flag | Action | |
| 662 | * --------------------------------------------------------------------------------- |
| 663 | * | 5G/5G+ | 2G/3G/4G/4G+ | true | return previous IconGroup | |
| 664 | * | 5G/5G+ | 5G/5G+ | true | Bypass | |
| 665 | * | 2G/3G/4G/4G+ | 5G/5G+ | true | Bypass | |
| 666 | * | 2G/3G/4G/4G+ | 2G/3G/4G/4G+ | true | Bypass | |
| 667 | * | SS.connected | SS.disconnect | T|F | Reset timer | |
| 668 | * |NETWORK_TYPE_LTE|!NETWORK_TYPE_LTE| T|F | Reset timer | |
| 669 | * | 5G/5G+ | 2G/3G/4G/4G+ | false| Bypass | |
| 670 | * | 5G/5G+ | 5G/5G+ | false| Bypass | |
| 671 | * | 2G/3G/4G/4G+ | 5G/5G+ | false| SendMessageDelay(time), flag->true | |
| 672 | * | 2G/3G/4G/4G+ | 2G/3G/4G/4G+ | false| Bypass | |
| 673 | * --------------------------------------------------------------------------------- |
| 674 | */ |
| 675 | private MobileIconGroup adjustNr5GIconGroupByDisplayGraceTime( |
| 676 | MobileIconGroup candidateIconGroup) { |
| 677 | if (mIsShowingIconGracefully && candidateIconGroup == null) { |
| 678 | candidateIconGroup = (MobileIconGroup) mCurrentState.iconGroup; |
| 679 | } else if (!mIsShowingIconGracefully && candidateIconGroup != null |
| 680 | && mLastState.iconGroup != candidateIconGroup) { |
| 681 | mDisplayGraceHandler.sendMessageDelayed( |
| 682 | mDisplayGraceHandler.obtainMessage(MSG_DISPLAY_GRACE), |
| 683 | mConfig.nrIconDisplayGracePeriodMs); |
| 684 | mIsShowingIconGracefully = true; |
| 685 | } else if (!mCurrentState.connected || mDataState == TelephonyManager.DATA_DISCONNECTED |
| 686 | || candidateIconGroup == null) { |
| 687 | mDisplayGraceHandler.removeMessages(MSG_DISPLAY_GRACE); |
| 688 | mIsShowingIconGracefully = false; |
| 689 | candidateIconGroup = null; |
| 690 | } |
| 691 | |
| 692 | return candidateIconGroup; |
| 693 | } |
| 694 | |
Evan Laird | 2ea99c1 | 2019-09-19 16:52:58 -0400 | [diff] [blame] | 695 | boolean isDataDisabled() { |
Shuo Qian | 2914158 | 2020-01-02 15:18:01 -0800 | [diff] [blame] | 696 | return !mPhone.isDataConnectionEnabled(); |
Jason Monk | 1a95c86 | 2016-01-27 15:18:41 -0500 | [diff] [blame] | 697 | } |
| 698 | |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 699 | @VisibleForTesting |
| 700 | void setActivity(int activity) { |
| 701 | mCurrentState.activityIn = activity == TelephonyManager.DATA_ACTIVITY_INOUT |
| 702 | || activity == TelephonyManager.DATA_ACTIVITY_IN; |
| 703 | mCurrentState.activityOut = activity == TelephonyManager.DATA_ACTIVITY_INOUT |
| 704 | || activity == TelephonyManager.DATA_ACTIVITY_OUT; |
SongFerngWang | 52dada7 | 2019-08-14 16:59:29 +0800 | [diff] [blame] | 705 | mCurrentState.activityDormant = activity == TelephonyManager.DATA_ACTIVITY_DORMANT; |
| 706 | |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 707 | notifyListenersIfNecessary(); |
| 708 | } |
| 709 | |
| 710 | @Override |
| 711 | public void dump(PrintWriter pw) { |
| 712 | super.dump(pw); |
| 713 | pw.println(" mSubscription=" + mSubscriptionInfo + ","); |
| 714 | pw.println(" mServiceState=" + mServiceState + ","); |
| 715 | pw.println(" mSignalStrength=" + mSignalStrength + ","); |
| 716 | pw.println(" mDataState=" + mDataState + ","); |
| 717 | pw.println(" mDataNetType=" + mDataNetType + ","); |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 718 | pw.println(" mCA=" + mCA + ","); |
| 719 | pw.println(" mCAPlus=" + mCAPlus + ","); |
andychou | 9e39628 | 2019-04-10 20:49:06 +0800 | [diff] [blame] | 720 | pw.println(" mInflateSignalStrengths=" + mInflateSignalStrengths + ","); |
Malcolm Chen | 04be9d1 | 2019-06-11 19:48:38 -0700 | [diff] [blame] | 721 | pw.println(" isDataDisabled=" + isDataDisabled() + ","); |
Bill Lin | 767c0db | 2019-08-15 20:42:06 +0800 | [diff] [blame] | 722 | pw.println(" mIsShowingIconGracefully=" + mIsShowingIconGracefully + ","); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | class MobilePhoneStateListener extends PhoneStateListener { |
Jayachandran C | ff50c8e | 2019-10-30 16:41:59 -0700 | [diff] [blame] | 726 | public MobilePhoneStateListener(Executor executor) { |
| 727 | super(executor); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 728 | } |
| 729 | |
| 730 | @Override |
| 731 | public void onSignalStrengthsChanged(SignalStrength signalStrength) { |
| 732 | if (DEBUG) { |
| 733 | Log.d(mTag, "onSignalStrengthsChanged signalStrength=" + signalStrength + |
| 734 | ((signalStrength == null) ? "" : (" level=" + signalStrength.getLevel()))); |
| 735 | } |
| 736 | mSignalStrength = signalStrength; |
| 737 | updateTelephony(); |
| 738 | } |
| 739 | |
| 740 | @Override |
| 741 | public void onServiceStateChanged(ServiceState state) { |
| 742 | if (DEBUG) { |
SongFerngWang | 2670cba | 2019-12-23 19:21:14 +0800 | [diff] [blame] | 743 | Log.d(mTag, "onServiceStateChanged voiceState=" + state.getState() |
| 744 | + " dataState=" + state.getDataRegistrationState()); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 745 | } |
| 746 | mServiceState = state; |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 747 | if (mServiceState != null) { |
Hall Liu | 5a95a70 | 2020-01-06 19:04:10 -0800 | [diff] [blame] | 748 | NetworkRegistrationInfo regInfo = mServiceState.getNetworkRegistrationInfo( |
| 749 | DOMAIN_PS, TRANSPORT_TYPE_WWAN); |
| 750 | if (regInfo != null) { |
| 751 | updateDataNetType(regInfo.getAccessNetworkTechnology()); |
| 752 | } |
Robert Greenwalt | ea0d7139 | 2016-07-28 18:50:10 -0700 | [diff] [blame] | 753 | } |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 754 | updateTelephony(); |
| 755 | } |
| 756 | |
| 757 | @Override |
| 758 | public void onDataConnectionStateChanged(int state, int networkType) { |
| 759 | if (DEBUG) { |
| 760 | Log.d(mTag, "onDataConnectionStateChanged: state=" + state |
| 761 | + " type=" + networkType); |
| 762 | } |
| 763 | mDataState = state; |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 764 | updateDataNetType(networkType); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 765 | updateTelephony(); |
| 766 | } |
| 767 | |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 768 | private void updateDataNetType(int networkType) { |
| 769 | mDataNetType = networkType; |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 770 | mCA = false; |
| 771 | mCAPlus = false; |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 772 | if (mDataNetType == TelephonyManager.NETWORK_TYPE_LTE) { |
| 773 | if (isCarrierSpecificDataIcon()) { |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 774 | mCAPlus = true; |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 775 | } else if (mServiceState != null && mServiceState.isUsingCarrierAggregation()) { |
Daniel Bright | aa81904 | 2020-01-10 18:05:01 -0800 | [diff] [blame] | 776 | mCA = true; |
SongFerngWang | 3cbcf75 | 2019-03-21 23:14:20 +0800 | [diff] [blame] | 777 | } |
| 778 | } |
| 779 | } |
| 780 | |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 781 | @Override |
| 782 | public void onDataActivity(int direction) { |
| 783 | if (DEBUG) { |
| 784 | Log.d(mTag, "onDataActivity: direction=" + direction); |
| 785 | } |
| 786 | setActivity(direction); |
| 787 | } |
Andrew Flynn | a478d70 | 2015-04-14 23:33:45 -0400 | [diff] [blame] | 788 | |
| 789 | @Override |
| 790 | public void onCarrierNetworkChange(boolean active) { |
| 791 | if (DEBUG) { |
| 792 | Log.d(mTag, "onCarrierNetworkChange: active=" + active); |
| 793 | } |
| 794 | mCurrentState.carrierNetworkChangeMode = active; |
| 795 | |
| 796 | updateTelephony(); |
| 797 | } |
Fabian Kozynski | aaf7897 | 2019-07-08 10:02:08 -0400 | [diff] [blame] | 798 | |
| 799 | @Override |
| 800 | public void onActiveDataSubscriptionIdChanged(int subId) { |
| 801 | if (DEBUG) Log.d(mTag, "onActiveDataSubscriptionIdChanged: subId=" + subId); |
| 802 | updateDataSim(); |
| 803 | updateTelephony(); |
| 804 | } |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 805 | }; |
| 806 | |
| 807 | static class MobileIconGroup extends SignalController.IconGroup { |
| 808 | final int mDataContentDescription; // mContentDescriptionDataType |
| 809 | final int mDataType; |
| 810 | final boolean mIsWide; |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 811 | final int mQsDataType; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 812 | |
| 813 | public MobileIconGroup(String name, int[][] sbIcons, int[][] qsIcons, int[] contentDesc, |
| 814 | int sbNullState, int qsNullState, int sbDiscState, int qsDiscState, |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 815 | int discContentDesc, int dataContentDesc, int dataType, boolean isWide) { |
Andrew Flynn | 2fdbe12 | 2015-06-01 16:34:21 -0400 | [diff] [blame] | 816 | super(name, sbIcons, qsIcons, contentDesc, sbNullState, qsNullState, sbDiscState, |
| 817 | qsDiscState, discContentDesc); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 818 | mDataContentDescription = dataContentDesc; |
| 819 | mDataType = dataType; |
| 820 | mIsWide = isWide; |
Amin Shaikh | d64e626 | 2018-03-08 10:08:13 -0500 | [diff] [blame] | 821 | mQsDataType = dataType; // TODO: remove this field |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 822 | } |
| 823 | } |
| 824 | |
| 825 | static class MobileState extends SignalController.State { |
| 826 | String networkName; |
Pavel Zhamaitsiak | 5504d39 | 2015-03-27 09:24:47 -0700 | [diff] [blame] | 827 | String networkNameData; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 828 | boolean dataSim; |
| 829 | boolean dataConnected; |
| 830 | boolean isEmergency; |
| 831 | boolean airplaneMode; |
Andrew Flynn | a478d70 | 2015-04-14 23:33:45 -0400 | [diff] [blame] | 832 | boolean carrierNetworkChangeMode; |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 833 | boolean isDefault; |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 834 | boolean userSetup; |
Jason Monk | 0f0de13 | 2016-12-19 15:36:13 -0500 | [diff] [blame] | 835 | boolean roaming; |
Evan Laird | 2ea99c1 | 2019-09-19 16:52:58 -0400 | [diff] [blame] | 836 | boolean defaultDataOff; // Tracks the on/off state of the defaultDataSubscription |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 837 | |
| 838 | @Override |
| 839 | public void copyFrom(State s) { |
| 840 | super.copyFrom(s); |
| 841 | MobileState state = (MobileState) s; |
| 842 | dataSim = state.dataSim; |
| 843 | networkName = state.networkName; |
Pavel Zhamaitsiak | 5504d39 | 2015-03-27 09:24:47 -0700 | [diff] [blame] | 844 | networkNameData = state.networkNameData; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 845 | dataConnected = state.dataConnected; |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 846 | isDefault = state.isDefault; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 847 | isEmergency = state.isEmergency; |
| 848 | airplaneMode = state.airplaneMode; |
Andrew Flynn | a478d70 | 2015-04-14 23:33:45 -0400 | [diff] [blame] | 849 | carrierNetworkChangeMode = state.carrierNetworkChangeMode; |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 850 | userSetup = state.userSetup; |
Jason Monk | 0f0de13 | 2016-12-19 15:36:13 -0500 | [diff] [blame] | 851 | roaming = state.roaming; |
Evan Laird | 2ea99c1 | 2019-09-19 16:52:58 -0400 | [diff] [blame] | 852 | defaultDataOff = state.defaultDataOff; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 853 | } |
| 854 | |
| 855 | @Override |
| 856 | protected void toString(StringBuilder builder) { |
| 857 | super.toString(builder); |
| 858 | builder.append(','); |
| 859 | builder.append("dataSim=").append(dataSim).append(','); |
| 860 | builder.append("networkName=").append(networkName).append(','); |
Pavel Zhamaitsiak | 5504d39 | 2015-03-27 09:24:47 -0700 | [diff] [blame] | 861 | builder.append("networkNameData=").append(networkNameData).append(','); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 862 | builder.append("dataConnected=").append(dataConnected).append(','); |
Jason Monk | 0f0de13 | 2016-12-19 15:36:13 -0500 | [diff] [blame] | 863 | builder.append("roaming=").append(roaming).append(','); |
Jason Monk | 33f8ae7 | 2015-05-08 10:45:15 -0400 | [diff] [blame] | 864 | builder.append("isDefault=").append(isDefault).append(','); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 865 | builder.append("isEmergency=").append(isEmergency).append(','); |
Andrew Flynn | a478d70 | 2015-04-14 23:33:45 -0400 | [diff] [blame] | 866 | builder.append("airplaneMode=").append(airplaneMode).append(','); |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 867 | builder.append("carrierNetworkChangeMode=").append(carrierNetworkChangeMode) |
| 868 | .append(','); |
Evan Laird | 2ea99c1 | 2019-09-19 16:52:58 -0400 | [diff] [blame] | 869 | builder.append("userSetup=").append(userSetup).append(','); |
| 870 | builder.append("defaultDataOff=").append(defaultDataOff); |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 871 | } |
| 872 | |
| 873 | @Override |
| 874 | public boolean equals(Object o) { |
| 875 | return super.equals(o) |
| 876 | && Objects.equals(((MobileState) o).networkName, networkName) |
Pavel Zhamaitsiak | 5504d39 | 2015-03-27 09:24:47 -0700 | [diff] [blame] | 877 | && Objects.equals(((MobileState) o).networkNameData, networkNameData) |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 878 | && ((MobileState) o).dataSim == dataSim |
| 879 | && ((MobileState) o).dataConnected == dataConnected |
| 880 | && ((MobileState) o).isEmergency == isEmergency |
| 881 | && ((MobileState) o).airplaneMode == airplaneMode |
Andrew Flynn | a478d70 | 2015-04-14 23:33:45 -0400 | [diff] [blame] | 882 | && ((MobileState) o).carrierNetworkChangeMode == carrierNetworkChangeMode |
Jason Monk | fd57ea7 | 2016-04-29 13:37:58 -0400 | [diff] [blame] | 883 | && ((MobileState) o).userSetup == userSetup |
Jason Monk | 0f0de13 | 2016-12-19 15:36:13 -0500 | [diff] [blame] | 884 | && ((MobileState) o).isDefault == isDefault |
Evan Laird | 2ea99c1 | 2019-09-19 16:52:58 -0400 | [diff] [blame] | 885 | && ((MobileState) o).roaming == roaming |
| 886 | && ((MobileState) o).defaultDataOff == defaultDataOff; |
Jason Monk | da68f59 | 2015-01-07 10:55:58 -0500 | [diff] [blame] | 887 | } |
| 888 | } |
| 889 | } |