DisconnectCause.java revision 8c2d8c0c27ebd155e9e9d2c066df0297f265b5a6
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    /** Smallest valid value for call disconnect codes. */
153    public static final int MINIMUM_VALID_VALUE = NOT_DISCONNECTED;
154    /** Largest valid value for call disconnect codes. */
155    public static final int MAXIMUM_VALID_VALUE = EXITED_ECM;
156
157    /** Private constructor to avoid class instantiation. */
158    private DisconnectCause() {
159        // Do nothing.
160    }
161
162    /** Returns descriptive string for the specified disconnect cause. */
163    public static String toString(int cause) {
164        switch (cause) {
165        case NOT_DISCONNECTED:
166            return "NOT_DISCONNECTED";
167        case INCOMING_MISSED:
168            return "INCOMING_MISSED";
169        case NORMAL:
170            return "NORMAL";
171        case LOCAL:
172            return "LOCAL";
173        case BUSY:
174            return "BUSY";
175        case CONGESTION:
176            return "CONGESTION";
177        case INVALID_NUMBER:
178            return "INVALID_NUMBER";
179        case NUMBER_UNREACHABLE:
180            return "NUMBER_UNREACHABLE";
181        case SERVER_UNREACHABLE:
182            return "SERVER_UNREACHABLE";
183        case INVALID_CREDENTIALS:
184            return "INVALID_CREDENTIALS";
185        case OUT_OF_NETWORK:
186            return "OUT_OF_NETWORK";
187        case SERVER_ERROR:
188            return "SERVER_ERROR";
189        case TIMED_OUT:
190            return "TIMED_OUT";
191        case LOST_SIGNAL:
192            return "LOST_SIGNAL";
193        case LIMIT_EXCEEDED:
194            return "LIMIT_EXCEEDED";
195        case INCOMING_REJECTED:
196            return "INCOMING_REJECTED";
197        case POWER_OFF:
198            return "POWER_OFF";
199        case OUT_OF_SERVICE:
200            return "OUT_OF_SERVICE";
201        case ICC_ERROR:
202            return "ICC_ERROR";
203        case CALL_BARRED:
204            return "CALL_BARRED";
205        case FDN_BLOCKED:
206            return "FDN_BLOCKED";
207        case CS_RESTRICTED:
208            return "CS_RESTRICTED";
209        case CS_RESTRICTED_NORMAL:
210            return "CS_RESTRICTED_NORMAL";
211        case CS_RESTRICTED_EMERGENCY:
212            return "CS_RESTRICTED_EMERGENCY";
213        case UNOBTAINABLE_NUMBER:
214            return "UNOBTAINABLE_NUMBER";
215        case CDMA_LOCKED_UNTIL_POWER_CYCLE:
216            return "CDMA_LOCKED_UNTIL_POWER_CYCLE";
217        case CDMA_DROP:
218            return "CDMA_DROP";
219        case CDMA_INTERCEPT:
220            return "CDMA_INTERCEPT";
221        case CDMA_REORDER:
222            return "CDMA_REORDER";
223        case CDMA_SO_REJECT:
224            return "CDMA_SO_REJECT";
225        case CDMA_RETRY_ORDER:
226            return "CDMA_RETRY_ORDER";
227        case CDMA_ACCESS_FAILURE:
228            return "CDMA_ACCESS_FAILURE";
229        case CDMA_PREEMPTED:
230            return "CDMA_PREEMPTED";
231        case CDMA_NOT_EMERGENCY:
232            return "CDMA_NOT_EMERGENCY";
233        case CDMA_ACCESS_BLOCKED:
234            return "CDMA_ACCESS_BLOCKED";
235        case EMERGENCY_ONLY:
236            return "EMERGENCY_ONLY";
237        case NO_PHONE_NUMBER_SUPPLIED:
238            return "NO_PHONE_NUMBER_SUPPLIED";
239        case DIALED_MMI:
240            return "DIALED_MMI";
241        case VOICEMAIL_NUMBER_MISSING:
242            return "VOICEMAIL_NUMBER_MISSING";
243        case CDMA_CALL_LOST:
244            return "CDMA_CALL_LOST";
245        case EXITED_ECM:
246            return "EXITED_ECM";
247        case ERROR_UNSPECIFIED:
248            return "ERROR_UNSPECIFIED";
249        default:
250            return "INVALID";
251        }
252    }
253}
254