summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2013-09-28 16:38:51 +0200
committerPaul Kocialkowski <contact@paulk.fr>2013-09-28 16:38:51 +0200
commitfd051580b347b09bf43d1fab29cea3d58b113e09 (patch)
treedf76485577c71a1435be41a1b6115f2fe4795263
parent233ef2c6769c1c833e89651ae5846e66a5097cfb (diff)
downloadhardware_ril_samsung-ril-fd051580b347b09bf43d1fab29cea3d58b113e09.zip
hardware_ril_samsung-ril-fd051580b347b09bf43d1fab29cea3d58b113e09.tar.gz
hardware_ril_samsung-ril-fd051580b347b09bf43d1fab29cea3d58b113e09.tar.bz2
Check modem state before RIL requests and properly report it on crash
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--disp.c17
-rw-r--r--gprs.c12
-rw-r--r--ipc.c30
-rw-r--r--misc.c35
-rw-r--r--net.c30
-rw-r--r--pwr.c19
-rw-r--r--samsung-ril.c55
-rw-r--r--samsung-ril.h11
-rw-r--r--sec.c35
-rw-r--r--sms.c12
-rw-r--r--snd.c3
-rw-r--r--ss.c6
-rw-r--r--svc.c3
13 files changed, 198 insertions, 70 deletions
diff --git a/disp.c b/disp.c
index 6296826..72f8219 100644
--- a/disp.c
+++ b/disp.c
@@ -97,6 +97,9 @@ void ril_request_signal_strength(RIL_Token t)
{
unsigned char request = 1;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
ipc_fmt_send(IPC_DISP_ICON_INFO, IPC_TYPE_GET, &request, sizeof(request), ril_request_get_id(t));
}
@@ -112,12 +115,11 @@ void ipc_disp_icon_info(struct ipc_message_info *info)
if (info->data == NULL || info->length < sizeof(struct ipc_disp_icon_info))
goto error;
- icon_info = (struct ipc_disp_icon_info *) info->data;
-
- /* Don't consider this if modem isn't in normal power mode. */
- if (ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL)
+ if (ril_radio_state_complete(RADIO_STATE_OFF, RIL_TOKEN_NULL))
return;
+ icon_info = (struct ipc_disp_icon_info *) info->data;
+
if (info->type == IPC_TYPE_RESP) {
ipc2ril_rssi(icon_info->rssi, &ss);
ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, &ss, sizeof(ss));
@@ -147,12 +149,11 @@ void ipc_disp_rssi_info(struct ipc_message_info *info)
if (info->data == NULL || info->length < sizeof(struct ipc_disp_rssi_info))
return;
- rssi_info = (struct ipc_disp_rssi_info *) info->data;
-
- /* Don't consider this if modem isn't in normal power mode. */
- if (ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL)
+ if (ril_radio_state_complete(RADIO_STATE_OFF, RIL_TOKEN_NULL))
return;
+ rssi_info = (struct ipc_disp_rssi_info *) info->data;
+
ipc2ril_rssi(rssi_info->rssi, &ss);
ril_request_unsolicited(RIL_UNSOL_SIGNAL_STRENGTH, &ss, sizeof(ss));
diff --git a/gprs.c b/gprs.c
index ded89c7..4e77043 100644
--- a/gprs.c
+++ b/gprs.c
@@ -372,6 +372,9 @@ void ril_request_setup_data_call(RIL_Token t, void *data, int length)
if (data == NULL || length < (int) (4 * sizeof(char *)))
goto error;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
if (ril_data.ipc_fmt_client == NULL || ril_data.ipc_fmt_client->data == NULL)
goto error;
@@ -505,6 +508,9 @@ void ril_request_deactivate_data_call(RIL_Token t, void *data, int length)
if (data == NULL || length < (int) sizeof(char *))
goto error;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
cid = ((char **) data)[0];
gprs_connection = ril_gprs_connection_find_cid(atoi(cid));
@@ -897,6 +903,9 @@ void ril_request_last_data_call_fail_cause(RIL_Token t)
int last_failed_cid;
int fail_cause;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
last_failed_cid = ril_data.state.gprs_last_failed_cid;
if (!last_failed_cid) {
@@ -1059,5 +1068,8 @@ void ril_unsol_data_call_list_changed(void)
void ril_request_data_call_list(RIL_Token t)
{
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
ipc_fmt_send_get(IPC_GPRS_PDP_CONTEXT, ril_request_get_id(t));
}
diff --git a/ipc.c b/ipc.c
index 24df4b8..c7d3513 100644
--- a/ipc.c
+++ b/ipc.c
@@ -66,7 +66,7 @@ int ipc_fmt_read_loop(struct ril_client *client)
rc = ipc_client_poll(ipc_client, NULL);
if (rc < 0) {
LOGE("IPC FMT client poll failed, aborting");
- return -1;
+ goto error;
}
memset(&info, 0, sizeof(info));
@@ -75,7 +75,7 @@ int ipc_fmt_read_loop(struct ril_client *client)
if (ipc_client_recv(ipc_client, &info) < 0) {
RIL_CLIENT_UNLOCK(client);
LOGE("IPC FMT recv failed, aborting");
- return -1;
+ goto error;
}
RIL_CLIENT_UNLOCK(client);
@@ -84,7 +84,16 @@ int ipc_fmt_read_loop(struct ril_client *client)
ipc_client_response_free(ipc_client, &info);
}
- return 0;
+ rc = 0;
+ goto complete;
+
+error:
+ ril_radio_state_update(RADIO_STATE_UNAVAILABLE);
+
+ rc = -1;
+
+complete:
+ return rc;
}
int ipc_fmt_create(struct ril_client *client)
@@ -232,7 +241,7 @@ int ipc_rfs_read_loop(struct ril_client *client)
rc = ipc_client_poll(ipc_client, NULL);
if (rc < 0) {
LOGE("IPC RFS client poll failed, aborting");
- return -1;
+ goto error;
}
memset(&info, 0, sizeof(info));
@@ -241,7 +250,7 @@ int ipc_rfs_read_loop(struct ril_client *client)
if (ipc_client_recv(ipc_client, &info) < 0) {
RIL_CLIENT_UNLOCK(client);
LOGE("IPC RFS recv failed, aborting");
- return -1;
+ goto error;
}
RIL_CLIENT_UNLOCK(client);
@@ -250,7 +259,16 @@ int ipc_rfs_read_loop(struct ril_client *client)
ipc_client_response_free(ipc_client, &info);
}
- return 0;
+ rc = 0;
+ goto complete;
+
+error:
+ ril_radio_state_update(RADIO_STATE_UNAVAILABLE);
+
+ rc = -1;
+
+complete:
+ return rc;
}
int ipc_rfs_create(struct ril_client *client)
diff --git a/misc.c b/misc.c
index c4b0870..322e75c 100644
--- a/misc.c
+++ b/misc.c
@@ -34,6 +34,9 @@ void ril_request_get_imei_send(RIL_Token t)
void ril_request_get_imei(RIL_Token t)
{
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
if (ril_data.tokens.get_imei) {
LOGD("Another IMEI request is waiting, aborting");
ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
@@ -45,11 +48,7 @@ void ril_request_get_imei(RIL_Token t)
if (ril_data.tokens.get_imeisv) {
LOGD("IMEISV token found: %p", ril_data.tokens.get_imeisv);
- if (ril_data.state.radio_state != RADIO_STATE_OFF) {
- ril_request_get_imei_send(ril_data.tokens.get_imei);
- } else {
- LOGD("Radio is off, waiting");
- }
+ ril_request_get_imei_send(ril_data.tokens.get_imei);
} else {
LOGD("Waiting for IMEISV token");
}
@@ -57,6 +56,9 @@ void ril_request_get_imei(RIL_Token t)
void ril_request_get_imeisv(RIL_Token t)
{
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
if (ril_data.tokens.get_imeisv) {
LOGD("Another IMEISV request is waiting, aborting");
ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
@@ -68,11 +70,7 @@ void ril_request_get_imeisv(RIL_Token t)
if (ril_data.tokens.get_imei) {
LOGD("IMEI token found: %p", ril_data.tokens.get_imei);
- if (ril_data.state.radio_state != RADIO_STATE_OFF) {
- ril_request_get_imei_send(ril_data.tokens.get_imei);
- } else {
- LOGD("Radio is off, waiting");
- }
+ ril_request_get_imei_send(ril_data.tokens.get_imei);
} else {
LOGD("Waiting for IMEI token");
}
@@ -165,6 +163,9 @@ void ril_request_baseband_version(RIL_Token t)
{
unsigned char data;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
if (ril_data.tokens.baseband_version) {
LOGD("Another Baseband version request is waiting, aborting");
ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
@@ -173,12 +174,9 @@ void ril_request_baseband_version(RIL_Token t)
ril_data.tokens.baseband_version = t;
- if (ril_data.state.radio_state != RADIO_STATE_OFF) {
- data = 0xff;
+ data = 0xff;
- ipc_fmt_send(IPC_MISC_ME_VERSION, IPC_TYPE_GET,
- (unsigned char *) &data, sizeof(data), ril_request_get_id(t));
- }
+ ipc_fmt_send(IPC_MISC_ME_VERSION, IPC_TYPE_GET, (unsigned char *) &data, sizeof(data), ril_request_get_id(t));
}
void ipc_misc_me_version(struct ipc_message_info *info)
@@ -215,6 +213,9 @@ error:
void ril_request_get_imsi(RIL_Token t)
{
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
ipc_fmt_send_get(IPC_MISC_ME_IMSI, ril_request_get_id(t));
}
@@ -226,10 +227,6 @@ void ipc_misc_me_imsi(struct ipc_message_info *info)
if (info->data == NULL || info->length < sizeof(unsigned char))
goto error;
- /* Don't consider this if modem isn't in normal power mode. */
- if (ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL)
- return;
-
imsi_length = *((unsigned char *) info->data);
if (((int) info->length) < imsi_length + 1) {
diff --git a/net.c b/net.c
index 87f8c85..c9bb778 100644
--- a/net.c
+++ b/net.c
@@ -298,6 +298,9 @@ void ril_request_operator(RIL_Token t)
char *response[3];
size_t i;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
// IPC_NET_REGISTRATION_STATE_ROAMING is the biggest valid value
if (ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_NONE ||
ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_SEARCHING ||
@@ -454,6 +457,9 @@ void ril_request_registration_state(RIL_Token t)
char *response[4];
int i;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
if (ril_data.tokens.registration_state == RIL_TOKEN_DATA_WAITING) {
LOGD("Got RILJ request for UNSOL data");
@@ -502,6 +508,9 @@ void ril_request_gprs_registration_state(RIL_Token t)
char *response[4];
size_t i;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
if (ril_data.tokens.gprs_registration_state == RIL_TOKEN_DATA_WAITING) {
LOGD("Got RILJ request for UNSOL data");
@@ -681,8 +690,7 @@ void ipc_net_regist(struct ipc_message_info *info)
if (info == NULL)
return;
- /* Don't consider this if modem isn't in normal power mode. */
- if (ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL)
+ if (ril_radio_state_complete(RADIO_STATE_OFF, RIL_TOKEN_NULL))
return;
switch (info->type) {
@@ -701,6 +709,9 @@ void ipc_net_regist(struct ipc_message_info *info)
void ril_request_query_available_networks(RIL_Token t)
{
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
ipc_fmt_send_get(IPC_NET_PLMN_LIST, ril_request_get_id(t));
}
@@ -772,6 +783,9 @@ error:
void ril_request_get_preferred_network_type(RIL_Token t)
{
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
ipc_fmt_send_get(IPC_NET_MODE_SEL, ril_request_get_id(t));
}
@@ -783,6 +797,9 @@ void ril_request_set_preferred_network_type(RIL_Token t, void *data, size_t leng
if (data == NULL || length < (int) sizeof(int))
goto error;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
ril_mode = *((int *) data);
mode_sel.mode_sel = ril2ipc_mode_sel(ril_mode);
@@ -819,6 +836,9 @@ error:
void ril_request_query_network_selection_mode(RIL_Token t)
{
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
ipc_fmt_send_get(IPC_NET_PLMN_SEL, ril_request_get_id(t));
}
@@ -867,6 +887,9 @@ void ril_request_set_network_selection_automatic(RIL_Token t)
{
struct ipc_net_plmn_sel_set plmn_sel;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
ipc_net_plmn_sel_set_setup(&plmn_sel, IPC_NET_PLMN_SEL_AUTO, NULL, IPC_NET_ACCESS_TECHNOLOGY_UNKNOWN);
ipc_gen_phone_res_expect_to_func(ril_request_get_id(t), IPC_NET_PLMN_SEL, ipc_net_plmn_sel_complete);
@@ -881,6 +904,9 @@ void ril_request_set_network_selection_manual(RIL_Token t, void *data, size_t le
if (data == NULL || length < (int) sizeof(char *))
return;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
// FIXME: We always assume UMTS capability
ipc_net_plmn_sel_set_setup(&plmn_sel, IPC_NET_PLMN_SEL_MANUAL, data, IPC_NET_ACCESS_TECHNOLOGY_UMTS);
diff --git a/pwr.c b/pwr.c
index 02407ef..989f727 100644
--- a/pwr.c
+++ b/pwr.c
@@ -32,16 +32,12 @@
void ipc_pwr_phone_pwr_up(void)
{
- ril_data.state.radio_state = RADIO_STATE_OFF;
- ril_data.state.power_state = IPC_PWR_PHONE_STATE_LPM;
-
- RIL_START_UNLOCK();
+ ril_radio_state_update(RADIO_STATE_OFF);
}
void ipc_pwr_phone_reset(void)
{
- ril_data.state.radio_state = RADIO_STATE_OFF;
- ril_request_unsolicited(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0);
+ ril_radio_state_update(RADIO_STATE_OFF);
}
void ipc_pwr_phone_state(struct ipc_message_info *info)
@@ -62,9 +58,7 @@ void ipc_pwr_phone_state(struct ipc_message_info *info)
ril_data.tokens.radio_power = RIL_TOKEN_NULL;
}
- ril_data.state.radio_state = RADIO_STATE_OFF;
- ril_data.state.power_state = IPC_PWR_PHONE_STATE_LPM;
- ril_request_unsolicited(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0);
+ ril_radio_state_update(RADIO_STATE_OFF);
break;
case IPC_PWR_R(IPC_PWR_PHONE_STATE_NORMAL):
LOGD("Got power to NORMAL");
@@ -74,9 +68,7 @@ void ipc_pwr_phone_state(struct ipc_message_info *info)
ril_data.tokens.radio_power = RIL_TOKEN_NULL;
}
- ril_data.state.radio_state = RADIO_STATE_SIM_NOT_READY;
- ril_data.state.power_state = IPC_PWR_PHONE_STATE_NORMAL;
- ril_request_unsolicited(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0);
+ ril_radio_state_update(RADIO_STATE_SIM_NOT_READY);
break;
}
@@ -91,6 +83,9 @@ void ril_request_radio_power(RIL_Token t, void *data, int length)
if (data == NULL || length < (int) sizeof(int))
return;
+ if (ril_radio_state_complete(RADIO_STATE_UNAVAILABLE, t))
+ return;
+
power_state = *((int *) data);
LOGD("requested power_state is %d", power_state);
diff --git a/samsung-ril.c b/samsung-ril.c
index 9187f48..fc29660 100644
--- a/samsung-ril.c
+++ b/samsung-ril.c
@@ -233,6 +233,52 @@ void ril_request_timed_callback(RIL_TimedCallback callback, void *data, const st
}
/*
+ * RIL radio state
+ */
+
+int ril_radio_state_complete(RIL_RadioState radio_state, RIL_Token token)
+{
+ RIL_Errno error = RIL_E_SUCCESS;
+
+ // This goes from best case of failure to worst case of failure
+ switch (radio_state) {
+ case RADIO_STATE_SIM_NOT_READY:
+ if (ril_data.state.radio_state == RADIO_STATE_SIM_NOT_READY)
+ error = RIL_E_GENERIC_FAILURE;
+ case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
+ if (ril_data.state.radio_state == RADIO_STATE_SIM_LOCKED_OR_ABSENT)
+ error = RIL_E_GENERIC_FAILURE;
+ case RADIO_STATE_OFF:
+ if (ril_data.state.radio_state == RADIO_STATE_OFF)
+ error = RIL_E_RADIO_NOT_AVAILABLE;
+ case RADIO_STATE_UNAVAILABLE:
+ default:
+ if (ril_data.state.radio_state == RADIO_STATE_UNAVAILABLE)
+ error = RIL_E_RADIO_NOT_AVAILABLE;
+ break;
+ }
+
+ if (error != RIL_E_SUCCESS) {
+ if (token != RIL_TOKEN_NULL)
+ ril_request_complete(token, error, NULL, 0);
+
+ return 1;
+ }
+
+ return 0;
+}
+
+void ril_radio_state_update(RIL_RadioState radio_state)
+{
+ LOGD("Setting radio state to %d", radio_state);
+ ril_data.state.radio_state = radio_state;
+
+ ril_request_unsolicited(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0);
+
+ ril_tokens_check();
+}
+
+/*
* RIL tokens
*/
@@ -675,6 +721,8 @@ void ril_data_init(void)
memset(&ril_data, 0, sizeof(ril_data));
pthread_mutex_init(&ril_data.mutex, NULL);
+
+ ril_data.state.radio_state = RADIO_STATE_UNAVAILABLE;
}
/*
@@ -768,14 +816,7 @@ srs:
LOGD("SRS client ready");
end:
- ril_data.state.radio_state = RADIO_STATE_OFF;
- ril_data.state.power_state = IPC_PWR_PHONE_STATE_LPM;
-
RIL_UNLOCK();
- // Wait for power up
- RIL_START_LOCK();
- RIL_START_LOCK();
-
return &ril_ops;
}
diff --git a/samsung-ril.h b/samsung-ril.h
index ff63d27..d9b4055 100644
--- a/samsung-ril.h
+++ b/samsung-ril.h
@@ -53,8 +53,6 @@
#define RIL_LOCK() pthread_mutex_lock(&ril_data.mutex)
#define RIL_UNLOCK() pthread_mutex_unlock(&ril_data.mutex)
-#define RIL_START_LOCK() pthread_mutex_lock(&ril_data.start_mutex)
-#define RIL_START_UNLOCK() pthread_mutex_unlock(&ril_data.start_mutex)
#define RIL_CLIENT_LOCK(client) pthread_mutex_lock(&(client->mutex))
#define RIL_CLIENT_UNLOCK(client) pthread_mutex_unlock(&(client->mutex))
@@ -125,6 +123,13 @@ void ril_request_unsolicited(int request, void *data, size_t length);
void ril_request_timed_callback(RIL_TimedCallback callback, void *data, const struct timeval *time);
/*
+ * RIL radio state
+ */
+
+int ril_radio_state_complete(RIL_RadioState radio_state, RIL_Token token);
+void ril_radio_state_update(RIL_RadioState radio_state);
+
+/*
* RIL tokens
*/
@@ -165,7 +170,6 @@ typedef enum {
struct ril_state {
RIL_RadioState radio_state;
ril_sim_state sim_state;
- int power_state;
struct ipc_sec_sim_status_response sim_pin_status;
struct ipc_sec_sim_icc_type sim_icc_type;
@@ -207,7 +211,6 @@ struct ril_data {
struct ril_client *srs_client;
pthread_mutex_t mutex;
- pthread_mutex_t start_mutex;
};
extern struct ril_data ril_data;
diff --git a/sec.c b/sec.c
index 2e4ef32..0e0bdb6 100644
--- a/sec.c
+++ b/sec.c
@@ -76,10 +76,6 @@ void ril_state_update(ril_sim_state sim_state)
{
RIL_RadioState radio_state;
- /* If power mode isn't at least normal, don't update RIL state */
- if (ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL)
- return;
-
ril_data.state.sim_state = sim_state;
switch (sim_state) {
@@ -108,12 +104,7 @@ void ril_state_update(ril_sim_state sim_state)
break;
}
- LOGD("Setting radio state to %x", radio_state);
- ril_data.state.radio_state = radio_state;
-
- ril_tokens_check();
-
- ril_request_unsolicited(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0);
+ ril_radio_state_update(radio_state);
}
#if RIL_VERSION >= 6
@@ -221,8 +212,7 @@ void ipc_sec_sim_status(struct ipc_message_info *info)
switch (info->type) {
case IPC_TYPE_NOTI:
- // Don't consider this if modem isn't in normal power mode
- if (ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL)
+ if (ril_radio_state_complete(RADIO_STATE_OFF, RIL_TOKEN_NULL))
return;
LOGD("Got UNSOL PIN status message");
@@ -281,6 +271,9 @@ void ril_request_get_sim_status(RIL_Token t)
RIL_CardStatus card_status;
#endif
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
if (ril_data.tokens.pin_status == RIL_TOKEN_DATA_WAITING) {
LOGD("Got RILJ request for UNSOL data");
hex_dump(&(ril_data.state.sim_pin_status), sizeof(struct ipc_sec_sim_status_response));
@@ -511,6 +504,9 @@ void ril_request_sim_io(RIL_Token t, void *data, int length)
if (data == NULL || length < (int) sizeof(*sim_io))
goto error;
+ if (ril_radio_state_complete(RADIO_STATE_SIM_NOT_READY, t))
+ return;
+
#if RIL_VERSION >= 6
sim_io = (RIL_SIM_IO_v6 *) data;
#else
@@ -768,6 +764,9 @@ void ril_request_enter_sim_pin(RIL_Token t, void *data, size_t length)
if (data == NULL || length < (int) sizeof(char *))
goto error;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
// 1. Send PIN
if (strlen(data) > 16) {
LOGE("%s: pin exceeds maximum length", __func__);
@@ -803,6 +802,9 @@ void ril_request_change_sim_pin(RIL_Token t, void *data, size_t length)
if (data == NULL || length < (int) (2 * sizeof(char *)))
goto error;
+ if (ril_radio_state_complete(RADIO_STATE_SIM_NOT_READY, t))
+ return;
+
password_old = ((char **) data)[0];
password_new = ((char **) data)[1];
@@ -842,6 +844,9 @@ void ril_request_enter_sim_puk(RIL_Token t, void *data, size_t length)
if (data == NULL || length < (int) (2 * sizeof(char *)))
goto error;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
puk = ((char **) data)[0];
pin = ((char **) data)[1];
@@ -885,6 +890,9 @@ void ril_request_query_facility_lock(RIL_Token t, void *data, size_t length)
if (data == NULL || length < sizeof(char *))
goto error;
+ if (ril_radio_state_complete(RADIO_STATE_SIM_NOT_READY, t))
+ return;
+
facility = ((char **) data)[0];
if (!strcmp(facility, "SC")) {
@@ -927,6 +935,9 @@ void ril_request_set_facility_lock(RIL_Token t, void *data, size_t length)
if (data == NULL || length < (int) (4 * sizeof(char *)))
goto error;
+ if (ril_radio_state_complete(RADIO_STATE_SIM_NOT_READY, t))
+ return;
+
facility = ((char **) data)[0];
lock = ((char **) data)[1];
password = ((char **) data)[2];
diff --git a/sms.c b/sms.c
index 3b9a713..0b30f6e 100644
--- a/sms.c
+++ b/sms.c
@@ -361,6 +361,9 @@ void ril_request_send_sms(RIL_Token t, void *data, size_t length)
if (data == NULL || length < (int) (2 * sizeof(char *)))
goto error;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
pdu = ((char **) data)[1];
smsc = ((unsigned char **) data)[0];
pdu_length = 0;
@@ -668,6 +671,9 @@ void ril_request_sms_acknowledge(RIL_Token t, void *data, size_t length)
if (data == NULL || length < 2 * sizeof(int))
goto error;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
success = ((int *) data)[0];
fail_cause = ((int *) data)[1];
@@ -732,6 +738,9 @@ void ril_request_write_sms_to_sim(RIL_Token token, void *data, size_t size)
if (data == NULL || size < sizeof(RIL_SMS_WriteArgs))
goto error;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, token))
+ return;
+
args = (RIL_SMS_WriteArgs *) data;
if (args->pdu != NULL) {
@@ -808,6 +817,9 @@ void ril_request_delete_sms_on_sim(RIL_Token token, void *data, size_t size)
if (data == NULL || size < sizeof(index))
goto error;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, token))
+ return;
+
index = *((int *) data);
if (index <= 0 || index > 0xffff)
diff --git a/snd.c b/snd.c
index e1fec25..4af8287 100644
--- a/snd.c
+++ b/snd.c
@@ -69,6 +69,9 @@ void ril_request_set_mute(RIL_Token t, void *data, int length)
if (data == NULL || length < (int) sizeof(int))
return;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
value = (int *) data;
mute = *value ? 1 : 0;
diff --git a/ss.c b/ss.c
index 4ccd868..d05fa2f 100644
--- a/ss.c
+++ b/ss.c
@@ -56,6 +56,9 @@ void ril_request_send_ussd(RIL_Token t, void *data, size_t length)
if (data == NULL || length < (int) sizeof(char *))
goto error;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
switch (ril_data.state.ussd_state) {
case 0:
case IPC_SS_USSD_NO_ACTION_REQUIRE:
@@ -140,6 +143,9 @@ void ril_request_cancel_ussd(RIL_Token t, void *data, size_t length)
{
struct ipc_ss_ussd ussd;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, t))
+ return;
+
memset(&ussd, 0, sizeof(ussd));
ussd.state = IPC_SS_USSD_TERMINATED_BY_NET;
diff --git a/svc.c b/svc.c
index ae466b9..de60bcd 100644
--- a/svc.c
+++ b/svc.c
@@ -147,6 +147,9 @@ void ril_request_oem_hook_raw(RIL_Token token, void *data, int length)
if (data == NULL || length < (int) sizeof(RIL_OEMHookHeader))
goto error;
+ if (ril_radio_state_complete(RADIO_STATE_OFF, token))
+ return;
+
header = (RIL_OEMHookHeader *) data;
// Only SVC is supported