2 * This file is part of hayes-ril.
4 * Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr>
6 * Parts of this code are based on htcgeneric-ril, reference-ril:
7 * Copyright 2006-2011, htcgeneric-ril contributors
8 * Copyright 2006, The Android Open Source Project
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
25 #define LOG_TAG "RIL-SIM"
26 #include <utils/Log.h>
27 #include <telephony/ril.h>
29 #include <hayes-ril.h>
31 RIL_RadioState at2ril_cme_pin_status(int code)
34 case AT_CME_ERROR_PH_SIM_PIN_REQD:
35 case AT_CME_ERROR_PH_SIM_PUK_REQD:
36 case AT_CME_ERROR_PH_FSIM_PIN_REQD:
37 case AT_CME_ERROR_PH_FSIM_PUK_REQD:
38 case AT_CME_ERROR_SIM_NOT_INSERTED:
39 case AT_CME_ERROR_SIM_PIN_REQD:
40 case AT_CME_ERROR_SIM_PUK_REQD:
41 case AT_CME_ERROR_SIM_PIN2_REQD:
42 case AT_CME_ERROR_SIM_PUK2_REQD:
43 case AT_CME_ERROR_SIM_BLOCKED:
44 return RADIO_STATE_SIM_LOCKED_OR_ABSENT;
45 case AT_CME_ERROR_SIM_FAILURE:
46 case AT_CME_ERROR_SIM_BUSY:
47 case AT_CME_ERROR_SIM_WRONG:
48 case AT_CME_ERROR_SIM_POWERED_DOWN:
50 return RADIO_STATE_SIM_NOT_READY;
54 void at_cpin(struct at_response *response)
58 if(response->status == AT_STATUS_UNDEF)
61 if(response->status == AT_STATUS_CME_ERROR && response->error != NULL) {
62 code = atoi(response->error);
64 LOGD("Updating radio state!");
65 ril_globals.radio_state = at2ril_cme_pin_status(code);
66 RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0);
69 // TODO: gather more infos for ril_globals
70 } else if(response->status == AT_STATUS_OK) {
71 ril_globals.radio_state = RADIO_STATE_SIM_READY;
72 RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0);
73 // TODO: gather more infos for ril_globals
75 // Various error codes, not helping here
79 // TODO: Store the data we have in ril_globals (pointer alloc here?), then call UNSOL
81 LOGD("Handled AT+CPIN response");