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