PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/src/java/com/android/internal/telephony/dataconnection/DcFailCause.java

https://gitlab.com/Atomic-ROM/frameworks_opt_telephony
Java | 135 lines | 95 code | 14 blank | 26 comment | 54 complexity | c3f2db48810f4f5d8008f2a8375b731c MD5 | raw file
  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. import android.content.res.Resources;
  18. import android.content.Context;
  19. import android.telephony.SubscriptionManager;
  20. import com.android.internal.R;
  21. import java.util.HashMap;
  22. /**
  23. * Returned as the reason for a connection failure as defined
  24. * by RIL_DataCallFailCause in ril.h and some local errors.
  25. */
  26. public enum DcFailCause {
  27. NONE(0),
  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. // 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. PDP_FAIL_IPV4_CALL_THROTTLED(-7),
  56. PDP_FAIL_IPV6_CALL_THROTTLED(-8),
  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. private final boolean mRestartRadioOnRegularDeactivation = Resources.getSystem().getBoolean(
  66. com.android.internal.R.bool.config_restart_radio_on_pdp_fail_regular_deactivation);
  67. private final int mErrorCode;
  68. private static final HashMap<Integer, DcFailCause> sErrorCodeToFailCauseMap;
  69. static {
  70. sErrorCodeToFailCauseMap = new HashMap<Integer, DcFailCause>();
  71. for (DcFailCause fc : values()) {
  72. sErrorCodeToFailCauseMap.put(fc.getErrorCode(), fc);
  73. }
  74. }
  75. DcFailCause(int errorCode) {
  76. mErrorCode = errorCode;
  77. }
  78. public int getErrorCode() {
  79. return mErrorCode;
  80. }
  81. /** Radio has failed such that the radio should be restarted */
  82. public boolean isRestartRadioFail() {
  83. return (this == REGULAR_DEACTIVATION && mRestartRadioOnRegularDeactivation);
  84. }
  85. public boolean isPermanentFail(Context context, int subId) {
  86. if (this == ACTIVATION_REJECT_GGSN) {
  87. return (SubscriptionManager.getResourcesForSubId(context, subId).
  88. getBoolean(com.android.internal.R.bool.config_reject_ggsn_perm_failure));
  89. } else if (this == PROTOCOL_ERRORS) {
  90. return (SubscriptionManager.getResourcesForSubId(context, subId).
  91. getBoolean(com.android.internal.R.bool.config_protocol_errors_perm_failure));
  92. } else {
  93. return (this == OPERATOR_BARRED) || (this == MISSING_UNKNOWN_APN) ||
  94. (this == UNKNOWN_PDP_ADDRESS_TYPE) || (this == USER_AUTHENTICATION) ||
  95. (this == SERVICE_OPTION_NOT_SUPPORTED) ||
  96. (this == SERVICE_OPTION_NOT_SUBSCRIBED) || (this == NSAPI_IN_USE) ||
  97. (this == ONLY_IPV4_ALLOWED) || (this == ONLY_IPV6_ALLOWED) ||
  98. (this == RADIO_POWER_OFF) || (this == TETHERED_CALL_ACTIVE) ||
  99. (this == RADIO_NOT_AVAILABLE) || (this == UNACCEPTABLE_NETWORK_PARAMETER);
  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. public static DcFailCause fromInt(int errorCode) {
  115. DcFailCause fc = sErrorCodeToFailCauseMap.get(errorCode);
  116. if (fc == null) {
  117. fc = UNKNOWN;
  118. }
  119. return fc;
  120. }
  121. }