1 /*
2  * Copyright (C) 2018 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.ims;
18 
19 import android.annotation.IntDef;
20 import android.annotation.NonNull;
21 import android.annotation.Nullable;
22 import android.annotation.SystemApi;
23 import android.compat.annotation.UnsupportedAppUsage;
24 import android.os.Build;
25 import android.os.Parcel;
26 import android.os.Parcelable;
27 
28 import java.lang.annotation.Retention;
29 import java.lang.annotation.RetentionPolicy;
30 
31 /**
32  * Provides details on why an IMS call failed. Applications can use the methods in this class to
33  * get local or network fault behind an IMS services failure. For example, if the code is
34  * CODE_CALL_BARRED, then the call was blocked by network call barring configuration and it is not
35  * the device's bug and the user can retry the call when network lift the barring.
36  * Typical use case includes call backs when IMS call state changed with this class as a param
37  * containing details on why IMS call changed state/failed.
38  */
39 public final class ImsReasonInfo implements Parcelable {
40 
41     /**
42      * The Reason is unspecified.
43      */
44     public static final int CODE_UNSPECIFIED = 0;
45 
46 
47     // LOCAL
48 
49     // IMS -> Telephony
50     /**
51      * The passed argument is invalid.
52      */
53     public static final int CODE_LOCAL_ILLEGAL_ARGUMENT = 101;
54     /**
55      * The operation was invoked while in an invalid call state.
56      */
57     public static final int CODE_LOCAL_ILLEGAL_STATE = 102;
58     /**
59      * IMS service internal error
60      */
61     public static final int CODE_LOCAL_INTERNAL_ERROR = 103;
62     /**
63      * ImsService has crashed (service connection is lost).
64      */
65     public static final int CODE_LOCAL_IMS_SERVICE_DOWN = 106;
66     /**
67      * No pending incoming call exists
68      */
69     public static final int CODE_LOCAL_NO_PENDING_CALL = 107;
70     /**
71      * IMS Call ended during conference merge process
72      */
73     public static final int CODE_LOCAL_ENDED_BY_CONFERENCE_MERGE = 108;
74 
75     // IMS -> Telephony
76     /**
77      * Service unavailable; radio power off
78      */
79     public static final int CODE_LOCAL_POWER_OFF = 111;
80     /**
81      * Service unavailable; low battery
82      */
83     public static final int CODE_LOCAL_LOW_BATTERY = 112;
84     /**
85      * Service unavailable; out of service (data service state)
86      */
87     public static final int CODE_LOCAL_NETWORK_NO_SERVICE = 121;
88     /**
89      * Service unavailable; no LTE coverage
90      * (VoLTE is not supported even though IMS is registered)
91      */
92     public static final int CODE_LOCAL_NETWORK_NO_LTE_COVERAGE = 122;
93     /**
94      * Service unavailable; located in roaming area
95      */
96     public static final int CODE_LOCAL_NETWORK_ROAMING = 123;
97     /**
98      * Service unavailable; IP changed
99      */
100     public static final int CODE_LOCAL_NETWORK_IP_CHANGED = 124;
101     /**
102      * Service unavailable; for an unspecified reason
103      */
104     public static final int CODE_LOCAL_SERVICE_UNAVAILABLE = 131;
105     /**
106      * Service unavailable; IMS is not registered
107      */
108     public static final int CODE_LOCAL_NOT_REGISTERED = 132;
109 
110     // IMS <-> Telephony
111     /**
112      * Maximum number of simultaneous calls exceeded
113      */
114     public static final int CODE_LOCAL_CALL_EXCEEDED = 141;
115     // IMS <- Telephony
116     /**
117      * The call is busy.
118      */
119     public static final int CODE_LOCAL_CALL_BUSY = 142;
120     /**
121      * The Call has been declined locally on this device.
122      */
123     public static final int CODE_LOCAL_CALL_DECLINE = 143;
124     // IMS -> Telephony
125     /**
126      * Can not complete call; an SRVCC is in progress.
127      */
128     public static final int CODE_LOCAL_CALL_VCC_ON_PROGRESSING = 144;
129     /**
130      * Can not complete call; resource reservation is failed (QoS precondition)
131      */
132     public static final int CODE_LOCAL_CALL_RESOURCE_RESERVATION_FAILED = 145;
133     /**
134      * VoLTE service can't be provided by the network or remote end, retry the call.
135      * Resolve the extra code provided in (EXTRA_CODE_CALL_RETRY_*) if the below code is set
136      */
137     public static final int CODE_LOCAL_CALL_CS_RETRY_REQUIRED = 146;
138     /**
139      * VoLTE service can't be provided by the network temporarily, retry the call.
140      */
141     public static final int CODE_LOCAL_CALL_VOLTE_RETRY_REQUIRED = 147;
142     /**
143      * IMS call is already terminated (in TERMINATED state).
144      */
145     public static final int CODE_LOCAL_CALL_TERMINATED = 148;
146     /**
147      * Call was disconnected because a handover is not feasible due to network conditions.
148      */
149     public static final int CODE_LOCAL_HO_NOT_FEASIBLE = 149;
150     /**
151      * This device does not support IMS.
152      * @hide
153      */
154     public static final int CODE_LOCAL_IMS_NOT_SUPPORTED_ON_DEVICE = 150;
155 
156     /*
157      * TIMEOUT (IMS -> Telephony)
158      */
159     /**
160      * 1xx waiting timer is expired after sending INVITE request (MO calls only)
161      */
162     public static final int CODE_TIMEOUT_1XX_WAITING = 201;
163     /**
164      * User didn't answer during call setup operation (MO/MT)
165      * MO : 200 OK to INVITE request is not received,
166      * MT : No action from user after alerting the call
167      */
168     public static final int CODE_TIMEOUT_NO_ANSWER = 202;
169     /**
170      * User no answer during call update operation (MO/MT)
171      * MO : 200 OK to re-INVITE request is not received,
172      * MT : No action from user after alerting the call
173      */
174     public static final int CODE_TIMEOUT_NO_ANSWER_CALL_UPDATE = 203;
175 
176     /**
177      * The call was blocked by call barring configuration.
178      */
179     public static final int CODE_CALL_BARRED = 240;
180 
181     /**
182      * The operation is restricted to fixed dialing numbers only.
183      */
184     public static final int CODE_FDN_BLOCKED = 241;
185 
186     /**
187      * Network rejected the emergency call request because IMEI was used as identification
188      * and this capability is not supported by the network.
189      */
190     public static final int CODE_IMEI_NOT_ACCEPTED = 243;
191 
192     //STK CC errors
193     /**
194      * Stk Call Control modified DIAL request to USSD request.
195      */
196     public static final int CODE_DIAL_MODIFIED_TO_USSD = 244;
197     /**
198      * Stk Call Control modified DIAL request to SS request.
199      */
200     public static final int CODE_DIAL_MODIFIED_TO_SS = 245;
201     /**
202      * Stk Call Control modified DIAL request to DIAL with modified data.
203      */
204     public static final int CODE_DIAL_MODIFIED_TO_DIAL = 246;
205     /**
206      * Stk Call Control modified DIAL request to Video DIAL request.
207      */
208     public static final int CODE_DIAL_MODIFIED_TO_DIAL_VIDEO = 247;
209     /**
210      * Stk Call Control modified Video DIAL request to DIAL request.
211      */
212     public static final int CODE_DIAL_VIDEO_MODIFIED_TO_DIAL = 248;
213     /**
214      * Stk Call Control modified Video DIAL request to Video DIAL request.
215      */
216     public static final int CODE_DIAL_VIDEO_MODIFIED_TO_DIAL_VIDEO = 249;
217     /**
218      * Stk Call Control modified Video DIAL request to SS request.
219      */
220     public static final int CODE_DIAL_VIDEO_MODIFIED_TO_SS = 250;
221     /**
222      * Stk Call Control modified Video DIAL request to USSD request.
223      */
224     public static final int CODE_DIAL_VIDEO_MODIFIED_TO_USSD = 251;
225 
226     /*
227      * STATUSCODE (SIP response code) (IMS -> Telephony)
228      */
229     // 3xx responses
230     /**
231      * SIP 3xx response: SIP request is redirected
232      */
233     public static final int CODE_SIP_REDIRECTED = 321;
234     // 4xx responses
235     /**
236      * Sip 400 response : Bad Request
237      */
238     public static final int CODE_SIP_BAD_REQUEST = 331;
239     /**
240      * Sip 403 response : Forbidden
241      */
242     public static final int CODE_SIP_FORBIDDEN = 332;
243     /**
244      * Sip 404 response : Not Found
245      */
246     public static final int CODE_SIP_NOT_FOUND = 333;
247     /**
248      * Not supported, because of one of the following:
249      * SIP response 415 : Unsupported Media Type,
250      * SIP response 416 : Unsupported URI Scheme,
251      * SIP response 420 : Bad Extension
252      */
253     public static final int CODE_SIP_NOT_SUPPORTED = 334;
254     /**
255      * SIP response 408 : Request Timeout.
256      */
257     public static final int CODE_SIP_REQUEST_TIMEOUT = 335;
258     /**
259      * SIP response 480 : Temporarily Unavailable
260      */
261     public static final int CODE_SIP_TEMPRARILY_UNAVAILABLE = 336;
262     /**
263      * SIP response 484 : Address Incomplete
264      */
265     public static final int CODE_SIP_BAD_ADDRESS = 337;
266     /**
267      * Returned a busy response, may be one of the following:
268      * SIP response 486 : Busy Here,
269      * SIP response 600 : Busy Everywhere
270      */
271     public static final int CODE_SIP_BUSY = 338;
272     /**
273      * SIP response 487 : Request Terminated
274      */
275     public static final int CODE_SIP_REQUEST_CANCELLED = 339;
276     /**
277      * Received a not acceptable response, will be one of the following:
278      * SIP response 406 : Not Acceptable
279      * SIP response 488 : Not Acceptable Here
280      * SIP response 606 : Not Acceptable
281      */
282     public static final int CODE_SIP_NOT_ACCEPTABLE = 340;
283     /**
284      * Received a not acceptable response, will be one of the following:
285      * SIP response 410 : Gone
286      * SIP response 604 : Does Not Exist Anywhere
287      */
288     public static final int CODE_SIP_NOT_REACHABLE = 341;
289     /**
290      * Received another unspecified error SIP response from the client.
291      */
292     public static final int CODE_SIP_CLIENT_ERROR = 342;
293     /**
294      * SIP response 481: Transaction Does Not Exist
295      */
296     public static final int CODE_SIP_TRANSACTION_DOES_NOT_EXIST = 343;
297     // 5xx responses
298     /**
299      * SIP response 501 : Server Internal Error
300      */
301     public static final int CODE_SIP_SERVER_INTERNAL_ERROR = 351;
302     /**
303      * SIP response 503 : Service Unavailable
304      */
305     public static final int CODE_SIP_SERVICE_UNAVAILABLE = 352;
306     /**
307      * SIP response 504 : Server Time-out
308      */
309     public static final int CODE_SIP_SERVER_TIMEOUT = 353;
310     /**
311      * Received an unspecified SIP server error response.
312      */
313     public static final int CODE_SIP_SERVER_ERROR = 354;
314     // 6xx responses
315     /**
316      * 603 : Decline
317      */
318     public static final int CODE_SIP_USER_REJECTED = 361;
319     /**
320      * Unspecified 6xx error.
321      */
322     public static final int CODE_SIP_GLOBAL_ERROR = 362;
323 
324     /**
325      * Emergency call failed in the modem with a temporary fail cause and should be redialed on this
326      * slot.
327      */
328     public static final int CODE_EMERGENCY_TEMP_FAILURE = 363;
329     /**
330      * Emergency call failed in the modem with a permanent fail cause and should not be redialed on
331      * this slot. If there are any other slots available for emergency calling, try those.
332      */
333     public static final int CODE_EMERGENCY_PERM_FAILURE = 364;
334 
335     /**
336      * Call failure code during hangup/reject if user marked the call as unwanted.
337      *
338      * Android Telephony will receive information whether ROBO call feature is supported by the
339      * network from modem and propagate the same to AOSP as new ImsCallProfile members. OEMs can
340      * check this information and provide an option to the user to mark the call as unwanted.
341      */
342     public static final int CODE_SIP_USER_MARKED_UNWANTED = 365;
343 
344     /**
345      * SIP Response : 405
346      * Method not allowed for the address in the Request URI
347      */
348     public static final int CODE_SIP_METHOD_NOT_ALLOWED = 366;
349 
350     /**
351      * SIP Response : 407
352      * The request requires user authentication
353      */
354     public static final int CODE_SIP_PROXY_AUTHENTICATION_REQUIRED = 367;
355 
356     /**
357      * SIP Response : 413
358      * Request body too large
359      */
360     public static final int CODE_SIP_REQUEST_ENTITY_TOO_LARGE = 368;
361 
362     /**
363      * SIP Response : 414
364      * Request-URI too large
365      */
366     public static final int CODE_SIP_REQUEST_URI_TOO_LARGE = 369;
367 
368     /**
369      * SIP Response : 421
370      * Specific extension is required, which is not present in the HEADER
371      */
372     public static final int CODE_SIP_EXTENSION_REQUIRED = 370;
373 
374     /**
375      * SIP Response : 422
376      * The session expiration field too small
377      */
378     public static final int CODE_SIP_INTERVAL_TOO_BRIEF = 371;
379 
380     /**
381      * SIP Response : 481
382      * Request received by the server does not match any dialog or transaction
383      */
384     public static final int CODE_SIP_CALL_OR_TRANS_DOES_NOT_EXIST = 372;
385 
386     /**
387      * SIP Response : 482
388      * Server has detected a loop
389      */
390     public static final int CODE_SIP_LOOP_DETECTED = 373;
391 
392     /**
393      * SIP Response : 483
394      * Max-Forwards value reached
395      */
396     public static final int CODE_SIP_TOO_MANY_HOPS = 374;
397 
398     /**
399      * SIP Response : 485
400      * Request-URI is ambiguous
401      *
402      */
403     public static final int CODE_SIP_AMBIGUOUS = 376;
404 
405     /**
406      * SIP Response : 491
407      * Server has pending request for same dialog
408      */
409     public static final int CODE_SIP_REQUEST_PENDING = 377;
410 
411     /**
412      * SIP Response : 493
413      * The request cannot be decrypted by recipient
414      */
415     public static final int CODE_SIP_UNDECIPHERABLE = 378;
416 
417     /**
418      * MEDIA (IMS -> Telephony)
419      */
420     /**
421      * Media resource initialization failed
422      */
423     public static final int CODE_MEDIA_INIT_FAILED = 401;
424     /**
425      * RTP timeout (no audio / video traffic in the session)
426      */
427     public static final int CODE_MEDIA_NO_DATA = 402;
428     /**
429      * Media is not supported; so dropped the call
430      */
431     public static final int CODE_MEDIA_NOT_ACCEPTABLE = 403;
432     /**
433      * Unspecified media related error.
434      */
435     public static final int CODE_MEDIA_UNSPECIFIED = 404;
436 
437     /*
438      * USER
439      */
440     // Telephony -> IMS
441     /**
442      * User triggers the call to be terminated.
443      */
444     public static final int CODE_USER_TERMINATED = 501;
445     /**
446      * No action was taken while an incoming call was ringing.
447      */
448     public static final int CODE_USER_NOANSWER = 502;
449     /**
450      * User ignored an incoming call.
451      */
452     public static final int CODE_USER_IGNORE = 503;
453     /**
454      * User declined an incoming call.
455      */
456     public static final int CODE_USER_DECLINE = 504;
457     /**
458      * Device declined/ended a call due to a low battery condition.
459      */
460     public static final int CODE_LOW_BATTERY = 505;
461     /**
462      * Device declined a call due to a blacklisted caller ID.
463      */
464     public static final int CODE_BLACKLISTED_CALL_ID = 506;
465     // IMS -> Telephony
466     /**
467      * The call has been terminated by the network or remote user.
468      */
469     public static final int CODE_USER_TERMINATED_BY_REMOTE = 510;
470     /**
471     * Upgrade Downgrade request rejected by
472     * Remote user if the request is MO initiated
473     * Local user if the request is MT initiated
474     */
475     public static final int CODE_USER_REJECTED_SESSION_MODIFICATION = 511;
476 
477     /**
478     * Upgrade Downgrade request cancelled by the user who initiated it
479     */
480     public static final int CODE_USER_CANCELLED_SESSION_MODIFICATION = 512;
481 
482     /**
483      * UPGRADE DOWNGRADE operation failed
484      * This can happen due to failure from SIP/RTP/SDP generation or a Call end is
485      * triggered/received while Reinvite is in progress.
486      */
487     public static final int CODE_SESSION_MODIFICATION_FAILED = 1517;
488 
489     /*
490      * UT
491      */
492     /**
493      * UT is currently not supported on this device.
494      */
495     public static final int CODE_UT_NOT_SUPPORTED = 801;
496     /**
497      * UT services are currently not available on this device.
498      */
499     public static final int CODE_UT_SERVICE_UNAVAILABLE = 802;
500     /**
501      * The requested UT operation is not allowed.
502      */
503     public static final int CODE_UT_OPERATION_NOT_ALLOWED = 803;
504     /**
505      * The UT request resulted in a network error.
506      */
507     public static final int CODE_UT_NETWORK_ERROR = 804;
508     /**
509      * The password entered for UT operations does not match the stored password.
510      */
511     public static final int CODE_UT_CB_PASSWORD_MISMATCH = 821;
512     //STK CC errors
513     /**
514      * Sim Toolkit Call Control modified the UT operation to a dial command.
515      */
516     public static final int CODE_UT_SS_MODIFIED_TO_DIAL = 822;
517     /**
518      * Sim Toolkit Call Control modified the UT operation to a USSD command.
519      */
520     public static final int CODE_UT_SS_MODIFIED_TO_USSD = 823;
521     /**
522      * Sim Toolkit Call Control modified the UT operation to another supplementary service command.
523      */
524     public static final int CODE_UT_SS_MODIFIED_TO_SS = 824;
525     /**
526      * Sim Toolkit Call Control modified the UT operation to a video call dial command.
527      */
528     public static final int CODE_UT_SS_MODIFIED_TO_DIAL_VIDEO = 825;
529 
530     /**@hide*/
531     @IntDef(value = {
532             CODE_UT_NOT_SUPPORTED,
533             CODE_UT_SERVICE_UNAVAILABLE,
534             CODE_UT_OPERATION_NOT_ALLOWED,
535             CODE_UT_NETWORK_ERROR,
536             CODE_UT_CB_PASSWORD_MISMATCH,
537             CODE_UT_SS_MODIFIED_TO_DIAL,
538             CODE_UT_SS_MODIFIED_TO_USSD,
539             CODE_UT_SS_MODIFIED_TO_SS,
540             CODE_UT_SS_MODIFIED_TO_DIAL_VIDEO
541     }, prefix = "CODE_UT_")
542     @Retention(RetentionPolicy.SOURCE)
543     public @interface UtReason {}
544 
545     /**
546      * Emergency callback mode is not supported.
547      */
548     public static final int CODE_ECBM_NOT_SUPPORTED = 901;
549 
550     /**
551      * Fail code used to indicate that Multi-endpoint is not supported by the IMS framework.
552      */
553     public static final int CODE_MULTIENDPOINT_NOT_SUPPORTED = 902;
554 
555     /**
556      * IMS Registration error code
557      */
558     public static final int CODE_REGISTRATION_ERROR = 1000;
559 
560     /*
561      * CALL DROP error codes (Call could drop because of many reasons like Network not available,
562      *  handover, failed, etc)
563      */
564     /**
565      * MT call has ended due to a release from the network because the call was answered elsewhere.
566      */
567     public static final int CODE_ANSWERED_ELSEWHERE = 1014;
568 
569     /**
570      * For MultiEndpoint - Call Pull request has failed.
571      */
572     public static final int CODE_CALL_PULL_OUT_OF_SYNC = 1015;
573 
574     /**
575      * For MultiEndpoint - Call has been pulled from primary to secondary.
576      */
577     public static final int CODE_CALL_END_CAUSE_CALL_PULL = 1016;
578 
579     /**
580      * CALL DROP error code for the case when a device is ePDG capable and when the user is on an
581      * active wifi call and at the edge of coverage and there is no qualified LTE network available
582      * to handover the call to. We get a handover NOT_TRIGERRED message from the modem. This error
583      * code is received as part of the handover message.
584      */
585     public static final int CODE_CALL_DROP_IWLAN_TO_LTE_UNAVAILABLE = 1100;
586 
587     /**
588      * For MultiEndPoint - Call was rejected elsewhere
589      */
590     public static final int CODE_REJECTED_ELSEWHERE = 1017;
591 
592     /**
593      * Supplementary services (HOLD/RESUME) failure error codes.
594      * Values for Supplemetary services failure - Failed, Cancelled and Re-Invite collision.
595      */
596 
597     /**
598      * Supplementary Services (HOLD/RESUME) - the command failed.
599      */
600     public static final int CODE_SUPP_SVC_FAILED = 1201;
601     /**
602      * Supplementary Services (HOLD/RESUME) - the command was cancelled.
603      */
604     public static final int CODE_SUPP_SVC_CANCELLED = 1202;
605     /**
606      * Supplementary Services (HOLD/RESUME) - the command resulted in a re-invite collision.
607      */
608     public static final int CODE_SUPP_SVC_REINVITE_COLLISION = 1203;
609 
610     /**
611      * DPD Procedure received no response or send failed.
612      */
613     public static final int CODE_IWLAN_DPD_FAILURE = 1300;
614 
615     /**
616      * Establishment of the ePDG Tunnel Failed.
617      */
618     public static final int CODE_EPDG_TUNNEL_ESTABLISH_FAILURE = 1400;
619 
620     /**
621      * Re-keying of the ePDG Tunnel Failed; may not always result in teardown.
622      */
623     public static final int CODE_EPDG_TUNNEL_REKEY_FAILURE = 1401;
624 
625     /**
626      * Connection to the packet gateway is lost.
627      */
628     public static final int CODE_EPDG_TUNNEL_LOST_CONNECTION = 1402;
629 
630     /**
631      * The maximum number of calls allowed has been reached.  Used in a multi-endpoint scenario
632      * where the number of calls across all connected devices has reached the maximum.
633      */
634     public static final int CODE_MAXIMUM_NUMBER_OF_CALLS_REACHED = 1403;
635 
636     /**
637      * Similar to {@link #CODE_LOCAL_CALL_DECLINE}, except indicates that a remote device has
638      * declined the call.  Used in a multi-endpoint scenario where a remote device declined an
639      * incoming call.
640      */
641     public static final int CODE_REMOTE_CALL_DECLINE = 1404;
642 
643     /**
644      * Indicates the call was disconnected due to the user reaching their data limit.
645      */
646     public static final int CODE_DATA_LIMIT_REACHED = 1405;
647 
648     /**
649      * Indicates the call was disconnected due to the user disabling cellular data.
650      */
651     public static final int CODE_DATA_DISABLED = 1406;
652 
653     /**
654      * Indicates a call was disconnected due to loss of wifi signal.
655      */
656     public static final int CODE_WIFI_LOST = 1407;
657 
658     /**
659      * Indicates the registration attempt on IWLAN failed due to IKEv2 authetication failure
660      * during tunnel establishment.
661      */
662     public static final int CODE_IKEV2_AUTH_FAILURE = 1408;
663 
664     /** The call cannot be established because RADIO is OFF */
665     public static final int CODE_RADIO_OFF = 1500;
666 
667     /** The call cannot be established because of no valid SIM */
668     public static final int CODE_NO_VALID_SIM = 1501;
669 
670     /** The failure is due internal error at modem */
671     public static final int CODE_RADIO_INTERNAL_ERROR = 1502;
672 
673     /** The failure is due to UE timer expired while waiting for a response from network */
674     public static final int CODE_NETWORK_RESP_TIMEOUT = 1503;
675 
676     /** The failure is due to explicit reject from network */
677     public static final int CODE_NETWORK_REJECT = 1504;
678 
679     /** The failure is due to radio access failure. ex. RACH failure */
680     public static final int CODE_RADIO_ACCESS_FAILURE = 1505;
681 
682     /** Call/IMS registration failed/dropped because of a RLF */
683     public static final int CODE_RADIO_LINK_FAILURE = 1506;
684 
685     /** Call/IMS registration failed/dropped because of radio link lost */
686     public static final int CODE_RADIO_LINK_LOST = 1507;
687 
688     /** The call Call/IMS registration failed because of a radio uplink issue */
689     public static final int CODE_RADIO_UPLINK_FAILURE = 1508;
690 
691     /** Call failed because of a RRC connection setup failure */
692     public static final int CODE_RADIO_SETUP_FAILURE = 1509;
693 
694     /** Call failed/dropped because of RRC connection release from NW */
695     public static final int CODE_RADIO_RELEASE_NORMAL = 1510;
696 
697     /** Call failed/dropped because of RRC abnormally released by modem/network */
698     public static final int CODE_RADIO_RELEASE_ABNORMAL = 1511;
699 
700     /** Call failed because of access class barring */
701     public static final int CODE_ACCESS_CLASS_BLOCKED = 1512;
702 
703     /** Call/IMS registration is failed/dropped because of a network detach */
704     public static final int CODE_NETWORK_DETACH = 1513;
705 
706     /**
707      * Call failed due to SIP code 380 (Alternative Service response) while dialing an "undetected
708      * emergency number".  This scenario is important in some regions where the carrier network will
709      * identify other non-emergency help numbers (e.g. mountain rescue) when attempting to dial.
710      */
711     public static final int CODE_SIP_ALTERNATE_EMERGENCY_CALL = 1514;
712 
713     /**
714      * Call failed because of unobtainable number
715      * @hide
716      */
717     public static final int CODE_UNOBTAINABLE_NUMBER = 1515;
718 
719     /**
720      * Call failed because WiFi call could not complete and circuit switch silent redial
721      * is not allowed while roaming on another network.
722      */
723     public static final int CODE_NO_CSFB_IN_CS_ROAM = 1516;
724 
725     /**
726      * The rejection cause is not known.
727      * <p>
728      * Used with implicit call rejection.
729      */
730     public static final int CODE_REJECT_UNKNOWN = 1600;
731 
732     /**
733      * Ongoing call, and call waiting is disabled.
734      * <p>
735      * Used with implicit call rejection.
736      */
737     public static final int CODE_REJECT_ONGOING_CALL_WAITING_DISABLED = 1601;
738 
739     /**
740      * A call is ongoing on another sub.
741      * <p>
742      * Used with implicit call rejection.
743      */
744     public static final int CODE_REJECT_CALL_ON_OTHER_SUB = 1602;
745 
746     /**
747      * CDMA call collision.
748      * <p>
749      * Used with implicit call rejection.
750      */
751     public static final int CODE_REJECT_1X_COLLISION = 1603;
752 
753     /**
754      * IMS is not registered for service yet.
755      * <p>
756      * Used with implicit call rejection.
757      */
758     public static final int CODE_REJECT_SERVICE_NOT_REGISTERED = 1604;
759 
760     /**
761      * The call type is not allowed on the current RAT.
762      * <p>
763      * Used with implicit call rejection.
764      */
765     public static final int CODE_REJECT_CALL_TYPE_NOT_ALLOWED = 1605;
766 
767     /**
768      * And emergency call is ongoing.
769      * <p>
770      * Used with implicit call rejection.
771      */
772     public static final int CODE_REJECT_ONGOING_E911_CALL = 1606;
773 
774     /**
775      * Another call is in the process of being establilshed.
776      * <p>
777      * Used with implicit call rejection.
778      */
779     public static final int CODE_REJECT_ONGOING_CALL_SETUP = 1607;
780 
781     /**
782      * Maximum number of allowed calls are already in progress.
783      * <p>
784      * Used with implicit call rejection.
785      */
786     public static final int CODE_REJECT_MAX_CALL_LIMIT_REACHED = 1608;
787 
788     /**
789      * Invalid/unsupported SIP headers received.
790      * <p>
791      * Used with implicit call rejection.
792      */
793     public static final int CODE_REJECT_UNSUPPORTED_SIP_HEADERS = 1609;
794 
795     /**
796      * Invalid/unsupported SDP headers received.
797      * <p>
798      * Used with implicit call rejection.
799      */
800     public static final int CODE_REJECT_UNSUPPORTED_SDP_HEADERS = 1610;
801 
802     /**
803      * A call transfer is in progress.
804      * <p>
805      * Used with implicit call rejection.
806      */
807     public static final int CODE_REJECT_ONGOING_CALL_TRANSFER = 1611;
808 
809     /**
810      * An internal error occured while processing the call.
811      * <p>
812      * Used with implicit call rejection.
813      */
814     public static final int CODE_REJECT_INTERNAL_ERROR = 1612;
815 
816     /**
817      * Call failure due to lack of dedicated bearer.
818      * <p>
819      * Used with implicit call rejection.
820      */
821     public static final int CODE_REJECT_QOS_FAILURE = 1613;
822 
823     /**
824      * A call handover is in progress.
825      * <p>
826      * Used with implicit call rejection.
827      */
828     public static final int CODE_REJECT_ONGOING_HANDOVER = 1614;
829 
830     /**
831      * Video calling not supported with TTY.
832      * <p>
833      * Used with implicit call rejection.
834      */
835     public static final int CODE_REJECT_VT_TTY_NOT_ALLOWED = 1615;
836 
837     /**
838      * A call upgrade is in progress.
839      * <p>
840      * Used with implicit call rejection.
841      */
842     public static final int CODE_REJECT_ONGOING_CALL_UPGRADE = 1616;
843 
844     /**
845      * Call from conference server, when TTY mode is ON.
846      * <p>
847      * Used with implicit call rejection.
848      */
849     public static final int CODE_REJECT_CONFERENCE_TTY_NOT_ALLOWED = 1617;
850 
851     /**
852      * A conference call is ongoing.
853      * <p>
854      * Used with implicit call rejection.
855      */
856     public static final int CODE_REJECT_ONGOING_CONFERENCE_CALL = 1618;
857 
858     /**
859      * A video call with AVPF is not supported.
860      * <p>
861      * Used with implicit call rejection.
862      */
863     public static final int CODE_REJECT_VT_AVPF_NOT_ALLOWED = 1619;
864 
865     /**
866      * And encrypted call is ongoing; other calls not supported.
867      * <p>
868      * Used with implicit call rejection.
869      */
870     public static final int CODE_REJECT_ONGOING_ENCRYPTED_CALL = 1620;
871 
872     /**
873      * A CS call is ongoing.
874      * <p>
875      * Used with implicit call rejection.
876      */
877     public static final int CODE_REJECT_ONGOING_CS_CALL = 1621;
878 
879     /**
880      * An attempt was made to place an emergency call over WFC when emergency services is not
881      * currently available in the current location.
882      * @hide
883      */
884     public static final int CODE_EMERGENCY_CALL_OVER_WFC_NOT_AVAILABLE = 1622;
885 
886     /**
887      * Indicates that WiFi calling service is not available in the current location.
888      * @hide
889      */
890     public static final int CODE_WFC_SERVICE_NOT_AVAILABLE_IN_THIS_LOCATION = 1623;
891 
892     /**
893      * The dialed RTT call should be retried without RTT
894      * @hide
895      */
896     public static final int CODE_RETRY_ON_IMS_WITHOUT_RTT = 3001;
897 
898     /*
899      * OEM specific error codes. To be used by OEMs when they don't want to reveal error code which
900      * would be replaced by ERROR_UNSPECIFIED.
901      */
902     public static final int CODE_OEM_CAUSE_1 = 0xf001;
903     public static final int CODE_OEM_CAUSE_2 = 0xf002;
904     public static final int CODE_OEM_CAUSE_3 = 0xf003;
905     public static final int CODE_OEM_CAUSE_4 = 0xf004;
906     public static final int CODE_OEM_CAUSE_5 = 0xf005;
907     public static final int CODE_OEM_CAUSE_6 = 0xf006;
908     public static final int CODE_OEM_CAUSE_7 = 0xf007;
909     public static final int CODE_OEM_CAUSE_8 = 0xf008;
910     public static final int CODE_OEM_CAUSE_9 = 0xf009;
911     public static final int CODE_OEM_CAUSE_10 = 0xf00a;
912     public static final int CODE_OEM_CAUSE_11 = 0xf00b;
913     public static final int CODE_OEM_CAUSE_12 = 0xf00c;
914     public static final int CODE_OEM_CAUSE_13 = 0xf00d;
915     public static final int CODE_OEM_CAUSE_14 = 0xf00e;
916     public static final int CODE_OEM_CAUSE_15 = 0xf00f;
917 
918     /**
919      * @hide
920      */
921     @IntDef(value = {
922             CODE_UNSPECIFIED,
923             CODE_LOCAL_ILLEGAL_ARGUMENT,
924             CODE_LOCAL_ILLEGAL_STATE,
925             CODE_LOCAL_INTERNAL_ERROR,
926             CODE_LOCAL_IMS_SERVICE_DOWN,
927             CODE_LOCAL_NO_PENDING_CALL,
928             CODE_LOCAL_ENDED_BY_CONFERENCE_MERGE,
929             CODE_LOCAL_POWER_OFF,
930             CODE_LOCAL_LOW_BATTERY,
931             CODE_LOCAL_NETWORK_NO_SERVICE,
932             CODE_LOCAL_NETWORK_NO_LTE_COVERAGE,
933             CODE_LOCAL_NETWORK_ROAMING,
934             CODE_LOCAL_NETWORK_IP_CHANGED,
935             CODE_LOCAL_SERVICE_UNAVAILABLE,
936             CODE_LOCAL_NOT_REGISTERED,
937             CODE_LOCAL_CALL_EXCEEDED,
938             CODE_LOCAL_CALL_BUSY,
939             CODE_LOCAL_CALL_DECLINE,
940             CODE_LOCAL_CALL_VCC_ON_PROGRESSING,
941             CODE_LOCAL_CALL_RESOURCE_RESERVATION_FAILED,
942             CODE_LOCAL_CALL_CS_RETRY_REQUIRED,
943             CODE_LOCAL_CALL_VOLTE_RETRY_REQUIRED,
944             CODE_LOCAL_CALL_TERMINATED,
945             CODE_LOCAL_HO_NOT_FEASIBLE,
946             CODE_TIMEOUT_1XX_WAITING,
947             CODE_TIMEOUT_NO_ANSWER,
948             CODE_TIMEOUT_NO_ANSWER_CALL_UPDATE,
949             CODE_CALL_BARRED,
950             CODE_FDN_BLOCKED,
951             CODE_IMEI_NOT_ACCEPTED,
952             CODE_DIAL_MODIFIED_TO_USSD,
953             CODE_DIAL_MODIFIED_TO_SS,
954             CODE_DIAL_MODIFIED_TO_DIAL,
955             CODE_DIAL_MODIFIED_TO_DIAL_VIDEO,
956             CODE_DIAL_VIDEO_MODIFIED_TO_DIAL,
957             CODE_DIAL_VIDEO_MODIFIED_TO_DIAL_VIDEO,
958             CODE_DIAL_VIDEO_MODIFIED_TO_SS,
959             CODE_DIAL_VIDEO_MODIFIED_TO_USSD,
960             CODE_SIP_REDIRECTED,
961             CODE_SIP_BAD_REQUEST,
962             CODE_SIP_FORBIDDEN,
963             CODE_SIP_NOT_FOUND,
964             CODE_SIP_NOT_SUPPORTED,
965             CODE_SIP_REQUEST_TIMEOUT,
966             CODE_SIP_TEMPRARILY_UNAVAILABLE,
967             CODE_SIP_BAD_ADDRESS,
968             CODE_SIP_BUSY,
969             CODE_SIP_REQUEST_CANCELLED,
970             CODE_SIP_NOT_ACCEPTABLE,
971             CODE_SIP_NOT_REACHABLE,
972             CODE_SIP_CLIENT_ERROR,
973             CODE_SIP_TRANSACTION_DOES_NOT_EXIST,
974             CODE_SIP_SERVER_INTERNAL_ERROR,
975             CODE_SIP_SERVICE_UNAVAILABLE,
976             CODE_SIP_SERVER_TIMEOUT,
977             CODE_SIP_SERVER_ERROR,
978             CODE_SIP_USER_REJECTED,
979             CODE_SIP_GLOBAL_ERROR,
980             CODE_EMERGENCY_TEMP_FAILURE,
981             CODE_EMERGENCY_PERM_FAILURE,
982             CODE_SIP_USER_MARKED_UNWANTED,
983             CODE_SIP_METHOD_NOT_ALLOWED,
984             CODE_SIP_PROXY_AUTHENTICATION_REQUIRED,
985             CODE_SIP_REQUEST_ENTITY_TOO_LARGE,
986             CODE_SIP_REQUEST_URI_TOO_LARGE,
987             CODE_SIP_EXTENSION_REQUIRED,
988             CODE_SIP_INTERVAL_TOO_BRIEF,
989             CODE_SIP_CALL_OR_TRANS_DOES_NOT_EXIST,
990             CODE_SIP_LOOP_DETECTED,
991             CODE_SIP_TOO_MANY_HOPS,
992             CODE_SIP_AMBIGUOUS,
993             CODE_SIP_REQUEST_PENDING,
994             CODE_SIP_UNDECIPHERABLE,
995             CODE_MEDIA_INIT_FAILED,
996             CODE_MEDIA_NO_DATA,
997             CODE_MEDIA_NOT_ACCEPTABLE,
998             CODE_MEDIA_UNSPECIFIED,
999             CODE_USER_TERMINATED,
1000             CODE_USER_NOANSWER,
1001             CODE_USER_IGNORE,
1002             CODE_USER_DECLINE,
1003             CODE_LOW_BATTERY,
1004             CODE_BLACKLISTED_CALL_ID,
1005             CODE_USER_TERMINATED_BY_REMOTE,
1006             CODE_USER_REJECTED_SESSION_MODIFICATION,
1007             CODE_USER_CANCELLED_SESSION_MODIFICATION,
1008             CODE_SESSION_MODIFICATION_FAILED,
1009             CODE_UT_NOT_SUPPORTED,
1010             CODE_UT_SERVICE_UNAVAILABLE,
1011             CODE_UT_OPERATION_NOT_ALLOWED,
1012             CODE_UT_NETWORK_ERROR,
1013             CODE_UT_CB_PASSWORD_MISMATCH,
1014             CODE_UT_SS_MODIFIED_TO_DIAL,
1015             CODE_UT_SS_MODIFIED_TO_USSD,
1016             CODE_UT_SS_MODIFIED_TO_SS,
1017             CODE_UT_SS_MODIFIED_TO_DIAL_VIDEO,
1018             CODE_ECBM_NOT_SUPPORTED,
1019             CODE_MULTIENDPOINT_NOT_SUPPORTED,
1020             CODE_REGISTRATION_ERROR,
1021             CODE_ANSWERED_ELSEWHERE,
1022             CODE_CALL_PULL_OUT_OF_SYNC,
1023             CODE_CALL_END_CAUSE_CALL_PULL,
1024             CODE_CALL_DROP_IWLAN_TO_LTE_UNAVAILABLE,
1025             CODE_REJECTED_ELSEWHERE,
1026             CODE_SUPP_SVC_FAILED,
1027             CODE_SUPP_SVC_CANCELLED,
1028             CODE_SUPP_SVC_REINVITE_COLLISION,
1029             CODE_IWLAN_DPD_FAILURE,
1030             CODE_EPDG_TUNNEL_ESTABLISH_FAILURE,
1031             CODE_EPDG_TUNNEL_REKEY_FAILURE,
1032             CODE_EPDG_TUNNEL_LOST_CONNECTION,
1033             CODE_MAXIMUM_NUMBER_OF_CALLS_REACHED,
1034             CODE_REMOTE_CALL_DECLINE,
1035             CODE_DATA_LIMIT_REACHED,
1036             CODE_DATA_DISABLED,
1037             CODE_WIFI_LOST,
1038             CODE_IKEV2_AUTH_FAILURE,
1039             CODE_RADIO_OFF,
1040             CODE_NO_VALID_SIM,
1041             CODE_RADIO_INTERNAL_ERROR,
1042             CODE_NETWORK_RESP_TIMEOUT,
1043             CODE_NETWORK_REJECT,
1044             CODE_RADIO_ACCESS_FAILURE,
1045             CODE_RADIO_LINK_FAILURE,
1046             CODE_RADIO_LINK_LOST,
1047             CODE_RADIO_UPLINK_FAILURE,
1048             CODE_RADIO_SETUP_FAILURE,
1049             CODE_RADIO_RELEASE_NORMAL,
1050             CODE_RADIO_RELEASE_ABNORMAL,
1051             CODE_ACCESS_CLASS_BLOCKED,
1052             CODE_NETWORK_DETACH,
1053             CODE_SIP_ALTERNATE_EMERGENCY_CALL,
1054             CODE_UNOBTAINABLE_NUMBER,
1055             CODE_NO_CSFB_IN_CS_ROAM,
1056             CODE_REJECT_UNKNOWN,
1057             CODE_REJECT_ONGOING_CALL_WAITING_DISABLED,
1058             CODE_REJECT_CALL_ON_OTHER_SUB,
1059             CODE_REJECT_1X_COLLISION,
1060             CODE_REJECT_SERVICE_NOT_REGISTERED,
1061             CODE_REJECT_CALL_TYPE_NOT_ALLOWED,
1062             CODE_REJECT_ONGOING_E911_CALL,
1063             CODE_REJECT_ONGOING_CALL_SETUP,
1064             CODE_REJECT_MAX_CALL_LIMIT_REACHED,
1065             CODE_REJECT_UNSUPPORTED_SIP_HEADERS,
1066             CODE_REJECT_UNSUPPORTED_SDP_HEADERS,
1067             CODE_REJECT_ONGOING_CALL_TRANSFER,
1068             CODE_REJECT_INTERNAL_ERROR,
1069             CODE_REJECT_QOS_FAILURE,
1070             CODE_REJECT_ONGOING_HANDOVER,
1071             CODE_REJECT_VT_TTY_NOT_ALLOWED,
1072             CODE_REJECT_ONGOING_CALL_UPGRADE,
1073             CODE_REJECT_CONFERENCE_TTY_NOT_ALLOWED,
1074             CODE_REJECT_ONGOING_CONFERENCE_CALL,
1075             CODE_REJECT_VT_AVPF_NOT_ALLOWED,
1076             CODE_REJECT_ONGOING_ENCRYPTED_CALL,
1077             CODE_REJECT_ONGOING_CS_CALL,
1078             CODE_RETRY_ON_IMS_WITHOUT_RTT,
1079             CODE_OEM_CAUSE_1,
1080             CODE_OEM_CAUSE_2,
1081             CODE_OEM_CAUSE_3,
1082             CODE_OEM_CAUSE_4,
1083             CODE_OEM_CAUSE_5,
1084             CODE_OEM_CAUSE_6,
1085             CODE_OEM_CAUSE_7,
1086             CODE_OEM_CAUSE_8,
1087             CODE_OEM_CAUSE_9,
1088             CODE_OEM_CAUSE_10,
1089             CODE_OEM_CAUSE_11,
1090             CODE_OEM_CAUSE_12,
1091             CODE_OEM_CAUSE_13,
1092             CODE_OEM_CAUSE_14,
1093             CODE_OEM_CAUSE_15
1094     }, prefix = "CODE_")
1095     @Retention(RetentionPolicy.SOURCE)
1096     public @interface ImsCode {}
1097 
1098     /**
1099      * Network string error messages.
1100      * mExtraMessage may have these values.
1101      * @hide
1102      */
1103     @SystemApi
1104     public static final String EXTRA_MSG_SERVICE_NOT_AUTHORIZED =
1105             "Forbidden. Not Authorized for Service";
1106 
1107 
1108     /*
1109      * Extra codes for the specific code value
1110      * This value can be referred when the code is CODE_LOCAL_CALL_CS_RETRY_REQUIRED.
1111      */
1112     /**
1113      * An extra that may be populated when the {@link #CODE_LOCAL_CALL_CS_RETRY_REQUIRED} result has
1114      * been returned.
1115      * <p>
1116      * Try to connect the call using CS
1117      */
1118     public static final int EXTRA_CODE_CALL_RETRY_NORMAL = 1;
1119     /**
1120      * An extra that may be populated when the {@link #CODE_LOCAL_CALL_CS_RETRY_REQUIRED} result has
1121      * been returned.
1122      * <p>
1123      * Try to connect the call using CS and do not notify the user.
1124      */
1125     public static final int EXTRA_CODE_CALL_RETRY_SILENT_REDIAL = 2;
1126     /**
1127      * An extra that may be populated when the {@link #CODE_LOCAL_CALL_CS_RETRY_REQUIRED} result has
1128      * been returned.
1129      * <p>
1130      * Try to connect the call using CS by using the settings.
1131      */
1132     public static final int EXTRA_CODE_CALL_RETRY_BY_SETTINGS = 3;
1133 
1134 
1135     // For main reason code
1136     /** @hide */
1137     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "{@code "
1138             + "#getCode()}")
1139     public int mCode;
1140     // For the extra code value; it depends on the code value.
1141     /** @hide */
1142     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "{@code "
1143             + "#getExtraCode()}")
1144     public int mExtraCode;
1145     // For the additional message of the reason info.
1146     /** @hide */
1147     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "{@code "
1148             + "#getExtraMessage()}")
1149     public String mExtraMessage;
1150 
1151     /** @hide */
ImsReasonInfo()1152     public ImsReasonInfo() {
1153         mCode = CODE_UNSPECIFIED;
1154         mExtraCode = CODE_UNSPECIFIED;
1155         mExtraMessage = null;
1156     }
1157 
ImsReasonInfo(Parcel in)1158     private ImsReasonInfo(Parcel in) {
1159         mCode = in.readInt();
1160         mExtraCode = in.readInt();
1161         mExtraMessage = in.readString();
1162     }
1163 
1164     /** @hide */
1165     @UnsupportedAppUsage
ImsReasonInfo(int code, int extraCode)1166     public ImsReasonInfo(int code, int extraCode) {
1167         mCode = code;
1168         mExtraCode = extraCode;
1169         mExtraMessage = null;
1170     }
1171 
ImsReasonInfo(@msCode int code, int extraCode, @Nullable String extraMessage)1172     public ImsReasonInfo(@ImsCode int code, int extraCode, @Nullable String extraMessage) {
1173         mCode = code;
1174         mExtraCode = extraCode;
1175         mExtraMessage = extraMessage;
1176     }
1177 
1178     /**
1179      * @return an integer representing more information about the completion of an operation.
1180      */
getCode()1181     public @ImsCode int getCode() {
1182         return mCode;
1183     }
1184 
1185     /**
1186      * @return an optional OEM specified code that provides extra information.
1187      */
getExtraCode()1188     public int getExtraCode() {
1189         return mExtraCode;
1190     }
1191 
1192     /**
1193      * @return an optional OEM specified string that provides extra information about the operation
1194      * result.
1195      */
getExtraMessage()1196     public @Nullable String getExtraMessage() {
1197         return mExtraMessage;
1198     }
1199 
1200     /**
1201      * @return the string format of {@link ImsReasonInfo}
1202      */
1203     @NonNull
1204     @Override
toString()1205     public String toString() {
1206         return "ImsReasonInfo :: {" + mCode + ", " + mExtraCode + ", " + mExtraMessage + "}";
1207     }
1208 
1209     @Override
describeContents()1210     public int describeContents() {
1211         return 0;
1212     }
1213 
1214     @Override
writeToParcel(@onNull Parcel out, int flags)1215     public void writeToParcel(@NonNull Parcel out, int flags) {
1216         out.writeInt(mCode);
1217         out.writeInt(mExtraCode);
1218         out.writeString(mExtraMessage);
1219     }
1220 
1221     public static final @NonNull Creator<ImsReasonInfo> CREATOR = new Creator<ImsReasonInfo>() {
1222         @Override
1223         public ImsReasonInfo createFromParcel(Parcel in) {
1224             return new ImsReasonInfo(in);
1225         }
1226 
1227         @Override
1228         public ImsReasonInfo[] newArray(int size) {
1229             return new ImsReasonInfo[size];
1230         }
1231     };
1232 }
1233