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