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.
23 #define LOG_TAG "RIL-PWR"
24 #include <utils/Log.h>
25 #include <telephony/ril.h>
27 #include <hayes-ril.h>
29 int at_cfun_enable_expect(struct at_response *response, void *data, RIL_Token t)
31 if(response->status == AT_STATUS_UNDEF)
32 return AT_RESPONSE_UNHANDELD_REASON_STATUS;
34 LOGD("Updating radio state from AT+CFUN response");
36 switch(response->status) {
38 ril_globals.radio_state = RADIO_STATE_SIM_NOT_READY;
39 RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0);
43 return AT_RESPONSE_HANDLED_OK;
46 int at_cfun_disable_expect(struct at_response *response, void *data, RIL_Token t)
48 if(response->status == AT_STATUS_UNDEF)
49 return AT_RESPONSE_UNHANDELD_REASON_STATUS;
51 LOGD("Updating radio state from AT+CFUN response");
53 switch(response->status) {
55 ril_globals.radio_state = RADIO_STATE_OFF;
56 RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0);
60 return AT_RESPONSE_HANDLED_OK;
63 void ril_power_on(void)
67 at_send_expect_to_func("AT+CFUN=1", NULL, NULL, 0x0000, at_cfun_enable_expect);
69 ril_device_at_power_on(ril_device);
72 void ril_power_off(void)
76 ril_device_at_power_off(ril_device);
78 at_send_expect_to_func("AT+CFUN=0", NULL, NULL, 0x0000, at_cfun_disable_expect);
81 void ril_request_radio_power(RIL_Token t, void *data, size_t length)
83 int power_state = *((int *)data);
90 at_send_expect_to_func("AT+CPIN?", NULL, NULL, 0x0000, at_cpin_expect);
95 RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);