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