DcFailCause.java revision 2ae42257ebafdbb0470cedeab41c2f1b418b285c
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 */ 16package com.android.internal.telephony.dataconnection; 17 18import 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 */ 24public 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 ONLY_IPV4_ALLOWED(0x32), /* no retry */ 41 ONLY_IPV6_ALLOWED(0x33), /* no retry */ 42 ONLY_SINGLE_BEARER_ALLOWED(0x34), 43 PROTOCOL_ERRORS(0x6F), /* no retry */ 44 45 // Local errors generated by Vendor RIL 46 // specified in ril.h 47 REGISTRATION_FAIL(-1), 48 GPRS_REGISTRATION_FAIL(-2), 49 SIGNAL_LOST(-3), /* no retry */ 50 PREF_RADIO_TECH_CHANGED(-4), /* no retry */ 51 RADIO_POWER_OFF(-5), /* no retry */ 52 TETHERED_CALL_ACTIVE(-6), /* no retry */ 53 ERROR_UNSPECIFIED(0xFFFF), 54 55 // Errors generated by the Framework 56 // specified here 57 UNKNOWN(0x10000), 58 RADIO_NOT_AVAILABLE(0x10001), /* no retry */ 59 UNACCEPTABLE_NETWORK_PARAMETER(0x10002), /* no retry */ 60 CONNECTION_TO_DATACONNECTIONAC_BROKEN(0x10003), 61 LOST_CONNECTION(0x10004), 62 RESET_BY_FRAMEWORK(0x10005); 63 64 private final int mErrorCode; 65 private static final HashMap<Integer, DcFailCause> sErrorCodeToFailCauseMap; 66 static { 67 sErrorCodeToFailCauseMap = new HashMap<Integer, DcFailCause>(); 68 for (DcFailCause fc : values()) { 69 sErrorCodeToFailCauseMap.put(fc.getErrorCode(), fc); 70 } 71 } 72 73 DcFailCause(int errorCode) { 74 mErrorCode = errorCode; 75 } 76 77 public int getErrorCode() { 78 return mErrorCode; 79 } 80 81 public boolean isPermanentFail() { 82 return (this == OPERATOR_BARRED) || (this == MISSING_UNKNOWN_APN) || 83 (this == UNKNOWN_PDP_ADDRESS_TYPE) || (this == USER_AUTHENTICATION) || 84 (this == ACTIVATION_REJECT_GGSN) || (this == SERVICE_OPTION_NOT_SUPPORTED) || 85 (this == SERVICE_OPTION_NOT_SUBSCRIBED) || (this == NSAPI_IN_USE) || 86 (this == ONLY_IPV4_ALLOWED) || (this == ONLY_IPV6_ALLOWED) || 87 (this == PROTOCOL_ERRORS) || (this == SIGNAL_LOST) || 88 (this == RADIO_POWER_OFF) || (this == TETHERED_CALL_ACTIVE) || 89 (this == RADIO_NOT_AVAILABLE) || (this == UNACCEPTABLE_NETWORK_PARAMETER); 90 } 91 92 public boolean isEventLoggable() { 93 return (this == OPERATOR_BARRED) || (this == INSUFFICIENT_RESOURCES) || 94 (this == UNKNOWN_PDP_ADDRESS_TYPE) || (this == USER_AUTHENTICATION) || 95 (this == ACTIVATION_REJECT_GGSN) || (this == ACTIVATION_REJECT_UNSPECIFIED) || 96 (this == SERVICE_OPTION_NOT_SUBSCRIBED) || 97 (this == SERVICE_OPTION_NOT_SUPPORTED) || 98 (this == SERVICE_OPTION_OUT_OF_ORDER) || (this == NSAPI_IN_USE) || 99 (this == ONLY_IPV4_ALLOWED) || (this == ONLY_IPV6_ALLOWED) || 100 (this == PROTOCOL_ERRORS) || (this == SIGNAL_LOST) || 101 (this == RADIO_POWER_OFF) || (this == TETHERED_CALL_ACTIVE) || 102 (this == UNACCEPTABLE_NETWORK_PARAMETER); 103 } 104 105 public static DcFailCause fromInt(int errorCode) { 106 DcFailCause fc = sErrorCodeToFailCauseMap.get(errorCode); 107 if (fc == null) { 108 fc = UNKNOWN; 109 } 110 return fc; 111 } 112} 113