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 android.content.res.Resources; 19 import java.util.HashMap; 20 21 /** 22 * Returned as the reason for a connection failure as defined 23 * by RIL_DataCallFailCause in ril.h and some local errors. 24 */ 25 public enum DcFailCause { 26 NONE(0), 27 28 // This series of errors as specified by the standards 29 // specified in ril.h 30 OPERATOR_BARRED(0x08), /* no retry */ 31 NAS_SIGNALLING(0x0E), 32 LLC_SNDCP(0x19), 33 INSUFFICIENT_RESOURCES(0x1A), 34 MISSING_UNKNOWN_APN(0x1B), /* no retry */ 35 UNKNOWN_PDP_ADDRESS_TYPE(0x1C), /* no retry */ 36 USER_AUTHENTICATION(0x1D), /* no retry */ 37 ACTIVATION_REJECT_GGSN(0x1E), /* no retry */ 38 ACTIVATION_REJECT_UNSPECIFIED(0x1F), 39 SERVICE_OPTION_NOT_SUPPORTED(0x20), /* no retry */ 40 SERVICE_OPTION_NOT_SUBSCRIBED(0x21), /* no retry */ 41 SERVICE_OPTION_OUT_OF_ORDER(0x22), 42 NSAPI_IN_USE(0x23), /* no retry */ 43 REGULAR_DEACTIVATION(0x24), /* possibly restart radio, based on config */ 44 QOS_NOT_ACCEPTED(0x25), 45 NETWORK_FAILURE(0x26), 46 UMTS_REACTIVATION_REQ(0x27), 47 FEATURE_NOT_SUPP(0x28), 48 TFT_SEMANTIC_ERROR(0x29), 49 TFT_SYTAX_ERROR(0x2A), 50 UNKNOWN_PDP_CONTEXT(0x2B), 51 FILTER_SEMANTIC_ERROR(0x2C), 52 FILTER_SYTAX_ERROR(0x2D), 53 PDP_WITHOUT_ACTIVE_TFT(0x2E), 54 ONLY_IPV4_ALLOWED(0x32), /* no retry */ 55 ONLY_IPV6_ALLOWED(0x33), /* no retry */ 56 ONLY_SINGLE_BEARER_ALLOWED(0x34), 57 ESM_INFO_NOT_RECEIVED(0x35), 58 PDN_CONN_DOES_NOT_EXIST(0x36), 59 MULTI_CONN_TO_SAME_PDN_NOT_ALLOWED(0x37), 60 MAX_ACTIVE_PDP_CONTEXT_REACHED(0x41), 61 UNSUPPORTED_APN_IN_CURRENT_PLMN(0x42), 62 INVALID_TRANSACTION_ID(0x51), 63 MESSAGE_INCORRECT_SEMANTIC(0x5F), 64 INVALID_MANDATORY_INFO(0x60), 65 MESSAGE_TYPE_UNSUPPORTED(0x61), 66 MSG_TYPE_NONCOMPATIBLE_STATE(0x62), 67 UNKNOWN_INFO_ELEMENT(0x63), 68 CONDITIONAL_IE_ERROR(0x64), 69 MSG_AND_PROTOCOL_STATE_UNCOMPATIBLE(0x65), 70 PROTOCOL_ERRORS(0x6F), /* no retry */ 71 APN_TYPE_CONFLICT(0x70), 72 INVALID_PCSCF_ADDR(0x71), 73 INTERNAL_CALL_PREEMPT_BY_HIGH_PRIO_APN(0x72), 74 EMM_ACCESS_BARRED(0x73), 75 EMERGENCY_IFACE_ONLY(0x74), 76 IFACE_MISMATCH(0x75), 77 COMPANION_IFACE_IN_USE(0x76), 78 IP_ADDRESS_MISMATCH(0x77), 79 IFACE_AND_POL_FAMILY_MISMATCH(0x78), 80 EMM_ACCESS_BARRED_INFINITE_RETRY(0x79), 81 AUTH_FAILURE_ON_EMERGENCY_CALL(0x7A), 82 83 // OEM sepecific error codes. To be used by OEMs when they don't 84 // want to reveal error code which would be replaced by ERROR_UNSPECIFIED 85 OEM_DCFAILCAUSE_1(0x1001), 86 OEM_DCFAILCAUSE_2(0x1002), 87 OEM_DCFAILCAUSE_3(0x1003), 88 OEM_DCFAILCAUSE_4(0x1004), 89 OEM_DCFAILCAUSE_5(0x1005), 90 OEM_DCFAILCAUSE_6(0x1006), 91 OEM_DCFAILCAUSE_7(0x1007), 92 OEM_DCFAILCAUSE_8(0x1008), 93 OEM_DCFAILCAUSE_9(0x1009), 94 OEM_DCFAILCAUSE_10(0x100A), 95 OEM_DCFAILCAUSE_11(0x100B), 96 OEM_DCFAILCAUSE_12(0x100C), 97 OEM_DCFAILCAUSE_13(0x100D), 98 OEM_DCFAILCAUSE_14(0x100E), 99 OEM_DCFAILCAUSE_15(0x100F), 100 101 // Local errors generated by Vendor RIL 102 // specified in ril.h 103 REGISTRATION_FAIL(-1), 104 GPRS_REGISTRATION_FAIL(-2), 105 SIGNAL_LOST(-3), 106 PREF_RADIO_TECH_CHANGED(-4), /* no retry */ 107 RADIO_POWER_OFF(-5), /* no retry */ 108 TETHERED_CALL_ACTIVE(-6), /* no retry */ 109 ERROR_UNSPECIFIED(0xFFFF), 110 111 // Errors generated by the Framework 112 // specified here 113 UNKNOWN(0x10000), 114 RADIO_NOT_AVAILABLE(0x10001), /* no retry */ 115 UNACCEPTABLE_NETWORK_PARAMETER(0x10002), /* no retry */ 116 CONNECTION_TO_DATACONNECTIONAC_BROKEN(0x10003), 117 LOST_CONNECTION(0x10004), 118 RESET_BY_FRAMEWORK(0x10005); 119 120 private final boolean mRestartRadioOnRegularDeactivation = Resources.getSystem().getBoolean( 121 com.android.internal.R.bool.config_restart_radio_on_pdp_fail_regular_deactivation); 122 private final int mErrorCode; 123 private static final HashMap<Integer, DcFailCause> sErrorCodeToFailCauseMap; 124 static { 125 sErrorCodeToFailCauseMap = new HashMap<Integer, DcFailCause>(); 126 for (DcFailCause fc : values()) { fc.getErrorCode()127 sErrorCodeToFailCauseMap.put(fc.getErrorCode(), fc); 128 } 129 } 130 DcFailCause(int errorCode)131 DcFailCause(int errorCode) { 132 mErrorCode = errorCode; 133 } 134 getErrorCode()135 public int getErrorCode() { 136 return mErrorCode; 137 } 138 139 /** Radio has failed such that the radio should be restarted */ isRestartRadioFail()140 public boolean isRestartRadioFail() { 141 return (this == REGULAR_DEACTIVATION && mRestartRadioOnRegularDeactivation); 142 } 143 isPermanentFail()144 public boolean isPermanentFail() { 145 return (this == OPERATOR_BARRED) || (this == MISSING_UNKNOWN_APN) || 146 (this == UNKNOWN_PDP_ADDRESS_TYPE) || (this == USER_AUTHENTICATION) || 147 (this == ACTIVATION_REJECT_GGSN) || (this == SERVICE_OPTION_NOT_SUPPORTED) || 148 (this == SERVICE_OPTION_NOT_SUBSCRIBED) || (this == NSAPI_IN_USE) || 149 (this == ONLY_IPV4_ALLOWED) || (this == ONLY_IPV6_ALLOWED) || 150 (this == PROTOCOL_ERRORS) || 151 (this == RADIO_POWER_OFF) || (this == TETHERED_CALL_ACTIVE) || 152 (this == RADIO_NOT_AVAILABLE) || (this == UNACCEPTABLE_NETWORK_PARAMETER) || 153 (this == SIGNAL_LOST); 154 } 155 isEventLoggable()156 public boolean isEventLoggable() { 157 return (this == OPERATOR_BARRED) || (this == INSUFFICIENT_RESOURCES) || 158 (this == UNKNOWN_PDP_ADDRESS_TYPE) || (this == USER_AUTHENTICATION) || 159 (this == ACTIVATION_REJECT_GGSN) || (this == ACTIVATION_REJECT_UNSPECIFIED) || 160 (this == SERVICE_OPTION_NOT_SUBSCRIBED) || 161 (this == SERVICE_OPTION_NOT_SUPPORTED) || 162 (this == SERVICE_OPTION_OUT_OF_ORDER) || (this == NSAPI_IN_USE) || 163 (this == ONLY_IPV4_ALLOWED) || (this == ONLY_IPV6_ALLOWED) || 164 (this == PROTOCOL_ERRORS) || (this == SIGNAL_LOST) || 165 (this == RADIO_POWER_OFF) || (this == TETHERED_CALL_ACTIVE) || 166 (this == UNACCEPTABLE_NETWORK_PARAMETER); 167 } 168 fromInt(int errorCode)169 public static DcFailCause fromInt(int errorCode) { 170 DcFailCause fc = sErrorCodeToFailCauseMap.get(errorCode); 171 if (fc == null) { 172 fc = UNKNOWN; 173 } 174 return fc; 175 } 176 } 177