CommandException.java revision cd3800ef6d32f5173e647924620501f7b5fcdb3f
1/* 2 * Copyright (C) 2007 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 17package com.android.internal.telephony; 18 19import com.android.internal.telephony.RILConstants; 20 21import android.telephony.Rlog; 22 23/** 24 * {@hide} 25 */ 26public class CommandException extends RuntimeException { 27 private Error mError; 28 29 public enum Error { 30 INVALID_RESPONSE, 31 RADIO_NOT_AVAILABLE, 32 GENERIC_FAILURE, 33 PASSWORD_INCORRECT, 34 SIM_PIN2, 35 SIM_PUK2, 36 REQUEST_NOT_SUPPORTED, 37 OP_NOT_ALLOWED_DURING_VOICE_CALL, 38 OP_NOT_ALLOWED_BEFORE_REG_NW, 39 SMS_FAIL_RETRY, 40 SIM_ABSENT, 41 SUBSCRIPTION_NOT_AVAILABLE, 42 MODE_NOT_SUPPORTED, 43 FDN_CHECK_FAILURE, 44 ILLEGAL_SIM_OR_ME, 45 MISSING_RESOURCE, 46 NO_SUCH_ELEMENT, 47 SUBSCRIPTION_NOT_SUPPORTED, 48 DIAL_MODIFIED_TO_USSD, 49 DIAL_MODIFIED_TO_SS, 50 DIAL_MODIFIED_TO_DIAL, 51 USSD_MODIFIED_TO_DIAL, 52 USSD_MODIFIED_TO_SS, 53 USSD_MODIFIED_TO_USSD, 54 SS_MODIFIED_TO_DIAL, 55 SS_MODIFIED_TO_USSD, 56 SS_MODIFIED_TO_SS, 57 SIM_ALREADY_POWERED_OFF, 58 SIM_ALREADY_POWERED_ON, 59 SIM_DATA_NOT_AVAILABLE, 60 SIM_SAP_CONNECT_FAILURE, 61 SIM_SAP_MSG_SIZE_TOO_LARGE, 62 SIM_SAP_MSG_SIZE_TOO_SMALL, 63 SIM_SAP_CONNECT_OK_CALL_ONGOING, 64 LCE_NOT_SUPPORTED, 65 NO_MEMORY, 66 INTERNAL_ERR, 67 SYSTEM_ERR, 68 MODEM_ERR, 69 INVALID_STATE, 70 NO_RESOURCES, 71 SIM_ERR, 72 INVALID_ARGUMENTS, 73 INVALID_SIM_STATE, 74 INVALID_MODEM_STATE, 75 INVALID_CALL_ID, 76 NO_SMS_TO_ACK, 77 NETWORK_ERR, 78 REQUEST_RATE_LIMITED, 79 OEM_ERROR_1, 80 OEM_ERROR_2, 81 OEM_ERROR_3, 82 OEM_ERROR_4, 83 OEM_ERROR_5, 84 OEM_ERROR_6, 85 OEM_ERROR_7, 86 OEM_ERROR_8, 87 OEM_ERROR_9, 88 OEM_ERROR_10, 89 OEM_ERROR_11, 90 OEM_ERROR_12, 91 OEM_ERROR_13, 92 OEM_ERROR_14, 93 OEM_ERROR_15, 94 OEM_ERROR_16, 95 OEM_ERROR_17, 96 OEM_ERROR_18, 97 OEM_ERROR_19, 98 OEM_ERROR_20, 99 OEM_ERROR_21, 100 OEM_ERROR_22, 101 OEM_ERROR_23, 102 OEM_ERROR_24, 103 OEM_ERROR_25, 104 } 105 106 public CommandException(Error e) { 107 super(e.toString()); 108 mError = e; 109 } 110 111 public CommandException(Error e, String errString) { 112 super(errString); 113 mError = e; 114 } 115 116 public static CommandException 117 fromRilErrno(int ril_errno) { 118 switch(ril_errno) { 119 case RILConstants.SUCCESS: return null; 120 case RILConstants.RIL_ERRNO_INVALID_RESPONSE: 121 return new CommandException(Error.INVALID_RESPONSE); 122 case RILConstants.RADIO_NOT_AVAILABLE: 123 return new CommandException(Error.RADIO_NOT_AVAILABLE); 124 case RILConstants.GENERIC_FAILURE: 125 return new CommandException(Error.GENERIC_FAILURE); 126 case RILConstants.PASSWORD_INCORRECT: 127 return new CommandException(Error.PASSWORD_INCORRECT); 128 case RILConstants.SIM_PIN2: 129 return new CommandException(Error.SIM_PIN2); 130 case RILConstants.SIM_PUK2: 131 return new CommandException(Error.SIM_PUK2); 132 case RILConstants.REQUEST_NOT_SUPPORTED: 133 return new CommandException(Error.REQUEST_NOT_SUPPORTED); 134 case RILConstants.OP_NOT_ALLOWED_DURING_VOICE_CALL: 135 return new CommandException(Error.OP_NOT_ALLOWED_DURING_VOICE_CALL); 136 case RILConstants.OP_NOT_ALLOWED_BEFORE_REG_NW: 137 return new CommandException(Error.OP_NOT_ALLOWED_BEFORE_REG_NW); 138 case RILConstants.SMS_SEND_FAIL_RETRY: 139 return new CommandException(Error.SMS_FAIL_RETRY); 140 case RILConstants.SIM_ABSENT: 141 return new CommandException(Error.SIM_ABSENT); 142 case RILConstants.SUBSCRIPTION_NOT_AVAILABLE: 143 return new CommandException(Error.SUBSCRIPTION_NOT_AVAILABLE); 144 case RILConstants.MODE_NOT_SUPPORTED: 145 return new CommandException(Error.MODE_NOT_SUPPORTED); 146 case RILConstants.FDN_CHECK_FAILURE: 147 return new CommandException(Error.FDN_CHECK_FAILURE); 148 case RILConstants.ILLEGAL_SIM_OR_ME: 149 return new CommandException(Error.ILLEGAL_SIM_OR_ME); 150 case RILConstants.MISSING_RESOURCE: 151 return new CommandException(Error.MISSING_RESOURCE); 152 case RILConstants.NO_SUCH_ELEMENT: 153 return new CommandException(Error.NO_SUCH_ELEMENT); 154 case RILConstants.SUBSCRIPTION_NOT_SUPPORTED: 155 return new CommandException(Error.SUBSCRIPTION_NOT_SUPPORTED); 156 case RILConstants.DIAL_MODIFIED_TO_USSD: 157 return new CommandException(Error.DIAL_MODIFIED_TO_USSD); 158 case RILConstants.DIAL_MODIFIED_TO_SS: 159 return new CommandException(Error.DIAL_MODIFIED_TO_SS); 160 case RILConstants.DIAL_MODIFIED_TO_DIAL: 161 return new CommandException(Error.DIAL_MODIFIED_TO_DIAL); 162 case RILConstants.USSD_MODIFIED_TO_DIAL: 163 return new CommandException(Error.USSD_MODIFIED_TO_DIAL); 164 case RILConstants.USSD_MODIFIED_TO_SS: 165 return new CommandException(Error.USSD_MODIFIED_TO_SS); 166 case RILConstants.USSD_MODIFIED_TO_USSD: 167 return new CommandException(Error.USSD_MODIFIED_TO_USSD); 168 case RILConstants.SS_MODIFIED_TO_DIAL: 169 return new CommandException(Error.SS_MODIFIED_TO_DIAL); 170 case RILConstants.SS_MODIFIED_TO_USSD: 171 return new CommandException(Error.SS_MODIFIED_TO_USSD); 172 case RILConstants.SS_MODIFIED_TO_SS: 173 return new CommandException(Error.SS_MODIFIED_TO_SS); 174 case RILConstants.SIM_ALREADY_POWERED_OFF: 175 return new CommandException(Error.SIM_ALREADY_POWERED_OFF); 176 case RILConstants.SIM_ALREADY_POWERED_ON: 177 return new CommandException(Error.SIM_ALREADY_POWERED_ON); 178 case RILConstants.SIM_DATA_NOT_AVAILABLE: 179 return new CommandException(Error.SIM_DATA_NOT_AVAILABLE); 180 case RILConstants.SIM_SAP_CONNECT_FAILURE: 181 return new CommandException(Error.SIM_SAP_CONNECT_FAILURE); 182 case RILConstants.SIM_SAP_MSG_SIZE_TOO_LARGE: 183 return new CommandException(Error.SIM_SAP_MSG_SIZE_TOO_LARGE); 184 case RILConstants.SIM_SAP_MSG_SIZE_TOO_SMALL: 185 return new CommandException(Error.SIM_SAP_MSG_SIZE_TOO_SMALL); 186 case RILConstants.SIM_SAP_CONNECT_OK_CALL_ONGOING: 187 return new CommandException(Error.SIM_SAP_CONNECT_OK_CALL_ONGOING); 188 case RILConstants.LCE_NOT_SUPPORTED: 189 return new CommandException(Error.LCE_NOT_SUPPORTED); 190 case RILConstants.NO_MEMORY: 191 return new CommandException(Error.NO_MEMORY); 192 case RILConstants.INTERNAL_ERR: 193 return new CommandException(Error.INTERNAL_ERR); 194 case RILConstants.SYSTEM_ERR: 195 return new CommandException(Error.SYSTEM_ERR); 196 case RILConstants.MODEM_ERR: 197 return new CommandException(Error.MODEM_ERR); 198 case RILConstants.INVALID_STATE: 199 return new CommandException(Error.INVALID_STATE); 200 case RILConstants.NO_RESOURCES: 201 return new CommandException(Error.NO_RESOURCES); 202 case RILConstants.SIM_ERR: 203 return new CommandException(Error.SIM_ERR); 204 case RILConstants.INVALID_ARGUMENTS: 205 return new CommandException(Error.INVALID_ARGUMENTS); 206 case RILConstants.INVALID_SIM_STATE: 207 return new CommandException(Error.INVALID_SIM_STATE); 208 case RILConstants.INVALID_MODEM_STATE: 209 return new CommandException(Error.INVALID_MODEM_STATE); 210 case RILConstants.INVALID_CALL_ID: 211 return new CommandException(Error.INVALID_CALL_ID); 212 case RILConstants.NO_SMS_TO_ACK: 213 return new CommandException(Error.NO_SMS_TO_ACK); 214 case RILConstants.NETWORK_ERR: 215 return new CommandException(Error.NETWORK_ERR); 216 case RILConstants.REQUEST_RATE_LIMITED: 217 return new CommandException(Error.REQUEST_RATE_LIMITED); 218 case RILConstants.OEM_ERROR_1: 219 return new CommandException(Error.OEM_ERROR_1); 220 case RILConstants.OEM_ERROR_2: 221 return new CommandException(Error.OEM_ERROR_2); 222 case RILConstants.OEM_ERROR_3: 223 return new CommandException(Error.OEM_ERROR_3); 224 case RILConstants.OEM_ERROR_4: 225 return new CommandException(Error.OEM_ERROR_4); 226 case RILConstants.OEM_ERROR_5: 227 return new CommandException(Error.OEM_ERROR_5); 228 case RILConstants.OEM_ERROR_6: 229 return new CommandException(Error.OEM_ERROR_6); 230 case RILConstants.OEM_ERROR_7: 231 return new CommandException(Error.OEM_ERROR_7); 232 case RILConstants.OEM_ERROR_8: 233 return new CommandException(Error.OEM_ERROR_8); 234 case RILConstants.OEM_ERROR_9: 235 return new CommandException(Error.OEM_ERROR_9); 236 case RILConstants.OEM_ERROR_10: 237 return new CommandException(Error.OEM_ERROR_10); 238 case RILConstants.OEM_ERROR_11: 239 return new CommandException(Error.OEM_ERROR_11); 240 case RILConstants.OEM_ERROR_12: 241 return new CommandException(Error.OEM_ERROR_12); 242 case RILConstants.OEM_ERROR_13: 243 return new CommandException(Error.OEM_ERROR_13); 244 case RILConstants.OEM_ERROR_14: 245 return new CommandException(Error.OEM_ERROR_14); 246 case RILConstants.OEM_ERROR_15: 247 return new CommandException(Error.OEM_ERROR_15); 248 case RILConstants.OEM_ERROR_16: 249 return new CommandException(Error.OEM_ERROR_16); 250 case RILConstants.OEM_ERROR_17: 251 return new CommandException(Error.OEM_ERROR_17); 252 case RILConstants.OEM_ERROR_18: 253 return new CommandException(Error.OEM_ERROR_18); 254 case RILConstants.OEM_ERROR_19: 255 return new CommandException(Error.OEM_ERROR_19); 256 case RILConstants.OEM_ERROR_20: 257 return new CommandException(Error.OEM_ERROR_20); 258 case RILConstants.OEM_ERROR_21: 259 return new CommandException(Error.OEM_ERROR_21); 260 case RILConstants.OEM_ERROR_22: 261 return new CommandException(Error.OEM_ERROR_22); 262 case RILConstants.OEM_ERROR_23: 263 return new CommandException(Error.OEM_ERROR_23); 264 case RILConstants.OEM_ERROR_24: 265 return new CommandException(Error.OEM_ERROR_24); 266 case RILConstants.OEM_ERROR_25: 267 return new CommandException(Error.OEM_ERROR_25); 268 269 default: 270 Rlog.e("GSM", "Unrecognized RIL errno " + ril_errno); 271 return new CommandException(Error.INVALID_RESPONSE); 272 } 273 } 274 275 public Error getCommandError() { 276 return mError; 277 } 278 279 280 281} 282