1 /* 2 * Copyright (c) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ims; 18 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 22 /** 23 * This class enables an application to get details on why a method call failed. 24 * 25 * @hide 26 */ 27 public class ImsReasonInfo implements Parcelable { 28 29 /** 30 * Reason types, defines the error category. 31 * UNSPECIFIED - unknown error reason 32 * LOCAL - indicates the local/device error reason 33 * LOCAL_TIMEOUT - indicates the local error reason when a specific timer is expired 34 * STATUSCODE - indicates the interworking error reason by SIP status code received 35 * from the network 36 * MEDIA - indicates the media error reason (local resource, SDP parameter, etc.) 37 * USER - indicates the error reason by the local or remote user 38 * UT - indicates the error reason for the supplementary service configuration 39 */ 40 public static final int TYPE_UNSPECIFIED = 0; 41 public static final int TYPE_LOCAL = 1; 42 public static final int TYPE_TIMEOUT = 2; 43 public static final int TYPE_STATUSCODE = 3; 44 public static final int TYPE_MEDIA = 4; 45 public static final int TYPE_USER = 5; 46 public static final int TYPE_UT = 8; 47 48 /** 49 * Specific code of each types 50 */ 51 public static final int CODE_UNSPECIFIED = 0; 52 53 /** 54 * LOCAL 55 */ 56 // IMS -> Telephony 57 // The passed argument is an invalid 58 public static final int CODE_LOCAL_ILLEGAL_ARGUMENT = 101; 59 // The operation is invoked in invalid call state 60 public static final int CODE_LOCAL_ILLEGAL_STATE = 102; 61 // IMS service internal error 62 public static final int CODE_LOCAL_INTERNAL_ERROR = 103; 63 // IMS service goes down (service connection is lost) 64 public static final int CODE_LOCAL_IMS_SERVICE_DOWN = 106; 65 // No pending incoming call exists 66 public static final int CODE_LOCAL_NO_PENDING_CALL = 107; 67 68 // IMS -> Telephony 69 // Service unavailable; by power off 70 public static final int CODE_LOCAL_POWER_OFF = 111; 71 // Service unavailable; by low battery 72 public static final int CODE_LOCAL_LOW_BATTERY = 112; 73 // Service unavailable; by out of service (data service state) 74 public static final int CODE_LOCAL_NETWORK_NO_SERVICE = 121; 75 // Service unavailable; by no LTE coverage 76 // (VoLTE is not supported even though IMS is registered) 77 public static final int CODE_LOCAL_NETWORK_NO_LTE_COVERAGE = 122; 78 // Service unavailable; by located in roaming area 79 public static final int CODE_LOCAL_NETWORK_ROAMING = 123; 80 // Service unavailable; by IP changed 81 public static final int CODE_LOCAL_NETWORK_IP_CHANGED = 124; 82 // Service unavailable; other 83 public static final int CODE_LOCAL_SERVICE_UNAVAILABLE = 131; 84 // Service unavailable; IMS connection is lost (IMS is not registered) 85 public static final int CODE_LOCAL_NOT_REGISTERED = 132; 86 87 // IMS <-> Telephony 88 // Max call exceeded 89 public static final int CODE_LOCAL_CALL_EXCEEDED = 141; 90 // IMS <- Telephony 91 // Call busy 92 public static final int CODE_LOCAL_CALL_BUSY = 142; 93 // Call decline 94 public static final int CODE_LOCAL_CALL_DECLINE = 143; 95 // IMS -> Telephony 96 // SRVCC is in progress 97 public static final int CODE_LOCAL_CALL_VCC_ON_PROGRESSING = 144; 98 // Resource reservation is failed (QoS precondition) 99 public static final int CODE_LOCAL_CALL_RESOURCE_RESERVATION_FAILED = 145; 100 // Retry CS call; VoLTE service can't be provided by the network or remote end 101 // Resolve the extra code(EXTRA_CODE_CALL_RETRY_*) if the below code is set 102 public static final int CODE_LOCAL_CALL_CS_RETRY_REQUIRED = 146; 103 // Retry VoLTE call; VoLTE service can't be provided by the network temporarily 104 public static final int CODE_LOCAL_CALL_VOLTE_RETRY_REQUIRED = 147; 105 // IMS call is already terminated (in TERMINATED state) 106 public static final int CODE_LOCAL_CALL_TERMINATED = 148; 107 108 /** 109 * TIMEOUT (IMS -> Telephony) 110 */ 111 // 1xx waiting timer is expired after sending INVITE request (MO only) 112 public static final int CODE_TIMEOUT_1XX_WAITING = 201; 113 // User no answer during call setup operation (MO/MT) 114 // MO : 200 OK to INVITE request is not received, 115 // MT : No action from user after alerting the call 116 public static final int CODE_TIMEOUT_NO_ANSWER = 202; 117 // User no answer during call update operation (MO/MT) 118 // MO : 200 OK to re-INVITE request is not received, 119 // MT : No action from user after alerting the call 120 public static final int CODE_TIMEOUT_NO_ANSWER_CALL_UPDATE = 203; 121 122 /** 123 * STATUSCODE (SIP response code) (IMS -> Telephony) 124 */ 125 // 3xx responses 126 // SIP request is redirected 127 public static final int CODE_SIP_REDIRECTED = 321; 128 // 4xx responses 129 // 400 : Bad Request 130 public static final int CODE_SIP_BAD_REQUEST = 331; 131 // 403 : Forbidden 132 public static final int CODE_SIP_FORBIDDEN = 332; 133 // 404 : Not Found 134 public static final int CODE_SIP_NOT_FOUND = 333; 135 // 415 : Unsupported Media Type 136 // 416 : Unsupported URI Scheme 137 // 420 : Bad Extension 138 public static final int CODE_SIP_NOT_SUPPORTED = 334; 139 // 408 : Request Timeout 140 public static final int CODE_SIP_REQUEST_TIMEOUT = 335; 141 // 480 : Temporarily Unavailable 142 public static final int CODE_SIP_TEMPRARILY_UNAVAILABLE = 336; 143 // 484 : Address Incomplete 144 public static final int CODE_SIP_BAD_ADDRESS = 337; 145 // 486 : Busy Here 146 // 600 : Busy Everywhere 147 public static final int CODE_SIP_BUSY = 338; 148 // 487 : Request Terminated 149 public static final int CODE_SIP_REQUEST_CANCELLED = 339; 150 // 406 : Not Acceptable 151 // 488 : Not Acceptable Here 152 // 606 : Not Acceptable 153 public static final int CODE_SIP_NOT_ACCEPTABLE = 340; 154 // 410 : Gone 155 // 604 : Does Not Exist Anywhere 156 public static final int CODE_SIP_NOT_REACHABLE = 341; 157 // Others 158 public static final int CODE_SIP_CLIENT_ERROR = 342; 159 // 5xx responses 160 // 501 : Server Internal Error 161 public static final int CODE_SIP_SERVER_INTERNAL_ERROR = 351; 162 // 503 : Service Unavailable 163 public static final int CODE_SIP_SERVICE_UNAVAILABLE = 352; 164 // 504 : Server Time-out 165 public static final int CODE_SIP_SERVER_TIMEOUT = 353; 166 // Others 167 public static final int CODE_SIP_SERVER_ERROR = 354; 168 // 6xx responses 169 // 603 : Decline 170 public static final int CODE_SIP_USER_REJECTED = 361; 171 // Others 172 public static final int CODE_SIP_GLOBAL_ERROR = 362; 173 174 /** 175 * MEDIA (IMS -> Telephony) 176 */ 177 // Media resource initialization failed 178 public static final int CODE_MEDIA_INIT_FAILED = 401; 179 // RTP timeout (no audio / video traffic in the session) 180 public static final int CODE_MEDIA_NO_DATA = 402; 181 // Media is not supported; so dropped the call 182 public static final int CODE_MEDIA_NOT_ACCEPTABLE = 403; 183 // Unknown media related errors 184 public static final int CODE_MEDIA_UNSPECIFIED = 404; 185 186 /** 187 * USER 188 */ 189 // Telephony -> IMS 190 // User triggers the call end 191 public static final int CODE_USER_TERMINATED = 501; 192 // No action while an incoming call is ringing 193 public static final int CODE_USER_NOANSWER = 502; 194 // User ignores an incoming call 195 public static final int CODE_USER_IGNORE = 503; 196 // User declines an incoming call 197 public static final int CODE_USER_DECLINE = 504; 198 // IMS -> Telephony 199 // The call is terminated by the network or remote user 200 public static final int CODE_USER_TERMINATED_BY_REMOTE = 510; 201 202 /** 203 * Extra codes for the specific code value 204 * This value can be referred when the code is CODE_LOCAL_CALL_CS_RETRY_REQUIRED. 205 */ 206 // Try to connect CS call; normal 207 public static final int EXTRA_CODE_CALL_RETRY_NORMAL = 1; 208 // Try to connect CS call without the notification to user 209 public static final int EXTRA_CODE_CALL_RETRY_SILENT_REDIAL = 2; 210 // Try to connect CS call by the settings of the menu 211 public static final int EXTRA_CODE_CALL_RETRY_BY_SETTINGS = 3; 212 213 /** 214 * UT 215 */ 216 public static final int CODE_UT_NOT_SUPPORTED = 801; 217 public static final int CODE_UT_SERVICE_UNAVAILABLE = 802; 218 public static final int CODE_UT_OPERATION_NOT_ALLOWED = 803; 219 public static final int CODE_UT_NETWORK_ERROR = 804; 220 public static final int CODE_UT_CB_PASSWORD_MISMATCH = 821; 221 222 /** 223 * ECBM 224 */ 225 public static final int CODE_ECBM_NOT_SUPPORTED = 901; 226 227 // For reason type 228 public int mReasonType; 229 // For main reason code 230 public int mCode; 231 // For the extra code value; it depends on the code value. 232 public int mExtraCode; 233 // For the additional message of the reason info. 234 public String mExtraMessage; 235 236 public ImsReasonInfo() { 237 mReasonType = TYPE_UNSPECIFIED; 238 mCode = CODE_UNSPECIFIED; 239 mExtraCode = CODE_UNSPECIFIED; 240 mExtraMessage = null; 241 } 242 243 public ImsReasonInfo(Parcel in) { 244 readFromParcel(in); 245 } 246 247 public ImsReasonInfo(int code, int extraCode) { 248 mReasonType = (int) (code / 100); 249 mCode = code; 250 mExtraCode = extraCode; 251 mExtraMessage = null; 252 } 253 254 public ImsReasonInfo(int code, int extraCode, String extraMessage) { 255 mReasonType = (int) (code / 100); 256 mCode = code; 257 mExtraCode = extraCode; 258 mExtraMessage = extraMessage; 259 } 260 261 /** 262 * 263 */ 264 public int getCode() { 265 return mCode; 266 } 267 268 /** 269 * 270 */ 271 public int getExtraCode() { 272 return mExtraCode; 273 } 274 275 /** 276 * 277 */ 278 public String getExtraMessage() { 279 return mExtraMessage; 280 } 281 282 /** 283 * 284 */ 285 public int getReasonType() { 286 return mReasonType; 287 } 288 289 /** 290 * Returns the string format of {@link ImsReasonInfo} 291 * 292 * @return the string format of {@link ImsReasonInfo} 293 */ 294 public String toString() { 295 return "ImsReasonInfo :: {" + mReasonType + ", " 296 + mCode + ", " + mExtraCode + ", " + mExtraMessage + "}"; 297 } 298 299 @Override 300 public int describeContents() { 301 return 0; 302 } 303 304 @Override 305 public void writeToParcel(Parcel out, int flags) { 306 out.writeInt(mReasonType); 307 out.writeInt(mCode); 308 out.writeInt(mExtraCode); 309 out.writeString(mExtraMessage); 310 } 311 312 private void readFromParcel(Parcel in) { 313 mReasonType = in.readInt(); 314 mCode = in.readInt(); 315 mExtraCode = in.readInt(); 316 mExtraMessage = in.readString(); 317 } 318 319 public static final Creator<ImsReasonInfo> CREATOR = new Creator<ImsReasonInfo>() { 320 @Override 321 public ImsReasonInfo createFromParcel(Parcel in) { 322 return new ImsReasonInfo(in); 323 } 324 325 @Override 326 public ImsReasonInfo[] newArray(int size) { 327 return new ImsReasonInfo[size]; 328 } 329 }; 330 } 331