1 /*
2  * Copyright (c) 2013 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 com.android.ims;
18 
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 
22 /**
23  * This class enables an application to get details on why a method call failed.
24  *
25  * @hide
26  */
27 public class ImsReasonInfo implements Parcelable {
28 
29     /**
30      * Specific code of each types
31      */
32     public static final int CODE_UNSPECIFIED = 0;
33 
34     /**
35      * LOCAL
36      */
37     // IMS -> Telephony
38     // The passed argument is an invalid
39     public static final int CODE_LOCAL_ILLEGAL_ARGUMENT = 101;
40     // The operation is invoked in invalid call state
41     public static final int CODE_LOCAL_ILLEGAL_STATE = 102;
42     // IMS service internal error
43     public static final int CODE_LOCAL_INTERNAL_ERROR = 103;
44     // IMS service goes down (service connection is lost)
45     public static final int CODE_LOCAL_IMS_SERVICE_DOWN = 106;
46     // No pending incoming call exists
47     public static final int CODE_LOCAL_NO_PENDING_CALL = 107;
48     // IMS Call ended during conference merge process
49     public static final int CODE_LOCAL_ENDED_BY_CONFERENCE_MERGE = 108;
50 
51     // IMS -> Telephony
52     // Service unavailable; by power off
53     public static final int CODE_LOCAL_POWER_OFF = 111;
54     // Service unavailable; by low battery
55     public static final int CODE_LOCAL_LOW_BATTERY = 112;
56     // Service unavailable; by out of service (data service state)
57     public static final int CODE_LOCAL_NETWORK_NO_SERVICE = 121;
58     // Service unavailable; by no LTE coverage
59     // (VoLTE is not supported even though IMS is registered)
60     public static final int CODE_LOCAL_NETWORK_NO_LTE_COVERAGE = 122;
61     // Service unavailable; by located in roaming area
62     public static final int CODE_LOCAL_NETWORK_ROAMING = 123;
63     // Service unavailable; by IP changed
64     public static final int CODE_LOCAL_NETWORK_IP_CHANGED = 124;
65     // Service unavailable; other
66     public static final int CODE_LOCAL_SERVICE_UNAVAILABLE = 131;
67     // Service unavailable; IMS connection is lost (IMS is not registered)
68     public static final int CODE_LOCAL_NOT_REGISTERED = 132;
69 
70     // IMS <-> Telephony
71     // Max call exceeded
72     public static final int CODE_LOCAL_CALL_EXCEEDED = 141;
73     // IMS <- Telephony
74     // Call busy
75     public static final int CODE_LOCAL_CALL_BUSY = 142;
76     // Call decline
77     public static final int CODE_LOCAL_CALL_DECLINE = 143;
78     // IMS -> Telephony
79     // SRVCC is in progress
80     public static final int CODE_LOCAL_CALL_VCC_ON_PROGRESSING = 144;
81     // Resource reservation is failed (QoS precondition)
82     public static final int CODE_LOCAL_CALL_RESOURCE_RESERVATION_FAILED = 145;
83     // Retry CS call; VoLTE service can't be provided by the network or remote end
84     // Resolve the extra code(EXTRA_CODE_CALL_RETRY_*) if the below code is set
85     public static final int CODE_LOCAL_CALL_CS_RETRY_REQUIRED = 146;
86     // Retry VoLTE call; VoLTE service can't be provided by the network temporarily
87     public static final int CODE_LOCAL_CALL_VOLTE_RETRY_REQUIRED = 147;
88     // IMS call is already terminated (in TERMINATED state)
89     public static final int CODE_LOCAL_CALL_TERMINATED = 148;
90     // Handover not feasible
91     public static final int CODE_LOCAL_HO_NOT_FEASIBLE = 149;
92 
93     /**
94      * TIMEOUT (IMS -> Telephony)
95      */
96     // 1xx waiting timer is expired after sending INVITE request (MO only)
97     public static final int CODE_TIMEOUT_1XX_WAITING = 201;
98     // User no answer during call setup operation (MO/MT)
99     // MO : 200 OK to INVITE request is not received,
100     // MT : No action from user after alerting the call
101     public static final int CODE_TIMEOUT_NO_ANSWER = 202;
102     // User no answer during call update operation (MO/MT)
103     // MO : 200 OK to re-INVITE request is not received,
104     // MT : No action from user after alerting the call
105     public static final int CODE_TIMEOUT_NO_ANSWER_CALL_UPDATE = 203;
106 
107     //Call failures for FDN
108     public static final int CODE_FDN_BLOCKED = 241;
109 
110     /**
111      * STATUSCODE (SIP response code) (IMS -> Telephony)
112      */
113     // 3xx responses
114     // SIP request is redirected
115     public static final int CODE_SIP_REDIRECTED = 321;
116     // 4xx responses
117     // 400 : Bad Request
118     public static final int CODE_SIP_BAD_REQUEST = 331;
119     // 403 : Forbidden
120     public static final int CODE_SIP_FORBIDDEN = 332;
121     // 404 : Not Found
122     public static final int CODE_SIP_NOT_FOUND = 333;
123     // 415 : Unsupported Media Type
124     // 416 : Unsupported URI Scheme
125     // 420 : Bad Extension
126     public static final int CODE_SIP_NOT_SUPPORTED = 334;
127     // 408 : Request Timeout
128     public static final int CODE_SIP_REQUEST_TIMEOUT = 335;
129     // 480 : Temporarily Unavailable
130     public static final int CODE_SIP_TEMPRARILY_UNAVAILABLE = 336;
131     // 484 : Address Incomplete
132     public static final int CODE_SIP_BAD_ADDRESS = 337;
133     // 486 : Busy Here
134     // 600 : Busy Everywhere
135     public static final int CODE_SIP_BUSY = 338;
136     // 487 : Request Terminated
137     public static final int CODE_SIP_REQUEST_CANCELLED = 339;
138     // 406 : Not Acceptable
139     // 488 : Not Acceptable Here
140     // 606 : Not Acceptable
141     public static final int CODE_SIP_NOT_ACCEPTABLE = 340;
142     // 410 : Gone
143     // 604 : Does Not Exist Anywhere
144     public static final int CODE_SIP_NOT_REACHABLE = 341;
145     // Others
146     public static final int CODE_SIP_CLIENT_ERROR = 342;
147     // 5xx responses
148     // 501 : Server Internal Error
149     public static final int CODE_SIP_SERVER_INTERNAL_ERROR = 351;
150     // 503 : Service Unavailable
151     public static final int CODE_SIP_SERVICE_UNAVAILABLE = 352;
152     // 504 : Server Time-out
153     public static final int CODE_SIP_SERVER_TIMEOUT = 353;
154     // Others
155     public static final int CODE_SIP_SERVER_ERROR = 354;
156     // 6xx responses
157     // 603 : Decline
158     public static final int CODE_SIP_USER_REJECTED = 361;
159     // Others
160     public static final int CODE_SIP_GLOBAL_ERROR = 362;
161     // Emergency failure
162     public static final int CODE_EMERGENCY_TEMP_FAILURE = 363;
163     public static final int CODE_EMERGENCY_PERM_FAILURE = 364;
164 
165     /**
166      * MEDIA (IMS -> Telephony)
167      */
168     // Media resource initialization failed
169     public static final int CODE_MEDIA_INIT_FAILED = 401;
170     // RTP timeout (no audio / video traffic in the session)
171     public static final int CODE_MEDIA_NO_DATA = 402;
172     // Media is not supported; so dropped the call
173     public static final int CODE_MEDIA_NOT_ACCEPTABLE = 403;
174     // Unknown media related errors
175     public static final int CODE_MEDIA_UNSPECIFIED = 404;
176 
177     /**
178      * USER
179      */
180     // Telephony -> IMS
181     // User triggers the call end
182     public static final int CODE_USER_TERMINATED = 501;
183     // No action while an incoming call is ringing
184     public static final int CODE_USER_NOANSWER = 502;
185     // User ignores an incoming call
186     public static final int CODE_USER_IGNORE = 503;
187     // User declines an incoming call
188     public static final int CODE_USER_DECLINE = 504;
189     // Device declines/ends a call due to low battery
190     public static final int CODE_LOW_BATTERY = 505;
191     // Device declines call due to blacklisted call ID
192     public static final int CODE_BLACKLISTED_CALL_ID = 506;
193     // IMS -> Telephony
194     // The call is terminated by the network or remote user
195     public static final int CODE_USER_TERMINATED_BY_REMOTE = 510;
196 
197     /**
198      * Extra codes for the specific code value
199      * This value can be referred when the code is CODE_LOCAL_CALL_CS_RETRY_REQUIRED.
200      */
201     // Try to connect CS call; normal
202     public static final int EXTRA_CODE_CALL_RETRY_NORMAL = 1;
203     // Try to connect CS call without the notification to user
204     public static final int EXTRA_CODE_CALL_RETRY_SILENT_REDIAL = 2;
205     // Try to connect CS call by the settings of the menu
206     public static final int EXTRA_CODE_CALL_RETRY_BY_SETTINGS = 3;
207 
208     /**
209      * UT
210      */
211     public static final int CODE_UT_NOT_SUPPORTED = 801;
212     public static final int CODE_UT_SERVICE_UNAVAILABLE = 802;
213     public static final int CODE_UT_OPERATION_NOT_ALLOWED = 803;
214     public static final int CODE_UT_NETWORK_ERROR = 804;
215     public static final int CODE_UT_CB_PASSWORD_MISMATCH = 821;
216 
217     /**
218      * ECBM
219      */
220     public static final int CODE_ECBM_NOT_SUPPORTED = 901;
221 
222     /**
223      * Fail code used to indicate that Multi-endpoint is not supported by the Ims framework.
224      */
225     public static final int CODE_MULTIENDPOINT_NOT_SUPPORTED = 902;
226 
227     /**
228      * Ims Registration error code
229      */
230     public static final int CODE_REGISTRATION_ERROR = 1000;
231 
232     /**
233      * CALL DROP error codes (Call could drop because of many reasons like Network not available,
234      *  handover, failed, etc)
235      */
236 
237     /**
238      * CALL DROP error code for the case when a device is ePDG capable and when the user is on an
239      * active wifi call and at the edge of coverage and there is no qualified LTE network available
240      * to handover the call to. We get a handover NOT_TRIGERRED message from the modem. This error
241      * code is received as part of the handover message.
242      */
243     public static final int CODE_CALL_DROP_IWLAN_TO_LTE_UNAVAILABLE = 1100;
244 
245     /**
246      * MT call has ended due to a release from the network
247      * because the call was answered elsewhere
248      */
249     public static final int CODE_ANSWERED_ELSEWHERE = 1014;
250 
251     /**
252      * For MultiEndpoint - Call Pull request has failed
253      */
254     public static final int CODE_CALL_PULL_OUT_OF_SYNC = 1015;
255 
256     /**
257      * For MultiEndpoint - Call has been pulled from primary to secondary
258      */
259     public static final int CODE_CALL_END_CAUSE_CALL_PULL = 1016;
260 
261     /**
262      * Supplementary services (HOLD/RESUME) failure error codes.
263      * Values for Supplemetary services failure - Failed, Cancelled and Re-Invite collision.
264      */
265     public static final int CODE_SUPP_SVC_FAILED = 1201;
266     public static final int CODE_SUPP_SVC_CANCELLED = 1202;
267     public static final int CODE_SUPP_SVC_REINVITE_COLLISION = 1203;
268 
269     /**
270      * DPD Procedure received no response or send failed
271      */
272     public static final int CODE_IWLAN_DPD_FAILURE = 1300;
273 
274     /**
275      * Establishment of the ePDG Tunnel Failed
276      */
277     public static final int CODE_EPDG_TUNNEL_ESTABLISH_FAILURE = 1400;
278 
279     /**
280      * Re-keying of the ePDG Tunnel Failed; may not always result in teardown
281      */
282     public static final int CODE_EPDG_TUNNEL_REKEY_FAILURE = 1401;
283 
284     /**
285      * Connection to the packet gateway is lost
286      */
287     public static final int CODE_EPDG_TUNNEL_LOST_CONNECTION = 1402;
288 
289     /**
290      * The maximum number of calls allowed has been reached.  Used in a multi-endpoint scenario
291      * where the number of calls across all connected devices has reached the maximum.
292      */
293     public static final int CODE_MAXIMUM_NUMBER_OF_CALLS_REACHED = 1403;
294 
295     /**
296      * Similar to {@link #CODE_LOCAL_CALL_DECLINE}, except indicates that a remote device has
297      * declined the call.  Used in a multi-endpoint scenario where a remote device declined an
298      * incoming call.
299      */
300     public static final int CODE_REMOTE_CALL_DECLINE = 1404;
301 
302     /**
303      * Indicates the call was disconnected due to the user reaching their data limit.
304      */
305     public static final int CODE_DATA_LIMIT_REACHED = 1405;
306 
307     /**
308      * Indicates the call was disconnected due to the user disabling cellular data.
309      */
310     public static final int CODE_DATA_DISABLED = 1406;
311 
312     /**
313      * Indicates a call was disconnected due to loss of wifi signal.
314      */
315     public static final int CODE_WIFI_LOST = 1407;
316 
317     /**
318      * Indicates the registration attempt on IWLAN failed due to IKEv2 authetication failure
319      * during tunnel establishment.
320      */
321     public static final int CODE_IKEV2_AUTH_FAILURE = 1408;
322 
323     /** The call cannot be established because RADIO is OFF */
324     public static final int CODE_RADIO_OFF = 1500;
325 
326     /** The call cannot be established because of no valid SIM */
327     public static final int CODE_NO_VALID_SIM = 1501;
328 
329     /** The failure is due internal error at modem */
330     public static final int CODE_RADIO_INTERNAL_ERROR = 1502;
331 
332     /** The failure is due to UE timer expired while waiting for a response from network */
333     public static final int CODE_NETWORK_RESP_TIMEOUT = 1503;
334 
335     /** The failure is due to explicit reject from network */
336     public static final int CODE_NETWORK_REJECT = 1504;
337 
338     /** The failure is due to radio access failure. ex. RACH failure */
339     public static final int CODE_RADIO_ACCESS_FAILURE = 1505;
340 
341     /** Call/IMS registration failed/dropped because of a RLF */
342     public static final int CODE_RADIO_LINK_FAILURE = 1506;
343 
344     /** Call/IMS registration failed/dropped because of radio link lost */
345     public static final int CODE_RADIO_LINK_LOST = 1507;
346 
347     /** The call Call/IMS registration failed because of a radio uplink issue */
348     public static final int CODE_RADIO_UPLINK_FAILURE = 1508;
349 
350     /** Call failed because of a RRC connection setup failure */
351     public static final int CODE_RADIO_SETUP_FAILURE = 1509;
352 
353     /** Call failed/dropped because of RRC connection release from NW */
354     public static final int CODE_RADIO_RELEASE_NORMAL = 1510;
355 
356     /** Call failed/dropped because of RRC abnormally released by modem/network */
357     public static final int CODE_RADIO_RELEASE_ABNORMAL = 1511;
358 
359     /** Call failed because of access class barring */
360     public static final int CODE_ACCESS_CLASS_BLOCKED = 1512;
361 
362     /** Call/IMS registration is failed/dropped because of a network detach */
363     public static final int CODE_NETWORK_DETACH = 1513;
364 
365     /* OEM specific error codes. To be used by OEMs when they don't want to
366    reveal error code which would be replaced by ERROR_UNSPECIFIED */
367     public static final int CODE_OEM_CAUSE_1 = 0xf001;
368     public static final int CODE_OEM_CAUSE_2 = 0xf002;
369     public static final int CODE_OEM_CAUSE_3 = 0xf003;
370     public static final int CODE_OEM_CAUSE_4 = 0xf004;
371     public static final int CODE_OEM_CAUSE_5 = 0xf005;
372     public static final int CODE_OEM_CAUSE_6 = 0xf006;
373     public static final int CODE_OEM_CAUSE_7 = 0xf007;
374     public static final int CODE_OEM_CAUSE_8 = 0xf008;
375     public static final int CODE_OEM_CAUSE_9 = 0xf009;
376     public static final int CODE_OEM_CAUSE_10 = 0xf00a;
377     public static final int CODE_OEM_CAUSE_11 = 0xf00b;
378     public static final int CODE_OEM_CAUSE_12 = 0xf00c;
379     public static final int CODE_OEM_CAUSE_13 = 0xf00d;
380     public static final int CODE_OEM_CAUSE_14 = 0xf00e;
381     public static final int CODE_OEM_CAUSE_15 = 0xf00f;
382 
383     /**
384      * Network string error messages.
385      * mExtraMessage may have these values.
386      */
387     public static final String EXTRA_MSG_SERVICE_NOT_AUTHORIZED
388             = "Forbidden. Not Authorized for Service";
389 
390 
391     // For main reason code
392     public int mCode;
393     // For the extra code value; it depends on the code value.
394     public int mExtraCode;
395     // For the additional message of the reason info.
396     public String mExtraMessage;
ImsReasonInfo()397     public ImsReasonInfo() {
398         mCode = CODE_UNSPECIFIED;
399         mExtraCode = CODE_UNSPECIFIED;
400         mExtraMessage = null;
401     }
402 
ImsReasonInfo(Parcel in)403     public ImsReasonInfo(Parcel in) {
404         readFromParcel(in);
405     }
406 
ImsReasonInfo(int code, int extraCode)407     public ImsReasonInfo(int code, int extraCode) {
408         mCode = code;
409         mExtraCode = extraCode;
410         mExtraMessage = null;
411     }
412 
ImsReasonInfo(int code, int extraCode, String extraMessage)413     public ImsReasonInfo(int code, int extraCode, String extraMessage) {
414         mCode = code;
415         mExtraCode = extraCode;
416         mExtraMessage = extraMessage;
417     }
418 
419     /**
420      *
421      */
getCode()422     public int getCode() {
423         return mCode;
424     }
425 
426     /**
427      *
428      */
getExtraCode()429     public int getExtraCode() {
430         return mExtraCode;
431     }
432 
433     /**
434      *
435      */
getExtraMessage()436     public String getExtraMessage() {
437         return mExtraMessage;
438     }
439 
440     /**
441      * Returns the string format of {@link ImsReasonInfo}
442      *
443      * @return the string format of {@link ImsReasonInfo}
444      */
toString()445     public String toString() {
446         return "ImsReasonInfo :: {" + mCode + ", " + mExtraCode + ", " + mExtraMessage + "}";
447     }
448 
449     @Override
describeContents()450     public int describeContents() {
451         return 0;
452     }
453 
454     @Override
writeToParcel(Parcel out, int flags)455     public void writeToParcel(Parcel out, int flags) {
456         out.writeInt(mCode);
457         out.writeInt(mExtraCode);
458         out.writeString(mExtraMessage);
459     }
460 
readFromParcel(Parcel in)461     private void readFromParcel(Parcel in) {
462         mCode = in.readInt();
463         mExtraCode = in.readInt();
464         mExtraMessage = in.readString();
465     }
466 
467     public static final Creator<ImsReasonInfo> CREATOR = new Creator<ImsReasonInfo>() {
468         @Override
469         public ImsReasonInfo createFromParcel(Parcel in) {
470             return new ImsReasonInfo(in);
471         }
472 
473         @Override
474         public ImsReasonInfo[] newArray(int size) {
475             return new ImsReasonInfo[size];
476         }
477     };
478 }
479