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 INSUFFICIENT_RESOURCES(0x1A), 32 MISSING_UNKNOWN_APN(0x1B), /* no retry */ 33 UNKNOWN_PDP_ADDRESS_TYPE(0x1C), /* no retry */ 34 USER_AUTHENTICATION(0x1D), /* no retry */ 35 ACTIVATION_REJECT_GGSN(0x1E), /* no retry */ 36 ACTIVATION_REJECT_UNSPECIFIED(0x1F), 37 SERVICE_OPTION_NOT_SUPPORTED(0x20), /* no retry */ 38 SERVICE_OPTION_NOT_SUBSCRIBED(0x21), /* no retry */ 39 SERVICE_OPTION_OUT_OF_ORDER(0x22), 40 NSAPI_IN_USE(0x23), /* no retry */ 41 REGULAR_DEACTIVATION(0x24), /* possibly restart radio, based on config */ 42 ONLY_IPV4_ALLOWED(0x32), /* no retry */ 43 ONLY_IPV6_ALLOWED(0x33), /* no retry */ 44 ONLY_SINGLE_BEARER_ALLOWED(0x34), 45 PROTOCOL_ERRORS(0x6F), /* no retry */ 46 47 // Local errors generated by Vendor RIL 48 // specified in ril.h 49 REGISTRATION_FAIL(-1), 50 GPRS_REGISTRATION_FAIL(-2), 51 SIGNAL_LOST(-3), 52 PREF_RADIO_TECH_CHANGED(-4), /* no retry */ 53 RADIO_POWER_OFF(-5), /* no retry */ 54 TETHERED_CALL_ACTIVE(-6), /* no retry */ 55 ERROR_UNSPECIFIED(0xFFFF), 56 57 // Errors generated by the Framework 58 // specified here 59 UNKNOWN(0x10000), 60 RADIO_NOT_AVAILABLE(0x10001), /* no retry */ 61 UNACCEPTABLE_NETWORK_PARAMETER(0x10002), /* no retry */ 62 CONNECTION_TO_DATACONNECTIONAC_BROKEN(0x10003), 63 LOST_CONNECTION(0x10004), 64 RESET_BY_FRAMEWORK(0x10005); 65 66 private final boolean mRestartRadioOnRegularDeactivation = Resources.getSystem().getBoolean( 67 com.android.internal.R.bool.config_restart_radio_on_pdp_fail_regular_deactivation); 68 private final int mErrorCode; 69 private static final HashMap<Integer, DcFailCause> sErrorCodeToFailCauseMap; 70 static { 71 sErrorCodeToFailCauseMap = new HashMap<Integer, DcFailCause>(); 72 for (DcFailCause fc : values()) { 73 sErrorCodeToFailCauseMap.put(fc.getErrorCode(), fc); 74 } 75 } 76 77 DcFailCause(int errorCode) { 78 mErrorCode = errorCode; 79 } 80 81 public int getErrorCode() { 82 return mErrorCode; 83 } 84 85 /** Radio has failed such that the radio should be restarted */ 86 public boolean isRestartRadioFail() { 87 return (this == REGULAR_DEACTIVATION && mRestartRadioOnRegularDeactivation); 88 } 89 90 public boolean isPermanentFail() { 91 return (this == OPERATOR_BARRED) || (this == MISSING_UNKNOWN_APN) || 92 (this == UNKNOWN_PDP_ADDRESS_TYPE) || (this == USER_AUTHENTICATION) || 93 (this == ACTIVATION_REJECT_GGSN) || (this == SERVICE_OPTION_NOT_SUPPORTED) || 94 (this == SERVICE_OPTION_NOT_SUBSCRIBED) || (this == NSAPI_IN_USE) || 95 (this == ONLY_IPV4_ALLOWED) || (this == ONLY_IPV6_ALLOWED) || 96 (this == PROTOCOL_ERRORS) || 97 (this == RADIO_POWER_OFF) || (this == TETHERED_CALL_ACTIVE) || 98 (this == RADIO_NOT_AVAILABLE) || (this == UNACCEPTABLE_NETWORK_PARAMETER) || 99 (this == SIGNAL_LOST); 100 } 101 102 public boolean isEventLoggable() { 103 return (this == OPERATOR_BARRED) || (this == INSUFFICIENT_RESOURCES) || 104 (this == UNKNOWN_PDP_ADDRESS_TYPE) || (this == USER_AUTHENTICATION) || 105 (this == ACTIVATION_REJECT_GGSN) || (this == ACTIVATION_REJECT_UNSPECIFIED) || 106 (this == SERVICE_OPTION_NOT_SUBSCRIBED) || 107 (this == SERVICE_OPTION_NOT_SUPPORTED) || 108 (this == SERVICE_OPTION_OUT_OF_ORDER) || (this == NSAPI_IN_USE) || 109 (this == ONLY_IPV4_ALLOWED) || (this == ONLY_IPV6_ALLOWED) || 110 (this == PROTOCOL_ERRORS) || (this == SIGNAL_LOST) || 111 (this == RADIO_POWER_OFF) || (this == TETHERED_CALL_ACTIVE) || 112 (this == UNACCEPTABLE_NETWORK_PARAMETER); 113 } 114 115 public static DcFailCause fromInt(int errorCode) { 116 DcFailCause fc = sErrorCodeToFailCauseMap.get(errorCode); 117 if (fc == null) { 118 fc = UNKNOWN; 119 } 120 return fc; 121 } 122 } 123