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