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