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