ImsReasonInfo.java revision ddf570e8226bd21448b44b3327d4bcb2608f4d00
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
17package com.android.ims;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21
22/**
23 * This class enables an application to get details on why a method call failed.
24 *
25 * @hide
26 */
27public class ImsReasonInfo implements Parcelable {
28    /**
29     * Specific code of each types
30     */
31    public static final int CODE_UNSPECIFIED = 0;
32
33    /**
34     * LOCAL
35     */
36    // IMS -> Telephony
37    // The passed argument is an invalid
38    public static final int CODE_LOCAL_ILLEGAL_ARGUMENT = 101;
39    // The operation is invoked in invalid call state
40    public static final int CODE_LOCAL_ILLEGAL_STATE = 102;
41    // IMS service internal error
42    public static final int CODE_LOCAL_INTERNAL_ERROR = 103;
43    // IMS service goes down (service connection is lost)
44    public static final int CODE_LOCAL_IMS_SERVICE_DOWN = 106;
45    // No pending incoming call exists
46    public static final int CODE_LOCAL_NO_PENDING_CALL = 107;
47
48    // IMS -> Telephony
49    // Service unavailable; by power off
50    public static final int CODE_LOCAL_POWER_OFF = 111;
51    // Service unavailable; by low battery
52    public static final int CODE_LOCAL_LOW_BATTERY = 112;
53    // Service unavailable; by out of service (data service state)
54    public static final int CODE_LOCAL_NETWORK_NO_SERVICE = 121;
55    // Service unavailable; by no LTE coverage
56    // (VoLTE is not supported even though IMS is registered)
57    public static final int CODE_LOCAL_NETWORK_NO_LTE_COVERAGE = 122;
58    // Service unavailable; by located in roaming area
59    public static final int CODE_LOCAL_NETWORK_ROAMING = 123;
60    // Service unavailable; by IP changed
61    public static final int CODE_LOCAL_NETWORK_IP_CHANGED = 124;
62    // Service unavailable; other
63    public static final int CODE_LOCAL_SERVICE_UNAVAILABLE = 131;
64    // Service unavailable; IMS connection is lost (IMS is not registered)
65    public static final int CODE_LOCAL_NOT_REGISTERED = 132;
66
67    // IMS <-> Telephony
68    // Max call exceeded
69    public static final int CODE_LOCAL_CALL_EXCEEDED = 141;
70    // IMS <- Telephony
71    // Call busy
72    public static final int CODE_LOCAL_CALL_BUSY = 142;
73    // Call decline
74    public static final int CODE_LOCAL_CALL_DECLINE = 143;
75    // IMS -> Telephony
76    // SRVCC is in progress
77    public static final int CODE_LOCAL_CALL_VCC_ON_PROGRESSING = 144;
78    // Resource reservation is failed (QoS precondition)
79    public static final int CODE_LOCAL_CALL_RESOURCE_RESERVATION_FAILED = 145;
80    // Retry CS call; VoLTE service can't be provided by the network or remote end
81    // Resolve the extra code(EXTRA_CODE_CALL_RETRY_*) if the below code is set
82    public static final int CODE_LOCAL_CALL_CS_RETRY_REQUIRED = 146;
83    // Retry VoLTE call; VoLTE service can't be provided by the network temporarily
84    public static final int CODE_LOCAL_CALL_VOLTE_RETRY_REQUIRED = 147;
85    // IMS call is already terminated (in TERMINATED state)
86    public static final int CODE_LOCAL_CALL_TERMINATED = 148;
87
88    /**
89     * TIMEOUT (IMS -> Telephony)
90     */
91    // 1xx waiting timer is expired after sending INVITE request (MO only)
92    public static final int CODE_TIMEOUT_1XX_WAITING = 201;
93    // User no answer during call setup operation (MO/MT)
94    // MO : 200 OK to INVITE request is not received,
95    // MT : No action from user after alerting the call
96    public static final int CODE_TIMEOUT_NO_ANSWER = 202;
97    // User no answer during call update operation (MO/MT)
98    // MO : 200 OK to re-INVITE request is not received,
99    // MT : No action from user after alerting the call
100    public static final int CODE_TIMEOUT_NO_ANSWER_CALL_UPDATE = 203;
101
102    //Call failures for FDN
103    public static final int CODE_FDN_BLOCKED = 241;
104
105    /**
106     * STATUSCODE (SIP response code) (IMS -> Telephony)
107     */
108    // 3xx responses
109    // SIP request is redirected
110    public static final int CODE_SIP_REDIRECTED = 321;
111    // 4xx responses
112    // 400 : Bad Request
113    public static final int CODE_SIP_BAD_REQUEST = 331;
114    // 403 : Forbidden
115    public static final int CODE_SIP_FORBIDDEN = 332;
116    // 404 : Not Found
117    public static final int CODE_SIP_NOT_FOUND = 333;
118    // 415 : Unsupported Media Type
119    // 416 : Unsupported URI Scheme
120    // 420 : Bad Extension
121    public static final int CODE_SIP_NOT_SUPPORTED = 334;
122    // 408 : Request Timeout
123    public static final int CODE_SIP_REQUEST_TIMEOUT = 335;
124    // 480 : Temporarily Unavailable
125    public static final int CODE_SIP_TEMPRARILY_UNAVAILABLE = 336;
126    // 484 : Address Incomplete
127    public static final int CODE_SIP_BAD_ADDRESS = 337;
128    // 486 : Busy Here
129    // 600 : Busy Everywhere
130    public static final int CODE_SIP_BUSY = 338;
131    // 487 : Request Terminated
132    public static final int CODE_SIP_REQUEST_CANCELLED = 339;
133    // 406 : Not Acceptable
134    // 488 : Not Acceptable Here
135    // 606 : Not Acceptable
136    public static final int CODE_SIP_NOT_ACCEPTABLE = 340;
137    // 410 : Gone
138    // 604 : Does Not Exist Anywhere
139    public static final int CODE_SIP_NOT_REACHABLE = 341;
140    // Others
141    public static final int CODE_SIP_CLIENT_ERROR = 342;
142    // 5xx responses
143    // 501 : Server Internal Error
144    public static final int CODE_SIP_SERVER_INTERNAL_ERROR = 351;
145    // 503 : Service Unavailable
146    public static final int CODE_SIP_SERVICE_UNAVAILABLE = 352;
147    // 504 : Server Time-out
148    public static final int CODE_SIP_SERVER_TIMEOUT = 353;
149    // Others
150    public static final int CODE_SIP_SERVER_ERROR = 354;
151    // 6xx responses
152    // 603 : Decline
153    public static final int CODE_SIP_USER_REJECTED = 361;
154    // Others
155    public static final int CODE_SIP_GLOBAL_ERROR = 362;
156
157    /**
158     * MEDIA (IMS -> Telephony)
159     */
160    // Media resource initialization failed
161    public static final int CODE_MEDIA_INIT_FAILED = 401;
162    // RTP timeout (no audio / video traffic in the session)
163    public static final int CODE_MEDIA_NO_DATA = 402;
164    // Media is not supported; so dropped the call
165    public static final int CODE_MEDIA_NOT_ACCEPTABLE = 403;
166    // Unknown media related errors
167    public static final int CODE_MEDIA_UNSPECIFIED = 404;
168
169    /**
170     * USER
171     */
172    // Telephony -> IMS
173    // User triggers the call end
174    public static final int CODE_USER_TERMINATED = 501;
175    // No action while an incoming call is ringing
176    public static final int CODE_USER_NOANSWER = 502;
177    // User ignores an incoming call
178    public static final int CODE_USER_IGNORE = 503;
179    // User declines an incoming call
180    public static final int CODE_USER_DECLINE = 504;
181    // Device declines/ends a call due to low battery
182    public static final int CODE_LOW_BATTERY = 505;
183    // Device declines call due to blacklisted call ID
184    public static final int CODE_BLACKLISTED_CALL_ID = 506;
185    // IMS -> Telephony
186    // The call is terminated by the network or remote user
187    public static final int CODE_USER_TERMINATED_BY_REMOTE = 510;
188
189    /**
190     * Extra codes for the specific code value
191     * This value can be referred when the code is CODE_LOCAL_CALL_CS_RETRY_REQUIRED.
192     */
193    // Try to connect CS call; normal
194    public static final int EXTRA_CODE_CALL_RETRY_NORMAL = 1;
195    // Try to connect CS call without the notification to user
196    public static final int EXTRA_CODE_CALL_RETRY_SILENT_REDIAL = 2;
197    // Try to connect CS call by the settings of the menu
198    public static final int EXTRA_CODE_CALL_RETRY_BY_SETTINGS = 3;
199
200    /**
201     * UT
202     */
203    public static final int CODE_UT_NOT_SUPPORTED = 801;
204    public static final int CODE_UT_SERVICE_UNAVAILABLE = 802;
205    public static final int CODE_UT_OPERATION_NOT_ALLOWED = 803;
206    public static final int CODE_UT_NETWORK_ERROR = 804;
207    public static final int CODE_UT_CB_PASSWORD_MISMATCH = 821;
208
209    /**
210     * ECBM
211     */
212    public static final int CODE_ECBM_NOT_SUPPORTED = 901;
213
214    /**
215     * Ims Registration error code
216     */
217    public static final int CODE_REGISTRATION_ERROR = 1000;
218
219    /**
220     * CALL DROP error codes (Call could drop because of many reasons like Network not available,
221     *  handover, failed, etc)
222     */
223
224    /**
225     * CALL DROP error code for the case when a device is ePDG capable and when the user is on an
226     * active wifi call and at the edge of coverage and there is no qualified LTE network available
227     * to handover the call to. We get a handover NOT_TRIGERRED message from the modem. This error
228     * code is received as part of the handover message.
229     */
230    public static final int CODE_CALL_DROP_IWLAN_TO_LTE_UNAVAILABLE = 1100;
231
232    /**
233     * MT call has ended due to a release from the network
234     * because the call was answered elsewhere
235     */
236    public static final int CODE_ANSWERED_ELSEWHERE = 1014;
237
238    /**
239     * Network string error messages.
240     * mExtraMessage may have these values.
241     */
242    public static final String EXTRA_MSG_SERVICE_NOT_AUTHORIZED
243            = "Forbidden. Not Authorized for Service";
244
245    // For main reason code
246    public int mCode;
247    // For the extra code value; it depends on the code value.
248    public int mExtraCode;
249    // For the additional message of the reason info.
250    public String mExtraMessage;
251    public ImsReasonInfo() {
252        mCode = CODE_UNSPECIFIED;
253        mExtraCode = CODE_UNSPECIFIED;
254        mExtraMessage = null;
255    }
256
257    public ImsReasonInfo(Parcel in) {
258        readFromParcel(in);
259    }
260
261    public ImsReasonInfo(int code, int extraCode) {
262        mCode = code;
263        mExtraCode = extraCode;
264        mExtraMessage = null;
265    }
266
267    public ImsReasonInfo(int code, int extraCode, String extraMessage) {
268        mCode = code;
269        mExtraCode = extraCode;
270        mExtraMessage = extraMessage;
271    }
272
273    /**
274     *
275     */
276    public int getCode() {
277        return mCode;
278    }
279
280    /**
281     *
282     */
283    public int getExtraCode() {
284        return mExtraCode;
285    }
286
287    /**
288     *
289     */
290    public String getExtraMessage() {
291        return mExtraMessage;
292    }
293
294    /**
295     * Returns the string format of {@link ImsReasonInfo}
296     *
297     * @return the string format of {@link ImsReasonInfo}
298     */
299    public String toString() {
300        return "ImsReasonInfo :: {" + mCode + ", " + mExtraCode + ", " + mExtraMessage + "}";
301    }
302
303    @Override
304    public int describeContents() {
305        return 0;
306    }
307
308    @Override
309    public void writeToParcel(Parcel out, int flags) {
310        out.writeInt(mCode);
311        out.writeInt(mExtraCode);
312        out.writeString(mExtraMessage);
313    }
314
315    private void readFromParcel(Parcel in) {
316        mCode = in.readInt();
317        mExtraCode = in.readInt();
318        mExtraMessage = in.readString();
319    }
320
321    public static final Creator<ImsReasonInfo> CREATOR = new Creator<ImsReasonInfo>() {
322        @Override
323        public ImsReasonInfo createFromParcel(Parcel in) {
324            return new ImsReasonInfo(in);
325        }
326
327        @Override
328        public ImsReasonInfo[] newArray(int size) {
329            return new ImsReasonInfo[size];
330        }
331    };
332}
333