Home | History | Annotate | Download | only in dataconnection
      1 /*
      2  * Copyright (C) 2006 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 package com.android.internal.telephony.dataconnection;
     17 
     18 import java.util.HashMap;
     19 
     20 /**
     21  * Returned as the reason for a connection failure as defined
     22  * by RIL_DataCallFailCause in ril.h and some local errors.
     23  */
     24 public enum DcFailCause {
     25     NONE(0),
     26 
     27     // This series of errors as specified by the standards
     28     // specified in ril.h
     29     OPERATOR_BARRED(0x08),                  /* no retry */
     30     INSUFFICIENT_RESOURCES(0x1A),
     31     MISSING_UNKNOWN_APN(0x1B),              /* no retry */
     32     UNKNOWN_PDP_ADDRESS_TYPE(0x1C),         /* no retry */
     33     USER_AUTHENTICATION(0x1D),              /* no retry */
     34     ACTIVATION_REJECT_GGSN(0x1E),           /* no retry */
     35     ACTIVATION_REJECT_UNSPECIFIED(0x1F),
     36     SERVICE_OPTION_NOT_SUPPORTED(0x20),     /* no retry */
     37     SERVICE_OPTION_NOT_SUBSCRIBED(0x21),    /* no retry */
     38     SERVICE_OPTION_OUT_OF_ORDER(0x22),
     39     NSAPI_IN_USE(0x23),                     /* no retry */
     40     REGULAR_DEACTIVATION(0x24),             /* Restart radio */
     41     ONLY_IPV4_ALLOWED(0x32),                /* no retry */
     42     ONLY_IPV6_ALLOWED(0x33),                /* no retry */
     43     ONLY_SINGLE_BEARER_ALLOWED(0x34),
     44     PROTOCOL_ERRORS(0x6F),                  /* no retry */
     45 
     46     // Local errors generated by Vendor RIL
     47     // specified in ril.h
     48     REGISTRATION_FAIL(-1),
     49     GPRS_REGISTRATION_FAIL(-2),
     50     SIGNAL_LOST(-3),
     51     PREF_RADIO_TECH_CHANGED(-4),            /* no retry */
     52     RADIO_POWER_OFF(-5),                    /* no retry */
     53     TETHERED_CALL_ACTIVE(-6),               /* no retry */
     54     ERROR_UNSPECIFIED(0xFFFF),
     55 
     56     // Errors generated by the Framework
     57     // specified here
     58     UNKNOWN(0x10000),
     59     RADIO_NOT_AVAILABLE(0x10001),                   /* no retry */
     60     UNACCEPTABLE_NETWORK_PARAMETER(0x10002),        /* no retry */
     61     CONNECTION_TO_DATACONNECTIONAC_BROKEN(0x10003),
     62     LOST_CONNECTION(0x10004),
     63     RESET_BY_FRAMEWORK(0x10005);
     64 
     65     private final int mErrorCode;
     66     private static final HashMap<Integer, DcFailCause> sErrorCodeToFailCauseMap;
     67     static {
     68         sErrorCodeToFailCauseMap = new HashMap<Integer, DcFailCause>();
     69         for (DcFailCause fc : values()) {
     70             sErrorCodeToFailCauseMap.put(fc.getErrorCode(), fc);
     71         }
     72     }
     73 
     74     DcFailCause(int errorCode) {
     75         mErrorCode = errorCode;
     76     }
     77 
     78     public int getErrorCode() {
     79         return mErrorCode;
     80     }
     81 
     82     /** Radio has failed such that the radio should be restarted */
     83     public boolean isRestartRadioFail() {
     84         return (this == REGULAR_DEACTIVATION);
     85     }
     86 
     87     public boolean isPermanentFail() {
     88         return (this == OPERATOR_BARRED) || (this == MISSING_UNKNOWN_APN) ||
     89                (this == UNKNOWN_PDP_ADDRESS_TYPE) || (this == USER_AUTHENTICATION) ||
     90                (this == ACTIVATION_REJECT_GGSN) || (this == SERVICE_OPTION_NOT_SUPPORTED) ||
     91                (this == SERVICE_OPTION_NOT_SUBSCRIBED) || (this == NSAPI_IN_USE) ||
     92                (this == ONLY_IPV4_ALLOWED) || (this == ONLY_IPV6_ALLOWED) ||
     93                (this == PROTOCOL_ERRORS) ||
     94                (this == RADIO_POWER_OFF) || (this == TETHERED_CALL_ACTIVE) ||
     95                (this == RADIO_NOT_AVAILABLE) || (this == UNACCEPTABLE_NETWORK_PARAMETER);
     96     }
     97 
     98     public boolean isEventLoggable() {
     99         return (this == OPERATOR_BARRED) || (this == INSUFFICIENT_RESOURCES) ||
    100                 (this == UNKNOWN_PDP_ADDRESS_TYPE) || (this == USER_AUTHENTICATION) ||
    101                 (this == ACTIVATION_REJECT_GGSN) || (this == ACTIVATION_REJECT_UNSPECIFIED) ||
    102                 (this == SERVICE_OPTION_NOT_SUBSCRIBED) ||
    103                 (this == SERVICE_OPTION_NOT_SUPPORTED) ||
    104                 (this == SERVICE_OPTION_OUT_OF_ORDER) || (this == NSAPI_IN_USE) ||
    105                 (this == ONLY_IPV4_ALLOWED) || (this == ONLY_IPV6_ALLOWED) ||
    106                 (this == PROTOCOL_ERRORS) || (this == SIGNAL_LOST) ||
    107                 (this == RADIO_POWER_OFF) || (this == TETHERED_CALL_ACTIVE) ||
    108                 (this == UNACCEPTABLE_NETWORK_PARAMETER);
    109     }
    110 
    111     public static DcFailCause fromInt(int errorCode) {
    112         DcFailCause fc = sErrorCodeToFailCauseMap.get(errorCode);
    113         if (fc == null) {
    114             fc = UNKNOWN;
    115         }
    116         return fc;
    117     }
    118 }
    119