1 /* 2 * Copyright (C) 2014 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.annotation.NonNull; 20 import android.compat.annotation.UnsupportedAppUsage; 21 22 /** 23 * Describes the cause of a disconnected call. Those disconnect causes can be converted into a more 24 * generic {@link android.telecom.DisconnectCause} object. 25 * 26 * Used in {@link PhoneStateListener#onCallDisconnectCauseChanged}. 27 */ 28 public final class DisconnectCause { 29 30 /** The disconnect cause is not valid (Not received a disconnect cause) */ 31 public static final int NOT_VALID = -1; 32 /** Has not yet disconnected */ 33 public static final int NOT_DISCONNECTED = 0; 34 /** An incoming call that was missed and never answered */ 35 public static final int INCOMING_MISSED = 1; 36 /** Normal; Remote hangup*/ 37 public static final int NORMAL = 2; 38 /** Normal; Local hangup */ 39 public static final int LOCAL = 3; 40 /** Outgoing call to busy line */ 41 public static final int BUSY = 4; 42 /** Outgoing call to congested network */ 43 public static final int CONGESTION = 5; 44 /** Not presently used */ 45 public static final int MMI = 6; 46 /** Invalid dial string */ 47 public static final int INVALID_NUMBER = 7; 48 /** Cannot reach the peer */ 49 public static final int NUMBER_UNREACHABLE = 8; 50 /** Cannot reach the server */ 51 public static final int SERVER_UNREACHABLE = 9; 52 /** Invalid credentials */ 53 public static final int INVALID_CREDENTIALS = 10; 54 /** Calling from out of network is not allowed */ 55 public static final int OUT_OF_NETWORK = 11; 56 /** Server error */ 57 public static final int SERVER_ERROR = 12; 58 /** Client timed out */ 59 public static final int TIMED_OUT = 13; 60 /** Client went out of network range */ 61 public static final int LOST_SIGNAL = 14; 62 /** GSM or CDMA ACM limit exceeded */ 63 public static final int LIMIT_EXCEEDED = 15; 64 /** An incoming call that was rejected */ 65 public static final int INCOMING_REJECTED = 16; 66 /** Radio is turned off explicitly */ 67 public static final int POWER_OFF = 17; 68 /** Out of service */ 69 public static final int OUT_OF_SERVICE = 18; 70 /** No ICC, ICC locked, or other ICC error */ 71 public static final int ICC_ERROR = 19; 72 /** Call was blocked by call barring */ 73 public static final int CALL_BARRED = 20; 74 /** Call was blocked by fixed dial number */ 75 public static final int FDN_BLOCKED = 21; 76 /** Call was blocked by restricted all voice access */ 77 public static final int CS_RESTRICTED = 22; 78 /** Call was blocked by restricted normal voice access */ 79 public static final int CS_RESTRICTED_NORMAL = 23; 80 /** Call was blocked by restricted emergency voice access */ 81 public static final int CS_RESTRICTED_EMERGENCY = 24; 82 /** Unassigned number */ 83 public static final int UNOBTAINABLE_NUMBER = 25; 84 /** MS is locked until next power cycle */ 85 public static final int CDMA_LOCKED_UNTIL_POWER_CYCLE = 26; 86 /** Drop call*/ 87 public static final int CDMA_DROP = 27; 88 /** INTERCEPT order received, MS state idle entered */ 89 public static final int CDMA_INTERCEPT = 28; 90 /** MS has been redirected, call is cancelled */ 91 public static final int CDMA_REORDER = 29; 92 /** Service option rejection */ 93 public static final int CDMA_SO_REJECT = 30; 94 /** Requested service is rejected, retry delay is set */ 95 public static final int CDMA_RETRY_ORDER = 31; 96 /** Unable to obtain access to the CDMA system */ 97 public static final int CDMA_ACCESS_FAILURE = 32; 98 /** Not a preempted call */ 99 public static final int CDMA_PREEMPTED = 33; 100 /** Not an emergency call */ 101 public static final int CDMA_NOT_EMERGENCY = 34; 102 /** Access Blocked by CDMA network */ 103 public static final int CDMA_ACCESS_BLOCKED = 35; 104 /** Unknown error or not specified */ 105 public static final int ERROR_UNSPECIFIED = 36; 106 /** 107 * Only emergency numbers are allowed, but we tried to dial a non-emergency number. 108 * @hide 109 */ 110 // TODO: This should be the same as NOT_EMERGENCY 111 public static final int EMERGENCY_ONLY = 37; 112 /** 113 * The supplied CALL Intent didn't contain a valid phone number. 114 */ 115 public static final int NO_PHONE_NUMBER_SUPPLIED = 38; 116 /** 117 * Our initial phone number was actually an MMI sequence. 118 */ 119 public static final int DIALED_MMI = 39; 120 /** 121 * We tried to call a voicemail: URI but the device has no voicemail number configured. 122 */ 123 public static final int VOICEMAIL_NUMBER_MISSING = 40; 124 /** 125 * This status indicates that InCallScreen should display the 126 * CDMA-specific "call lost" dialog. (If an outgoing call fails, 127 * and the CDMA "auto-retry" feature is enabled, *and* the retried 128 * call fails too, we display this specific dialog.) 129 * 130 * TODO: this is currently unused, since the "call lost" dialog 131 * needs to be triggered by a *disconnect* event, rather than when 132 * the InCallScreen first comes to the foreground. For now we use 133 * the needToShowCallLostDialog field for this (see below.) 134 * 135 * @hide 136 */ 137 public static final int CDMA_CALL_LOST = 41; 138 /** 139 * This status indicates that the call was placed successfully, 140 * but additionally, the InCallScreen needs to display the 141 * "Exiting ECM" dialog. 142 * 143 * (Details: "Emergency callback mode" is a CDMA-specific concept 144 * where the phone disallows data connections over the cell 145 * network for some period of time after you make an emergency 146 * call. If the phone is in ECM and you dial a non-emergency 147 * number, that automatically *cancels* ECM, but we additionally 148 * need to warn the user that ECM has been canceled (see bug 149 * 4207607.)) 150 * 151 * TODO: Rethink where the best place to put this is. It is not a notification 152 * of a failure of the connection -- it is an additional message that accompanies 153 * a successful connection giving the user important information about what happened. 154 * 155 * {@hide} 156 */ 157 public static final int EXITED_ECM = 42; 158 159 /** 160 * The outgoing call failed with an unknown cause. 161 */ 162 public static final int OUTGOING_FAILURE = 43; 163 164 /** 165 * The outgoing call was canceled by the {@link android.telecom.ConnectionService}. 166 */ 167 public static final int OUTGOING_CANCELED = 44; 168 169 /** 170 * The call, which was an IMS call, disconnected because it merged with another call. 171 */ 172 public static final int IMS_MERGED_SUCCESSFULLY = 45; 173 174 /** 175 * Stk Call Control modified DIAL request to USSD request. 176 */ 177 public static final int DIAL_MODIFIED_TO_USSD = 46; 178 /** 179 * Stk Call Control modified DIAL request to SS request. 180 */ 181 public static final int DIAL_MODIFIED_TO_SS = 47; 182 /** 183 * Stk Call Control modified DIAL request to DIAL with modified data. 184 */ 185 public static final int DIAL_MODIFIED_TO_DIAL = 48; 186 187 /** 188 * The call was terminated because CDMA phone service and roaming have already been activated. 189 */ 190 public static final int CDMA_ALREADY_ACTIVATED = 49; 191 192 /** 193 * The call was terminated because it is not possible to place a video call while TTY is 194 * enabled. 195 */ 196 public static final int VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED = 50; 197 198 /** 199 * The call was terminated because it was pulled to another device. 200 */ 201 public static final int CALL_PULLED = 51; 202 203 /** 204 * The call was terminated because it was answered on another device. 205 */ 206 public static final int ANSWERED_ELSEWHERE = 52; 207 208 /** 209 * The call was terminated because the maximum allowable number of calls has been reached. 210 */ 211 public static final int MAXIMUM_NUMBER_OF_CALLS_REACHED = 53; 212 213 /** 214 * The call was terminated because cellular data has been disabled. 215 * Used when in a video call and the user disables cellular data via the settings. 216 */ 217 public static final int DATA_DISABLED = 54; 218 219 /** 220 * The call was terminated because the data policy has disabled cellular data. 221 * Used when in a video call and the user has exceeded the device data limit. 222 */ 223 public static final int DATA_LIMIT_REACHED = 55; 224 225 /** 226 * The call being placed was detected as a call forwarding number and was being dialed while 227 * roaming on a carrier that does not allow this. 228 */ 229 public static final int DIALED_CALL_FORWARDING_WHILE_ROAMING = 57; 230 231 /** 232 * The network does not accept the emergency call request because IMEI was used as 233 * identification and this cability is not supported by the network. 234 */ 235 public static final int IMEI_NOT_ACCEPTED = 58; 236 237 /** 238 * A call over WIFI was disconnected because the WIFI signal was lost or became too degraded to 239 * continue the call. 240 */ 241 public static final int WIFI_LOST = 59; 242 243 /** 244 * The call has failed because of access class barring. 245 */ 246 public static final int IMS_ACCESS_BLOCKED = 60; 247 248 /** 249 * The call has ended (mid-call) because the device's battery is too low. 250 */ 251 public static final int LOW_BATTERY = 61; 252 253 /** 254 * A call was not dialed because the device's battery is too low. 255 */ 256 public static final int DIAL_LOW_BATTERY = 62; 257 258 /** 259 * Emergency call failed with a temporary fail cause and can be redialed on this slot. 260 */ 261 public static final int EMERGENCY_TEMP_FAILURE = 63; 262 263 /** 264 * Emergency call failed with a permanent fail cause and should not be redialed on this 265 * slot. 266 */ 267 public static final int EMERGENCY_PERM_FAILURE = 64; 268 269 /** 270 * This cause is used to report a normal event only when no other cause in the normal class 271 * applies. 272 */ 273 public static final int NORMAL_UNSPECIFIED = 65; 274 275 /** 276 * Stk Call Control modified DIAL request to video DIAL request. 277 */ 278 public static final int DIAL_MODIFIED_TO_DIAL_VIDEO = 66; 279 280 /** 281 * Stk Call Control modified Video DIAL request to SS request. 282 */ 283 public static final int DIAL_VIDEO_MODIFIED_TO_SS = 67; 284 285 /** 286 * Stk Call Control modified Video DIAL request to USSD request. 287 */ 288 public static final int DIAL_VIDEO_MODIFIED_TO_USSD = 68; 289 290 /** 291 * Stk Call Control modified Video DIAL request to DIAL request. 292 */ 293 public static final int DIAL_VIDEO_MODIFIED_TO_DIAL = 69; 294 295 /** 296 * Stk Call Control modified Video DIAL request to Video DIAL request. 297 */ 298 public static final int DIAL_VIDEO_MODIFIED_TO_DIAL_VIDEO = 70; 299 300 /** 301 * The network has reported that an alternative emergency number has been dialed, but the user 302 * must exit airplane mode to place the call. 303 */ 304 public static final int IMS_SIP_ALTERNATE_EMERGENCY_CALL = 71; 305 306 /** 307 * Indicates that a new outgoing call cannot be placed because there is already an outgoing 308 * call dialing out. 309 */ 310 public static final int ALREADY_DIALING = 72; 311 312 /** 313 * Indicates that a new outgoing call cannot be placed while there is a ringing call. 314 */ 315 public static final int CANT_CALL_WHILE_RINGING = 73; 316 317 /** 318 * Indicates that a new outgoing call cannot be placed because calling has been disabled using 319 * the ro.telephony.disable-call system property. 320 */ 321 public static final int CALLING_DISABLED = 74; 322 323 /** 324 * Indicates that a new outgoing call cannot be placed because there is currently an ongoing 325 * foreground and background call. 326 */ 327 public static final int TOO_MANY_ONGOING_CALLS = 75; 328 329 /** 330 * Indicates that a new outgoing call cannot be placed because OTASP provisioning is currently 331 * in process. 332 */ 333 public static final int OTASP_PROVISIONING_IN_PROCESS = 76; 334 335 /** 336 * Indicates that the call is dropped due to RTCP inactivity, primarily due to media path 337 * disruption. 338 */ 339 public static final int MEDIA_TIMEOUT = 77; 340 341 /** 342 * Indicates that an emergency call cannot be placed over WFC because the service is not 343 * available in the current location. 344 */ 345 public static final int EMERGENCY_CALL_OVER_WFC_NOT_AVAILABLE = 78; 346 347 /** 348 * Indicates that WiFi calling service is not available in the current location. 349 */ 350 public static final int WFC_SERVICE_NOT_AVAILABLE_IN_THIS_LOCATION = 79; 351 352 /** 353 * Indicates that an emergency call was placed, which caused the existing connection to be 354 * hung up. 355 */ 356 public static final int OUTGOING_EMERGENCY_CALL_PLACED = 80; 357 358 //********************************************************************************************* 359 // When adding a disconnect type: 360 // 1) Update toString() with the newly added disconnect type. 361 // 2) Update android.telecom.DisconnectCauseUtil with any mappings to a telecom.DisconnectCause. 362 //********************************************************************************************* 363 364 /** Private constructor to avoid class instantiation. */ DisconnectCause()365 private DisconnectCause() { 366 // Do nothing. 367 } 368 369 /** 370 * Returns descriptive string for the specified disconnect cause. 371 * @hide 372 */ 373 @UnsupportedAppUsage toString(int cause)374 public static @NonNull String toString(int cause) { 375 switch (cause) { 376 case NOT_DISCONNECTED: 377 return "NOT_DISCONNECTED"; 378 case INCOMING_MISSED: 379 return "INCOMING_MISSED"; 380 case NORMAL: 381 return "NORMAL"; 382 case LOCAL: 383 return "LOCAL"; 384 case BUSY: 385 return "BUSY"; 386 case CONGESTION: 387 return "CONGESTION"; 388 case INVALID_NUMBER: 389 return "INVALID_NUMBER"; 390 case NUMBER_UNREACHABLE: 391 return "NUMBER_UNREACHABLE"; 392 case SERVER_UNREACHABLE: 393 return "SERVER_UNREACHABLE"; 394 case INVALID_CREDENTIALS: 395 return "INVALID_CREDENTIALS"; 396 case OUT_OF_NETWORK: 397 return "OUT_OF_NETWORK"; 398 case SERVER_ERROR: 399 return "SERVER_ERROR"; 400 case TIMED_OUT: 401 return "TIMED_OUT"; 402 case LOST_SIGNAL: 403 return "LOST_SIGNAL"; 404 case LIMIT_EXCEEDED: 405 return "LIMIT_EXCEEDED"; 406 case INCOMING_REJECTED: 407 return "INCOMING_REJECTED"; 408 case POWER_OFF: 409 return "POWER_OFF"; 410 case OUT_OF_SERVICE: 411 return "OUT_OF_SERVICE"; 412 case ICC_ERROR: 413 return "ICC_ERROR"; 414 case CALL_BARRED: 415 return "CALL_BARRED"; 416 case FDN_BLOCKED: 417 return "FDN_BLOCKED"; 418 case CS_RESTRICTED: 419 return "CS_RESTRICTED"; 420 case CS_RESTRICTED_NORMAL: 421 return "CS_RESTRICTED_NORMAL"; 422 case CS_RESTRICTED_EMERGENCY: 423 return "CS_RESTRICTED_EMERGENCY"; 424 case UNOBTAINABLE_NUMBER: 425 return "UNOBTAINABLE_NUMBER"; 426 case CDMA_LOCKED_UNTIL_POWER_CYCLE: 427 return "CDMA_LOCKED_UNTIL_POWER_CYCLE"; 428 case CDMA_DROP: 429 return "CDMA_DROP"; 430 case CDMA_INTERCEPT: 431 return "CDMA_INTERCEPT"; 432 case CDMA_REORDER: 433 return "CDMA_REORDER"; 434 case CDMA_SO_REJECT: 435 return "CDMA_SO_REJECT"; 436 case CDMA_RETRY_ORDER: 437 return "CDMA_RETRY_ORDER"; 438 case CDMA_ACCESS_FAILURE: 439 return "CDMA_ACCESS_FAILURE"; 440 case CDMA_PREEMPTED: 441 return "CDMA_PREEMPTED"; 442 case CDMA_NOT_EMERGENCY: 443 return "CDMA_NOT_EMERGENCY"; 444 case CDMA_ACCESS_BLOCKED: 445 return "CDMA_ACCESS_BLOCKED"; 446 case EMERGENCY_ONLY: 447 return "EMERGENCY_ONLY"; 448 case NO_PHONE_NUMBER_SUPPLIED: 449 return "NO_PHONE_NUMBER_SUPPLIED"; 450 case DIALED_MMI: 451 return "DIALED_MMI"; 452 case VOICEMAIL_NUMBER_MISSING: 453 return "VOICEMAIL_NUMBER_MISSING"; 454 case CDMA_CALL_LOST: 455 return "CDMA_CALL_LOST"; 456 case EXITED_ECM: 457 return "EXITED_ECM"; 458 case DIAL_MODIFIED_TO_USSD: 459 return "DIAL_MODIFIED_TO_USSD"; 460 case DIAL_MODIFIED_TO_SS: 461 return "DIAL_MODIFIED_TO_SS"; 462 case DIAL_MODIFIED_TO_DIAL: 463 return "DIAL_MODIFIED_TO_DIAL"; 464 case DIAL_MODIFIED_TO_DIAL_VIDEO: 465 return "DIAL_MODIFIED_TO_DIAL_VIDEO"; 466 case DIAL_VIDEO_MODIFIED_TO_SS: 467 return "DIAL_VIDEO_MODIFIED_TO_SS"; 468 case DIAL_VIDEO_MODIFIED_TO_USSD: 469 return "DIAL_VIDEO_MODIFIED_TO_USSD"; 470 case DIAL_VIDEO_MODIFIED_TO_DIAL: 471 return "DIAL_VIDEO_MODIFIED_TO_DIAL"; 472 case DIAL_VIDEO_MODIFIED_TO_DIAL_VIDEO: 473 return "DIAL_VIDEO_MODIFIED_TO_DIAL_VIDEO"; 474 case ERROR_UNSPECIFIED: 475 return "ERROR_UNSPECIFIED"; 476 case OUTGOING_FAILURE: 477 return "OUTGOING_FAILURE"; 478 case OUTGOING_CANCELED: 479 return "OUTGOING_CANCELED"; 480 case IMS_MERGED_SUCCESSFULLY: 481 return "IMS_MERGED_SUCCESSFULLY"; 482 case CDMA_ALREADY_ACTIVATED: 483 return "CDMA_ALREADY_ACTIVATED"; 484 case VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED: 485 return "VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED"; 486 case CALL_PULLED: 487 return "CALL_PULLED"; 488 case ANSWERED_ELSEWHERE: 489 return "ANSWERED_ELSEWHERE"; 490 case MAXIMUM_NUMBER_OF_CALLS_REACHED: 491 return "MAXIMUM_NUMER_OF_CALLS_REACHED"; 492 case DATA_DISABLED: 493 return "DATA_DISABLED"; 494 case DATA_LIMIT_REACHED: 495 return "DATA_LIMIT_REACHED"; 496 case DIALED_CALL_FORWARDING_WHILE_ROAMING: 497 return "DIALED_CALL_FORWARDING_WHILE_ROAMING"; 498 case IMEI_NOT_ACCEPTED: 499 return "IMEI_NOT_ACCEPTED"; 500 case WIFI_LOST: 501 return "WIFI_LOST"; 502 case IMS_ACCESS_BLOCKED: 503 return "IMS_ACCESS_BLOCKED"; 504 case LOW_BATTERY: 505 return "LOW_BATTERY"; 506 case DIAL_LOW_BATTERY: 507 return "DIAL_LOW_BATTERY"; 508 case EMERGENCY_TEMP_FAILURE: 509 return "EMERGENCY_TEMP_FAILURE"; 510 case EMERGENCY_PERM_FAILURE: 511 return "EMERGENCY_PERM_FAILURE"; 512 case NORMAL_UNSPECIFIED: 513 return "NORMAL_UNSPECIFIED"; 514 case IMS_SIP_ALTERNATE_EMERGENCY_CALL: 515 return "IMS_SIP_ALTERNATE_EMERGENCY_CALL"; 516 case ALREADY_DIALING: 517 return "ALREADY_DIALING"; 518 case CANT_CALL_WHILE_RINGING: 519 return "CANT_CALL_WHILE_RINGING"; 520 case CALLING_DISABLED: 521 return "CALLING_DISABLED"; 522 case TOO_MANY_ONGOING_CALLS: 523 return "TOO_MANY_ONGOING_CALLS"; 524 case OTASP_PROVISIONING_IN_PROCESS: 525 return "OTASP_PROVISIONING_IN_PROCESS"; 526 case MEDIA_TIMEOUT: 527 return "MEDIA_TIMEOUT"; 528 case EMERGENCY_CALL_OVER_WFC_NOT_AVAILABLE: 529 return "EMERGENCY_CALL_OVER_WFC_NOT_AVAILABLE"; 530 case WFC_SERVICE_NOT_AVAILABLE_IN_THIS_LOCATION: 531 return "WFC_SERVICE_NOT_AVAILABLE_IN_THIS_LOCATION"; 532 case OUTGOING_EMERGENCY_CALL_PLACED: 533 return "OUTGOING_EMERGENCY_CALL_PLACED"; 534 default: 535 return "INVALID: " + cause; 536 } 537 } 538 } 539