| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 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 android.telephony; |
| 18 | |
| 19 | import android.os.Bundle; |
| 20 | import android.os.Parcel; |
| 21 | import android.os.Parcelable; |
| Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 22 | import android.telephony.Rlog; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Contains phone state and service related information. |
| 26 | * |
| 27 | * The following phone information is included in returned ServiceState: |
| 28 | * |
| 29 | * <ul> |
| 30 | * <li>Service state: IN_SERVICE, OUT_OF_SERVICE, EMERGENCY_ONLY, POWER_OFF |
| 31 | * <li>Roaming indicator |
| 32 | * <li>Operator name, short name and numeric id |
| 33 | * <li>Network selection mode |
| 34 | * </ul> |
| 35 | */ |
| 36 | public class ServiceState implements Parcelable { |
| 37 | |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 38 | static final String LOG_TAG = "PHONE"; |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 39 | static final boolean DBG = true; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 40 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | /** |
| 42 | * Normal operation condition, the phone is registered |
| 43 | * with an operator either in home network or in roaming. |
| 44 | */ |
| 45 | public static final int STATE_IN_SERVICE = 0; |
| 46 | |
| 47 | /** |
| 48 | * Phone is not registered with any operator, the phone |
| 49 | * can be currently searching a new operator to register to, or not |
| 50 | * searching to registration at all, or registration is denied, or radio |
| 51 | * signal is not available. |
| 52 | */ |
| 53 | public static final int STATE_OUT_OF_SERVICE = 1; |
| 54 | |
| 55 | /** |
| 56 | * The phone is registered and locked. Only emergency numbers are allowed. {@more} |
| 57 | */ |
| 58 | public static final int STATE_EMERGENCY_ONLY = 2; |
| 59 | |
| 60 | /** |
| Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 61 | * Radio of telephony is explicitly powered off. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 62 | */ |
| 63 | public static final int STATE_POWER_OFF = 3; |
| 64 | |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 65 | /** |
| 66 | * RIL level registration state values from ril.h |
| 67 | * ((const char **)response)[0] is registration state 0-6, |
| 68 | * 0 - Not registered, MT is not currently searching |
| 69 | * a new operator to register |
| 70 | * 1 - Registered, home network |
| 71 | * 2 - Not registered, but MT is currently searching |
| 72 | * a new operator to register |
| 73 | * 3 - Registration denied |
| 74 | * 4 - Unknown |
| 75 | * 5 - Registered, roaming |
| 76 | * 10 - Same as 0, but indicates that emergency calls |
| 77 | * are enabled. |
| 78 | * 12 - Same as 2, but indicates that emergency calls |
| 79 | * are enabled. |
| 80 | * 13 - Same as 3, but indicates that emergency calls |
| 81 | * are enabled. |
| 82 | * 14 - Same as 4, but indicates that emergency calls |
| 83 | * are enabled. |
| 84 | * @hide |
| 85 | */ |
| 86 | public static final int RIL_REG_STATE_NOT_REG = 0; |
| 87 | /** @hide */ |
| 88 | public static final int RIL_REG_STATE_HOME = 1; |
| 89 | /** @hide */ |
| 90 | public static final int RIL_REG_STATE_SEARCHING = 2; |
| 91 | /** @hide */ |
| 92 | public static final int RIL_REG_STATE_DENIED = 3; |
| 93 | /** @hide */ |
| 94 | public static final int RIL_REG_STATE_UNKNOWN = 4; |
| 95 | /** @hide */ |
| 96 | public static final int RIL_REG_STATE_ROAMING = 5; |
| 97 | /** @hide */ |
| 98 | public static final int RIL_REG_STATE_NOT_REG_EMERGENCY_CALL_ENABLED = 10; |
| 99 | /** @hide */ |
| 100 | public static final int RIL_REG_STATE_SEARCHING_EMERGENCY_CALL_ENABLED = 12; |
| 101 | /** @hide */ |
| 102 | public static final int RIL_REG_STATE_DENIED_EMERGENCY_CALL_ENABLED = 13; |
| 103 | /** @hide */ |
| 104 | public static final int RIL_REG_STATE_UNKNOWN_EMERGENCY_CALL_ENABLED = 14; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | * Available radio technologies for GSM, UMTS and CDMA. |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 108 | * Duplicates the constants from hardware/radio/include/ril.h |
| 109 | * This should only be used by agents working with the ril. Others |
| 110 | * should use the equivalent TelephonyManager.NETWORK_TYPE_* |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 111 | */ |
| 112 | /** @hide */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 113 | public static final int RIL_RADIO_TECHNOLOGY_UNKNOWN = 0; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 114 | /** @hide */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 115 | public static final int RIL_RADIO_TECHNOLOGY_GPRS = 1; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 116 | /** @hide */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 117 | public static final int RIL_RADIO_TECHNOLOGY_EDGE = 2; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 118 | /** @hide */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 119 | public static final int RIL_RADIO_TECHNOLOGY_UMTS = 3; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 120 | /** @hide */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 121 | public static final int RIL_RADIO_TECHNOLOGY_IS95A = 4; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 122 | /** @hide */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 123 | public static final int RIL_RADIO_TECHNOLOGY_IS95B = 5; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 124 | /** @hide */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 125 | public static final int RIL_RADIO_TECHNOLOGY_1xRTT = 6; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 126 | /** @hide */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 127 | public static final int RIL_RADIO_TECHNOLOGY_EVDO_0 = 7; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 128 | /** @hide */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 129 | public static final int RIL_RADIO_TECHNOLOGY_EVDO_A = 8; |
| Li Zhe | ebe6634 | 2009-08-14 19:22:16 +0800 | [diff] [blame] | 130 | /** @hide */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 131 | public static final int RIL_RADIO_TECHNOLOGY_HSDPA = 9; |
| Li Zhe | ebe6634 | 2009-08-14 19:22:16 +0800 | [diff] [blame] | 132 | /** @hide */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 133 | public static final int RIL_RADIO_TECHNOLOGY_HSUPA = 10; |
| Li Zhe | ebe6634 | 2009-08-14 19:22:16 +0800 | [diff] [blame] | 134 | /** @hide */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 135 | public static final int RIL_RADIO_TECHNOLOGY_HSPA = 11; |
| Naveen Kalla | 0a5174a | 2010-04-21 14:48:03 -0700 | [diff] [blame] | 136 | /** @hide */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 137 | public static final int RIL_RADIO_TECHNOLOGY_EVDO_B = 12; |
| Wink Saville | 9d7d628 | 2011-03-12 14:52:01 -0800 | [diff] [blame] | 138 | /** @hide */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 139 | public static final int RIL_RADIO_TECHNOLOGY_EHRPD = 13; |
| Wink Saville | 9d7d628 | 2011-03-12 14:52:01 -0800 | [diff] [blame] | 140 | /** @hide */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 141 | public static final int RIL_RADIO_TECHNOLOGY_LTE = 14; |
| Ramesh Sudini | f572761 | 2011-03-08 15:51:52 -0600 | [diff] [blame] | 142 | /** @hide */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 143 | public static final int RIL_RADIO_TECHNOLOGY_HSPAP = 15; |
| Naveen Kalla | fc2cbe9 | 2011-12-29 15:07:41 -0800 | [diff] [blame] | 144 | /** |
| 145 | * GSM radio technology only supports voice. It does not support data. |
| 146 | * @hide |
| 147 | */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 148 | public static final int RIL_RADIO_TECHNOLOGY_GSM = 16; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 149 | |
| 150 | /** |
| 151 | * Available registration states for GSM, UMTS and CDMA. |
| 152 | */ |
| 153 | /** @hide */ |
| 154 | public static final int REGISTRATION_STATE_NOT_REGISTERED_AND_NOT_SEARCHING = 0; |
| 155 | /** @hide */ |
| 156 | public static final int REGISTRATION_STATE_HOME_NETWORK = 1; |
| 157 | /** @hide */ |
| 158 | public static final int REGISTRATION_STATE_NOT_REGISTERED_AND_SEARCHING = 2; |
| 159 | /** @hide */ |
| 160 | public static final int REGISTRATION_STATE_REGISTRATION_DENIED = 3; |
| 161 | /** @hide */ |
| 162 | public static final int REGISTRATION_STATE_UNKNOWN = 4; |
| 163 | /** @hide */ |
| 164 | public static final int REGISTRATION_STATE_ROAMING = 5; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 165 | |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 166 | private int mVoiceRegState = STATE_OUT_OF_SERVICE; |
| 167 | private int mDataRegState = STATE_OUT_OF_SERVICE; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 168 | private boolean mRoaming; |
| 169 | private String mOperatorAlphaLong; |
| 170 | private String mOperatorAlphaShort; |
| 171 | private String mOperatorNumeric; |
| 172 | private boolean mIsManualNetworkSelection; |
| 173 | |
| John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 174 | private boolean mIsEmergencyOnly; |
| 175 | |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 176 | private int mRilVoiceRadioTechnology; |
| 177 | private int mRilDataRadioTechnology; |
| 178 | |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 179 | private boolean mCssIndicator; |
| 180 | private int mNetworkId; |
| 181 | private int mSystemId; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 182 | private int mCdmaRoamingIndicator; |
| 183 | private int mCdmaDefaultRoamingIndicator; |
| Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 184 | private int mCdmaEriIconIndex; |
| 185 | private int mCdmaEriIconMode; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 186 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 187 | /** |
| 188 | * Create a new ServiceState from a intent notifier Bundle |
| 189 | * |
| 190 | * This method is used by PhoneStateIntentReceiver and maybe by |
| 191 | * external applications. |
| 192 | * |
| 193 | * @param m Bundle from intent notifier |
| 194 | * @return newly created ServiceState |
| 195 | * @hide |
| 196 | */ |
| 197 | public static ServiceState newFromBundle(Bundle m) { |
| 198 | ServiceState ret; |
| 199 | ret = new ServiceState(); |
| 200 | ret.setFromNotifierBundle(m); |
| 201 | return ret; |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Empty constructor |
| 206 | */ |
| 207 | public ServiceState() { |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * Copy constructors |
| 212 | * |
| 213 | * @param s Source service state |
| 214 | */ |
| 215 | public ServiceState(ServiceState s) { |
| 216 | copyFrom(s); |
| 217 | } |
| 218 | |
| 219 | protected void copyFrom(ServiceState s) { |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 220 | mVoiceRegState = s.mVoiceRegState; |
| 221 | mDataRegState = s.mDataRegState; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 222 | mRoaming = s.mRoaming; |
| 223 | mOperatorAlphaLong = s.mOperatorAlphaLong; |
| 224 | mOperatorAlphaShort = s.mOperatorAlphaShort; |
| 225 | mOperatorNumeric = s.mOperatorNumeric; |
| 226 | mIsManualNetworkSelection = s.mIsManualNetworkSelection; |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 227 | mRilVoiceRadioTechnology = s.mRilVoiceRadioTechnology; |
| 228 | mRilDataRadioTechnology = s.mRilDataRadioTechnology; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 229 | mCssIndicator = s.mCssIndicator; |
| 230 | mNetworkId = s.mNetworkId; |
| 231 | mSystemId = s.mSystemId; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 232 | mCdmaRoamingIndicator = s.mCdmaRoamingIndicator; |
| 233 | mCdmaDefaultRoamingIndicator = s.mCdmaDefaultRoamingIndicator; |
| Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 234 | mCdmaEriIconIndex = s.mCdmaEriIconIndex; |
| 235 | mCdmaEriIconMode = s.mCdmaEriIconMode; |
| John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 236 | mIsEmergencyOnly = s.mIsEmergencyOnly; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | /** |
| 240 | * Construct a ServiceState object from the given parcel. |
| 241 | */ |
| 242 | public ServiceState(Parcel in) { |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 243 | mVoiceRegState = in.readInt(); |
| 244 | mDataRegState = in.readInt(); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 245 | mRoaming = in.readInt() != 0; |
| 246 | mOperatorAlphaLong = in.readString(); |
| 247 | mOperatorAlphaShort = in.readString(); |
| 248 | mOperatorNumeric = in.readString(); |
| 249 | mIsManualNetworkSelection = in.readInt() != 0; |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 250 | mRilVoiceRadioTechnology = in.readInt(); |
| 251 | mRilDataRadioTechnology = in.readInt(); |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 252 | mCssIndicator = (in.readInt() != 0); |
| 253 | mNetworkId = in.readInt(); |
| 254 | mSystemId = in.readInt(); |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 255 | mCdmaRoamingIndicator = in.readInt(); |
| 256 | mCdmaDefaultRoamingIndicator = in.readInt(); |
| Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 257 | mCdmaEriIconIndex = in.readInt(); |
| 258 | mCdmaEriIconMode = in.readInt(); |
| John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 259 | mIsEmergencyOnly = in.readInt() != 0; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | public void writeToParcel(Parcel out, int flags) { |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 263 | out.writeInt(mVoiceRegState); |
| 264 | out.writeInt(mDataRegState); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 265 | out.writeInt(mRoaming ? 1 : 0); |
| 266 | out.writeString(mOperatorAlphaLong); |
| 267 | out.writeString(mOperatorAlphaShort); |
| 268 | out.writeString(mOperatorNumeric); |
| 269 | out.writeInt(mIsManualNetworkSelection ? 1 : 0); |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 270 | out.writeInt(mRilVoiceRadioTechnology); |
| 271 | out.writeInt(mRilDataRadioTechnology); |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 272 | out.writeInt(mCssIndicator ? 1 : 0); |
| 273 | out.writeInt(mNetworkId); |
| 274 | out.writeInt(mSystemId); |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 275 | out.writeInt(mCdmaRoamingIndicator); |
| 276 | out.writeInt(mCdmaDefaultRoamingIndicator); |
| Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 277 | out.writeInt(mCdmaEriIconIndex); |
| 278 | out.writeInt(mCdmaEriIconMode); |
| John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 279 | out.writeInt(mIsEmergencyOnly ? 1 : 0); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | public int describeContents() { |
| 283 | return 0; |
| 284 | } |
| 285 | |
| Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 286 | public static final Parcelable.Creator<ServiceState> CREATOR = |
| 287 | new Parcelable.Creator<ServiceState>() { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 288 | public ServiceState createFromParcel(Parcel in) { |
| 289 | return new ServiceState(in); |
| 290 | } |
| 291 | |
| 292 | public ServiceState[] newArray(int size) { |
| 293 | return new ServiceState[size]; |
| 294 | } |
| 295 | }; |
| 296 | |
| 297 | /** |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 298 | * Get current voice service state |
| 299 | */ |
| 300 | public int getState() { |
| 301 | return getVoiceRegState(); |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * Get current voice service state |
| Wink Saville | b690ac3 | 2012-11-14 17:03:01 -0800 | [diff] [blame] | 306 | * |
| Wink Saville | 69e2522 | 2012-11-15 15:16:45 -0800 | [diff] [blame] | 307 | * @see #STATE_IN_SERVICE |
| 308 | * @see #STATE_OUT_OF_SERVICE |
| 309 | * @see #STATE_EMERGENCY_ONLY |
| 310 | * @see #STATE_POWER_OFF |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 311 | * |
| 312 | * @hide |
| Wink Saville | b690ac3 | 2012-11-14 17:03:01 -0800 | [diff] [blame] | 313 | */ |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 314 | public int getVoiceRegState() { |
| 315 | return mVoiceRegState; |
| 316 | } |
| 317 | |
| 318 | /** |
| 319 | * Get current data service state |
| 320 | * |
| 321 | * @see #STATE_IN_SERVICE |
| 322 | * @see #STATE_OUT_OF_SERVICE |
| 323 | * @see #STATE_EMERGENCY_ONLY |
| 324 | * @see #STATE_POWER_OFF |
| 325 | * |
| 326 | * @hide |
| 327 | */ |
| 328 | public int getDataRegState() { |
| 329 | return mDataRegState; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | /** |
| 333 | * Get current roaming indicator of phone |
| 334 | * (note: not just decoding from TS 27.007 7.2) |
| 335 | * |
| 336 | * @return true if TS 27.007 7.2 roaming is true |
| 337 | * and ONS is different from SPN |
| 338 | * |
| 339 | */ |
| 340 | public boolean getRoaming() { |
| 341 | return mRoaming; |
| 342 | } |
| 343 | |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 344 | /** |
| 345 | * @hide |
| 346 | */ |
| John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 347 | public boolean isEmergencyOnly() { |
| 348 | return mIsEmergencyOnly; |
| 349 | } |
| 350 | |
| 351 | /** |
| 352 | * @hide |
| 353 | */ |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 354 | public int getCdmaRoamingIndicator(){ |
| 355 | return this.mCdmaRoamingIndicator; |
| 356 | } |
| 357 | |
| 358 | /** |
| 359 | * @hide |
| 360 | */ |
| 361 | public int getCdmaDefaultRoamingIndicator(){ |
| 362 | return this.mCdmaDefaultRoamingIndicator; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 363 | } |
| 364 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 365 | /** |
| Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 366 | * @hide |
| 367 | */ |
| 368 | public int getCdmaEriIconIndex() { |
| 369 | return this.mCdmaEriIconIndex; |
| 370 | } |
| 371 | |
| 372 | /** |
| 373 | * @hide |
| 374 | */ |
| 375 | public int getCdmaEriIconMode() { |
| 376 | return this.mCdmaEriIconMode; |
| 377 | } |
| 378 | |
| 379 | /** |
| Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 380 | * Get current registered operator name in long alphanumeric format. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 381 | * |
| Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 382 | * In GSM/UMTS, long format can be up to 16 characters long. |
| 383 | * In CDMA, returns the ERI text, if set. Otherwise, returns the ONS. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 384 | * |
| 385 | * @return long name of operator, null if unregistered or unknown |
| 386 | */ |
| 387 | public String getOperatorAlphaLong() { |
| 388 | return mOperatorAlphaLong; |
| 389 | } |
| 390 | |
| 391 | /** |
| Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 392 | * Get current registered operator name in short alphanumeric format. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 393 | * |
| Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 394 | * In GSM/UMTS, short format can be up to 8 characters long. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 395 | * |
| 396 | * @return short name of operator, null if unregistered or unknown |
| 397 | */ |
| 398 | public String getOperatorAlphaShort() { |
| 399 | return mOperatorAlphaShort; |
| 400 | } |
| 401 | |
| 402 | /** |
| Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 403 | * Get current registered operator numeric id. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 404 | * |
| 405 | * In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit |
| Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 406 | * network code. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 407 | * |
| 408 | * @return numeric format of operator, null if unregistered or unknown |
| 409 | */ |
| Jean-Baptiste Queru | e25863c | 2010-05-18 11:54:42 -0700 | [diff] [blame] | 410 | /* |
| Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 411 | * The country code can be decoded using |
| 412 | * {@link com.android.internal.telephony.MccTable#countryCodeForMcc(int)}. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 413 | */ |
| 414 | public String getOperatorNumeric() { |
| 415 | return mOperatorNumeric; |
| 416 | } |
| 417 | |
| 418 | /** |
| Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 419 | * Get current network selection mode. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 420 | * |
| 421 | * @return true if manual mode, false if automatic mode |
| 422 | */ |
| 423 | public boolean getIsManualSelection() { |
| 424 | return mIsManualNetworkSelection; |
| 425 | } |
| 426 | |
| 427 | @Override |
| 428 | public int hashCode() { |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 429 | return ((mVoiceRegState * 31) |
| 430 | + (mDataRegState * 37) |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 431 | + (mRoaming ? 1 : 0) |
| 432 | + (mIsManualNetworkSelection ? 1 : 0) |
| 433 | + ((null == mOperatorAlphaLong) ? 0 : mOperatorAlphaLong.hashCode()) |
| 434 | + ((null == mOperatorAlphaShort) ? 0 : mOperatorAlphaShort.hashCode()) |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 435 | + ((null == mOperatorNumeric) ? 0 : mOperatorNumeric.hashCode()) |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 436 | + mCdmaRoamingIndicator |
| John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 437 | + mCdmaDefaultRoamingIndicator |
| 438 | + (mIsEmergencyOnly ? 1 : 0)); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | @Override |
| 442 | public boolean equals (Object o) { |
| 443 | ServiceState s; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 444 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 445 | try { |
| 446 | s = (ServiceState) o; |
| 447 | } catch (ClassCastException ex) { |
| 448 | return false; |
| 449 | } |
| 450 | |
| 451 | if (o == null) { |
| 452 | return false; |
| 453 | } |
| 454 | |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 455 | return (mVoiceRegState == s.mVoiceRegState |
| 456 | && mDataRegState == s.mDataRegState |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 457 | && mRoaming == s.mRoaming |
| 458 | && mIsManualNetworkSelection == s.mIsManualNetworkSelection |
| 459 | && equalsHandlesNulls(mOperatorAlphaLong, s.mOperatorAlphaLong) |
| 460 | && equalsHandlesNulls(mOperatorAlphaShort, s.mOperatorAlphaShort) |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 461 | && equalsHandlesNulls(mOperatorNumeric, s.mOperatorNumeric) |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 462 | && equalsHandlesNulls(mRilVoiceRadioTechnology, s.mRilVoiceRadioTechnology) |
| 463 | && equalsHandlesNulls(mRilDataRadioTechnology, s.mRilDataRadioTechnology) |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 464 | && equalsHandlesNulls(mCssIndicator, s.mCssIndicator) |
| 465 | && equalsHandlesNulls(mNetworkId, s.mNetworkId) |
| 466 | && equalsHandlesNulls(mSystemId, s.mSystemId) |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 467 | && equalsHandlesNulls(mCdmaRoamingIndicator, s.mCdmaRoamingIndicator) |
| 468 | && equalsHandlesNulls(mCdmaDefaultRoamingIndicator, |
| John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 469 | s.mCdmaDefaultRoamingIndicator) |
| 470 | && mIsEmergencyOnly == s.mIsEmergencyOnly); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 471 | } |
| 472 | |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 473 | /** |
| 474 | * Convert radio technology to String |
| 475 | * |
| 476 | * @param radioTechnology |
| 477 | * @return String representation of the RAT |
| 478 | * |
| 479 | * @hide |
| 480 | */ |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 481 | public static String rilRadioTechnologyToString(int rt) { |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 482 | String rtString; |
| 483 | |
| 484 | switch(rt) { |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 485 | case RIL_RADIO_TECHNOLOGY_UNKNOWN: |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 486 | rtString = "Unknown"; |
| 487 | break; |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 488 | case RIL_RADIO_TECHNOLOGY_GPRS: |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 489 | rtString = "GPRS"; |
| 490 | break; |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 491 | case RIL_RADIO_TECHNOLOGY_EDGE: |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 492 | rtString = "EDGE"; |
| 493 | break; |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 494 | case RIL_RADIO_TECHNOLOGY_UMTS: |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 495 | rtString = "UMTS"; |
| 496 | break; |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 497 | case RIL_RADIO_TECHNOLOGY_IS95A: |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 498 | rtString = "CDMA-IS95A"; |
| 499 | break; |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 500 | case RIL_RADIO_TECHNOLOGY_IS95B: |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 501 | rtString = "CDMA-IS95B"; |
| 502 | break; |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 503 | case RIL_RADIO_TECHNOLOGY_1xRTT: |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 504 | rtString = "1xRTT"; |
| 505 | break; |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 506 | case RIL_RADIO_TECHNOLOGY_EVDO_0: |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 507 | rtString = "EvDo-rev.0"; |
| 508 | break; |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 509 | case RIL_RADIO_TECHNOLOGY_EVDO_A: |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 510 | rtString = "EvDo-rev.A"; |
| 511 | break; |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 512 | case RIL_RADIO_TECHNOLOGY_HSDPA: |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 513 | rtString = "HSDPA"; |
| 514 | break; |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 515 | case RIL_RADIO_TECHNOLOGY_HSUPA: |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 516 | rtString = "HSUPA"; |
| 517 | break; |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 518 | case RIL_RADIO_TECHNOLOGY_HSPA: |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 519 | rtString = "HSPA"; |
| 520 | break; |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 521 | case RIL_RADIO_TECHNOLOGY_EVDO_B: |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 522 | rtString = "EvDo-rev.B"; |
| 523 | break; |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 524 | case RIL_RADIO_TECHNOLOGY_EHRPD: |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 525 | rtString = "eHRPD"; |
| 526 | break; |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 527 | case RIL_RADIO_TECHNOLOGY_LTE: |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 528 | rtString = "LTE"; |
| 529 | break; |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 530 | case RIL_RADIO_TECHNOLOGY_HSPAP: |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 531 | rtString = "HSPAP"; |
| 532 | break; |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 533 | case RIL_RADIO_TECHNOLOGY_GSM: |
| Naveen Kalla | fc2cbe9 | 2011-12-29 15:07:41 -0800 | [diff] [blame] | 534 | rtString = "GSM"; |
| 535 | break; |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 536 | default: |
| 537 | rtString = "Unexpected"; |
| Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 538 | Rlog.w(LOG_TAG, "Unexpected radioTechnology=" + rt); |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 539 | break; |
| 540 | } |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 541 | return rtString; |
| Wink Saville | db09b5d | 2011-06-03 09:06:28 -0700 | [diff] [blame] | 542 | } |
| 543 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 544 | @Override |
| 545 | public String toString() { |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 546 | String radioTechnology = rilRadioTechnologyToString(mRilVoiceRadioTechnology); |
| 547 | String dataRadioTechnology = rilRadioTechnologyToString(mRilDataRadioTechnology); |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 548 | |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 549 | return (mVoiceRegState + " " + mDataRegState + " " + (mRoaming ? "roaming" : "home") |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 550 | + " " + mOperatorAlphaLong |
| 551 | + " " + mOperatorAlphaShort |
| 552 | + " " + mOperatorNumeric |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 553 | + " " + (mIsManualNetworkSelection ? "(manual)" : "") |
| 554 | + " " + radioTechnology |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 555 | + " " + dataRadioTechnology |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 556 | + " " + (mCssIndicator ? "CSS supported" : "CSS not supported") |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 557 | + " " + mNetworkId |
| 558 | + " " + mSystemId |
| Wink Saville | e613adc | 2010-11-16 16:11:41 -0800 | [diff] [blame] | 559 | + " RoamInd=" + mCdmaRoamingIndicator |
| 560 | + " DefRoamInd=" + mCdmaDefaultRoamingIndicator |
| 561 | + " EmergOnly=" + mIsEmergencyOnly); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 562 | } |
| 563 | |
| Robert Greenwalt | a226745 | 2011-06-30 12:24:26 -0700 | [diff] [blame] | 564 | private void setNullState(int state) { |
| Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 565 | if (DBG) Rlog.d(LOG_TAG, "[ServiceState] setNullState=" + state); |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 566 | mVoiceRegState = state; |
| 567 | mDataRegState = state; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 568 | mRoaming = false; |
| 569 | mOperatorAlphaLong = null; |
| 570 | mOperatorAlphaShort = null; |
| 571 | mOperatorNumeric = null; |
| 572 | mIsManualNetworkSelection = false; |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 573 | mRilVoiceRadioTechnology = 0; |
| 574 | mRilDataRadioTechnology = 0; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 575 | mCssIndicator = false; |
| 576 | mNetworkId = -1; |
| 577 | mSystemId = -1; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 578 | mCdmaRoamingIndicator = -1; |
| 579 | mCdmaDefaultRoamingIndicator = -1; |
| Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 580 | mCdmaEriIconIndex = -1; |
| 581 | mCdmaEriIconMode = -1; |
| John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 582 | mIsEmergencyOnly = false; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 583 | } |
| 584 | |
| Robert Greenwalt | a226745 | 2011-06-30 12:24:26 -0700 | [diff] [blame] | 585 | public void setStateOutOfService() { |
| 586 | setNullState(STATE_OUT_OF_SERVICE); |
| 587 | } |
| 588 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 589 | public void setStateOff() { |
| Robert Greenwalt | a226745 | 2011-06-30 12:24:26 -0700 | [diff] [blame] | 590 | setNullState(STATE_POWER_OFF); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 591 | } |
| 592 | |
| 593 | public void setState(int state) { |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 594 | setVoiceRegState(state); |
| Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 595 | if (DBG) Rlog.e(LOG_TAG, "[ServiceState] setState deprecated use setVoiceRegState()"); |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | /** @hide */ |
| 599 | public void setVoiceRegState(int state) { |
| 600 | mVoiceRegState = state; |
| Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 601 | if (DBG) Rlog.d(LOG_TAG, "[ServiceState] setVoiceRegState=" + mVoiceRegState); |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | /** @hide */ |
| 605 | public void setDataRegState(int state) { |
| 606 | mDataRegState = state; |
| Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 607 | if (DBG) Rlog.d(LOG_TAG, "[ServiceState] setDataRegState=" + mDataRegState); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | public void setRoaming(boolean roaming) { |
| 611 | mRoaming = roaming; |
| 612 | } |
| 613 | |
| John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 614 | |
| 615 | /** |
| 616 | * @hide |
| 617 | */ |
| 618 | public void setEmergencyOnly(boolean emergencyOnly) { |
| 619 | mIsEmergencyOnly = emergencyOnly; |
| 620 | } |
| 621 | |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 622 | /** |
| 623 | * @hide |
| 624 | */ |
| 625 | public void setCdmaRoamingIndicator(int roaming) { |
| 626 | this.mCdmaRoamingIndicator = roaming; |
| 627 | } |
| 628 | |
| 629 | /** |
| 630 | * @hide |
| 631 | */ |
| 632 | public void setCdmaDefaultRoamingIndicator (int roaming) { |
| 633 | this.mCdmaDefaultRoamingIndicator = roaming; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 634 | } |
| 635 | |
| Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 636 | /** |
| 637 | * @hide |
| 638 | */ |
| 639 | public void setCdmaEriIconIndex(int index) { |
| 640 | this.mCdmaEriIconIndex = index; |
| 641 | } |
| 642 | |
| 643 | /** |
| 644 | * @hide |
| 645 | */ |
| 646 | public void setCdmaEriIconMode(int mode) { |
| 647 | this.mCdmaEriIconMode = mode; |
| 648 | } |
| 649 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 650 | public void setOperatorName(String longName, String shortName, String numeric) { |
| 651 | mOperatorAlphaLong = longName; |
| 652 | mOperatorAlphaShort = shortName; |
| 653 | mOperatorNumeric = numeric; |
| 654 | } |
| 655 | |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 656 | /** |
| Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 657 | * In CDMA, mOperatorAlphaLong can be set from the ERI text. |
| 658 | * This is done from the CDMAPhone and not from the CdmaServiceStateTracker. |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 659 | * |
| 660 | * @hide |
| 661 | */ |
| Kazuhiro Ondo | c91c7f9 | 2011-06-02 00:19:49 -0500 | [diff] [blame] | 662 | public void setOperatorAlphaLong(String longName) { |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 663 | mOperatorAlphaLong = longName; |
| 664 | } |
| 665 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 666 | public void setIsManualSelection(boolean isManual) { |
| 667 | mIsManualNetworkSelection = isManual; |
| 668 | } |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 669 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 670 | /** |
| Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 671 | * Test whether two objects hold the same data values or both are null. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 672 | * |
| 673 | * @param a first obj |
| 674 | * @param b second obj |
| 675 | * @return true if two objects equal or both are null |
| 676 | */ |
| 677 | private static boolean equalsHandlesNulls (Object a, Object b) { |
| 678 | return (a == null) ? (b == null) : a.equals (b); |
| 679 | } |
| 680 | |
| 681 | /** |
| Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 682 | * Set ServiceState based on intent notifier map. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 683 | * |
| 684 | * @param m intent notifier map |
| 685 | * @hide |
| 686 | */ |
| 687 | private void setFromNotifierBundle(Bundle m) { |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 688 | mVoiceRegState = m.getInt("voiceRegState"); |
| 689 | mDataRegState = m.getInt("dataRegState"); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 690 | mRoaming = m.getBoolean("roaming"); |
| 691 | mOperatorAlphaLong = m.getString("operator-alpha-long"); |
| 692 | mOperatorAlphaShort = m.getString("operator-alpha-short"); |
| 693 | mOperatorNumeric = m.getString("operator-numeric"); |
| 694 | mIsManualNetworkSelection = m.getBoolean("manual"); |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 695 | mRilVoiceRadioTechnology = m.getInt("radioTechnology"); |
| Sungmin Choi | 20a03ec | 2013-10-19 17:26:11 -0700 | [diff] [blame] | 696 | mRilDataRadioTechnology = m.getInt("dataRadioTechnology"); |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 697 | mCssIndicator = m.getBoolean("cssIndicator"); |
| 698 | mNetworkId = m.getInt("networkId"); |
| 699 | mSystemId = m.getInt("systemId"); |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 700 | mCdmaRoamingIndicator = m.getInt("cdmaRoamingIndicator"); |
| 701 | mCdmaDefaultRoamingIndicator = m.getInt("cdmaDefaultRoamingIndicator"); |
| John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 702 | mIsEmergencyOnly = m.getBoolean("emergencyOnly"); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | /** |
| Jake Hamby | 390de22 | 2010-05-10 18:46:45 -0700 | [diff] [blame] | 706 | * Set intent notifier Bundle based on service state. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 707 | * |
| 708 | * @param m intent notifier Bundle |
| 709 | * @hide |
| 710 | */ |
| 711 | public void fillInNotifierBundle(Bundle m) { |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 712 | m.putInt("voiceRegState", mVoiceRegState); |
| 713 | m.putInt("dataRegState", mDataRegState); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 714 | m.putBoolean("roaming", Boolean.valueOf(mRoaming)); |
| 715 | m.putString("operator-alpha-long", mOperatorAlphaLong); |
| 716 | m.putString("operator-alpha-short", mOperatorAlphaShort); |
| 717 | m.putString("operator-numeric", mOperatorNumeric); |
| 718 | m.putBoolean("manual", Boolean.valueOf(mIsManualNetworkSelection)); |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 719 | m.putInt("radioTechnology", mRilVoiceRadioTechnology); |
| 720 | m.putInt("dataRadioTechnology", mRilDataRadioTechnology); |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 721 | m.putBoolean("cssIndicator", mCssIndicator); |
| 722 | m.putInt("networkId", mNetworkId); |
| 723 | m.putInt("systemId", mSystemId); |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 724 | m.putInt("cdmaRoamingIndicator", mCdmaRoamingIndicator); |
| 725 | m.putInt("cdmaDefaultRoamingIndicator", mCdmaDefaultRoamingIndicator); |
| John Wang | 56c2d2f | 2010-04-07 08:57:17 -0700 | [diff] [blame] | 726 | m.putBoolean("emergencyOnly", Boolean.valueOf(mIsEmergencyOnly)); |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 727 | } |
| 728 | |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 729 | /** @hide */ |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 730 | public void setRilVoiceRadioTechnology(int rt) { |
| 731 | this.mRilVoiceRadioTechnology = rt; |
| 732 | } |
| 733 | |
| 734 | /** @hide */ |
| 735 | public void setRilDataRadioTechnology(int rt) { |
| 736 | this.mRilDataRadioTechnology = rt; |
| Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 737 | if (DBG) Rlog.d(LOG_TAG, "[ServiceState] setDataRadioTechnology=" + mRilDataRadioTechnology); |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 738 | } |
| 739 | |
| 740 | /** @hide */ |
| 741 | public void setCssIndicator(int css) { |
| 742 | this.mCssIndicator = (css != 0); |
| 743 | } |
| 744 | |
| 745 | /** @hide */ |
| 746 | public void setSystemAndNetworkId(int systemId, int networkId) { |
| 747 | this.mSystemId = systemId; |
| 748 | this.mNetworkId = networkId; |
| 749 | } |
| 750 | |
| 751 | /** @hide */ |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 752 | public int getRilVoiceRadioTechnology() { |
| 753 | return this.mRilVoiceRadioTechnology; |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 754 | } |
| Mathias Agopian | d13f9aa | 2012-02-24 19:28:42 -0800 | [diff] [blame] | 755 | /** @hide */ |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 756 | public int getRilDataRadioTechnology() { |
| 757 | return this.mRilDataRadioTechnology; |
| 758 | } |
| 759 | /** |
| 760 | * @hide |
| 761 | * @Deprecated to be removed Q3 2013 use {@link #getRilDataRadioTechnology} or |
| 762 | * {@link #getRilVoiceRadioTechnology} |
| 763 | */ |
| Mathias Agopian | d13f9aa | 2012-02-24 19:28:42 -0800 | [diff] [blame] | 764 | public int getRadioTechnology() { |
| Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 765 | Rlog.e(LOG_TAG, "ServiceState.getRadioTechnology() DEPRECATED will be removed *******"); |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 766 | return getRilDataRadioTechnology(); |
| Mathias Agopian | d13f9aa | 2012-02-24 19:28:42 -0800 | [diff] [blame] | 767 | } |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 768 | |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 769 | private int rilRadioTechnologyToNetworkType(int rt) { |
| 770 | switch(rt) { |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 771 | case ServiceState.RIL_RADIO_TECHNOLOGY_GPRS: |
| 772 | return TelephonyManager.NETWORK_TYPE_GPRS; |
| 773 | case ServiceState.RIL_RADIO_TECHNOLOGY_EDGE: |
| 774 | return TelephonyManager.NETWORK_TYPE_EDGE; |
| 775 | case ServiceState.RIL_RADIO_TECHNOLOGY_UMTS: |
| 776 | return TelephonyManager.NETWORK_TYPE_UMTS; |
| 777 | case ServiceState.RIL_RADIO_TECHNOLOGY_HSDPA: |
| 778 | return TelephonyManager.NETWORK_TYPE_HSDPA; |
| 779 | case ServiceState.RIL_RADIO_TECHNOLOGY_HSUPA: |
| 780 | return TelephonyManager.NETWORK_TYPE_HSUPA; |
| 781 | case ServiceState.RIL_RADIO_TECHNOLOGY_HSPA: |
| 782 | return TelephonyManager.NETWORK_TYPE_HSPA; |
| 783 | case ServiceState.RIL_RADIO_TECHNOLOGY_IS95A: |
| 784 | case ServiceState.RIL_RADIO_TECHNOLOGY_IS95B: |
| 785 | return TelephonyManager.NETWORK_TYPE_CDMA; |
| 786 | case ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT: |
| 787 | return TelephonyManager.NETWORK_TYPE_1xRTT; |
| 788 | case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0: |
| 789 | return TelephonyManager.NETWORK_TYPE_EVDO_0; |
| 790 | case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A: |
| 791 | return TelephonyManager.NETWORK_TYPE_EVDO_A; |
| 792 | case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_B: |
| 793 | return TelephonyManager.NETWORK_TYPE_EVDO_B; |
| 794 | case ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD: |
| 795 | return TelephonyManager.NETWORK_TYPE_EHRPD; |
| 796 | case ServiceState.RIL_RADIO_TECHNOLOGY_LTE: |
| 797 | return TelephonyManager.NETWORK_TYPE_LTE; |
| 798 | case ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP: |
| 799 | return TelephonyManager.NETWORK_TYPE_HSPAP; |
| 800 | default: |
| 801 | return TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 802 | } |
| 803 | } |
| 804 | |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 805 | /** |
| 806 | * @Deprecated to be removed Q3 2013 use {@link #getVoiceNetworkType} |
| 807 | * @hide |
| 808 | */ |
| 809 | public int getNetworkType() { |
| Wink Saville | 599a90c | 2012-11-27 12:29:13 -0800 | [diff] [blame] | 810 | Rlog.e(LOG_TAG, "ServiceState.getNetworkType() DEPRECATED will be removed *******"); |
| Wink Saville | 0dde2c2 | 2012-11-16 08:12:11 -0800 | [diff] [blame] | 811 | return rilRadioTechnologyToNetworkType(mRilVoiceRadioTechnology); |
| 812 | } |
| 813 | |
| 814 | /** @hide */ |
| 815 | public int getDataNetworkType() { |
| 816 | return rilRadioTechnologyToNetworkType(mRilDataRadioTechnology); |
| 817 | } |
| 818 | |
| 819 | /** @hide */ |
| 820 | public int getVoiceNetworkType() { |
| 821 | return rilRadioTechnologyToNetworkType(mRilVoiceRadioTechnology); |
| 822 | } |
| 823 | |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 824 | /** @hide */ |
| Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 825 | public int getCssIndicator() { |
| 826 | return this.mCssIndicator ? 1 : 0; |
| 827 | } |
| 828 | |
| 829 | /** @hide */ |
| 830 | public int getNetworkId() { |
| 831 | return this.mNetworkId; |
| 832 | } |
| 833 | |
| 834 | /** @hide */ |
| 835 | public int getSystemId() { |
| 836 | return this.mSystemId; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 837 | } |
| Naveen Kalla | fc2cbe9 | 2011-12-29 15:07:41 -0800 | [diff] [blame] | 838 | |
| 839 | /** @hide */ |
| 840 | public static boolean isGsm(int radioTechnology) { |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 841 | return radioTechnology == RIL_RADIO_TECHNOLOGY_GPRS |
| 842 | || radioTechnology == RIL_RADIO_TECHNOLOGY_EDGE |
| 843 | || radioTechnology == RIL_RADIO_TECHNOLOGY_UMTS |
| 844 | || radioTechnology == RIL_RADIO_TECHNOLOGY_HSDPA |
| 845 | || radioTechnology == RIL_RADIO_TECHNOLOGY_HSUPA |
| 846 | || radioTechnology == RIL_RADIO_TECHNOLOGY_HSPA |
| 847 | || radioTechnology == RIL_RADIO_TECHNOLOGY_LTE |
| 848 | || radioTechnology == RIL_RADIO_TECHNOLOGY_HSPAP |
| 849 | || radioTechnology == RIL_RADIO_TECHNOLOGY_GSM; |
| Naveen Kalla | fc2cbe9 | 2011-12-29 15:07:41 -0800 | [diff] [blame] | 850 | } |
| 851 | |
| 852 | /** @hide */ |
| 853 | public static boolean isCdma(int radioTechnology) { |
| Robert Greenwalt | 1434d7b | 2012-02-17 13:14:08 -0800 | [diff] [blame] | 854 | return radioTechnology == RIL_RADIO_TECHNOLOGY_IS95A |
| 855 | || radioTechnology == RIL_RADIO_TECHNOLOGY_IS95B |
| 856 | || radioTechnology == RIL_RADIO_TECHNOLOGY_1xRTT |
| 857 | || radioTechnology == RIL_RADIO_TECHNOLOGY_EVDO_0 |
| 858 | || radioTechnology == RIL_RADIO_TECHNOLOGY_EVDO_A |
| 859 | || radioTechnology == RIL_RADIO_TECHNOLOGY_EVDO_B |
| 860 | || radioTechnology == RIL_RADIO_TECHNOLOGY_EHRPD; |
| Naveen Kalla | fc2cbe9 | 2011-12-29 15:07:41 -0800 | [diff] [blame] | 861 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 862 | } |