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.annotation.SystemApi;
21 import android.compat.annotation.UnsupportedAppUsage;
22 
23 /**
24  * Describes the cause of a disconnected call. Those disconnect causes can be converted into a more
25  * generic {@link android.telecom.DisconnectCause} object.
26  *
27  * @hide
28  */
29 @SystemApi
30 public final class DisconnectCause {
31 
32     /** The disconnect cause is not valid (Not received a disconnect cause) */
33     public static final int NOT_VALID                      = -1;
34     /** Has not yet disconnected */
35     public static final int NOT_DISCONNECTED               = 0;
36     /** An incoming call that was missed and never answered */
37     public static final int INCOMING_MISSED                = 1;
38     /** Normal; Remote hangup*/
39     public static final int NORMAL                         = 2;
40     /** Normal; Local hangup */
41     public static final int LOCAL                          = 3;
42     /** Outgoing call to busy line */
43     public static final int BUSY                           = 4;
44     /** Outgoing call to congested network */
45     public static final int CONGESTION                     = 5;
46     /** Not presently used */
47     public static final int MMI                            = 6;
48     /** Invalid dial string */
49     public static final int INVALID_NUMBER                 = 7;
50     /** Cannot reach the peer */
51     public static final int NUMBER_UNREACHABLE             = 8;
52     /** Cannot reach the server */
53     public static final int SERVER_UNREACHABLE             = 9;
54     /** Invalid credentials */
55     public static final int INVALID_CREDENTIALS            = 10;
56     /** Calling from out of network is not allowed */
57     public static final int OUT_OF_NETWORK                 = 11;
58     /** Server error */
59     public static final int SERVER_ERROR                   = 12;
60     /** Client timed out */
61     public static final int TIMED_OUT                      = 13;
62     /** Client went out of network range */
63     public static final int LOST_SIGNAL                    = 14;
64     /** GSM or CDMA ACM limit exceeded */
65     public static final int LIMIT_EXCEEDED                 = 15;
66     /** An incoming call that was rejected */
67     public static final int INCOMING_REJECTED              = 16;
68     /** Radio is turned off explicitly */
69     public static final int POWER_OFF                      = 17;
70     /** Out of service */
71     public static final int OUT_OF_SERVICE                 = 18;
72     /** No ICC, ICC locked, or other ICC error */
73     public static final int ICC_ERROR                      = 19;
74     /** Call was blocked by call barring */
75     public static final int CALL_BARRED                    = 20;
76     /** Call was blocked by fixed dial number */
77     public static final int FDN_BLOCKED                    = 21;
78     /** Call was blocked by restricted all voice access */
79     public static final int CS_RESTRICTED                  = 22;
80     /** Call was blocked by restricted normal voice access */
81     public static final int CS_RESTRICTED_NORMAL           = 23;
82     /** Call was blocked by restricted emergency voice access */
83     public static final int CS_RESTRICTED_EMERGENCY        = 24;
84     /** Unassigned number */
85     public static final int UNOBTAINABLE_NUMBER            = 25;
86     /** MS is locked until next power cycle */
87     public static final int CDMA_LOCKED_UNTIL_POWER_CYCLE  = 26;
88     /** Drop call*/
89     public static final int CDMA_DROP                      = 27;
90     /** INTERCEPT order received, MS state idle entered */
91     public static final int CDMA_INTERCEPT                 = 28;
92     /** MS has been redirected, call is cancelled */
93     public static final int CDMA_REORDER                   = 29;
94     /** Service option rejection */
95     public static final int CDMA_SO_REJECT                 = 30;
96     /** Requested service is rejected, retry delay is set */
97     public static final int CDMA_RETRY_ORDER               = 31;
98     /** Unable to obtain access to the CDMA system */
99     public static final int CDMA_ACCESS_FAILURE            = 32;
100     /** Not a preempted call */
101     public static final int CDMA_PREEMPTED                 = 33;
102     /** Not an emergency call */
103     public static final int CDMA_NOT_EMERGENCY             = 34;
104     /** Access Blocked by CDMA network */
105     public static final int CDMA_ACCESS_BLOCKED            = 35;
106     /** Unknown error or not specified */
107     public static final int ERROR_UNSPECIFIED              = 36;
108     /**
109      * Only emergency numbers are allowed, but we tried to dial a non-emergency number.
110      * @hide
111      */
112     // TODO: This should be the same as NOT_EMERGENCY
113     public static final int EMERGENCY_ONLY                 = 37;
114     /**
115      * The supplied CALL Intent didn't contain a valid phone number.
116      */
117     public static final int NO_PHONE_NUMBER_SUPPLIED       = 38;
118     /**
119      * Our initial phone number was actually an MMI sequence.
120      */
121     public static final int DIALED_MMI                     = 39;
122     /**
123      * We tried to call a voicemail: URI but the device has no voicemail number configured.
124      */
125     public static final int VOICEMAIL_NUMBER_MISSING       = 40;
126     /**
127      * This status indicates that InCallScreen should display the
128      * CDMA-specific "call lost" dialog.  (If an outgoing call fails,
129      * and the CDMA "auto-retry" feature is enabled, *and* the retried
130      * call fails too, we display this specific dialog.)
131      *
132      * TODO: this is currently unused, since the "call lost" dialog
133      * needs to be triggered by a *disconnect* event, rather than when
134      * the InCallScreen first comes to the foreground.  For now we use
135      * the needToShowCallLostDialog field for this (see below.)
136      *
137      * @hide
138      */
139     public static final int CDMA_CALL_LOST                 = 41;
140     /**
141      * This status indicates that the call was placed successfully,
142      * but additionally, the InCallScreen needs to display the
143      * "Exiting ECM" dialog.
144      *
145      * (Details: "Emergency callback mode" is a CDMA-specific concept
146      * where the phone disallows data connections over the cell
147      * network for some period of time after you make an emergency
148      * call.  If the phone is in ECM and you dial a non-emergency
149      * number, that automatically *cancels* ECM, but we additionally
150      * need to warn the user that ECM has been canceled (see bug
151      * 4207607.))
152      *
153      * TODO: Rethink where the best place to put this is. It is not a notification
154      * of a failure of the connection -- it is an additional message that accompanies
155      * a successful connection giving the user important information about what happened.
156      *
157      * {@hide}
158      */
159     public static final int EXITED_ECM                     = 42;
160 
161     /**
162      * The outgoing call failed with an unknown cause.
163      */
164     public static final int OUTGOING_FAILURE               = 43;
165 
166     /**
167      * The outgoing call was canceled by the {@link android.telecom.ConnectionService}.
168      */
169     public static final int OUTGOING_CANCELED              = 44;
170 
171     /**
172      * The call, which was an IMS call, disconnected because it merged with another call.
173      */
174     public static final int IMS_MERGED_SUCCESSFULLY        = 45;
175 
176     /**
177      * Stk Call Control modified DIAL request to USSD request.
178      */
179     public static final int DIAL_MODIFIED_TO_USSD          = 46;
180     /**
181      * Stk Call Control modified DIAL request to SS request.
182      */
183     public static final int DIAL_MODIFIED_TO_SS            = 47;
184     /**
185      * Stk Call Control modified DIAL request to DIAL with modified data.
186      */
187     public static final int DIAL_MODIFIED_TO_DIAL          = 48;
188 
189     /**
190      * The call was terminated because CDMA phone service and roaming have already been activated.
191      */
192     public static final int CDMA_ALREADY_ACTIVATED         = 49;
193 
194     /**
195      * The call was terminated because it is not possible to place a video call while TTY is
196      * enabled.
197      */
198     public static final int VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED = 50;
199 
200     /**
201      * The call was terminated because it was pulled to another device.
202      */
203     public static final int CALL_PULLED = 51;
204 
205     /**
206      * The call was terminated because it was answered on another device.
207      */
208     public static final int ANSWERED_ELSEWHERE = 52;
209 
210     /**
211      * The call was terminated because the maximum allowable number of calls has been reached.
212      */
213     public static final int MAXIMUM_NUMBER_OF_CALLS_REACHED = 53;
214 
215     /**
216      * The call was terminated because cellular data has been disabled.
217      * Used when in a video call and the user disables cellular data via the settings.
218      */
219     public static final int DATA_DISABLED = 54;
220 
221     /**
222      * The call was terminated because the data policy has disabled cellular data.
223      * Used when in a video call and the user has exceeded the device data limit.
224      */
225     public static final int DATA_LIMIT_REACHED = 55;
226 
227     /**
228      * The call being placed was detected as a call forwarding number and was being dialed while
229      * roaming on a carrier that does not allow this.
230      */
231     public static final int DIALED_CALL_FORWARDING_WHILE_ROAMING = 57;
232 
233     /**
234      * The network does not accept the emergency call request because IMEI was used as
235      * identification and this cability is not supported by the network.
236      */
237     public static final int IMEI_NOT_ACCEPTED = 58;
238 
239     /**
240      * A call over WIFI was disconnected because the WIFI signal was lost or became too degraded to
241      * continue the call.
242      */
243     public static final int WIFI_LOST = 59;
244 
245     /**
246      * The call has failed because of access class barring.
247      */
248     public static final int IMS_ACCESS_BLOCKED = 60;
249 
250     /**
251      * The call has ended (mid-call) because the device's battery is too low.
252      */
253     public static final int LOW_BATTERY = 61;
254 
255     /**
256      * A call was not dialed because the device's battery is too low.
257      */
258     public static final int DIAL_LOW_BATTERY = 62;
259 
260     /**
261      * Emergency call failed with a temporary fail cause and can be redialed on this slot.
262      */
263     public static final int EMERGENCY_TEMP_FAILURE = 63;
264 
265     /**
266      * Emergency call failed with a permanent fail cause and should not be redialed on this
267      * slot.
268      */
269     public static final int EMERGENCY_PERM_FAILURE = 64;
270 
271     /**
272      * This cause is used to report a normal event only when no other cause in the normal class
273      * applies.
274      */
275     public static final int NORMAL_UNSPECIFIED = 65;
276 
277     /**
278      * Stk Call Control modified DIAL request to video DIAL request.
279      */
280     public static final int DIAL_MODIFIED_TO_DIAL_VIDEO = 66;
281 
282     /**
283      * Stk Call Control modified Video DIAL request to SS request.
284      */
285     public static final int DIAL_VIDEO_MODIFIED_TO_SS = 67;
286 
287     /**
288      * Stk Call Control modified Video DIAL request to USSD request.
289      */
290     public static final int DIAL_VIDEO_MODIFIED_TO_USSD = 68;
291 
292     /**
293      * Stk Call Control modified Video DIAL request to DIAL request.
294      */
295     public static final int DIAL_VIDEO_MODIFIED_TO_DIAL = 69;
296 
297     /**
298      * Stk Call Control modified Video DIAL request to Video DIAL request.
299      */
300     public static final int DIAL_VIDEO_MODIFIED_TO_DIAL_VIDEO = 70;
301 
302     /**
303      * The network has reported that an alternative emergency number has been dialed, but the user
304      * must exit airplane mode to place the call.
305      */
306     public static final int IMS_SIP_ALTERNATE_EMERGENCY_CALL = 71;
307 
308     /**
309      * Indicates that a new outgoing call cannot be placed because there is already an outgoing
310      * call dialing out.
311      */
312     public static final int ALREADY_DIALING = 72;
313 
314     /**
315      * Indicates that a new outgoing call cannot be placed while there is a ringing call.
316      */
317     public static final int CANT_CALL_WHILE_RINGING = 73;
318 
319     /**
320      * Indicates that a new outgoing call cannot be placed because calling has been disabled using
321      * the ro.telephony.disable-call system property.
322      */
323     public static final int CALLING_DISABLED = 74;
324 
325     /**
326      * Indicates that a new outgoing call cannot be placed because there is currently an ongoing
327      * foreground and background call.
328      */
329     public static final int TOO_MANY_ONGOING_CALLS = 75;
330 
331     /**
332      * Indicates that a new outgoing call cannot be placed because OTASP provisioning is currently
333      * in process.
334      */
335     public static final int OTASP_PROVISIONING_IN_PROCESS = 76;
336 
337     /**
338      * Indicates that the call is dropped due to RTCP inactivity, primarily due to media path
339      * disruption.
340      * @hide
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      * @hide
348      */
349     public static final int EMERGENCY_CALL_OVER_WFC_NOT_AVAILABLE = 78;
350 
351     /**
352      * Indicates that WiFi calling service is not available in the current location.
353      * @hide
354      */
355     public static final int WFC_SERVICE_NOT_AVAILABLE_IN_THIS_LOCATION = 79;
356 
357     /**
358      * Indicates that an emergency call was placed, which caused the existing connection to be
359      * hung up.
360      */
361     public static final int OUTGOING_EMERGENCY_CALL_PLACED = 80;
362 
363     /**
364      * Indicates that incoming call was rejected by the modem before the call went in ringing
365      */
366     public static final int INCOMING_AUTO_REJECTED = 81;
367 
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         default:
548             return "INVALID: " + cause;
549         }
550     }
551 }
552