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 * Indicates that incoming call was rejected by the modem before the call went in ringing 360 */ 361 public static final int INCOMING_AUTO_REJECTED = 81; 362 363 364 //********************************************************************************************* 365 // When adding a disconnect type: 366 // 1) Update toString() with the newly added disconnect type. 367 // 2) Update android.telecom.DisconnectCauseUtil with any mappings to a telecom.DisconnectCause. 368 //********************************************************************************************* 369 370 /** Private constructor to avoid class instantiation. */ DisconnectCause()371 private DisconnectCause() { 372 // Do nothing. 373 } 374 375 /** 376 * Returns descriptive string for the specified disconnect cause. 377 * @hide 378 */ 379 @UnsupportedAppUsage toString(int cause)380 public static @NonNull String toString(int cause) { 381 switch (cause) { 382 case NOT_DISCONNECTED: 383 return "NOT_DISCONNECTED"; 384 case INCOMING_MISSED: 385 return "INCOMING_MISSED"; 386 case NORMAL: 387 return "NORMAL"; 388 case LOCAL: 389 return "LOCAL"; 390 case BUSY: 391 return "BUSY"; 392 case CONGESTION: 393 return "CONGESTION"; 394 case INVALID_NUMBER: 395 return "INVALID_NUMBER"; 396 case NUMBER_UNREACHABLE: 397 return "NUMBER_UNREACHABLE"; 398 case SERVER_UNREACHABLE: 399 return "SERVER_UNREACHABLE"; 400 case INVALID_CREDENTIALS: 401 return "INVALID_CREDENTIALS"; 402 case OUT_OF_NETWORK: 403 return "OUT_OF_NETWORK"; 404 case SERVER_ERROR: 405 return "SERVER_ERROR"; 406 case TIMED_OUT: 407 return "TIMED_OUT"; 408 case LOST_SIGNAL: 409 return "LOST_SIGNAL"; 410 case LIMIT_EXCEEDED: 411 return "LIMIT_EXCEEDED"; 412 case INCOMING_REJECTED: 413 return "INCOMING_REJECTED"; 414 case POWER_OFF: 415 return "POWER_OFF"; 416 case OUT_OF_SERVICE: 417 return "OUT_OF_SERVICE"; 418 case ICC_ERROR: 419 return "ICC_ERROR"; 420 case CALL_BARRED: 421 return "CALL_BARRED"; 422 case FDN_BLOCKED: 423 return "FDN_BLOCKED"; 424 case CS_RESTRICTED: 425 return "CS_RESTRICTED"; 426 case CS_RESTRICTED_NORMAL: 427 return "CS_RESTRICTED_NORMAL"; 428 case CS_RESTRICTED_EMERGENCY: 429 return "CS_RESTRICTED_EMERGENCY"; 430 case UNOBTAINABLE_NUMBER: 431 return "UNOBTAINABLE_NUMBER"; 432 case CDMA_LOCKED_UNTIL_POWER_CYCLE: 433 return "CDMA_LOCKED_UNTIL_POWER_CYCLE"; 434 case CDMA_DROP: 435 return "CDMA_DROP"; 436 case CDMA_INTERCEPT: 437 return "CDMA_INTERCEPT"; 438 case CDMA_REORDER: 439 return "CDMA_REORDER"; 440 case CDMA_SO_REJECT: 441 return "CDMA_SO_REJECT"; 442 case CDMA_RETRY_ORDER: 443 return "CDMA_RETRY_ORDER"; 444 case CDMA_ACCESS_FAILURE: 445 return "CDMA_ACCESS_FAILURE"; 446 case CDMA_PREEMPTED: 447 return "CDMA_PREEMPTED"; 448 case CDMA_NOT_EMERGENCY: 449 return "CDMA_NOT_EMERGENCY"; 450 case CDMA_ACCESS_BLOCKED: 451 return "CDMA_ACCESS_BLOCKED"; 452 case EMERGENCY_ONLY: 453 return "EMERGENCY_ONLY"; 454 case NO_PHONE_NUMBER_SUPPLIED: 455 return "NO_PHONE_NUMBER_SUPPLIED"; 456 case DIALED_MMI: 457 return "DIALED_MMI"; 458 case VOICEMAIL_NUMBER_MISSING: 459 return "VOICEMAIL_NUMBER_MISSING"; 460 case CDMA_CALL_LOST: 461 return "CDMA_CALL_LOST"; 462 case EXITED_ECM: 463 return "EXITED_ECM"; 464 case DIAL_MODIFIED_TO_USSD: 465 return "DIAL_MODIFIED_TO_USSD"; 466 case DIAL_MODIFIED_TO_SS: 467 return "DIAL_MODIFIED_TO_SS"; 468 case DIAL_MODIFIED_TO_DIAL: 469 return "DIAL_MODIFIED_TO_DIAL"; 470 case DIAL_MODIFIED_TO_DIAL_VIDEO: 471 return "DIAL_MODIFIED_TO_DIAL_VIDEO"; 472 case DIAL_VIDEO_MODIFIED_TO_SS: 473 return "DIAL_VIDEO_MODIFIED_TO_SS"; 474 case DIAL_VIDEO_MODIFIED_TO_USSD: 475 return "DIAL_VIDEO_MODIFIED_TO_USSD"; 476 case DIAL_VIDEO_MODIFIED_TO_DIAL: 477 return "DIAL_VIDEO_MODIFIED_TO_DIAL"; 478 case DIAL_VIDEO_MODIFIED_TO_DIAL_VIDEO: 479 return "DIAL_VIDEO_MODIFIED_TO_DIAL_VIDEO"; 480 case ERROR_UNSPECIFIED: 481 return "ERROR_UNSPECIFIED"; 482 case OUTGOING_FAILURE: 483 return "OUTGOING_FAILURE"; 484 case OUTGOING_CANCELED: 485 return "OUTGOING_CANCELED"; 486 case IMS_MERGED_SUCCESSFULLY: 487 return "IMS_MERGED_SUCCESSFULLY"; 488 case CDMA_ALREADY_ACTIVATED: 489 return "CDMA_ALREADY_ACTIVATED"; 490 case VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED: 491 return "VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED"; 492 case CALL_PULLED: 493 return "CALL_PULLED"; 494 case ANSWERED_ELSEWHERE: 495 return "ANSWERED_ELSEWHERE"; 496 case MAXIMUM_NUMBER_OF_CALLS_REACHED: 497 return "MAXIMUM_NUMER_OF_CALLS_REACHED"; 498 case DATA_DISABLED: 499 return "DATA_DISABLED"; 500 case DATA_LIMIT_REACHED: 501 return "DATA_LIMIT_REACHED"; 502 case DIALED_CALL_FORWARDING_WHILE_ROAMING: 503 return "DIALED_CALL_FORWARDING_WHILE_ROAMING"; 504 case IMEI_NOT_ACCEPTED: 505 return "IMEI_NOT_ACCEPTED"; 506 case WIFI_LOST: 507 return "WIFI_LOST"; 508 case IMS_ACCESS_BLOCKED: 509 return "IMS_ACCESS_BLOCKED"; 510 case LOW_BATTERY: 511 return "LOW_BATTERY"; 512 case DIAL_LOW_BATTERY: 513 return "DIAL_LOW_BATTERY"; 514 case EMERGENCY_TEMP_FAILURE: 515 return "EMERGENCY_TEMP_FAILURE"; 516 case EMERGENCY_PERM_FAILURE: 517 return "EMERGENCY_PERM_FAILURE"; 518 case NORMAL_UNSPECIFIED: 519 return "NORMAL_UNSPECIFIED"; 520 case IMS_SIP_ALTERNATE_EMERGENCY_CALL: 521 return "IMS_SIP_ALTERNATE_EMERGENCY_CALL"; 522 case ALREADY_DIALING: 523 return "ALREADY_DIALING"; 524 case CANT_CALL_WHILE_RINGING: 525 return "CANT_CALL_WHILE_RINGING"; 526 case CALLING_DISABLED: 527 return "CALLING_DISABLED"; 528 case TOO_MANY_ONGOING_CALLS: 529 return "TOO_MANY_ONGOING_CALLS"; 530 case OTASP_PROVISIONING_IN_PROCESS: 531 return "OTASP_PROVISIONING_IN_PROCESS"; 532 case MEDIA_TIMEOUT: 533 return "MEDIA_TIMEOUT"; 534 case EMERGENCY_CALL_OVER_WFC_NOT_AVAILABLE: 535 return "EMERGENCY_CALL_OVER_WFC_NOT_AVAILABLE"; 536 case WFC_SERVICE_NOT_AVAILABLE_IN_THIS_LOCATION: 537 return "WFC_SERVICE_NOT_AVAILABLE_IN_THIS_LOCATION"; 538 case OUTGOING_EMERGENCY_CALL_PLACED: 539 return "OUTGOING_EMERGENCY_CALL_PLACED"; 540 case INCOMING_AUTO_REJECTED: 541 return "INCOMING_AUTO_REJECTED"; 542 default: 543 return "INVALID: " + cause; 544 } 545 } 546 } 547