DisconnectCause.java revision ef9f6f957d897ea0ed82114185b8fa3fefd4917b
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
17package android.telephony;
18
19/**
20 * Contains disconnect call causes generated by the framework and the RIL.
21 */
22public class DisconnectCause {
23
24    /** The disconnect cause is not valid (Not received a disconnect cause) */
25    public static final int NOT_VALID                      = -1;
26    /** Has not yet disconnected */
27    public static final int NOT_DISCONNECTED               = 0;
28    /** An incoming call that was missed and never answered */
29    public static final int INCOMING_MISSED                = 1;
30    /** Normal; Remote hangup*/
31    public static final int NORMAL                         = 2;
32    /** Normal; Local hangup */
33    public static final int LOCAL                          = 3;
34    /** Outgoing call to busy line */
35    public static final int BUSY                           = 4;
36    /** Outgoing call to congested network */
37    public static final int CONGESTION                     = 5;
38    /** Not presently used */
39    public static final int MMI                            = 6;
40    /** Invalid dial string */
41    public static final int INVALID_NUMBER                 = 7;
42    /** Cannot reach the peer */
43    public static final int NUMBER_UNREACHABLE             = 8;
44    /** Cannot reach the server */
45    public static final int SERVER_UNREACHABLE             = 9;
46    /** Invalid credentials */
47    public static final int INVALID_CREDENTIALS            = 10;
48    /** Calling from out of network is not allowed */
49    public static final int OUT_OF_NETWORK                 = 11;
50    /** Server error */
51    public static final int SERVER_ERROR                   = 12;
52    /** Client timed out */
53    public static final int TIMED_OUT                      = 13;
54    /** Client went out of network range */
55    public static final int LOST_SIGNAL                    = 14;
56    /** GSM or CDMA ACM limit exceeded */
57    public static final int LIMIT_EXCEEDED                 = 15;
58    /** An incoming call that was rejected */
59    public static final int INCOMING_REJECTED              = 16;
60    /** Radio is turned off explicitly */
61    public static final int POWER_OFF                      = 17;
62    /** Out of service */
63    public static final int OUT_OF_SERVICE                 = 18;
64    /** No ICC, ICC locked, or other ICC error */
65    public static final int ICC_ERROR                      = 19;
66    /** Call was blocked by call barring */
67    public static final int CALL_BARRED                    = 20;
68    /** Call was blocked by fixed dial number */
69    public static final int FDN_BLOCKED                    = 21;
70    /** Call was blocked by restricted all voice access */
71    public static final int CS_RESTRICTED                  = 22;
72    /** Call was blocked by restricted normal voice access */
73    public static final int CS_RESTRICTED_NORMAL           = 23;
74    /** Call was blocked by restricted emergency voice access */
75    public static final int CS_RESTRICTED_EMERGENCY        = 24;
76    /** Unassigned number */
77    public static final int UNOBTAINABLE_NUMBER            = 25;
78    /** MS is locked until next power cycle */
79    public static final int CDMA_LOCKED_UNTIL_POWER_CYCLE  = 26;
80    /** Drop call*/
81    public static final int CDMA_DROP                      = 27;
82    /** INTERCEPT order received, MS state idle entered */
83    public static final int CDMA_INTERCEPT                 = 28;
84    /** MS has been redirected, call is cancelled */
85    public static final int CDMA_REORDER                   = 29;
86    /** Service option rejection */
87    public static final int CDMA_SO_REJECT                 = 30;
88    /** Requested service is rejected, retry delay is set */
89    public static final int CDMA_RETRY_ORDER               = 31;
90    /** Unable to obtain access to the CDMA system */
91    public static final int CDMA_ACCESS_FAILURE            = 32;
92    /** Not a preempted call */
93    public static final int CDMA_PREEMPTED                 = 33;
94    /** Not an emergency call */
95    public static final int CDMA_NOT_EMERGENCY             = 34;
96    /** Access Blocked by CDMA network */
97    public static final int CDMA_ACCESS_BLOCKED            = 35;
98    /** Unknown error or not specified */
99    public static final int ERROR_UNSPECIFIED              = 36;
100    /**
101     * Only emergency numbers are allowed, but we tried to dial
102     * a non-emergency number.
103     */
104    // TODO: This should be the same as NOT_EMERGENCY
105    public static final int EMERGENCY_ONLY                 = 37;
106    /**
107     * The supplied CALL Intent didn't contain a valid phone number.
108     */
109    public static final int NO_PHONE_NUMBER_SUPPLIED       = 38;
110    /**
111     * Our initial phone number was actually an MMI sequence.
112     */
113    public static final int DIALED_MMI                     = 39;
114    /**
115     * We tried to call a voicemail: URI but the device has no
116     * voicemail number configured.
117     */
118    public static final int VOICEMAIL_NUMBER_MISSING       = 40;
119    /**
120     * This status indicates that InCallScreen should display the
121     * CDMA-specific "call lost" dialog.  (If an outgoing call fails,
122     * and the CDMA "auto-retry" feature is enabled, *and* the retried
123     * call fails too, we display this specific dialog.)
124     *
125     * TODO: this is currently unused, since the "call lost" dialog
126     * needs to be triggered by a *disconnect* event, rather than when
127     * the InCallScreen first comes to the foreground.  For now we use
128     * the needToShowCallLostDialog field for this (see below.)
129     */
130    public static final int CDMA_CALL_LOST                 = 41;
131    /**
132     * This status indicates that the call was placed successfully,
133     * but additionally, the InCallScreen needs to display the
134     * "Exiting ECM" dialog.
135     *
136     * (Details: "Emergency callback mode" is a CDMA-specific concept
137     * where the phone disallows data connections over the cell
138     * network for some period of time after you make an emergency
139     * call.  If the phone is in ECM and you dial a non-emergency
140     * number, that automatically *cancels* ECM, but we additionally
141     * need to warn the user that ECM has been canceled (see bug
142     * 4207607.))
143     *
144     * TODO: Rethink where the best place to put this is. It is not a notification
145     * of a failure of the connection -- it is an additional message that accompanies
146     * a successful connection giving the user important information about what happened.
147     *
148     * {@hide}
149     */
150    public static final int EXITED_ECM                     = 42;
151
152    /**
153     * The outgoing call failed with an unknown cause.
154     */
155    public static final int OUTGOING_FAILURE = 43;
156
157    /**
158     * The outgoing call was canceled by the {@link android.telecom.ConnectionService}.
159     */
160    public static final int OUTGOING_CANCELED = 44;
161
162    /** Smallest valid value for call disconnect codes. */
163    public static final int MINIMUM_VALID_VALUE = NOT_DISCONNECTED;
164
165    /** Largest valid value for call disconnect codes. */
166    public static final int MAXIMUM_VALID_VALUE = OUTGOING_CANCELED;
167
168    /** Private constructor to avoid class instantiation. */
169    private DisconnectCause() {
170        // Do nothing.
171    }
172
173    /** Returns descriptive string for the specified disconnect cause. */
174    public static String toString(int cause) {
175        switch (cause) {
176        case NOT_DISCONNECTED:
177            return "NOT_DISCONNECTED";
178        case INCOMING_MISSED:
179            return "INCOMING_MISSED";
180        case NORMAL:
181            return "NORMAL";
182        case LOCAL:
183            return "LOCAL";
184        case BUSY:
185            return "BUSY";
186        case CONGESTION:
187            return "CONGESTION";
188        case INVALID_NUMBER:
189            return "INVALID_NUMBER";
190        case NUMBER_UNREACHABLE:
191            return "NUMBER_UNREACHABLE";
192        case SERVER_UNREACHABLE:
193            return "SERVER_UNREACHABLE";
194        case INVALID_CREDENTIALS:
195            return "INVALID_CREDENTIALS";
196        case OUT_OF_NETWORK:
197            return "OUT_OF_NETWORK";
198        case SERVER_ERROR:
199            return "SERVER_ERROR";
200        case TIMED_OUT:
201            return "TIMED_OUT";
202        case LOST_SIGNAL:
203            return "LOST_SIGNAL";
204        case LIMIT_EXCEEDED:
205            return "LIMIT_EXCEEDED";
206        case INCOMING_REJECTED:
207            return "INCOMING_REJECTED";
208        case POWER_OFF:
209            return "POWER_OFF";
210        case OUT_OF_SERVICE:
211            return "OUT_OF_SERVICE";
212        case ICC_ERROR:
213            return "ICC_ERROR";
214        case CALL_BARRED:
215            return "CALL_BARRED";
216        case FDN_BLOCKED:
217            return "FDN_BLOCKED";
218        case CS_RESTRICTED:
219            return "CS_RESTRICTED";
220        case CS_RESTRICTED_NORMAL:
221            return "CS_RESTRICTED_NORMAL";
222        case CS_RESTRICTED_EMERGENCY:
223            return "CS_RESTRICTED_EMERGENCY";
224        case UNOBTAINABLE_NUMBER:
225            return "UNOBTAINABLE_NUMBER";
226        case CDMA_LOCKED_UNTIL_POWER_CYCLE:
227            return "CDMA_LOCKED_UNTIL_POWER_CYCLE";
228        case CDMA_DROP:
229            return "CDMA_DROP";
230        case CDMA_INTERCEPT:
231            return "CDMA_INTERCEPT";
232        case CDMA_REORDER:
233            return "CDMA_REORDER";
234        case CDMA_SO_REJECT:
235            return "CDMA_SO_REJECT";
236        case CDMA_RETRY_ORDER:
237            return "CDMA_RETRY_ORDER";
238        case CDMA_ACCESS_FAILURE:
239            return "CDMA_ACCESS_FAILURE";
240        case CDMA_PREEMPTED:
241            return "CDMA_PREEMPTED";
242        case CDMA_NOT_EMERGENCY:
243            return "CDMA_NOT_EMERGENCY";
244        case CDMA_ACCESS_BLOCKED:
245            return "CDMA_ACCESS_BLOCKED";
246        case EMERGENCY_ONLY:
247            return "EMERGENCY_ONLY";
248        case NO_PHONE_NUMBER_SUPPLIED:
249            return "NO_PHONE_NUMBER_SUPPLIED";
250        case DIALED_MMI:
251            return "DIALED_MMI";
252        case VOICEMAIL_NUMBER_MISSING:
253            return "VOICEMAIL_NUMBER_MISSING";
254        case CDMA_CALL_LOST:
255            return "CDMA_CALL_LOST";
256        case EXITED_ECM:
257            return "EXITED_ECM";
258        case ERROR_UNSPECIFIED:
259            return "ERROR_UNSPECIFIED";
260        case OUTGOING_FAILURE:
261            return "OUTGOING_FAILURE";
262        case OUTGOING_CANCELED:
263            return "OUTGOING_CANCELED";
264        default:
265            return "INVALID";
266        }
267    }
268}
269