diff options
-rw-r--r-- | call.c | 63 | ||||
-rw-r--r-- | client.c | 13 | ||||
-rw-r--r-- | disp.c | 12 | ||||
-rw-r--r-- | gen.c | 6 | ||||
-rw-r--r-- | gprs.c | 99 | ||||
-rw-r--r-- | ipc.c | 92 | ||||
-rw-r--r-- | ipc.h | 2 | ||||
-rw-r--r-- | misc.c | 90 | ||||
-rw-r--r-- | net.c | 200 | ||||
-rw-r--r-- | pwr.c | 37 | ||||
-rw-r--r-- | rfs.c | 10 | ||||
-rw-r--r-- | samsung-ril.c | 434 | ||||
-rw-r--r-- | samsung-ril.h | 152 | ||||
-rw-r--r-- | sat.c | 16 | ||||
-rw-r--r-- | sec.c | 191 | ||||
-rw-r--r-- | sms.c | 40 | ||||
-rw-r--r-- | snd.c | 10 | ||||
-rw-r--r-- | srs.c | 10 | ||||
-rw-r--r-- | ss.c | 28 | ||||
-rw-r--r-- | util.c | 38 | ||||
-rw-r--r-- | util.h | 9 |
21 files changed, 858 insertions, 694 deletions
@@ -67,10 +67,10 @@ RIL_LastCallFailCause ipc2ril_call_fail_cause(unsigned char end_cause) */ void ipc_call_incoming(struct ipc_message_info *info) { - RIL_onUnsolicitedResponse(RIL_UNSOL_CALL_RING, NULL, 0); + ril_request_unsolicited(RIL_UNSOL_CALL_RING, NULL, 0); /* FIXME: Do we really need to send this? */ - RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0); + ril_request_unsolicited(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0); } /** @@ -85,11 +85,11 @@ void ipc_call_status(struct ipc_message_info *info) struct ipc_call_status *call_status = (struct ipc_call_status *) info->data; - memcpy(&(ril_state.call_status), call_status, sizeof(struct ipc_call_status)); + memcpy(&(ril_data.state.call_status), call_status, sizeof(struct ipc_call_status)); LOGD("Updating Call Status data"); - RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0); + ril_request_unsolicited(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0); } /** @@ -134,10 +134,10 @@ void ril_request_dial(RIL_Token t, void *data, size_t datalen) call.length = strlen(dial->address); memcpy(call.number, dial->address, strlen(dial->address)); - ipc_fmt_send(IPC_CALL_OUTGOING, IPC_TYPE_EXEC, (unsigned char *) &call, sizeof(call), reqGetId(t)); + ipc_fmt_send(IPC_CALL_OUTGOING, IPC_TYPE_EXEC, (unsigned char *) &call, sizeof(call), ril_request_get_id(t)); /* FIXME: This should actually be sent based on the response from baseband */ - RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + ril_request_complete(t, RIL_E_SUCCESS, NULL, 0); } /** @@ -149,7 +149,7 @@ void ril_request_dial(RIL_Token t, void *data, size_t datalen) */ void ril_request_get_current_calls(RIL_Token t) { - ipc_fmt_send_get(IPC_CALL_LIST, reqGetId(t)); + ipc_fmt_send_get(IPC_CALL_LIST, ril_request_get_id(t)); } /** @@ -171,7 +171,8 @@ void ipc_call_list(struct ipc_message_info *info) if(num_entries == 0) { // Don't bother with mem alloc - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, NULL, 0); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, NULL, 0); + return; } entry = (struct ipc_call_list_entry *) ((char *) info->data + 1); @@ -208,7 +209,7 @@ void ipc_call_list(struct ipc_message_info *info) entry = (struct ipc_call_list_entry *) (number + entry->number_len); } - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, calls, (num_entries * sizeof(RIL_Call *))); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, calls, (num_entries * sizeof(RIL_Call *))); for(i = 0; i < num_entries; i++) { free(calls[i]); @@ -225,13 +226,13 @@ void ipc_call_list(struct ipc_message_info *info) */ void ril_request_hangup(RIL_Token t) { - ipc_fmt_send_exec(IPC_CALL_RELEASE, reqGetId(t)); + ipc_fmt_send_exec(IPC_CALL_RELEASE, ril_request_get_id(t)); /* FIXME: This should actually be sent based on the response from baseband */ - RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + ril_request_complete(t, RIL_E_SUCCESS, NULL, 0); /* FIXME: Do we really need to send this? */ - RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0); + ril_request_unsolicited(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0); } /** @@ -242,13 +243,13 @@ void ril_request_hangup(RIL_Token t) */ void ril_request_answer(RIL_Token t) { - ipc_fmt_send_exec(IPC_CALL_ANSWER, reqGetId(t)); + ipc_fmt_send_exec(IPC_CALL_ANSWER, ril_request_get_id(t)); /* FIXME: This should actually be sent based on the response from baseband */ - RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + ril_request_complete(t, RIL_E_SUCCESS, NULL, 0); /* FIXME: Do we really need to send this? */ - RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0); + ril_request_unsolicited(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0); } /** @@ -259,14 +260,14 @@ void ril_request_last_call_fail_cause(RIL_Token t) { RIL_LastCallFailCause fail_cause; struct ipc_call_status *call_status = - &(ril_state.call_status); + &(ril_data.state.call_status); fail_cause = ipc2ril_call_fail_cause(call_status->end_cause); // Empty global call_status memset(call_status, 0, sizeof(struct ipc_call_status)); - RIL_onRequestComplete(t, RIL_E_SUCCESS, &fail_cause, sizeof(RIL_LastCallFailCause)); + ril_request_complete(t, RIL_E_SUCCESS, &fail_cause, sizeof(RIL_LastCallFailCause)); } /** @@ -287,13 +288,13 @@ void ril_request_dtmf(RIL_Token t, void *data, int length) unsigned char dtmf_count = 1; int i; - if(ril_state.dtmf_tone != 0) { + if(ril_data.state.dtmf_tone != 0) { LOGD("Another tone wasn't stopped, stopping that one before anything"); cont_dtmf.state = IPC_CALL_DTMF_STATE_STOP; cont_dtmf.tone = 0; - ipc_fmt_send(IPC_CALL_CONT_DTMF, IPC_TYPE_SET, (void *) &cont_dtmf, sizeof(cont_dtmf), reqGetId(t)); + ipc_fmt_send(IPC_CALL_CONT_DTMF, IPC_TYPE_SET, (void *) &cont_dtmf, sizeof(cont_dtmf), ril_request_get_id(t)); usleep(300); } @@ -313,9 +314,9 @@ void ril_request_dtmf(RIL_Token t, void *data, int length) memcpy(burst + 1 + sizeof(struct ipc_call_cont_dtmf) * i, &cont_dtmf, sizeof(cont_dtmf)); } - ipc_gen_phone_res_expect_to_abort(reqGetId(t), IPC_CALL_BURST_DTMF); + ipc_gen_phone_res_expect_to_abort(ril_request_get_id(t), IPC_CALL_BURST_DTMF); - ipc_fmt_send(IPC_CALL_BURST_DTMF, IPC_TYPE_EXEC, (void *) burst, burst_len, reqGetId(t)); + ipc_fmt_send(IPC_CALL_BURST_DTMF, IPC_TYPE_EXEC, (void *) burst, burst_len, ril_request_get_id(t)); free(burst); } @@ -328,23 +329,23 @@ void ipc_call_burst_dtmf(struct ipc_message_info *info) if(ret == 0) { LOGD("Apparently, something went wrong with DTMF burst"); - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); } - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, NULL, 0); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, NULL, 0); } void ril_request_dtmf_start(RIL_Token t, void *data, int length) { struct ipc_call_cont_dtmf cont_dtmf; - if(ril_state.dtmf_tone != 0) { + if(ril_data.state.dtmf_tone != 0) { LOGD("Another tone wasn't stopped, stopping that one before anything"); cont_dtmf.state = IPC_CALL_DTMF_STATE_STOP; cont_dtmf.tone = 0; - ipc_fmt_send(IPC_CALL_CONT_DTMF, IPC_TYPE_SET, (void *) &cont_dtmf, sizeof(cont_dtmf), reqGetId(t)); + ipc_fmt_send(IPC_CALL_CONT_DTMF, IPC_TYPE_SET, (void *) &cont_dtmf, sizeof(cont_dtmf), ril_request_get_id(t)); usleep(300); } @@ -352,11 +353,11 @@ void ril_request_dtmf_start(RIL_Token t, void *data, int length) cont_dtmf.state = IPC_CALL_DTMF_STATE_START; cont_dtmf.tone = ((unsigned char *)data)[0]; - ril_state.dtmf_tone = cont_dtmf.tone; + ril_data.state.dtmf_tone = cont_dtmf.tone; - ipc_gen_phone_res_expect_to_complete(reqGetId(t), IPC_CALL_CONT_DTMF); + ipc_gen_phone_res_expect_to_complete(ril_request_get_id(t), IPC_CALL_CONT_DTMF); - ipc_fmt_send(IPC_CALL_CONT_DTMF, IPC_TYPE_SET, (void *) &cont_dtmf, sizeof(cont_dtmf), reqGetId(t)); + ipc_fmt_send(IPC_CALL_CONT_DTMF, IPC_TYPE_SET, (void *) &cont_dtmf, sizeof(cont_dtmf), ril_request_get_id(t)); } void ril_request_dtmf_stop(RIL_Token t) @@ -365,9 +366,9 @@ void ril_request_dtmf_stop(RIL_Token t) cont_dtmf.state = IPC_CALL_DTMF_STATE_STOP; cont_dtmf.tone = 0; - ril_state.dtmf_tone = 0; + ril_data.state.dtmf_tone = 0; - ipc_gen_phone_res_expect_to_complete(reqGetId(t), IPC_CALL_CONT_DTMF); + ipc_gen_phone_res_expect_to_complete(ril_request_get_id(t), IPC_CALL_CONT_DTMF); - ipc_fmt_send(IPC_CALL_CONT_DTMF, IPC_TYPE_SET, (void *) &cont_dtmf, sizeof(cont_dtmf), reqGetId(t)); + ipc_fmt_send(IPC_CALL_CONT_DTMF, IPC_TYPE_SET, (void *) &cont_dtmf, sizeof(cont_dtmf), ril_request_get_id(t)); } @@ -38,13 +38,13 @@ struct ril_client *ril_client_new(struct ril_client_funcs *client_funcs) memset(ril_client, 0, sizeof(struct ril_client)); if(client_funcs->create) - ril_client->create = client_funcs->create; + ril_client->funcs.create = client_funcs->create; if(client_funcs->destroy) - ril_client->destroy = client_funcs->destroy; + ril_client->funcs.destroy = client_funcs->destroy; if(client_funcs->read_loop) - ril_client->read_loop = client_funcs->read_loop; + ril_client->funcs.read_loop = client_funcs->read_loop; pthread_mutex_init(&(ril_client->mutex), NULL); @@ -56,7 +56,6 @@ int ril_client_free(struct ril_client *client) pthread_mutex_destroy(&(client->mutex)); free(client); - client = NULL; return 0; } @@ -69,7 +68,7 @@ int ril_client_create(struct ril_client *client) for(c = 10 ; c > 0 ; c--) { LOGD("Creating RIL client inners, try #%d", 11-c); - rc = client->create(client); + rc = client->funcs.create(client); if(rc < 0) LOGD("RIL client inners creation failed!"); @@ -97,7 +96,7 @@ int ril_client_destroy(struct ril_client *client) for(c = 5 ; c > 0 ; c--) { LOGD("Destroying RIL client inners, try #%d", 6-c); - rc = client->destroy(client); + rc = client->funcs.destroy(client); if(rc < 0) LOGD("RIL client inners destroying failed!"); @@ -134,7 +133,7 @@ void *ril_client_thread(void *data) for(c = 5 ; c > 0 ; c--) { client->state = RIL_CLIENT_READY; - rc = client->read_loop(client); + rc = client->funcs.read_loop(client); if(rc < 0) { client->state = RIL_CLIENT_ERROR; @@ -59,7 +59,7 @@ void ril_request_signal_strength(RIL_Token t) { unsigned char request = 1; - ipc_fmt_send(IPC_DISP_ICON_INFO, IPC_TYPE_GET, &request, sizeof(request), reqGetId(t)); + ipc_fmt_send(IPC_DISP_ICON_INFO, IPC_TYPE_GET, &request, sizeof(request), ril_request_get_id(t)); } void ipc_disp_icon_info(struct ipc_message_info *info) @@ -68,7 +68,7 @@ void ipc_disp_icon_info(struct ipc_message_info *info) RIL_SignalStrength ss; /* Don't consider this if modem isn't in normal power mode. */ - if(ril_state.power_mode < POWER_MODE_NORMAL) + if(ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) return; if(info->type == IPC_TYPE_NOTI && icon_info->rssi == 0xff) @@ -78,10 +78,10 @@ void ipc_disp_icon_info(struct ipc_message_info *info) if(info->type == IPC_TYPE_NOTI) { LOGD("Unsol request!"); - RIL_onUnsolicitedResponse(RIL_UNSOL_SIGNAL_STRENGTH, &ss, sizeof(ss)); + ril_request_unsolicited(RIL_UNSOL_SIGNAL_STRENGTH, &ss, sizeof(ss)); } else if(info->type == IPC_TYPE_RESP) { LOGD("Sol request!"); - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, &ss, sizeof(ss)); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, &ss, sizeof(ss)); } } @@ -92,10 +92,10 @@ void ipc_disp_rssi_info(struct ipc_message_info *info) int rssi; /* Don't consider this if modem isn't in normal power mode. */ - if(ril_state.power_mode < POWER_MODE_NORMAL) + if(ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) return; ipc2ril_rssi(rssi_info->rssi, &ss); - RIL_onUnsolicitedResponse(RIL_UNSOL_SIGNAL_STRENGTH, &ss, sizeof(ss)); + ril_request_unsolicited(RIL_UNSOL_SIGNAL_STRENGTH, &ss, sizeof(ss)); } @@ -48,7 +48,7 @@ int ipc_gen_phone_res_id = 0; * * On a custom function, don't forget to get a clean new aseq if you're going to * send some data to the modem, just liek this: - * aseq = ril_request_reg_id(reqGetToken(info->aseq)); + * aseq = ril_request_reg_id(ril_request_get_token(info->aseq)); * * Please use GEN_PHONE_RES engine as often as possible! */ @@ -152,7 +152,7 @@ void ipc_gen_phone_res(struct ipc_message_info *info) if(ipc_gen_phone_res_expects[id].func != NULL) { LOGE("Not safe to run the custom function, reporting generic failure"); - RIL_onRequestComplete(reqGetToken(ipc_gen_phone_res_expects[id].aseq), RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(ril_request_get_token(ipc_gen_phone_res_expects[id].aseq), RIL_E_GENERIC_FAILURE, NULL, 0); } } @@ -169,7 +169,7 @@ void ipc_gen_phone_res(struct ipc_message_info *info) e = RIL_E_SUCCESS; if(ipc_gen_phone_res_expects[id].to_complete || (ipc_gen_phone_res_expects[id].to_abort && rc < 0)) { - RIL_onRequestComplete(reqGetToken(ipc_gen_phone_res_expects[id].aseq), e, NULL, 0); + ril_request_complete(ril_request_get_token(ipc_gen_phone_res_expects[id].aseq), e, NULL, 0); ipc_gen_phone_res_clean_id(id); return; } @@ -88,7 +88,7 @@ void ril_gprs_connections_init(void) struct ipc_client *ipc_client; int ril_gprs_connections_size = 0; - ipc_client = ((struct ipc_client_object *) ipc_fmt_client->object)->ipc_client; + ipc_client = ((struct ipc_client_data *) ril_data.ipc_fmt_client->data)->ipc_client; ipc_client_gprs_get_capabilities(ipc_client, &gprs_capabilities); ril_gprs_connections_size = @@ -195,12 +195,12 @@ void ipc_gprs_pdp_context_enable_complete(struct ipc_message_info *info) struct ril_gprs_connection *gprs_connection; int rc; - gprs_connection = ril_gprs_connection_get_token(reqGetToken(info->aseq)); + gprs_connection = ril_gprs_connection_get_token(ril_request_get_token(info->aseq)); if(!gprs_connection) { LOGE("Unable to find GPRS connection, aborting"); - RIL_onRequestComplete(reqGetToken(info->aseq), + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); return; } @@ -211,9 +211,9 @@ void ipc_gprs_pdp_context_enable_complete(struct ipc_message_info *info) gprs_connection->fail_cause = PDP_FAIL_ERROR_UNSPECIFIED; gprs_connection->token = (RIL_Token) 0x00; - ril_state.gprs_last_failed_cid = gprs_connection->cid; + ril_data.state.gprs_last_failed_cid = gprs_connection->cid; - RIL_onRequestComplete(reqGetToken(info->aseq), + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); return; } @@ -225,15 +225,16 @@ void ipc_gprs_define_pdp_context_complete(struct ipc_message_info *info) { struct ipc_gen_phone_res *phone_res = (struct ipc_gen_phone_res *) info->data; struct ril_gprs_connection *gprs_connection; + struct ril_request_info *request; int aseq; int rc; - gprs_connection = ril_gprs_connection_get_token(reqGetToken(info->aseq)); + gprs_connection = ril_gprs_connection_get_token(ril_request_get_token(info->aseq)); if(!gprs_connection) { LOGE("Unable to find GPRS connection, aborting"); - RIL_onRequestComplete(reqGetToken(info->aseq), + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); return; } @@ -244,15 +245,18 @@ void ipc_gprs_define_pdp_context_complete(struct ipc_message_info *info) gprs_connection->fail_cause = PDP_FAIL_ERROR_UNSPECIFIED; gprs_connection->token = (RIL_Token) 0x00; - ril_state.gprs_last_failed_cid = gprs_connection->cid; + ril_data.state.gprs_last_failed_cid = gprs_connection->cid; - RIL_onRequestComplete(reqGetToken(info->aseq), + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); return; } - // We need to get a clean new aseq here - aseq = ril_request_reg_id(reqGetToken(info->aseq)); + request = ril_request_info_find_id(info->aseq); + aseq = ril_request_id_get(); + + if(request != NULL) + request->id = aseq; ipc_gen_phone_res_expect_to_func(aseq, IPC_GPRS_PDP_CONTEXT, ipc_gprs_pdp_context_enable_complete); @@ -266,15 +270,16 @@ void ipc_gprs_port_list_complete(struct ipc_message_info *info) { struct ipc_gen_phone_res *phone_res = (struct ipc_gen_phone_res *) info->data; struct ril_gprs_connection *gprs_connection; + struct ril_request_info *request; int rc; int aseq; - gprs_connection = ril_gprs_connection_get_token(reqGetToken(info->aseq)); + gprs_connection = ril_gprs_connection_get_token(ril_request_get_token(info->aseq)); if(!gprs_connection) { LOGE("Unable to find GPRS connection, aborting"); - RIL_onRequestComplete(reqGetToken(info->aseq), + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); return; } @@ -285,16 +290,18 @@ void ipc_gprs_port_list_complete(struct ipc_message_info *info) gprs_connection->fail_cause = PDP_FAIL_ERROR_UNSPECIFIED; gprs_connection->token = (RIL_Token) 0x00; - ril_state.gprs_last_failed_cid = gprs_connection->cid; + ril_data.state.gprs_last_failed_cid = gprs_connection->cid; - RIL_onRequestComplete(reqGetToken(info->aseq), + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); return; } - // We need to get a clean new aseq here - aseq = ril_request_reg_id(reqGetToken(info->aseq)); + request = ril_request_info_find_id(info->aseq); + aseq = ril_request_id_get(); + if(request != NULL) + request->id = aseq; ipc_gen_phone_res_expect_to_func(aseq, IPC_GPRS_DEFINE_PDP_CONTEXT, ipc_gprs_define_pdp_context_complete); @@ -315,7 +322,7 @@ void ril_request_setup_data_call(RIL_Token t, void *data, int length) char *password = NULL; char *apn = NULL; - ipc_client = ((struct ipc_client_object *) ipc_fmt_client->object)->ipc_client; + ipc_client = ((struct ipc_client_data *) ril_data.ipc_fmt_client->data)->ipc_client; apn = ((char **) data)[2]; username = ((char **) data)[3]; @@ -328,7 +335,7 @@ void ril_request_setup_data_call(RIL_Token t, void *data, int length) if(!gprs_connection) { LOGE("Unable to create GPRS connection, aborting"); - RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); return; } @@ -348,18 +355,18 @@ void ril_request_setup_data_call(RIL_Token t, void *data, int length) if(gprs_capabilities.port_list) { ipc_gprs_port_list_setup(&port_list); - ipc_gen_phone_res_expect_to_func(reqGetId(t), IPC_GPRS_PORT_LIST, + ipc_gen_phone_res_expect_to_func(ril_request_get_id(t), IPC_GPRS_PORT_LIST, ipc_gprs_port_list_complete); ipc_fmt_send(IPC_GPRS_PORT_LIST, IPC_TYPE_SET, - (void *) &port_list, sizeof(struct ipc_gprs_port_list), reqGetId(t)); + (void *) &port_list, sizeof(struct ipc_gprs_port_list), ril_request_get_id(t)); } else { - ipc_gen_phone_res_expect_to_func(reqGetId(t), IPC_GPRS_DEFINE_PDP_CONTEXT, + ipc_gen_phone_res_expect_to_func(ril_request_get_id(t), IPC_GPRS_DEFINE_PDP_CONTEXT, ipc_gprs_define_pdp_context_complete); ipc_fmt_send(IPC_GPRS_DEFINE_PDP_CONTEXT, IPC_TYPE_SET, (void *) &(gprs_connection->define_context), - sizeof(struct ipc_gprs_define_pdp_context), reqGetId(t)); + sizeof(struct ipc_gprs_define_pdp_context), ril_request_get_id(t)); } } @@ -374,7 +381,7 @@ void ipc_gprs_ip_configuration(struct ipc_message_info *info) if(!gprs_connection) { LOGE("Unable to find GPRS connection, aborting"); - RIL_onRequestComplete(reqGetToken(info->aseq), + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); return; } @@ -394,12 +401,12 @@ void ipc_gprs_pdp_context_disable_complete(struct ipc_message_info *info) struct ril_gprs_connection *gprs_connection; int rc; - gprs_connection = ril_gprs_connection_get_token(reqGetToken(info->aseq)); + gprs_connection = ril_gprs_connection_get_token(ril_request_get_token(info->aseq)); if(!gprs_connection) { LOGE("Unable to find GPRS connection, aborting"); - RIL_onRequestComplete(reqGetToken(info->aseq), + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); return; } @@ -411,7 +418,7 @@ void ipc_gprs_pdp_context_disable_complete(struct ipc_message_info *info) // RILJ is not going to ask for fail reason ril_gprs_connection_del(gprs_connection); - RIL_onRequestComplete(reqGetToken(info->aseq), + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); return; } @@ -432,7 +439,7 @@ void ril_request_deactivate_data_call(RIL_Token t, void *data, int length) if(!gprs_connection) { LOGE("Unable to find GPRS connection, aborting"); - RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); return; } @@ -440,11 +447,11 @@ void ril_request_deactivate_data_call(RIL_Token t, void *data, int length) ipc_gprs_pdp_context_setup(&context, gprs_connection->cid, 0, NULL, NULL); - ipc_gen_phone_res_expect_to_func(reqGetId(t), IPC_GPRS_PDP_CONTEXT, + ipc_gen_phone_res_expect_to_func(ril_request_get_id(t), IPC_GPRS_PDP_CONTEXT, ipc_gprs_pdp_context_disable_complete); ipc_fmt_send(IPC_GPRS_PDP_CONTEXT, IPC_TYPE_SET, - (void *) &context, sizeof(struct ipc_gprs_pdp_context_set), reqGetId(t)); + (void *) &context, sizeof(struct ipc_gprs_pdp_context_set), ril_request_get_id(t)); } #if RIL_VERSION >= 6 @@ -470,7 +477,7 @@ int ipc_gprs_connection_enable(struct ril_gprs_connection *gprs_connection, int rc; - ipc_client = ((struct ipc_client_object *) ipc_fmt_client->object)->ipc_client; + ipc_client = ((struct ipc_client_data *) ril_data.ipc_fmt_client->data)->ipc_client; ip_configuration = &(gprs_connection->ip_configuration); @@ -586,7 +593,7 @@ int ipc_gprs_connection_disable(struct ril_gprs_connection *gprs_connection) char *interface; int rc; - ipc_client = ((struct ipc_client_object *) ipc_fmt_client->object)->ipc_client; + ipc_client = ((struct ipc_client_data *) ril_data.ipc_fmt_client->data)->ipc_client; if(gprs_connection->interface == NULL) { interface = ipc_client_gprs_get_iface(ipc_client, gprs_connection->cid); @@ -670,7 +677,7 @@ void ipc_gprs_call_status(struct ipc_message_info *info) if(!gprs_connection) { LOGE("Unable to find GPRS connection, aborting"); - RIL_onRequestComplete(reqGetToken(info->aseq), + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); return; } @@ -688,16 +695,16 @@ void ipc_gprs_call_status(struct ipc_message_info *info) gprs_connection->enabled = 0; gprs_connection->fail_cause = PDP_FAIL_ERROR_UNSPECIFIED; - ril_state.gprs_last_failed_cid = gprs_connection->cid; + ril_data.state.gprs_last_failed_cid = gprs_connection->cid; - RIL_onRequestComplete(gprs_connection->token, + ril_request_complete(gprs_connection->token, RIL_E_GENERIC_FAILURE, NULL, 0); } else { LOGD("GPRS interface enabled"); gprs_connection->enabled = 1; - RIL_onRequestComplete(gprs_connection->token, + ril_request_complete(gprs_connection->token, RIL_E_SUCCESS, &setup_data_call_response, sizeof(setup_data_call_response)); gprs_connection->token = (RIL_Token) 0x00; @@ -721,7 +728,7 @@ void ipc_gprs_call_status(struct ipc_message_info *info) if(rc < 0) { LOGE("Failed to disable GPRS interface"); - RIL_onRequestComplete(gprs_connection->token, + ril_request_complete(gprs_connection->token, RIL_E_GENERIC_FAILURE, NULL, 0); // RILJ is not going to ask for fail reason @@ -731,7 +738,7 @@ void ipc_gprs_call_status(struct ipc_message_info *info) gprs_connection->enabled = 0; - RIL_onRequestComplete(gprs_connection->token, + ril_request_complete(gprs_connection->token, RIL_E_SUCCESS, NULL, 0); ril_gprs_connection_del(gprs_connection); @@ -753,9 +760,9 @@ void ipc_gprs_call_status(struct ipc_message_info *info) gprs_connection->enabled = 0; gprs_connection->fail_cause = ipc2ril_gprs_fail_cause(call_status->fail_cause); - ril_state.gprs_last_failed_cid = gprs_connection->cid; + ril_data.state.gprs_last_failed_cid = gprs_connection->cid; - RIL_onRequestComplete(gprs_connection->token, + ril_request_complete(gprs_connection->token, RIL_E_GENERIC_FAILURE, NULL, 0); gprs_connection->token = (RIL_Token) 0x00; @@ -794,7 +801,7 @@ void ril_request_last_data_call_fail_cause(RIL_Token t) int last_failed_cid; int fail_cause; - last_failed_cid = ril_state.gprs_last_failed_cid; + last_failed_cid = ril_data.state.gprs_last_failed_cid; if(!last_failed_cid) { LOGE("No GPRS connection was reported to have failed"); @@ -821,8 +828,8 @@ fail_cause_unspecified: fail_cause = PDP_FAIL_ERROR_UNSPECIFIED; fail_cause_return: - ril_state.gprs_last_failed_cid = 0; - RIL_onRequestComplete(t, RIL_E_SUCCESS, &fail_cause, sizeof(fail_cause)); + ril_data.state.gprs_last_failed_cid = 0; + ril_request_complete(t, RIL_E_SUCCESS, &fail_cause, sizeof(fail_cause)); } /* @@ -928,10 +935,10 @@ void ipc_gprs_pdp_context(struct ipc_message_info *info) ipc_gprs_pdp_context_fix(data_call_list, IPC_GPRS_PDP_CONTEXT_GET_DESC_COUNT); if(info->aseq == 0xff) - RIL_onUnsolicitedResponse(RIL_UNSOL_DATA_CALL_LIST_CHANGED, + ril_request_unsolicited(RIL_UNSOL_DATA_CALL_LIST_CHANGED, &data_call_list, sizeof(data_call_list)); else - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, &data_call_list, sizeof(data_call_list)); for(i = 0; i < IPC_GPRS_PDP_CONTEXT_GET_DESC_COUNT; i++) { @@ -946,5 +953,5 @@ void ril_unsol_data_call_list_changed(void) void ril_request_data_call_list(RIL_Token t) { - ipc_fmt_send_get(IPC_GPRS_PDP_CONTEXT, reqGetId(t)); + ipc_fmt_send_get(IPC_GPRS_PDP_CONTEXT, ril_request_get_id(t)); } @@ -42,21 +42,21 @@ void ipc_fmt_send(const unsigned short command, const char type, unsigned char * { struct ipc_client *ipc_client; - if(ipc_fmt_client == NULL) { + if(ril_data.ipc_fmt_client == NULL) { LOGE("ipc_fmt_client is null, aborting!"); return; } - if(ipc_fmt_client->object == NULL) { - LOGE("ipc_fmt_client object is null, aborting!"); + if(ril_data.ipc_fmt_client->data == NULL) { + LOGE("ipc_fmt_client data is null, aborting!"); return; } - ipc_client = ((struct ipc_client_object *) ipc_fmt_client->object)->ipc_client; + ipc_client = ((struct ipc_client_data *) ril_data.ipc_fmt_client->data)->ipc_client; - RIL_CLIENT_LOCK(ipc_fmt_client); + RIL_CLIENT_LOCK(ril_data.ipc_fmt_client); ipc_client_send(ipc_client, command, type, data, length, mseq); - RIL_CLIENT_UNLOCK(ipc_fmt_client); + RIL_CLIENT_UNLOCK(ril_data.ipc_fmt_client); } int ipc_fmt_read_loop(struct ril_client *client) @@ -71,13 +71,13 @@ int ipc_fmt_read_loop(struct ril_client *client) return -1; } - if(client->object == NULL) { - LOGE("client object is NULL, aborting!"); + if(client->data == NULL) { + LOGE("client data is NULL, aborting!"); return -1; } - ipc_client = ((struct ipc_client_object *) client->object)->ipc_client; - ipc_client_fd = ((struct ipc_client_object *) client->object)->ipc_client_fd; + ipc_client = ((struct ipc_client_data *) client->data)->ipc_client; + ipc_client_fd = ((struct ipc_client_data *) client->data)->ipc_client_fd; FD_ZERO(&fds); FD_SET(ipc_client_fd, &fds); @@ -111,18 +111,18 @@ int ipc_fmt_read_loop(struct ril_client *client) int ipc_fmt_create(struct ril_client *client) { - struct ipc_client_object *client_object; + struct ipc_client_data *client_data; struct ipc_client *ipc_client; int ipc_client_fd; int rc; - client_object = malloc(sizeof(struct ipc_client_object)); - memset(client_object, 0, sizeof(struct ipc_client_object)); - client_object->ipc_client_fd = -1; + client_data = malloc(sizeof(struct ipc_client_data)); + memset(client_data, 0, sizeof(struct ipc_client_data)); + client_data->ipc_client_fd = -1; - client->object = client_object; + client->data = client_data; - ipc_client = (struct ipc_client *) client_object->ipc_client; + ipc_client = (struct ipc_client *) client_data->ipc_client; LOGD("Creating new FMT client"); ipc_client = ipc_client_new(IPC_CLIENT_TYPE_FMT); @@ -132,7 +132,7 @@ int ipc_fmt_create(struct ril_client *client) return -1; } - client_object->ipc_client = ipc_client; + client_data->ipc_client = ipc_client; LOGD("Setting log handler"); rc = ipc_client_set_log_handler(ipc_client, ipc_log_handler, NULL); @@ -170,7 +170,7 @@ int ipc_fmt_create(struct ril_client *client) LOGD("Obtaining ipc_client_fd"); ipc_client_fd = ipc_client_get_handlers_common_data_fd(ipc_client); - client_object->ipc_client_fd = ipc_client_fd; + client_data->ipc_client_fd = ipc_client_fd; if(ipc_client_fd < 0) { LOGE("%s: client_fmt_fd is negative, aborting", __FUNCTION__); @@ -201,17 +201,17 @@ int ipc_fmt_destroy(struct ril_client *client) return 0; } - if(client->object == NULL) { - LOGE("client object was already destroyed"); + if(client->data == NULL) { + LOGE("client data was already destroyed"); return 0; } - ipc_client_fd = ((struct ipc_client_object *) client->object)->ipc_client_fd; + ipc_client_fd = ((struct ipc_client_data *) client->data)->ipc_client_fd; if(ipc_client_fd) close(ipc_client_fd); - ipc_client = ((struct ipc_client_object *) client->object)->ipc_client; + ipc_client = ((struct ipc_client_data *) client->data)->ipc_client; if(ipc_client != NULL) { ipc_client_destroy_handlers_common_data(ipc_client); @@ -220,7 +220,7 @@ int ipc_fmt_destroy(struct ril_client *client) ipc_client_free(ipc_client); } - free(client->object); + free(client->data); return 0; } @@ -233,21 +233,21 @@ void ipc_rfs_send(const unsigned short command, unsigned char *data, const int l { struct ipc_client *ipc_client; - if(ipc_rfs_client == NULL) { + if(ril_data.ipc_rfs_client == NULL) { LOGE("ipc_rfs_client is null, aborting!"); return; } - if(ipc_rfs_client->object == NULL) { - LOGE("ipc_rfs_client object is null, aborting!"); + if(ril_data.ipc_rfs_client->data == NULL) { + LOGE("ipc_rfs_client data is null, aborting!"); return; } - ipc_client = ((struct ipc_client_object *) ipc_rfs_client->object)->ipc_client; + ipc_client = ((struct ipc_client_data *) ril_data.ipc_rfs_client->data)->ipc_client; - RIL_CLIENT_LOCK(ipc_rfs_client); + RIL_CLIENT_LOCK(ril_data.ipc_rfs_client); ipc_client_send(ipc_client, command, 0, data, length, mseq); - RIL_CLIENT_UNLOCK(ipc_rfs_client); + RIL_CLIENT_UNLOCK(ril_data.ipc_rfs_client); } int ipc_rfs_read_loop(struct ril_client *client) @@ -262,13 +262,13 @@ int ipc_rfs_read_loop(struct ril_client *client) return -1; } - if(client->object == NULL) { - LOGE("client object is NULL, aborting!"); + if(client->data == NULL) { + LOGE("client data is NULL, aborting!"); return -1; } - ipc_client = ((struct ipc_client_object *) client->object)->ipc_client; - ipc_client_fd = ((struct ipc_client_object *) client->object)->ipc_client_fd; + ipc_client = ((struct ipc_client_data *) client->data)->ipc_client; + ipc_client_fd = ((struct ipc_client_data *) client->data)->ipc_client_fd; FD_ZERO(&fds); FD_SET(ipc_client_fd, &fds); @@ -302,18 +302,18 @@ int ipc_rfs_read_loop(struct ril_client *client) int ipc_rfs_create(struct ril_client *client) { - struct ipc_client_object *client_object; + struct ipc_client_data *client_data; struct ipc_client *ipc_client; int ipc_client_fd; int rc; - client_object = malloc(sizeof(struct ipc_client_object)); - memset(client_object, 0, sizeof(struct ipc_client_object)); - client_object->ipc_client_fd = -1; + client_data = malloc(sizeof(struct ipc_client_data)); + memset(client_data, 0, sizeof(struct ipc_client_data)); + client_data->ipc_client_fd = -1; - client->object = client_object; + client->data = client_data; - ipc_client = (struct ipc_client *) client_object->ipc_client; + ipc_client = (struct ipc_client *) client_data->ipc_client; LOGD("Creating new RFS client"); ipc_client = ipc_client_new(IPC_CLIENT_TYPE_RFS); @@ -323,7 +323,7 @@ int ipc_rfs_create(struct ril_client *client) return -1; } - client_object->ipc_client = ipc_client; + client_data->ipc_client = ipc_client; LOGD("Setting log handler"); rc = ipc_client_set_log_handler(ipc_client, ipc_log_handler, NULL); @@ -353,7 +353,7 @@ int ipc_rfs_create(struct ril_client *client) LOGD("Obtaining ipc_client_fd"); ipc_client_fd = ipc_client_get_handlers_common_data_fd(ipc_client); - client_object->ipc_client_fd = ipc_client_fd; + client_data->ipc_client_fd = ipc_client_fd; if(ipc_client_fd < 0) { LOGE("%s: client_rfs_fd is negative, aborting", __FUNCTION__); @@ -379,17 +379,17 @@ int ipc_rfs_destroy(struct ril_client *client) return 0; } - if(client->object == NULL) { - LOGE("client object was already destroyed"); + if(client->data == NULL) { + LOGE("client data was already destroyed"); return 0; } - ipc_client_fd = ((struct ipc_client_object *) client->object)->ipc_client_fd; + ipc_client_fd = ((struct ipc_client_data *) client->data)->ipc_client_fd; if(ipc_client_fd) close(ipc_client_fd); - ipc_client = ((struct ipc_client_object *) client->object)->ipc_client; + ipc_client = ((struct ipc_client_data *) client->data)->ipc_client; if(ipc_client != NULL) { ipc_client_destroy_handlers_common_data(ipc_client); @@ -397,7 +397,7 @@ int ipc_rfs_destroy(struct ril_client *client) ipc_client_free(ipc_client); } - free(client->object); + free(client->data); return 0; } @@ -33,7 +33,7 @@ #define ipc_fmt_send_exec(command, mseq) \ ipc_fmt_send(command, IPC_TYPE_EXEC, NULL, 0, mseq) -struct ipc_client_object { +struct ipc_client_data { struct ipc_client *ipc_client; int ipc_client_fd; }; @@ -31,24 +31,24 @@ void ril_request_get_imei_send(RIL_Token t) data = IPC_MISC_ME_SN_SERIAL_NUM; ipc_fmt_send(IPC_MISC_ME_SN, IPC_TYPE_GET, - (unsigned char *) &data, sizeof(data), reqGetId(t)); + (unsigned char *) &data, sizeof(data), ril_request_get_id(t)); } void ril_request_get_imei(RIL_Token t) { - if(ril_state.tokens.get_imei) { + if(ril_data.tokens.get_imei) { LOGD("Another IMEI request is waiting, aborting"); - RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); return; } - ril_state.tokens.get_imei = t; + ril_data.tokens.get_imei = t; - if(ril_state.tokens.get_imeisv) { - LOGD("IMEISV token found: 0x%p", ril_state.tokens.get_imeisv); + if(ril_data.tokens.get_imeisv) { + LOGD("IMEISV token found: %p", ril_data.tokens.get_imeisv); - if(ril_state.radio_state != RADIO_STATE_OFF) { - ril_request_get_imei_send(ril_state.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"); } @@ -59,19 +59,19 @@ void ril_request_get_imei(RIL_Token t) void ril_request_get_imeisv(RIL_Token t) { - if(ril_state.tokens.get_imeisv) { + if(ril_data.tokens.get_imeisv) { LOGD("Another IMEISV request is waiting, aborting"); - RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); return; } - ril_state.tokens.get_imeisv = t; + ril_data.tokens.get_imeisv = t; - if(ril_state.tokens.get_imei) { - LOGD("IMEI token found: 0x%p", ril_state.tokens.get_imei); + if(ril_data.tokens.get_imei) { + LOGD("IMEI token found: %p", ril_data.tokens.get_imei); - if(ril_state.radio_state != RADIO_STATE_OFF) { - ril_request_get_imei_send(ril_state.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"); } @@ -88,9 +88,9 @@ void ipc_misc_me_sn_imei(RIL_Token t, void *data, int length) imei_info = (struct ipc_misc_me_sn *) data; - if(ril_state.tokens.get_imei != t) - LOGE("IMEI tokens mismatch (0x%p and 0x%p)", - ril_state.tokens.get_imei, t); + if(ril_data.tokens.get_imei != t) + LOGE("IMEI tokens mismatch (%p and %p)", + ril_data.tokens.get_imei, t); if(imei_info->length > 32) return; @@ -104,22 +104,22 @@ void ipc_misc_me_sn_imei(RIL_Token t, void *data, int length) memcpy(imeisv, (imei_info->data + imei_info->length - 2), 2); // In case of token mismatch, complete both requests - if(t && ril_state.tokens.get_imei != t) { - RIL_onRequestComplete(t, RIL_E_SUCCESS, imei, sizeof(char *)); + if(t && ril_data.tokens.get_imei != t) { + ril_request_complete(t, RIL_E_SUCCESS, imei, sizeof(char *)); } // IMEI - if(ril_state.tokens.get_imei) { - RIL_onRequestComplete(ril_state.tokens.get_imei, + if(ril_data.tokens.get_imei) { + ril_request_complete(ril_data.tokens.get_imei, RIL_E_SUCCESS, imei, sizeof(char *)); - ril_state.tokens.get_imei = 0; + ril_data.tokens.get_imei = 0; } // IMEI SV - if(ril_state.tokens.get_imeisv) { - RIL_onRequestComplete(ril_state.tokens.get_imeisv, + if(ril_data.tokens.get_imeisv) { + ril_request_complete(ril_data.tokens.get_imeisv, RIL_E_SUCCESS, imeisv, sizeof(char *)); - ril_state.tokens.get_imeisv = 0; + ril_data.tokens.get_imeisv = 0; } } @@ -129,7 +129,7 @@ void ipc_misc_me_sn(struct ipc_message_info *info) switch(me_sn_info->type) { case IPC_MISC_ME_SN_SERIAL_NUM: - ipc_misc_me_sn_imei(reqGetToken(info->aseq), info->data, info->length); + ipc_misc_me_sn_imei(ril_request_get_token(info->aseq), info->data, info->length); break; case IPC_MISC_ME_SN_SERIAL_NUM_SERIAL: LOGD("Got IPC_MISC_ME_SN_SERIAL_NUM_SERIAL: %s\n", @@ -141,19 +141,19 @@ void ipc_misc_me_sn(struct ipc_message_info *info) void ril_request_baseband_version(RIL_Token t) { unsigned char data; - if(ril_state.tokens.baseband_version) { + if(ril_data.tokens.baseband_version) { LOGD("Another Baseband version request is waiting, aborting"); - RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); return; } - ril_state.tokens.baseband_version = t; + ril_data.tokens.baseband_version = t; - if(ril_state.radio_state != RADIO_STATE_OFF) { + if(ril_data.state.radio_state != RADIO_STATE_OFF) { data = 0xff; ipc_fmt_send(IPC_MISC_ME_VERSION, IPC_TYPE_GET, - (unsigned char *) &data, sizeof(data), reqGetId(t)); + (unsigned char *) &data, sizeof(data), ril_request_get_id(t)); } } @@ -162,18 +162,18 @@ void ipc_misc_me_version(struct ipc_message_info *info) char sw_version[33]; struct ipc_misc_me_version *version = (struct ipc_misc_me_version *) info->data; - RIL_Token t = reqGetToken(info->aseq); + RIL_Token t = ril_request_get_token(info->aseq); - if(ril_state.tokens.baseband_version != t) - LOGE("Baseband tokens mismatch (0x%p and 0x%p)", - ril_state.tokens.baseband_version, t); + if(ril_data.tokens.baseband_version != t) + LOGE("Baseband tokens mismatch (%p and %p)", + ril_data.tokens.baseband_version, t); memcpy(sw_version, version->sw_version, 32); sw_version[32] = '\0'; - RIL_onRequestComplete(t, RIL_E_SUCCESS, sw_version, sizeof(sw_version)); - ril_state.tokens.baseband_version = 0; + ril_request_complete(t, RIL_E_SUCCESS, sw_version, sizeof(sw_version)); + ril_data.tokens.baseband_version = 0; } /** @@ -186,7 +186,7 @@ void ipc_misc_me_version(struct ipc_message_info *info) */ void ril_request_get_imsi(RIL_Token t) { - ipc_fmt_send_get(IPC_MISC_ME_IMSI, reqGetId(t)); + ipc_fmt_send_get(IPC_MISC_ME_IMSI, ril_request_get_id(t)); } /** @@ -202,9 +202,13 @@ void ipc_misc_me_imsi(struct ipc_message_info *info) unsigned char *imsi_length; char *imsi; + /* Don't consider this if modem isn't in normal power mode. */ + if(ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) + return; + if(info->length < 1) { LOGE("%s: zero data length", __FUNCTION__); - RIL_onRequestComplete(reqGetToken(info->aseq), + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); return; } @@ -213,7 +217,7 @@ void ipc_misc_me_imsi(struct ipc_message_info *info) if(((int) info->length) < *imsi_length + 1) { LOGE("%s: missing IMSI data", __FUNCTION__); - RIL_onRequestComplete(reqGetToken(info->aseq), + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); return; } @@ -223,7 +227,7 @@ void ipc_misc_me_imsi(struct ipc_message_info *info) memcpy(imsi, ((unsigned char*) info->data) + 1, *imsi_length); imsi[*imsi_length] = '\0'; - RIL_onRequestComplete(reqGetToken(info->aseq), + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, imsi, *imsi_length+1); } @@ -236,6 +240,6 @@ void ipc_misc_time_info(struct ipc_message_info *info) nitz->year, nitz->mon, nitz->day, nitz->hour, nitz->min, nitz->sec, nitz->tz, 0); - RIL_onUnsolicitedResponse(RIL_UNSOL_NITZ_TIME_RECEIVED, + ril_request_unsolicited(RIL_UNSOL_NITZ_TIME_RECEIVED, str, strlen(str) + 1); } @@ -198,9 +198,9 @@ void ipc2ril_gprs_reg_state_resp(struct ipc_net_regist_response *netinfo, char * */ void ril_tokens_net_set_data_waiting(void) { - ril_state.tokens.registration_state = RIL_TOKEN_DATA_WAITING; - ril_state.tokens.gprs_registration_state = RIL_TOKEN_DATA_WAITING; - ril_state.tokens.operator = RIL_TOKEN_DATA_WAITING; + ril_data.tokens.registration_state = RIL_TOKEN_DATA_WAITING; + ril_data.tokens.gprs_registration_state = RIL_TOKEN_DATA_WAITING; + ril_data.tokens.operator = RIL_TOKEN_DATA_WAITING; } /** @@ -208,7 +208,7 @@ void ril_tokens_net_set_data_waiting(void) */ int ril_tokens_net_get_data_waiting(void) { - return ril_state.tokens.registration_state == RIL_TOKEN_DATA_WAITING || ril_state.tokens.gprs_registration_state == RIL_TOKEN_DATA_WAITING || ril_state.tokens.operator == RIL_TOKEN_DATA_WAITING; + return ril_data.tokens.registration_state == RIL_TOKEN_DATA_WAITING || ril_data.tokens.gprs_registration_state == RIL_TOKEN_DATA_WAITING || ril_data.tokens.operator == RIL_TOKEN_DATA_WAITING; } /** @@ -217,9 +217,9 @@ int ril_tokens_net_get_data_waiting(void) void ril_tokens_net_state_dump(void) { LOGD("ril_tokens_net_state_dump:\n\ - \tril_state.tokens.registration_state = 0x%p\n\ - \tril_state.tokens.gprs_registration_state = 0x%p\n\ - \tril_state.tokens.operator = 0x%p\n", ril_state.tokens.registration_state, ril_state.tokens.gprs_registration_state, ril_state.tokens.operator); + \tril_data.tokens.registration_state = %p\n\ + \tril_data.tokens.gprs_registration_state = %p\n\ + \tril_data.tokens.operator = %p\n", ril_data.tokens.registration_state, ril_data.tokens.gprs_registration_state, ril_data.tokens.operator); } void ril_plmn_split(char *plmn_data, char **plmn, unsigned int *mcc, unsigned int *mnc) @@ -326,43 +326,43 @@ void ril_request_operator(RIL_Token t) size_t i; // IPC_NET_REGISTRATION_STATE_ROAMING is the biggest valid value - if(ril_state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_NONE || - ril_state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_SEARCHING || - ril_state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_UNKNOWN || - ril_state.netinfo.reg_state > IPC_NET_REGISTRATION_STATE_ROAMING) { - RIL_onRequestComplete(t, RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW, NULL, 0); + if(ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_NONE || + ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_SEARCHING || + ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_UNKNOWN || + ril_data.state.netinfo.reg_state > IPC_NET_REGISTRATION_STATE_ROAMING) { + ril_request_complete(t, RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW, NULL, 0); - ril_state.tokens.operator = (RIL_Token) 0x00; + ril_data.tokens.operator = (RIL_Token) 0x00; return; } - if(ril_state.tokens.operator == RIL_TOKEN_DATA_WAITING) { + if(ril_data.tokens.operator == RIL_TOKEN_DATA_WAITING) { LOGD("Got RILJ request for UNSOL data"); /* Send back the data we got UNSOL */ - ril_plmn_string(ril_state.plmndata.plmn, response); + ril_plmn_string(ril_data.state.plmndata.plmn, response); - RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); + ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); for(i = 0; i < sizeof(response) / sizeof(char *) ; i++) { if(response[i] != NULL) free(response[i]); } - ril_state.tokens.operator = (RIL_Token) 0x00; - } else if(ril_state.tokens.operator == (RIL_Token) 0x00) { + ril_data.tokens.operator = (RIL_Token) 0x00; + } else if(ril_data.tokens.operator == (RIL_Token) 0x00) { LOGD("Got RILJ request for SOL data"); /* Request data to the modem */ - ril_state.tokens.operator = t; + ril_data.tokens.operator = t; - ipc_fmt_send_get(IPC_NET_CURRENT_PLMN, reqGetId(t)); + ipc_fmt_send_get(IPC_NET_CURRENT_PLMN, ril_request_get_id(t)); } else { LOGE("Another request is going on, returning UNSOL data"); /* Send back the data we got UNSOL */ - ril_plmn_string(ril_state.plmndata.plmn, response); + ril_plmn_string(ril_data.state.plmndata.plmn, response); - RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); + ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); for(i = 0; i < sizeof(response) / sizeof(char *) ; i++) { if(response[i] != NULL) @@ -384,7 +384,7 @@ void ril_request_operator(RIL_Token t) */ void ipc_net_current_plmn(struct ipc_message_info *message) { - RIL_Token t = reqGetToken(message->aseq); + RIL_Token t = ril_request_get_token(message->aseq); struct ipc_net_current_plmn_response *plmndata = (struct ipc_net_current_plmn_response *) message->data; char *response[3]; @@ -395,28 +395,28 @@ void ipc_net_current_plmn(struct ipc_message_info *message) LOGD("Got UNSOL Operator message"); // IPC_NET_REGISTRATION_STATE_ROAMING is the biggest valid value - if(ril_state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_NONE || - ril_state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_SEARCHING || - ril_state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_UNKNOWN || - ril_state.netinfo.reg_state > IPC_NET_REGISTRATION_STATE_ROAMING) { + if(ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_NONE || + ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_SEARCHING || + ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_UNKNOWN || + ril_data.state.netinfo.reg_state > IPC_NET_REGISTRATION_STATE_ROAMING) { /* Better keeping it up to date */ - memcpy(&(ril_state.plmndata), plmndata, sizeof(struct ipc_net_current_plmn_response)); + memcpy(&(ril_data.state.plmndata), plmndata, sizeof(struct ipc_net_current_plmn_response)); return; } else { - if(ril_state.tokens.operator != (RIL_Token) 0x00 && ril_state.tokens.operator != RIL_TOKEN_DATA_WAITING) { + if(ril_data.tokens.operator != (RIL_Token) 0x00 && ril_data.tokens.operator != RIL_TOKEN_DATA_WAITING) { LOGE("Another Operator Req is in progress, skipping"); return; } - memcpy(&(ril_state.plmndata), plmndata, sizeof(struct ipc_net_current_plmn_response)); + memcpy(&(ril_data.state.plmndata), plmndata, sizeof(struct ipc_net_current_plmn_response)); /* we already told RILJ to get the new data but it wasn't done yet */ - if(ril_tokens_net_get_data_waiting() && ril_state.tokens.operator == RIL_TOKEN_DATA_WAITING) { + if(ril_tokens_net_get_data_waiting() && ril_data.tokens.operator == RIL_TOKEN_DATA_WAITING) { LOGD("Updating Operator data in background"); } else { ril_tokens_net_set_data_waiting(); - RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, NULL, 0); + ril_request_unsolicited(RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, NULL, 0); } } break; @@ -424,36 +424,36 @@ void ipc_net_current_plmn(struct ipc_message_info *message) LOGD("Got SOL Operator message"); // IPC_NET_REGISTRATION_STATE_ROAMING is the biggest valid value - if(ril_state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_NONE || - ril_state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_SEARCHING || - ril_state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_UNKNOWN || - ril_state.netinfo.reg_state > IPC_NET_REGISTRATION_STATE_ROAMING) { + if(ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_NONE || + ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_SEARCHING || + ril_data.state.netinfo.reg_state == IPC_NET_REGISTRATION_STATE_UNKNOWN || + ril_data.state.netinfo.reg_state > IPC_NET_REGISTRATION_STATE_ROAMING) { /* Better keeping it up to date */ - memcpy(&(ril_state.plmndata), plmndata, sizeof(struct ipc_net_current_plmn_response)); + memcpy(&(ril_data.state.plmndata), plmndata, sizeof(struct ipc_net_current_plmn_response)); - RIL_onRequestComplete(t, RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW, NULL, 0); + ril_request_complete(t, RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW, NULL, 0); - if(ril_state.tokens.operator != RIL_TOKEN_DATA_WAITING) - ril_state.tokens.operator = (RIL_Token) 0x00; + if(ril_data.tokens.operator != RIL_TOKEN_DATA_WAITING) + ril_data.tokens.operator = (RIL_Token) 0x00; return; } else { - if(ril_state.tokens.operator != t) + if(ril_data.tokens.operator != t) LOGE("Operator tokens mismatch"); /* Better keeping it up to date */ - memcpy(&(ril_state.plmndata), plmndata, sizeof(struct ipc_net_current_plmn_response)); + memcpy(&(ril_data.state.plmndata), plmndata, sizeof(struct ipc_net_current_plmn_response)); ril_plmn_string(plmndata->plmn, response); - RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); + ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); for(i = 0; i < sizeof(response) / sizeof(char *) ; i++) { if(response[i] != NULL) free(response[i]); } - if(ril_state.tokens.operator != RIL_TOKEN_DATA_WAITING) - ril_state.tokens.operator = (RIL_Token) 0x00; + if(ril_data.tokens.operator != RIL_TOKEN_DATA_WAITING) + ril_data.tokens.operator = (RIL_Token) 0x00; } break; default: @@ -478,36 +478,36 @@ void ril_request_registration_state(RIL_Token t) char *response[4]; int i; - if(ril_state.tokens.registration_state == RIL_TOKEN_DATA_WAITING) { + if(ril_data.tokens.registration_state == RIL_TOKEN_DATA_WAITING) { LOGD("Got RILJ request for UNSOL data"); /* Send back the data we got UNSOL */ - ipc2ril_reg_state_resp(&(ril_state.netinfo), response); + ipc2ril_reg_state_resp(&(ril_data.state.netinfo), response); - RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); + ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); - for(i = 0; i < sizeof(response) / sizeof(char *) ; i++) { + for(i = 0; i < (int) (sizeof(response) / sizeof(char *)) ; i++) { if(response[i] != NULL) free(response[i]); } - ril_state.tokens.registration_state = (RIL_Token) 0x00; - } else if(ril_state.tokens.registration_state == (RIL_Token) 0x00) { + ril_data.tokens.registration_state = (RIL_Token) 0x00; + } else if(ril_data.tokens.registration_state == (RIL_Token) 0x00) { LOGD("Got RILJ request for SOL data"); /* Request data to the modem */ - ril_state.tokens.registration_state = t; + ril_data.tokens.registration_state = t; ipc_net_regist_get_setup(®ist_req, IPC_NET_SERVICE_DOMAIN_GSM); - ipc_fmt_send(IPC_NET_REGIST, IPC_TYPE_GET, (void *)®ist_req, sizeof(struct ipc_net_regist_get), reqGetId(t)); + ipc_fmt_send(IPC_NET_REGIST, IPC_TYPE_GET, (void *)®ist_req, sizeof(struct ipc_net_regist_get), ril_request_get_id(t)); } else { LOGE("Another request is going on, returning UNSOL data"); /* Send back the data we got UNSOL */ - ipc2ril_reg_state_resp(&(ril_state.netinfo), response); + ipc2ril_reg_state_resp(&(ril_data.state.netinfo), response); - RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); + ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); - for(i = 0; i < sizeof(response) / sizeof(char *) ; i++) { + for(i = 0; i < (int) (sizeof(response) / sizeof(char *)) ; i++) { if(response[i] != NULL) free(response[i]); } @@ -530,35 +530,35 @@ void ril_request_gprs_registration_state(RIL_Token t) char *response[4]; size_t i; - if(ril_state.tokens.gprs_registration_state == RIL_TOKEN_DATA_WAITING) { + if(ril_data.tokens.gprs_registration_state == RIL_TOKEN_DATA_WAITING) { LOGD("Got RILJ request for UNSOL data"); /* Send back the data we got UNSOL */ - ipc2ril_gprs_reg_state_resp(&(ril_state.gprs_netinfo), response); + ipc2ril_gprs_reg_state_resp(&(ril_data.state.gprs_netinfo), response); - RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); + ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); for(i = 0; i < sizeof(response) / sizeof(char *) ; i++) { if(response[i] != NULL) free(response[i]); } - ril_state.tokens.gprs_registration_state = (RIL_Token) 0x00; - } else if(ril_state.tokens.gprs_registration_state == (RIL_Token) 0x00) { + ril_data.tokens.gprs_registration_state = (RIL_Token) 0x00; + } else if(ril_data.tokens.gprs_registration_state == (RIL_Token) 0x00) { LOGD("Got RILJ request for SOL data"); /* Request data to the modem */ - ril_state.tokens.gprs_registration_state = t; + ril_data.tokens.gprs_registration_state = t; ipc_net_regist_get_setup(®ist_req, IPC_NET_SERVICE_DOMAIN_GPRS); - ipc_fmt_send(IPC_NET_REGIST, IPC_TYPE_GET, (void *)®ist_req, sizeof(struct ipc_net_regist_get), reqGetId(t)); + ipc_fmt_send(IPC_NET_REGIST, IPC_TYPE_GET, (void *)®ist_req, sizeof(struct ipc_net_regist_get), ril_request_get_id(t)); } else { LOGE("Another request is going on, returning UNSOL data"); /* Send back the data we got UNSOL */ - ipc2ril_gprs_reg_state_resp(&(ril_state.gprs_netinfo), response); + ipc2ril_gprs_reg_state_resp(&(ril_data.state.gprs_netinfo), response); - RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); + ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); for(i = 0; i < sizeof(response) / sizeof(char *) ; i++) { if(response[i] != NULL) @@ -578,36 +578,36 @@ void ipc_net_regist_unsol(struct ipc_message_info *message) switch(netinfo->domain) { case IPC_NET_SERVICE_DOMAIN_GSM: - if(ril_state.tokens.registration_state != (RIL_Token) 0 && ril_state.tokens.registration_state != RIL_TOKEN_DATA_WAITING) { + if(ril_data.tokens.registration_state != (RIL_Token) 0 && ril_data.tokens.registration_state != RIL_TOKEN_DATA_WAITING) { LOGE("Another NetRegist Req is in progress, skipping"); return; } - memcpy(&(ril_state.netinfo), netinfo, sizeof(struct ipc_net_regist_response)); + memcpy(&(ril_data.state.netinfo), netinfo, sizeof(struct ipc_net_regist_response)); /* we already told RILJ to get the new data but it wasn't done yet */ - if(ril_tokens_net_get_data_waiting() && ril_state.tokens.registration_state == RIL_TOKEN_DATA_WAITING) { + if(ril_tokens_net_get_data_waiting() && ril_data.tokens.registration_state == RIL_TOKEN_DATA_WAITING) { LOGD("Updating NetRegist data in background"); } else { ril_tokens_net_set_data_waiting(); - RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, NULL, 0); + ril_request_unsolicited(RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, NULL, 0); } break; case IPC_NET_SERVICE_DOMAIN_GPRS: - if(ril_state.tokens.gprs_registration_state != (RIL_Token) 0 && ril_state.tokens.gprs_registration_state != RIL_TOKEN_DATA_WAITING) { + if(ril_data.tokens.gprs_registration_state != (RIL_Token) 0 && ril_data.tokens.gprs_registration_state != RIL_TOKEN_DATA_WAITING) { LOGE("Another GPRS NetRegist Req is in progress, skipping"); return; } - memcpy(&(ril_state.gprs_netinfo), netinfo, sizeof(struct ipc_net_regist_response)); + memcpy(&(ril_data.state.gprs_netinfo), netinfo, sizeof(struct ipc_net_regist_response)); /* we already told RILJ to get the new data but it wasn't done yet */ - if(ril_tokens_net_get_data_waiting() && ril_state.tokens.gprs_registration_state == RIL_TOKEN_DATA_WAITING) { + if(ril_tokens_net_get_data_waiting() && ril_data.tokens.gprs_registration_state == RIL_TOKEN_DATA_WAITING) { LOGD("Updating GPRSNetRegist data in background"); } else { ril_tokens_net_set_data_waiting(); - RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, NULL, 0); + ril_request_unsolicited(RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, NULL, 0); } break; default: @@ -624,47 +624,47 @@ void ipc_net_regist_sol(struct ipc_message_info *message) size_t i; struct ipc_net_regist_response *netinfo = (struct ipc_net_regist_response *) message->data; - RIL_Token t = reqGetToken(message->aseq); + RIL_Token t = ril_request_get_token(message->aseq); LOGD("Got SOL NetRegist message"); switch(netinfo->domain) { case IPC_NET_SERVICE_DOMAIN_GSM: - if(ril_state.tokens.registration_state != t) + if(ril_data.tokens.registration_state != t) LOGE("Registration state tokens mismatch"); /* Better keeping it up to date */ - memcpy(&(ril_state.netinfo), netinfo, sizeof(struct ipc_net_regist_response)); + memcpy(&(ril_data.state.netinfo), netinfo, sizeof(struct ipc_net_regist_response)); ipc2ril_reg_state_resp(netinfo, response); - RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); + ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); for(i = 0; i < sizeof(response) / sizeof(char *) ; i++) { if(response[i] != NULL) free(response[i]); } - if(ril_state.tokens.registration_state != RIL_TOKEN_DATA_WAITING) - ril_state.tokens.registration_state = (RIL_Token) 0x00; + if(ril_data.tokens.registration_state != RIL_TOKEN_DATA_WAITING) + ril_data.tokens.registration_state = (RIL_Token) 0x00; break; case IPC_NET_SERVICE_DOMAIN_GPRS: - if(ril_state.tokens.gprs_registration_state != t) + if(ril_data.tokens.gprs_registration_state != t) LOGE("GPRS registration state tokens mismatch"); /* Better keeping it up to date */ - memcpy(&(ril_state.gprs_netinfo), netinfo, sizeof(struct ipc_net_regist_response)); + memcpy(&(ril_data.state.gprs_netinfo), netinfo, sizeof(struct ipc_net_regist_response)); ipc2ril_gprs_reg_state_resp(netinfo, response); - RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); + ril_request_complete(t, RIL_E_SUCCESS, response, sizeof(response)); for(i = 0; i < sizeof(response) / sizeof(char *) ; i++) { if(response[i] != NULL) free(response[i]); } - if(ril_state.tokens.registration_state != RIL_TOKEN_DATA_WAITING) - ril_state.tokens.gprs_registration_state = (RIL_Token) 0x00; + if(ril_data.tokens.registration_state != RIL_TOKEN_DATA_WAITING) + ril_data.tokens.gprs_registration_state = (RIL_Token) 0x00; break; default: LOGE("%s: unhandled service domain: %d", __FUNCTION__, netinfo->domain); @@ -681,7 +681,7 @@ void ipc_net_regist_sol(struct ipc_message_info *message) void ipc_net_regist(struct ipc_message_info *message) { /* Don't consider this if modem isn't in normal power mode. */ - if(ril_state.power_mode < POWER_MODE_NORMAL) + if(ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) return; switch(message->type) { @@ -705,7 +705,7 @@ void ipc_net_regist(struct ipc_message_info *message) */ void ril_request_query_available_networks(RIL_Token t) { - ipc_fmt_send_get(IPC_NET_PLMN_LIST, reqGetId(t)); + ipc_fmt_send_get(IPC_NET_PLMN_LIST, ril_request_get_id(t)); } /* FIXME: cleanup struct names & resp[] addressing */ @@ -756,7 +756,7 @@ void ipc_net_plmn_list(struct ipc_message_info *info) resp_ptr += 4; } - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, resp, (4 * sizeof(char*) * actual_size)); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, resp, (4 * sizeof(char*) * actual_size)); /* FIXME: free individual strings */ free(resp); @@ -764,7 +764,7 @@ void ipc_net_plmn_list(struct ipc_message_info *info) void ril_request_get_preferred_network_type(RIL_Token t) { - ipc_fmt_send_get(IPC_NET_MODE_SEL, reqGetId(t)); + ipc_fmt_send_get(IPC_NET_MODE_SEL, ril_request_get_id(t)); } void ril_request_set_preferred_network_type(RIL_Token t, void *data, size_t datalen) @@ -774,9 +774,9 @@ void ril_request_set_preferred_network_type(RIL_Token t, void *data, size_t data mode_sel.mode_sel = ril2ipc_mode_sel(ril_mode); - ipc_gen_phone_res_expect_to_complete(reqGetId(t), IPC_NET_MODE_SEL); + ipc_gen_phone_res_expect_to_complete(ril_request_get_id(t), IPC_NET_MODE_SEL); - ipc_fmt_send(IPC_NET_MODE_SEL, IPC_TYPE_SET, &mode_sel, sizeof(mode_sel), reqGetId(t)); + ipc_fmt_send(IPC_NET_MODE_SEL, IPC_TYPE_SET, (void *) &mode_sel, sizeof(mode_sel), ril_request_get_id(t)); } void ipc_net_mode_sel(struct ipc_message_info *info) @@ -784,13 +784,13 @@ void ipc_net_mode_sel(struct ipc_message_info *info) struct ipc_net_mode_sel *mode_sel = (struct ipc_net_mode_sel *) info->data; int ril_mode = ipc2ril_mode_sel(mode_sel->mode_sel); - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, &ril_mode, sizeof(int)); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, &ril_mode, sizeof(int)); } void ril_request_query_network_selection_mode(RIL_Token t) { - ipc_fmt_send_get(IPC_NET_PLMN_SEL, reqGetId(t)); + ipc_fmt_send_get(IPC_NET_PLMN_SEL, ril_request_get_id(t)); } void ipc_net_plmn_sel(struct ipc_message_info *info) @@ -806,7 +806,7 @@ void ipc_net_plmn_sel(struct ipc_message_info *info) plmn_sel = (struct ipc_net_plmn_sel_get *) info->data; ril_mode = ipc2ril_plmn_sel(plmn_sel->plmn_sel); - RIL_onRequestComplete(reqGetToken(info->aseq), + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, &ril_mode, sizeof(int)); } @@ -819,15 +819,15 @@ void ipc_net_plmn_sel_complete(struct ipc_message_info *info) if(rc < 0) { if((phone_res->code & 0x00ff) == 0x6f) { LOGE("Not authorized to register to this network!"); - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_ILLEGAL_SIM_OR_ME, NULL, 0); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_ILLEGAL_SIM_OR_ME, NULL, 0); } else { LOGE("There was an error during operator selection!"); - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); } return; } - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, NULL, 0); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, NULL, 0); } void ril_request_set_network_selection_automatic(RIL_Token t) @@ -836,9 +836,9 @@ void ril_request_set_network_selection_automatic(RIL_Token t) 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(reqGetId(t), IPC_NET_PLMN_SEL, ipc_net_plmn_sel_complete); + ipc_gen_phone_res_expect_to_func(ril_request_get_id(t), IPC_NET_PLMN_SEL, ipc_net_plmn_sel_complete); - ipc_fmt_send(IPC_NET_PLMN_SEL, IPC_TYPE_SET, &plmn_sel, sizeof(plmn_sel), reqGetId(t)); + ipc_fmt_send(IPC_NET_PLMN_SEL, IPC_TYPE_SET, (void *) &plmn_sel, sizeof(plmn_sel), ril_request_get_id(t)); } void ril_request_set_network_selection_manual(RIL_Token t, void *data, size_t datalen) @@ -848,7 +848,7 @@ void ril_request_set_network_selection_manual(RIL_Token t, void *data, size_t da // 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); - ipc_gen_phone_res_expect_to_func(reqGetId(t), IPC_NET_PLMN_SEL, ipc_net_plmn_sel_complete); + ipc_gen_phone_res_expect_to_func(ril_request_get_id(t), IPC_NET_PLMN_SEL, ipc_net_plmn_sel_complete); - ipc_fmt_send(IPC_NET_PLMN_SEL, IPC_TYPE_SET, &plmn_sel, sizeof(plmn_sel), reqGetId(t)); + ipc_fmt_send(IPC_NET_PLMN_SEL, IPC_TYPE_SET, (void *) &plmn_sel, sizeof(plmn_sel), ril_request_get_id(t)); } @@ -32,12 +32,10 @@ */ void ipc_pwr_phone_pwr_up(void) { - /* H1 baseband firmware bug workaround: sleep for 25ms to allow for nvram to initialize */ - usleep(25000); + ril_data.state.radio_state = RADIO_STATE_OFF; + ril_data.state.power_state = IPC_PWR_PHONE_STATE_LPM; - ril_state.radio_state = RADIO_STATE_OFF; - ril_state.power_mode = POWER_MODE_LPM; - RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0); + ril_request_unsolicited(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0); } /** @@ -56,27 +54,28 @@ void ipc_pwr_phone_state(struct ipc_message_info *info) { /* This shouldn't append for LPM (no respond message) */ case IPC_PWR_R(IPC_PWR_PHONE_STATE_LPM): - ril_state.power_mode = POWER_MODE_LPM; - ril_state.radio_state = RADIO_STATE_OFF; + ril_data.state.radio_state = RADIO_STATE_OFF; + ril_data.state.power_state = IPC_PWR_PHONE_STATE_LPM; + LOGD("Got power to LPM"); - RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0); + ril_request_unsolicited(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0); break; case IPC_PWR_R(IPC_PWR_PHONE_STATE_NORMAL): usleep(3000); - ril_state.power_mode = POWER_MODE_NORMAL; - ril_state.radio_state = RADIO_STATE_SIM_NOT_READY; + ril_data.state.radio_state = RADIO_STATE_SIM_NOT_READY; + ril_data.state.power_state = IPC_PWR_PHONE_STATE_NORMAL; LOGD("Got power to NORMAL"); /* * return RIL_E_SUCCESS is done at IPC_SEC_PIN_STATUS: * breaks return-from-airplane-mode if done here */ - RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0); + ril_request_unsolicited(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0); break; } - ril_tokens_check(); + ril_tokens_checks(); } /** @@ -96,21 +95,23 @@ void ril_request_radio_power(RIL_Token t, void *data, size_t datalen) if(power_state > 0) { LOGD("Request power to NORMAL"); power_data = IPC_PWR_PHONE_STATE_NORMAL; - ipc_fmt_send(IPC_PWR_PHONE_STATE, IPC_TYPE_EXEC, (void *) &power_data, sizeof(power_data), reqGetId(t)); + ipc_fmt_send(IPC_PWR_PHONE_STATE, IPC_TYPE_EXEC, (void *) &power_data, sizeof(power_data), ril_request_get_id(t)); - ril_state.tokens.radio_power = t; + ril_data.tokens.radio_power = t; /* Don't tell the RIL we're not off anymore: wait for the message */ } else { LOGD("Request power to LPM"); power_data = IPC_PWR_PHONE_STATE_LPM; - ipc_fmt_send(IPC_PWR_PHONE_STATE, IPC_TYPE_EXEC, (void *) &power_data, sizeof(power_data), reqGetId(t)); + ipc_fmt_send(IPC_PWR_PHONE_STATE, IPC_TYPE_EXEC, (void *) &power_data, sizeof(power_data), ril_request_get_id(t)); - RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + ril_request_complete(t, RIL_E_SUCCESS, NULL, 0); /* We're not going to get any message to make sure we're in LPM so tell RILJ we're off anyway */ ril_globals_init(); - ril_state_lpm(); - RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0); + 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); } } @@ -32,7 +32,10 @@ void ipc_rfs_nv_read_item(struct ipc_message_info *info) void *rfs_data; int rc; - ipc_client = ((struct ipc_client_object *) ipc_rfs_client->object)->ipc_client; + if(ril_data.ipc_rfs_client == NULL) + return; + + ipc_client = ((struct ipc_client_data *) ril_data.ipc_rfs_client->data)->ipc_client; if(rfs_io == NULL) { LOGE("Error: NULL rfs_io"); @@ -67,7 +70,10 @@ void ipc_rfs_nv_write_item(struct ipc_message_info *info) void *rfs_data; int rc; - ipc_client = ((struct ipc_client_object *) ipc_rfs_client->object)->ipc_client; + if(ril_data.ipc_rfs_client == NULL) + return; + + ipc_client = ((struct ipc_client_data *) ril_data.ipc_rfs_client->data)->ipc_client; if(rfs_io == NULL) { LOGE("Error: NULL rfs_io"); diff --git a/samsung-ril.c b/samsung-ril.c index 047c3d5..ab22f19 100644 --- a/samsung-ril.c +++ b/samsung-ril.c @@ -19,18 +19,10 @@ * */ -#include <time.h> -#include <pthread.h> - #define LOG_TAG "RIL" -#include <utils/Log.h> -#include <telephony/ril.h> - #include "samsung-ril.h" #include "util.h" -#define RIL_VERSION_STRING "Samsung RIL" - /** * Samsung-RIL TODO: * @@ -47,99 +39,207 @@ */ /** - * RIL global vars + * RIL data */ -struct ril_client *ipc_fmt_client; -struct ril_client *ipc_rfs_client; -struct ril_client *srs_client; +struct ril_data ril_data; -const struct RIL_Env *ril_env; -struct ril_state ril_state; +/** + * RIL requests + */ -static pthread_mutex_t ril_mutex = PTHREAD_MUTEX_INITIALIZER; +int ril_request_id_get(void) +{ + ril_data.request_id++; + ril_data.request_id %= 0xff; -static void ril_lock(void) { - pthread_mutex_lock(&ril_mutex); + return ril_data.request_id; } -static void ril_unlock(void) { - pthread_mutex_unlock(&ril_mutex); +int ril_request_id_set(int id) +{ + id %= 0xff; + + while(ril_data.request_id < id) { + ril_data.request_id++; + ril_data.request_id %= 0xff; + } + + return ril_data.request_id; } -/** - * RIL request token - */ +int ril_request_register(RIL_Token t, int id) +{ + struct ril_request_info *request; + struct list_head *list_end; + struct list_head *list; + + request = calloc(1, sizeof(struct ril_request_info)); + if(request == NULL) + return -1; + + request->token = t; + request->id = id; + request->canceled = 0; + + list_end = ril_data.requests; + while(list_end != NULL && list_end->next != NULL) + list_end = list_end->next; + + list = list_head_alloc((void *) request, list_end, NULL); + + if(ril_data.requests == NULL) + ril_data.requests = list; + + return 0; +} + +void ril_request_unregister(struct ril_request_info *request) +{ + struct list_head *list; + + if(request == NULL) + return; + + list = ril_data.requests; + while(list != NULL) { + if(list->data == (void *) request) { + memset(request, 0, sizeof(struct ril_request_info)); + free(request); -struct ril_request_token ril_requests_tokens[0x100]; -int ril_request_id = 0; + if(list == ril_data.requests) + ril_data.requests = list->next; -void ril_requests_tokens_init(void) + list_head_free(list); + + break; + } +list_continue: + list = list->next; + } +} + +struct ril_request_info *ril_request_info_find_id(int id) { - memset(ril_requests_tokens, 0, sizeof(struct ril_request_token) * 0x100); + struct ril_request_info *request; + struct list_head *list; + + list = ril_data.requests; + while(list != NULL) { + request = (struct ril_request_info *) list->data; + if(request == NULL) + goto list_continue; + + if(request->id == id) + return request; + +list_continue: + list = list->next; + } + + return NULL; } -int ril_request_id_new(void) +struct ril_request_info *ril_request_info_find_token(RIL_Token t) { - ril_request_id++; - ril_request_id %= 0x100; - return ril_request_id; + struct ril_request_info *request; + struct list_head *list; + + list = ril_data.requests; + while(list != NULL) { + request = list->data; + if(request == NULL) + goto list_continue; + + if(request->token == t) + return request; + +list_continue: + list = list->next; + } + + return NULL; } -int ril_request_reg_id(RIL_Token token) +int ril_request_set_canceled(RIL_Token t, int canceled) { - int id = ril_request_id_new(); + struct ril_request_info *request; - ril_requests_tokens[id].token = token; - ril_requests_tokens[id].canceled = 0; + request = ril_request_info_find_token(t); + if(request == NULL) + return -1; - return id; + request->canceled = canceled ? 1 : 0; + + return 0; } -int ril_request_get_id(RIL_Token token) +int ril_request_get_canceled(RIL_Token t) { - int i; + struct ril_request_info *request; - for(i=0 ; i < 0x100 ; i++) - if(ril_requests_tokens[i].token == token) - return i; + request = ril_request_info_find_token(t); + if(request == NULL) + return -1; - // If the token isn't registered yet, register it - return ril_request_reg_id(token); + return request->canceled; } RIL_Token ril_request_get_token(int id) { - return ril_requests_tokens[id].token; + struct ril_request_info *request; + + request = ril_request_info_find_id(id); + if(request == NULL) + return (RIL_Token) 0x00; + + return request->token; } -int ril_request_get_canceled(RIL_Token token) +int ril_request_get_id(RIL_Token t) { - int id; + struct ril_request_info *request; + int id, rc; + + request = ril_request_info_find_token(t); + if(request != NULL) + return request->id; - id = ril_request_get_id(token); + id = ril_request_id_get(); + rc = ril_request_register(t, id); + if(rc < 0) + return -1; - if(ril_requests_tokens[id].canceled > 0) - return 1; - else - return 0; + return id; } -void ril_request_set_canceled(RIL_Token token, int canceled) +void ril_request_complete(RIL_Token t, RIL_Errno e, void *data, size_t length) { - int id; + struct ril_request_info *request; + int canceled = 0; + + request = ril_request_info_find_token(t); + if(request == NULL) + goto complete; + + canceled = ril_request_get_canceled(t); + ril_request_unregister(request); - id = ril_request_get_id(token); + if(canceled) + return; - ril_requests_tokens[id].canceled = canceled; +complete: + ril_data.env->OnRequestComplete(t, e, data, length); } -void RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) +void ril_request_unsolicited(int request, void *data, size_t length) { - if(!ril_request_get_canceled(t)) - RIL_onRequestCompleteReal(t, e, response, responselen); - else - RIL_onRequestCompleteReal(t, RIL_E_CANCELLED, response, responselen); + ril_data.env->OnUnsolicitedResponse(request, data, length); +} + +void ril_request_timed_callback(RIL_TimedCallback callback, void *data, const struct timeval *time) +{ + ril_data.env->RequestTimedCallback(callback, data, time); } /** @@ -150,18 +250,18 @@ void ril_tokens_check(void) { RIL_Token t; - if(ril_state.tokens.baseband_version != 0) { - if(ril_state.radio_state != RADIO_STATE_OFF) { - t = ril_state.tokens.baseband_version; - ril_state.tokens.baseband_version = 0; + if(ril_data.tokens.baseband_version != 0) { + if(ril_data.state.radio_state != RADIO_STATE_OFF) { + t = ril_data.tokens.baseband_version; + ril_data.tokens.baseband_version = 0; ril_request_baseband_version(t); } } - if(ril_state.tokens.get_imei != 0 && ril_state.tokens.get_imeisv != 0) { - if(ril_state.radio_state != RADIO_STATE_OFF) { - t = ril_state.tokens.get_imei; - ril_state.tokens.get_imei = 0; + if(ril_data.tokens.get_imei != 0 && ril_data.tokens.get_imeisv != 0) { + if(ril_data.state.radio_state != RADIO_STATE_OFF) { + t = ril_data.tokens.get_imei; + ril_data.tokens.get_imei = 0; ril_request_get_imei(t); } } @@ -173,7 +273,13 @@ void ril_tokens_check(void) void ipc_fmt_dispatch(struct ipc_message_info *info) { - ril_lock(); + if(info == NULL) + return; + + RIL_LOCK(); + + ril_request_id_set(info->aseq); + switch(IPC_COMMAND(info)) { /* GEN */ case IPC_GEN_PHONE_RES: @@ -286,15 +392,20 @@ void ipc_fmt_dispatch(struct ipc_message_info *info) ipc_gprs_pdp_context(info); break; default: - LOGD("Unhandled command: %s (%04x)", ipc_command_to_str(IPC_COMMAND(info)), IPC_COMMAND(info)); + LOGE("%s: Unhandled request: %s (%04x)", __func__, ipc_command_to_str(IPC_COMMAND(info)), IPC_COMMAND(info)); break; } - ril_unlock(); + + RIL_UNLOCK(); } void ipc_rfs_dispatch(struct ipc_message_info *info) { - ril_lock(); + if(info == NULL) + return; + + RIL_LOCK(); + switch(IPC_COMMAND(info)) { case IPC_RFS_NV_READ_ITEM: ipc_rfs_nv_read_item(info); @@ -303,15 +414,20 @@ void ipc_rfs_dispatch(struct ipc_message_info *info) ipc_rfs_nv_write_item(info); break; default: - LOGD("Unhandled command: %s (%04x)", ipc_command_to_str(IPC_COMMAND(info)), IPC_COMMAND(info)); + LOGE("%s: Unhandled request: %s (%04x)", __func__, ipc_command_to_str(IPC_COMMAND(info)), IPC_COMMAND(info)); break; } - ril_unlock(); + + RIL_UNLOCK(); } void srs_dispatch(int fd, struct srs_message *message) { - ril_lock(); + if(message == NULL) + return; + + RIL_LOCK(); + switch(message->command) { case SRS_CONTROL_PING: srs_control_ping(fd, message); @@ -326,39 +442,25 @@ void srs_dispatch(int fd, struct srs_message *message) srs_snd_set_call_audio_path(message); break; default: - LOGD("Unhandled command: (%04x)", message->command); + LOGE("%s: Unhandled request: (%04x)", __func__, message->command); break; } - ril_unlock(); + + RIL_UNLOCK(); } /* - * RIL main dispatch function + * RIL interface */ -int ril_modem_check(void) +void ril_on_request(int request, void *data, size_t length, RIL_Token t) { - if(ipc_fmt_client == NULL) - return -1; - - if(ipc_fmt_client->state != RIL_CLIENT_READY) - return -1; - - return 0; -} - -void onRequest(int request, void *data, size_t datalen, RIL_Token t) -{ - ril_lock(); - if(ril_modem_check() < 0) { - RIL_onRequestComplete(t, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0); - goto done; - } + RIL_LOCK(); switch(request) { /* PWR */ case RIL_REQUEST_RADIO_POWER: - ril_request_radio_power(t, data, datalen); + ril_request_radio_power(t, data, length); break; case RIL_REQUEST_BASEBAND_VERSION: ril_request_baseband_version(t); @@ -379,41 +481,42 @@ void onRequest(int request, void *data, size_t datalen, RIL_Token t) break; /* SAT */ case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: - requestSatSendTerminalResponse(t, data, datalen); + requestSatSendTerminalResponse(t, data, length); break; case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: - requestSatSendEnvelopeCommand(t, data, datalen); + requestSatSendEnvelopeCommand(t, data, length); break; case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: - RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + ril_request_complete(t, RIL_E_SUCCESS, NULL, 0); break; /* SS */ case RIL_REQUEST_SEND_USSD: - ril_request_send_ussd(t, data, datalen); + ril_request_send_ussd(t, data, length); break; case RIL_REQUEST_CANCEL_USSD: - ril_request_cancel_ussd(t, data, datalen); + ril_request_cancel_ussd(t, data, length); + break; /* SEC */ case RIL_REQUEST_GET_SIM_STATUS: ril_request_get_sim_status(t); break; case RIL_REQUEST_SIM_IO: - ril_request_sim_io(t, data, datalen); + ril_request_sim_io(t, data, length); break; case RIL_REQUEST_ENTER_SIM_PIN: - ril_request_enter_sim_pin(t, data, datalen); + ril_request_enter_sim_pin(t, data, length); break; case RIL_REQUEST_CHANGE_SIM_PIN: - ril_request_change_sim_pin(t, data, datalen); + ril_request_change_sim_pin(t, data, length); break; case RIL_REQUEST_ENTER_SIM_PUK: - ril_request_enter_sim_puk(t, data, datalen); + ril_request_enter_sim_puk(t, data, length); break; case RIL_REQUEST_QUERY_FACILITY_LOCK: - ril_request_query_facility_lock(t, data, datalen); + ril_request_query_facility_lock(t, data, length); break; case RIL_REQUEST_SET_FACILITY_LOCK: - ril_request_set_facility_lock(t, data, datalen); + ril_request_set_facility_lock(t, data, length); break; /* NET */ case RIL_REQUEST_OPERATOR: @@ -432,7 +535,7 @@ void onRequest(int request, void *data, size_t datalen, RIL_Token t) ril_request_get_preferred_network_type(t); break; case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: - ril_request_set_preferred_network_type(t, data, datalen); + ril_request_set_preferred_network_type(t, data, length); break; case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: ril_request_query_network_selection_mode(t); @@ -441,21 +544,21 @@ void onRequest(int request, void *data, size_t datalen, RIL_Token t) ril_request_set_network_selection_automatic(t); break; case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: - ril_request_set_network_selection_manual(t, data, datalen); + ril_request_set_network_selection_manual(t, data, length); break; /* SMS */ case RIL_REQUEST_SEND_SMS: - ril_request_send_sms(t, data, datalen); + ril_request_send_sms(t, data, length); break; case RIL_REQUEST_SEND_SMS_EXPECT_MORE: - ril_request_send_sms_expect_more(t, data, datalen); + ril_request_send_sms_expect_more(t, data, length); break; case RIL_REQUEST_SMS_ACKNOWLEDGE: - ril_request_sms_acknowledge(t, data, datalen); + ril_request_sms_acknowledge(t, data, length); break; /* CALL */ case RIL_REQUEST_DIAL: - ril_request_dial(t, data, datalen); + ril_request_dial(t, data, length); break; case RIL_REQUEST_GET_CURRENT_CALLS: ril_request_get_current_calls(t); @@ -472,20 +575,20 @@ void onRequest(int request, void *data, size_t datalen, RIL_Token t) ril_request_last_call_fail_cause(t); break; case RIL_REQUEST_DTMF: - ril_request_dtmf(t, data, datalen); - break; + ril_request_dtmf(t, data, length); + break; case RIL_REQUEST_DTMF_START: - ril_request_dtmf_start(t, data, datalen); - break; + ril_request_dtmf_start(t, data, length); + break; case RIL_REQUEST_DTMF_STOP: ril_request_dtmf_stop(t); - break; + break; /* GPRS */ case RIL_REQUEST_SETUP_DATA_CALL: - ril_request_setup_data_call(t, data, datalen); + ril_request_setup_data_call(t, data, length); break; case RIL_REQUEST_DEACTIVATE_DATA_CALL: - ril_request_deactivate_data_call(t, data, datalen); + ril_request_deactivate_data_call(t, data, length); break; case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: ril_request_last_data_call_fail_cause(t); @@ -495,90 +598,91 @@ void onRequest(int request, void *data, size_t datalen, RIL_Token t) break; /* SND */ case RIL_REQUEST_SET_MUTE: - ril_request_set_mute(t, data, datalen); + ril_request_set_mute(t, data, length); + break; /* OTHER */ case RIL_REQUEST_SCREEN_STATE: /* This doesn't affect anything */ - RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + ril_request_complete(t, RIL_E_SUCCESS, NULL, 0); break; default: - LOGE("Request not implemented: %d\n", request); - RIL_onRequestComplete(t, RIL_E_REQUEST_NOT_SUPPORTED, NULL, 0); + LOGE("%s: Unhandled request: %d", __func__, request); + ril_request_complete(t, RIL_E_REQUEST_NOT_SUPPORTED, NULL, 0); break; } -done: - ril_unlock(); -} -/** - * RILJ related functions - */ + RIL_UNLOCK(); +} -RIL_RadioState currentState() +RIL_RadioState ril_on_state_request(void) { - LOGD("currentState()"); - return ril_state.radio_state; + return ril_data.state.radio_state; } -int onSupports(int requestCode) +int ril_on_supports(int request) { - switch(requestCode) { - default: - return 1; - } + return 1; } -void onCancel(RIL_Token t) +void ril_on_cancel(RIL_Token t) { ril_request_set_canceled(t, 1); } -const char *getVersion(void) +const char *ril_get_version(void) { return RIL_VERSION_STRING; } /** - * RIL init function + * RIL init */ -void ril_globals_init(void) +void ril_data_init(void) { - memset(&ril_state, 0, sizeof(ril_state)); - memset(&(ril_state.tokens), 0, sizeof(struct ril_tokens)); + memset(&ril_data, 0, sizeof(ril_data)); + + pthread_mutex_init(&ril_data.mutex, NULL); +} - ril_requests_tokens_init(); +void ril_globals_init(void) +{ ipc_gen_phone_res_expects_init(); ril_gprs_connections_init(); ril_request_sms_init(); ipc_sms_tpid_queue_init(); } -void ril_state_lpm(void) -{ - ril_state.radio_state = RADIO_STATE_OFF; - ril_state.power_mode = POWER_MODE_LPM; -} - +/** + * RIL interface + */ static const RIL_RadioFunctions ril_ops = { SAMSUNG_RIL_VERSION, - onRequest, - currentState, - onSupports, - onCancel, - getVersion + ril_on_request, + ril_on_state_request, + ril_on_supports, + ril_on_cancel, + ril_get_version }; const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc, char **argv) { + struct ril_client *ipc_fmt_client; + struct ril_client *ipc_rfs_client; + struct ril_client *srs_client; int rc; - ril_env = env; + if(env == NULL) + return NULL; + + ril_data_init(); + ril_data.env = (struct RIL_Env *) env; + + RIL_LOCK(); LOGD("Creating IPC FMT client"); - ril_lock(); ipc_fmt_client = ril_client_new(&ipc_fmt_client_funcs); rc = ril_client_create(ipc_fmt_client); @@ -594,6 +698,7 @@ const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc, char **a goto ipc_rfs; } + ril_data.ipc_fmt_client = ipc_fmt_client; LOGD("IPC FMT client ready"); ipc_rfs: @@ -614,6 +719,7 @@ ipc_rfs: goto srs; } + ril_data.ipc_rfs_client = ipc_rfs_client; LOGD("IPC RFS client ready"); srs: @@ -634,18 +740,14 @@ srs: goto end; } + ril_data.srs_client = srs_client; LOGD("SRS client ready"); end: - ril_globals_init(); - ril_state_lpm(); - ril_unlock(); + ril_data.state.radio_state = RADIO_STATE_OFF; + ril_data.state.power_state = IPC_PWR_PHONE_STATE_LPM; - return &ril_ops; -} + RIL_UNLOCK(); -int main(int argc, char *argv[]) -{ - return 0; + return &ril_ops; } - diff --git a/samsung-ril.h b/samsung-ril.h index 776ab31..5049987 100644 --- a/samsung-ril.h +++ b/samsung-ril.h @@ -24,7 +24,9 @@ #include <pthread.h> +#include <utils/Log.h> #include <telephony/ril.h> + #include <radio.h> #include "compat.h" @@ -35,43 +37,26 @@ * Defines */ -#define RIL_CLIENT_LOCK(client) pthread_mutex_lock(&(client->mutex)); -#define RIL_CLIENT_UNLOCK(client) pthread_mutex_unlock(&(client->mutex)); - -#define RIL_onRequestCompleteReal(t, e, response, responselen) ril_env->OnRequestComplete(t,e, response, responselen) -#define RIL_onUnsolicitedResponse(a,b,c) ril_env->OnUnsolicitedResponse(a,b,c) -#define RIL_requestTimedCallback(a,b,c) ril_env->RequestTimedCallback(a,b,c) +#define RIL_VERSION_STRING "Samsung RIL" -#define reqIdNew() ril_request_id_new() -#define reqGetId(t) ril_request_get_id(t) -#define reqGetToken(i) ril_request_get_token(i) +#define RIL_LOCK() pthread_mutex_lock(&ril_data.mutex) +#define RIL_UNLOCK() pthread_mutex_unlock(&ril_data.mutex) +#define RIL_CLIENT_LOCK(client) pthread_mutex_lock(&(client->mutex)) +#define RIL_CLIENT_UNLOCK(client) pthread_mutex_unlock(&(client->mutex)) #define RIL_TOKEN_DATA_WAITING (RIL_Token) 0xff -/** - * RIL structures - */ - -struct ril_client; -struct ril_token; -struct ril_tokens; -struct ril_state; - -/** - * RIL globals - */ - -extern struct ril_client *ipc_fmt_client; -extern struct ril_client *ipc_rfs_client; -extern struct ril_client *srs_client; - -extern const struct RIL_Env *ril_env; -extern struct ril_state ril_state; /** * RIL client */ -typedef int (*ril_client_func)(struct ril_client *client); +struct ril_client; + +struct ril_client_funcs { + int (*create)(struct ril_client *client); + int (*destroy)(struct ril_client *client); + int (*read_loop)(struct ril_client *client); +}; typedef enum { RIL_CLIENT_NULL = 0, @@ -79,26 +64,16 @@ typedef enum { RIL_CLIENT_READY = 2, RIL_CLIENT_DESTROYED = 3, RIL_CLIENT_ERROR = 4, - } ril_client_state; struct ril_client { - ril_client_func create; - ril_client_func destroy; - ril_client_func read_loop; + struct ril_client_funcs funcs; + ril_client_state state; - void *object; + void *data; pthread_t thread; pthread_mutex_t mutex; - - ril_client_state state; -}; - -struct ril_client_funcs { - ril_client_func create; - ril_client_func destroy; - ril_client_func read_loop; }; struct ril_client *ril_client_new(struct ril_client_funcs *client_funcs); @@ -108,22 +83,29 @@ int ril_client_destroy(struct ril_client *client); int ril_client_thread_start(struct ril_client *client); /** - * RIL request token + * RIL requests */ -struct ril_request_token { +struct ril_request_info { RIL_Token token; + int id; int canceled; }; -void ril_requests_tokens_init(void); -int ril_request_reg_id(RIL_Token token); -int ril_request_get_id(RIL_Token token); +int ril_request_id_get(void); +int ril_request_id_set(int id); +int ril_request_register(RIL_Token t, int id); +void ril_request_unregister(struct ril_request_info *request); +struct ril_request_info *ril_request_info_find_id(int id); +struct ril_request_info *ril_request_info_find_token(RIL_Token t); +int ril_request_set_canceled(RIL_Token t, int canceled); +int ril_request_get_canceled(RIL_Token t); RIL_Token ril_request_get_token(int id); -int ril_request_get_canceled(RIL_Token token); -void ril_request_set_canceled(RIL_Token token, int canceled); +int ril_request_get_id(RIL_Token t); -void RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen); +void ril_request_complete(RIL_Token t, RIL_Errno e, void *data, size_t length); +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 tokens @@ -139,7 +121,6 @@ struct ril_tokens { RIL_Token registration_state; RIL_Token gprs_registration_state; RIL_Token operator; - }; void ril_tokens_check(void); @@ -149,30 +130,22 @@ void ril_tokens_check(void); */ typedef enum { - SIM_ABSENT = 0, - SIM_NOT_READY = 1, - SIM_READY = 2, - SIM_PIN = 3, - SIM_PUK = 4, - SIM_BLOCKED = 5, - SIM_NETWORK_PERSO = 6, - SIM_NETWORK_SUBSET_PERSO = 7, - SIM_CORPORATE_PERSO = 8, - SIM_SERVICE_PROVIDER_PERSO = 9, -} SIM_Status; - -typedef enum { - POWER_MODE_LPM = 0, - POWER_MODE_NORMAL = 2, - POWER_MODE_SIM_INIT_COMPLETE = 4, -} Modem_PowerMode; + SIM_STATE_ABSENT = 0, + SIM_STATE_NOT_READY = 1, + SIM_STATE_READY = 2, + SIM_STATE_PIN = 3, + SIM_STATE_PUK = 4, + SIM_STATE_BLOCKED = 5, + SIM_STATE_NETWORK_PERSO = 6, + SIM_STATE_NETWORK_SUBSET_PERSO = 7, + SIM_STATE_CORPORATE_PERSO = 8, + SIM_STATE_SERVICE_PROVIDER_PERSO = 9, +} ril_sim_state; struct ril_state { RIL_RadioState radio_state; - SIM_Status sim_status; - Modem_PowerMode power_mode; - - struct ril_tokens tokens; + ril_sim_state sim_state; + int power_state; struct ipc_sec_sim_status_response sim_pin_status; struct ipc_sec_sim_icc_type sim_type; @@ -186,16 +159,34 @@ struct ril_state { int gprs_last_failed_cid; unsigned char dtmf_tone; - unsigned char ussd_state; }; -void ril_globals_init(void); void ril_state_lpm(void); -int ril_modem_check(void); /** - * Clients dispatch functions + * RIL data + */ + +struct ril_data { + struct RIL_Env *env; + + struct ril_state state; + struct ril_tokens tokens; + struct list_head *requests; + int request_id; + + struct ril_client *ipc_fmt_client; + struct ril_client *ipc_rfs_client; + struct ril_client *srs_client; + + pthread_mutex_t mutex; +}; + +extern struct ril_data ril_data; + +/** + * Dispatch functions */ void ipc_fmt_dispatch(struct ipc_message_info *info); @@ -220,16 +211,19 @@ void ipc_gen_phone_res_expect_to_abort(unsigned char aseq, unsigned short comman void ipc_gen_phone_res(struct ipc_message_info *info); /* PWR */ + void ipc_pwr_phone_pwr_up(void); void ipc_pwr_phone_state(struct ipc_message_info *info); void ril_request_radio_power(RIL_Token t, void *data, size_t datalen); /* DISP */ + void ril_request_signal_strength(RIL_Token t); void ipc_disp_icon_info(struct ipc_message_info *info); void ipc_disp_rssi_info(struct ipc_message_info *info); /* MISC */ + void ril_request_get_imei(RIL_Token t); void ril_request_get_imeisv(RIL_Token t); void ipc_misc_me_sn(struct ipc_message_info *info); @@ -252,7 +246,8 @@ void ril_request_cancel_ussd(RIL_Token t, void *data, size_t datalen); void ipc_ss_ussd(struct ipc_message_info *info); /* SEC */ -void ril_state_update(SIM_Status status); + +void ril_state_update(ril_sim_state status); void ipc_sec_sim_status(struct ipc_message_info *info); void ril_request_get_sim_status(RIL_Token t); void ril_request_sim_io(RIL_Token t, void *data, size_t datalen); @@ -268,6 +263,7 @@ void ipc_sec_phone_lock_complete(struct ipc_message_info *info); void ril_request_set_facility_lock(RIL_Token t, void *data, size_t datalen); /* NET */ + void ril_plmn_split(char *plmn_data, char **plmn, unsigned int *mcc, unsigned int *mnc); void ril_plmn_string(char *plmn_data, char *response[3]); unsigned char ril_plmn_act_get(char *plmn_data); @@ -287,6 +283,7 @@ void ril_request_set_network_selection_automatic(RIL_Token t); void ril_request_set_network_selection_manual(RIL_Token t, void *data, size_t datalen); /* SMS */ + struct ril_request_sms { char *pdu; int pdu_len; @@ -327,6 +324,7 @@ void ipc_sms_deliver_report(struct ipc_message_info *info); void ipc_sms_device_ready(struct ipc_message_info *info); /* Call */ + void ipc_call_incoming(struct ipc_message_info *info); void ipc_call_status(struct ipc_message_info *info); void ril_request_dial(RIL_Token t, void *data, size_t datalen); @@ -40,7 +40,7 @@ void respondSatProactiveCmdIndi(struct ipc_message_info *info) bin2hex((unsigned char*)info->data+2, data_len, hexdata); - RIL_onUnsolicitedResponse(RIL_UNSOL_STK_PROACTIVE_COMMAND, hexdata, sizeof(char*)); + ril_request_unsolicited(RIL_UNSOL_STK_PROACTIVE_COMMAND, hexdata, sizeof(char*)); free(hexdata); } @@ -59,7 +59,7 @@ void respondSatProactiveCmdResp(struct ipc_message_info *info) sw2 = ((unsigned char*)info->data)[1]; if(sw1 == 0x90 && sw2 == 0x00) { - RIL_onUnsolicitedResponse(RIL_UNSOL_STK_SESSION_END, NULL, 0); + ril_request_unsolicited(RIL_UNSOL_STK_SESSION_END, NULL, 0); } else { LOGE("%s: unhandled response sw1=%02x sw2=%02x", __FUNCTION__, sw1, sw2); } @@ -93,7 +93,7 @@ void requestSatSendTerminalResponse(RIL_Token t, void *data, size_t datalen) if(len > 255) { LOGE("%s: data exceeds maximum length", __FUNCTION__); - RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); } memset(buf, 0, sizeof(buf)); @@ -101,9 +101,9 @@ void requestSatSendTerminalResponse(RIL_Token t, void *data, size_t datalen) buf[0] = len; hex2bin(data, strlen(data), &buf[1]); - ipc_fmt_send(IPC_SAT_PROACTIVE_CMD, IPC_TYPE_GET, buf, sizeof(buf), reqGetId(t)); + ipc_fmt_send(IPC_SAT_PROACTIVE_CMD, IPC_TYPE_GET, buf, sizeof(buf), ril_request_get_id(t)); - RIL_onRequestComplete(t, RIL_E_SUCCESS, buf, sizeof(char*)); + ril_request_complete(t, RIL_E_SUCCESS, buf, sizeof(char*)); } /** @@ -120,7 +120,7 @@ void requestSatSendEnvelopeCommand(RIL_Token t, void *data, size_t datalen) if(len > 255) { LOGE("%s: data exceeds maximum length", __FUNCTION__); - RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); } memset(buf, 0, sizeof(buf)); @@ -128,7 +128,7 @@ void requestSatSendEnvelopeCommand(RIL_Token t, void *data, size_t datalen) buf[0] = len; hex2bin(data, strlen(data), &buf[1]); - ipc_fmt_send(IPC_SAT_ENVELOPE_CMD, IPC_TYPE_EXEC, buf, sizeof(buf), reqGetId(t)); + ipc_fmt_send(IPC_SAT_ENVELOPE_CMD, IPC_TYPE_EXEC, buf, sizeof(buf), ril_request_get_id(t)); } /** @@ -147,7 +147,7 @@ void respondSatEnvelopeCmd(struct ipc_message_info *info) bin2hex((unsigned char*)info->data+2, data_len, hexdata); - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, hexdata, sizeof(char*)); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, hexdata, sizeof(char*)); free(hexdata); } @@ -25,88 +25,87 @@ #include "samsung-ril.h" #include "util.h" -SIM_Status ipc2ril_sim_status(struct ipc_sec_sim_status_response *pin_status) +ril_sim_state ipc2ril_sim_state(struct ipc_sec_sim_status_response *pin_status) { switch(pin_status->status) { case IPC_SEC_SIM_STATUS_INITIALIZING: - return SIM_NOT_READY; + return SIM_STATE_NOT_READY; case IPC_SEC_SIM_STATUS_LOCK_SC: switch(pin_status->facility_lock) { case IPC_SEC_FACILITY_LOCK_TYPE_SC_UNLOCKED: - return SIM_READY; + return SIM_STATE_READY; case IPC_SEC_FACILITY_LOCK_TYPE_SC_PIN1_REQ: - return SIM_PIN; + return SIM_STATE_PIN; case IPC_SEC_FACILITY_LOCK_TYPE_SC_PUK_REQ: - return SIM_PUK; + return SIM_STATE_PUK; case IPC_SEC_FACILITY_LOCK_TYPE_SC_CARD_BLOCKED: - return SIM_BLOCKED; + return SIM_STATE_BLOCKED; default: - LOGE("%s: unknown SC substate %d --> setting SIM_ABSENT", __FUNCTION__, pin_status->facility_lock); - return SIM_ABSENT; + LOGE("Unknown SIM facility lock: 0x%x", pin_status->facility_lock); + return SIM_STATE_ABSENT; } break; case IPC_SEC_SIM_STATUS_LOCK_FD: - LOGE("%s: FD lock present (unhandled state --> setting SIM_ABSENT)", __FUNCTION__); - return SIM_ABSENT; + return SIM_STATE_ABSENT; case IPC_SEC_SIM_STATUS_LOCK_PN: - return SIM_NETWORK_PERSO; + return SIM_STATE_NETWORK_PERSO; case IPC_SEC_SIM_STATUS_LOCK_PU: - return SIM_NETWORK_SUBSET_PERSO; + return SIM_STATE_NETWORK_SUBSET_PERSO; case IPC_SEC_SIM_STATUS_LOCK_PP: - return SIM_SERVICE_PROVIDER_PERSO; + return SIM_STATE_SERVICE_PROVIDER_PERSO; case IPC_SEC_SIM_STATUS_LOCK_PC: - return SIM_CORPORATE_PERSO; + return SIM_STATE_CORPORATE_PERSO; case IPC_SEC_SIM_STATUS_INIT_COMPLETE: - return SIM_READY; + return SIM_STATE_READY; case IPC_SEC_SIM_STATUS_PB_INIT_COMPLETE: - /* Ignore phone book init complete */ - return ril_state.sim_status; + // Ignore phone book init complete + return ril_data.state.sim_state; case IPC_SEC_SIM_STATUS_SIM_LOCK_REQUIRED: case IPC_SEC_SIM_STATUS_INSIDE_PF_ERROR: case IPC_SEC_SIM_STATUS_CARD_NOT_PRESENT: case IPC_SEC_SIM_STATUS_CARD_ERROR: default: - /* Catchall for locked, card error and unknown states */ - return SIM_ABSENT; + LOGE("Unknown SIM status: 0x%x", pin_status->status); + return SIM_STATE_ABSENT; } } /** - * Update the radio state based on SIM status + * Update the radio state based on SIM state * * Out: RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED * Indicate when value of RIL_RadioState has changed * Callee will invoke RIL_RadioStateRequest method on main thread */ -void ril_state_update(SIM_Status status) +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_state.power_mode < POWER_MODE_NORMAL) + if(ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) return; - ril_state.sim_status = status; + ril_data.state.sim_state = sim_state; - switch(status) { - case SIM_READY: + switch(sim_state) { + case SIM_STATE_READY: #if RIL_VERSION >= 7 radio_state = RADIO_STATE_ON; #else radio_state = RADIO_STATE_SIM_READY; #endif break; - case SIM_NOT_READY: + case SIM_STATE_NOT_READY: radio_state = RADIO_STATE_SIM_NOT_READY; break; - case SIM_ABSENT: - case SIM_PIN: - case SIM_PUK: - case SIM_BLOCKED: - case SIM_NETWORK_PERSO: - case SIM_NETWORK_SUBSET_PERSO: - case SIM_CORPORATE_PERSO: - case SIM_SERVICE_PROVIDER_PERSO: + case SIM_STATE_ABSENT: + case SIM_STATE_PIN: + case SIM_STATE_PUK: + case SIM_STATE_BLOCKED: + case SIM_STATE_NETWORK_PERSO: + case SIM_STATE_NETWORK_SUBSET_PERSO: + case SIM_STATE_CORPORATE_PERSO: + case SIM_STATE_SERVICE_PROVIDER_PERSO: radio_state = RADIO_STATE_SIM_LOCKED_OR_ABSENT; break; default: @@ -115,16 +114,16 @@ void ril_state_update(SIM_Status status) } - ril_state.radio_state = radio_state; + ril_data.state.radio_state = radio_state; ril_tokens_check(); - RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0); + ril_request_unsolicited(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0); } void ipc2ril_card_status(struct ipc_sec_sim_status_response *pin_status, RIL_CardStatus *card_status) { - SIM_Status sim_status; + ril_sim_state sim_state; int app_status_array_length; int app_index; int i; @@ -167,10 +166,10 @@ void ipc2ril_card_status(struct ipc_sec_sim_status_response *pin_status, RIL_Car if(app_status_array_length > RIL_CARD_MAX_APPS) app_status_array_length = RIL_CARD_MAX_APPS; - sim_status = ipc2ril_sim_status(pin_status); + sim_state = ipc2ril_sim_state(pin_status); /* Card is assumed to be present if not explicitly absent */ - if(sim_status == SIM_ABSENT) { + if(sim_state == SIM_STATE_ABSENT) { card_status->card_state = RIL_CARDSTATE_ABSENT; } else { card_status->card_state = RIL_CARDSTATE_PRESENT; @@ -187,18 +186,18 @@ void ipc2ril_card_status(struct ipc_sec_sim_status_response *pin_status, RIL_Car memset((void *) &(card_status->applications[i]), 0, sizeof(RIL_AppStatus)); } - // sim_status corresponds to the app index on the table - card_status->gsm_umts_subscription_app_index = (int) sim_status; - card_status->cdma_subscription_app_index = (int) sim_status; + // sim_state corresponds to the app index on the table + card_status->gsm_umts_subscription_app_index = (int) sim_state; + card_status->cdma_subscription_app_index = (int) sim_state; card_status->num_applications = app_status_array_length; - LOGD("Selecting application #%d on %d", (int) sim_status, app_status_array_length); + LOGD("Selecting application #%d on %d", (int) sim_state, app_status_array_length); } void ril_tokens_pin_status_dump(void) { LOGD("ril_tokens_pin_status_dump:\n\ - \tril_state.tokens.pin_status = 0x%p\n", ril_state.tokens.pin_status); + \tril_data.tokens.pin_status = %p\n", ril_data.tokens.pin_status); } /** @@ -215,54 +214,54 @@ void ril_tokens_pin_status_dump(void) */ void ipc_sec_sim_status(struct ipc_message_info *info) { - RIL_Token t = reqGetToken(info->aseq); + RIL_Token t = ril_request_get_token(info->aseq); struct ipc_sec_sim_status_response *pin_status = (struct ipc_sec_sim_status_response *) info->data; RIL_CardStatus card_status; - SIM_Status sim_status; + ril_sim_state sim_state; - if(ril_state.power_mode == POWER_MODE_NORMAL && ril_state.tokens.radio_power != (RIL_Token) 0x00) { - RIL_onRequestComplete(ril_state.tokens.radio_power, RIL_E_SUCCESS, NULL, 0); - ril_state.tokens.radio_power = (RIL_Token) 0x00; + if(ril_data.state.power_state == IPC_PWR_PHONE_STATE_NORMAL && ril_data.tokens.radio_power != (RIL_Token) 0x00) { + ril_request_complete(ril_data.tokens.radio_power, RIL_E_SUCCESS, NULL, 0); + ril_data.tokens.radio_power = (RIL_Token) 0x00; } switch(info->type) { case IPC_TYPE_NOTI: // Don't consider this if modem isn't in normal power mode - if(ril_state.power_mode < POWER_MODE_NORMAL) + if(ril_data.state.power_state != IPC_PWR_PHONE_STATE_NORMAL) return; LOGD("Got UNSOL PIN status message"); - if(ril_state.tokens.pin_status != (RIL_Token) 0x00 && ril_state.tokens.pin_status != RIL_TOKEN_DATA_WAITING) { + if(ril_data.tokens.pin_status != (RIL_Token) 0x00 && ril_data.tokens.pin_status != RIL_TOKEN_DATA_WAITING) { LOGE("Another PIN status Req is in progress, skipping"); return; } - sim_status = ipc2ril_sim_status(pin_status); - ril_state_update(sim_status); + sim_state = ipc2ril_sim_state(pin_status); + ril_state_update(sim_state); - memcpy(&(ril_state.sim_pin_status), pin_status, sizeof(struct ipc_sec_sim_status_response)); + memcpy(&(ril_data.state.sim_pin_status), pin_status, sizeof(struct ipc_sec_sim_status_response)); - ril_state.tokens.pin_status = RIL_TOKEN_DATA_WAITING; - RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, NULL, 0); + ril_data.tokens.pin_status = RIL_TOKEN_DATA_WAITING; + ril_request_unsolicited(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, NULL, 0); break; case IPC_TYPE_RESP: LOGD("Got SOL PIN status message"); - if(ril_state.tokens.pin_status != t) + if(ril_data.tokens.pin_status != t) LOGE("PIN status tokens mismatch"); - sim_status = ipc2ril_sim_status(pin_status); - ril_state_update(sim_status); + sim_state = ipc2ril_sim_state(pin_status); + ril_state_update(sim_state); // Better keeping this up to date - memcpy(&(ril_state.sim_pin_status), pin_status, sizeof(struct ipc_sec_sim_status_response)); + memcpy(&(ril_data.state.sim_pin_status), pin_status, sizeof(struct ipc_sec_sim_status_response)); ipc2ril_card_status(pin_status, &card_status); - RIL_onRequestComplete(t, RIL_E_SUCCESS, &card_status, sizeof(RIL_CardStatus)); + ril_request_complete(t, RIL_E_SUCCESS, &card_status, sizeof(RIL_CardStatus)); - if(ril_state.tokens.pin_status != RIL_TOKEN_DATA_WAITING) - ril_state.tokens.pin_status = (RIL_Token) 0x00; + if(ril_data.tokens.pin_status != RIL_TOKEN_DATA_WAITING) + ril_data.tokens.pin_status = (RIL_Token) 0x00; break; default: LOGE("%s: unhandled ipc method: %d", __FUNCTION__, info->type); @@ -280,32 +279,31 @@ void ril_request_get_sim_status(RIL_Token t) { struct ipc_sec_sim_status_response *pin_status; RIL_CardStatus card_status; - SIM_Status sim_status; - if(ril_state.tokens.pin_status == RIL_TOKEN_DATA_WAITING) { + if(ril_data.tokens.pin_status == RIL_TOKEN_DATA_WAITING) { LOGD("Got RILJ request for UNSOL data"); - hex_dump(&(ril_state.sim_pin_status), sizeof(struct ipc_sec_sim_status_response)); - pin_status = &(ril_state.sim_pin_status); + hex_dump(&(ril_data.state.sim_pin_status), sizeof(struct ipc_sec_sim_status_response)); + pin_status = &(ril_data.state.sim_pin_status); ipc2ril_card_status(pin_status, &card_status); - RIL_onRequestComplete(t, RIL_E_SUCCESS, &card_status, sizeof(RIL_CardStatus)); + ril_request_complete(t, RIL_E_SUCCESS, &card_status, sizeof(RIL_CardStatus)); - ril_state.tokens.pin_status = (RIL_Token) 0x00; - } else if(ril_state.tokens.pin_status == (RIL_Token) 0x00) { + ril_data.tokens.pin_status = (RIL_Token) 0x00; + } else if(ril_data.tokens.pin_status == (RIL_Token) 0x00) { LOGD("Got RILJ request for SOL data"); /* Request data to the modem */ - ril_state.tokens.pin_status = t; + ril_data.tokens.pin_status = t; - ipc_fmt_send_get(IPC_SEC_SIM_STATUS, reqGetId(t)); + ipc_fmt_send_get(IPC_SEC_SIM_STATUS, ril_request_get_id(t)); } else { LOGE("Another request is going on, returning UNSOL data"); - pin_status = &(ril_state.sim_pin_status); + pin_status = &(ril_data.state.sim_pin_status); ipc2ril_card_status(pin_status, &card_status); - RIL_onRequestComplete(t, RIL_E_SUCCESS, &card_status, sizeof(card_status)); + ril_request_complete(t, RIL_E_SUCCESS, &card_status, sizeof(card_status)); } ril_tokens_pin_status_dump(); @@ -344,10 +342,10 @@ void ril_request_sim_io(RIL_Token t, void *data, size_t datalen) rsim_data->p2 = sim_io->p2; rsim_data->p3 = sim_io->p3; - if(sim_io->data != NULL && rsim_data_length > sizeof(struct ipc_sec_rsim_access_get)) + if(sim_io->data != NULL && rsim_data_length > (int) sizeof(struct ipc_sec_rsim_access_get)) hex2bin(sim_io->data, strlen(sim_io->data), (void *) (rsim_data + sizeof(struct ipc_sec_rsim_access_get))); - ipc_fmt_send(IPC_SEC_RSIM_ACCESS, IPC_TYPE_GET, (void *) rsim_data, rsim_data_length, reqGetId(t)); + ipc_fmt_send(IPC_SEC_RSIM_ACCESS, IPC_TYPE_GET, (void *) rsim_data, rsim_data_length, ril_request_get_id(t)); free(rsim_data); } @@ -381,7 +379,7 @@ void ipc_sec_rsim_access(struct ipc_message_info *info) response.simResponse[0] = '\0'; } - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, &response, sizeof(response)); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, &response, sizeof(response)); free(response.simResponse); } @@ -404,22 +402,22 @@ void ipc_sec_sim_status_complete(struct ipc_message_info *info) if(rc < 0) { if((phone_res->code & 0x00ff) == 0x10) { LOGE("Wrong password!"); - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_PASSWORD_INCORRECT, &attempts, sizeof(attempts)); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_PASSWORD_INCORRECT, &attempts, sizeof(attempts)); } else if((phone_res->code & 0x00ff) == 0x0c) { LOGE("Wrong password and no attempts left!"); attempts = 0; - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_PASSWORD_INCORRECT, &attempts, sizeof(attempts)); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_PASSWORD_INCORRECT, &attempts, sizeof(attempts)); - RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, NULL, 0); + ril_request_unsolicited(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, NULL, 0); } else { LOGE("There was an error during pin status complete!"); - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); } return; } - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, &attempts, sizeof(attempts)); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, &attempts, sizeof(attempts)); } /** @@ -462,15 +460,15 @@ void ril_request_enter_sim_pin(RIL_Token t, void *data, size_t datalen) /* 1. Send PIN */ if(strlen(data) > 16) { LOGE("%s: pin exceeds maximum length", __FUNCTION__); - RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); } ipc_sec_pin_status_set_setup(&pin_status, IPC_SEC_PIN_TYPE_PIN1, pin, NULL); - ipc_gen_phone_res_expect_to_func(reqGetId(t), IPC_SEC_SIM_STATUS, + ipc_gen_phone_res_expect_to_func(ril_request_get_id(t), IPC_SEC_SIM_STATUS, ipc_sec_sim_status_complete); - ipc_fmt_send_set(IPC_SEC_SIM_STATUS, reqGetId(t), (unsigned char *) &pin_status, sizeof(pin_status)); + ipc_fmt_send_set(IPC_SEC_SIM_STATUS, ril_request_get_id(t), (unsigned char *) &pin_status, sizeof(pin_status)); /* 2. Get lock status */ // FIXME: This is not clean at all @@ -478,7 +476,7 @@ void ril_request_enter_sim_pin(RIL_Token t, void *data, size_t datalen) buf[0] = 1; buf[1] = IPC_SEC_PIN_TYPE_PIN1; - ipc_fmt_send(IPC_SEC_LOCK_INFO, IPC_TYPE_GET, buf, sizeof(buf), reqGetId(t)); + ipc_fmt_send(IPC_SEC_LOCK_INFO, IPC_TYPE_GET, buf, sizeof(buf), ril_request_get_id(t)); } void ril_request_change_sim_pin(RIL_Token t, void *data, size_t datalen) @@ -503,10 +501,10 @@ void ril_request_change_sim_pin(RIL_Token t, void *data, size_t datalen) memcpy(locking_pw.password_old, password_old, locking_pw.length_old); - ipc_gen_phone_res_expect_to_func(reqGetId(t), IPC_SEC_CHANGE_LOCKING_PW, + ipc_gen_phone_res_expect_to_func(ril_request_get_id(t), IPC_SEC_CHANGE_LOCKING_PW, ipc_sec_sim_status_complete); - ipc_fmt_send_set(IPC_SEC_CHANGE_LOCKING_PW, reqGetId(t), (unsigned char *) &locking_pw, sizeof(locking_pw)); + ipc_fmt_send_set(IPC_SEC_CHANGE_LOCKING_PW, ril_request_get_id(t), (unsigned char *) &locking_pw, sizeof(locking_pw)); } void ril_request_enter_sim_puk(RIL_Token t, void *data, size_t datalen) @@ -517,10 +515,10 @@ void ril_request_enter_sim_puk(RIL_Token t, void *data, size_t datalen) ipc_sec_pin_status_set_setup(&pin_status, IPC_SEC_PIN_TYPE_PIN1, pin, puk); - ipc_gen_phone_res_expect_to_func(reqGetId(t), IPC_SEC_SIM_STATUS, + ipc_gen_phone_res_expect_to_func(ril_request_get_id(t), IPC_SEC_SIM_STATUS, ipc_sec_sim_status_complete); - ipc_fmt_send_set(IPC_SEC_SIM_STATUS, reqGetId(t), (unsigned char *) &pin_status, sizeof(pin_status)); + ipc_fmt_send_set(IPC_SEC_SIM_STATUS, ril_request_get_id(t), (unsigned char *) &pin_status, sizeof(pin_status)); } /** @@ -536,7 +534,7 @@ void ipc_sec_phone_lock(struct ipc_message_info *info) status = lock->status; - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, &status, sizeof(status)); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, &status, sizeof(status)); } /** @@ -565,9 +563,10 @@ void ril_request_query_facility_lock(RIL_Token t, void *data, size_t datalen) lock_request.facility = IPC_SEC_FACILITY_TYPE_PC; } else { LOGE("%s: unsupported facility: %s", __FUNCTION__, facility); - RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); } - ipc_fmt_send(IPC_SEC_PHONE_LOCK, IPC_TYPE_GET, &lock_request, sizeof(lock_request), reqGetId(t)); + + ipc_fmt_send(IPC_SEC_PHONE_LOCK, IPC_TYPE_GET, (void *) &lock_request, sizeof(lock_request), ril_request_get_id(t)); } // Both functions were the same @@ -605,7 +604,7 @@ void ril_request_set_facility_lock(RIL_Token t, void *data, size_t datalen) lock_request.type = IPC_SEC_SIM_STATUS_LOCK_PC; } else { LOGE("%s: unsupported facility: %s", __FUNCTION__, facility); - RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); } lock_request.lock = lock[0] == '1' ? 1 : 0; @@ -615,8 +614,8 @@ void ril_request_set_facility_lock(RIL_Token t, void *data, size_t datalen) memcpy(lock_request.password, password, lock_request.length); - ipc_gen_phone_res_expect_to_func(reqGetId(t), IPC_SEC_PHONE_LOCK, + ipc_gen_phone_res_expect_to_func(ril_request_get_id(t), IPC_SEC_PHONE_LOCK, ipc_sec_phone_lock_complete); - ipc_fmt_send(IPC_SEC_PHONE_LOCK, IPC_TYPE_SET, &lock_request, sizeof(lock_request), reqGetId(t)); + ipc_fmt_send(IPC_SEC_PHONE_LOCK, IPC_TYPE_SET, (void *) &lock_request, sizeof(lock_request), ril_request_get_id(t)); } @@ -238,7 +238,7 @@ void ril_request_send_sms(RIL_Token t, void *data, size_t datalen) if(!ril_request_sms_lock_acquire()) { LOGD("The SMS lock is already taken, adding req to the SMS queue"); - ril_request_sms_add(reqGetId(t), pdu, pdu_len, smsc, smsc_len); + ril_request_sms_add(ril_request_get_id(t), pdu, pdu_len, smsc, smsc_len); return; } @@ -247,9 +247,9 @@ void ril_request_send_sms(RIL_Token t, void *data, size_t datalen) LOGD("We have no SMSC, let's ask one"); /* Enqueue the request */ - ril_request_sms_add(reqGetId(t), pdu, pdu_len, NULL, 0); + ril_request_sms_add(ril_request_get_id(t), pdu, pdu_len, NULL, 0); - ipc_fmt_send_get(IPC_SMS_SVC_CENTER_ADDR, reqGetId(t)); + ipc_fmt_send_get(IPC_SMS_SVC_CENTER_ADDR, ril_request_get_id(t)); } else { ril_request_send_sms_complete(t, pdu, smsc); @@ -300,7 +300,7 @@ int ril_request_send_sms_next(void) /* We need to clear here to prevent infinite loop, but we can't free mem yet */ ril_request_sms_clear(id); - ril_request_send_sms(reqGetToken(aseq), (void *) request, sizeof(request)); + ril_request_send_sms(ril_request_get_token(aseq), (void *) request, sizeof(request)); if(pdu != NULL) free(pdu); @@ -334,7 +334,7 @@ void ril_request_send_sms_complete(RIL_Token t, char *pdu, char *smsc) if(pdu == NULL || smsc == NULL) { LOGE("Provided PDU or SMSC is NULL! Aborting"); - RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); /* Release the lock so we can accept new requests */ ril_request_sms_lock_release(); @@ -350,7 +350,7 @@ void ril_request_send_sms_complete(RIL_Token t, char *pdu, char *smsc) if(pdu_len / 2 > 0xff) { LOGE("PDU is too large, aborting"); - RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); /* Release the lock so we can accept new requests */ ril_request_sms_lock_release(); @@ -437,9 +437,9 @@ pdu_end: p += smsc_len; memcpy(p, pdu_dec, pdu_dec_len); - ipc_gen_phone_res_expect_to_func(reqGetId(t), IPC_SMS_SEND_MSG, ipc_sms_send_msg_complete); + ipc_gen_phone_res_expect_to_func(ril_request_get_id(t), IPC_SMS_SEND_MSG, ipc_sms_send_msg_complete); - ipc_fmt_send(IPC_SMS_SEND_MSG, IPC_TYPE_EXEC, data, data_len, reqGetId(t)); + ipc_fmt_send(IPC_SMS_SEND_MSG, IPC_TYPE_EXEC, data, data_len, ril_request_get_id(t)); free(pdu_dec); free(data); @@ -452,7 +452,7 @@ void ipc_sms_send_msg_complete(struct ipc_message_info *info) if(ipc_gen_phone_res_check(phone_res) < 0) { LOGE("IPC_GEN_PHONE_RES indicates error, abort request to RILJ"); - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); /* Release the lock so we can accept new requests */ ril_request_sms_lock_release(); @@ -477,7 +477,7 @@ void ipc_sms_svc_center_addr(struct ipc_message_info *info) if(id < 0) { LOGE("The request wasn't queued, reporting generic error!"); - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); /* Release the lock so we can accept new requests */ ril_request_sms_lock_release(); @@ -495,7 +495,7 @@ void ipc_sms_svc_center_addr(struct ipc_message_info *info) /* We need to clear here to prevent infinite loop, but we can't free mem yet */ ril_request_sms_clear(id); - ril_request_send_sms_complete(reqGetToken(info->aseq), pdu, (char *) info->data); + ril_request_send_sms_complete(ril_request_get_token(info->aseq), pdu, (char *) info->data); /* Now it is safe to free mem */ if(pdu != NULL) @@ -519,7 +519,7 @@ void ipc_sms_send_msg(struct ipc_message_info *info) response.ackPDU = NULL; ril_ack_err = ipc2ril_sms_ack_error(report_msg->error, &(response.errorCode)); - RIL_onRequestComplete(reqGetToken(info->aseq), ril_ack_err, &response, sizeof(response)); + ril_request_complete(ril_request_get_token(info->aseq), ril_ack_err, &response, sizeof(response)); /* Release the lock so we can accept new requests */ ril_request_sms_lock_release(); @@ -633,11 +633,11 @@ void ipc_sms_incoming_msg(struct ipc_message_info *info) ipc_sms_tpid_queue_add(msg->msg_tpid); if(msg->type == IPC_SMS_TYPE_POINT_TO_POINT) { - RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NEW_SMS, resp, resp_length); + ril_request_unsolicited(RIL_UNSOL_RESPONSE_NEW_SMS, resp, resp_length); } else if(msg->type == IPC_SMS_TYPE_STATUS_REPORT) { // FIXME: do we need to enqueue for this? - RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT, resp, resp_length); + ril_request_unsolicited(RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT, resp, resp_length); } else { LOGE("%s: Unknown message type", __FUNCTION__); } @@ -663,7 +663,7 @@ void ril_request_sms_acknowledge(RIL_Token t, void *data, size_t datalen) if(id < 0) { LOGE("There is no SMS message to ACK!"); - RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); return; } @@ -673,9 +673,9 @@ void ril_request_sms_acknowledge(RIL_Token t, void *data, size_t datalen) report_msg.msg_tpid = ipc_sms_tpid_queue[id]; report_msg.unk = 0; - ipc_gen_phone_res_expect_to_abort(reqGetId(t), IPC_SMS_DELIVER_REPORT); + ipc_gen_phone_res_expect_to_abort(ril_request_get_id(t), IPC_SMS_DELIVER_REPORT); - ipc_fmt_send(IPC_SMS_DELIVER_REPORT, IPC_TYPE_EXEC, (void *) &report_msg, sizeof(struct ipc_sms_deliv_report_msg), reqGetId(t)); + ipc_fmt_send(IPC_SMS_DELIVER_REPORT, IPC_TYPE_EXEC, (void *) &report_msg, sizeof(struct ipc_sms_deliv_report_msg), ril_request_get_id(t)); ipc_sms_tpid_queue_del(id); } @@ -688,7 +688,7 @@ void ipc_sms_deliver_report(struct ipc_message_info *info) { // TODO: check error code to eventually resend ACK - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, NULL, 0); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, NULL, 0); } /** @@ -698,9 +698,9 @@ void ipc_sms_deliver_report(struct ipc_message_info *info) void ipc_sms_device_ready(struct ipc_message_info *info) { #if RIL_VERSION >= 7 - if(ril_state.radio_state == RADIO_STATE_ON) { + if(ril_data.state.radio_state == RADIO_STATE_ON) { #else - if(ril_state.radio_state == RADIO_STATE_SIM_READY) { + if(ril_data.state.radio_state == RADIO_STATE_SIM_READY) { #endif ipc_fmt_send(IPC_SMS_DEVICE_READY, IPC_TYPE_SET, NULL, 0, info->aseq); } @@ -72,9 +72,9 @@ void ril_request_set_mute(RIL_Token t, void *data, size_t datalen) LOGD("Mute data is %d\n", mute_data); - ipc_gen_phone_res_expect_to_complete(reqGetId(t), IPC_SND_MIC_MUTE_CTRL); + ipc_gen_phone_res_expect_to_complete(ril_request_get_id(t), IPC_SND_MIC_MUTE_CTRL); - ipc_fmt_send(IPC_SND_MIC_MUTE_CTRL, IPC_TYPE_SET, (void *) &mute_data, sizeof(mute_data), reqGetId(t)); + ipc_fmt_send(IPC_SND_MIC_MUTE_CTRL, IPC_TYPE_SET, (void *) &mute_data, sizeof(mute_data), ril_request_get_id(t)); } void srs_snd_set_call_clock_sync(struct srs_message *message) @@ -82,7 +82,7 @@ void srs_snd_set_call_clock_sync(struct srs_message *message) unsigned char data = *((unsigned char *) message->data); LOGD("Clock sync data is 0x%x\n", data); - ipc_fmt_send(IPC_SND_CLOCK_CTRL, IPC_TYPE_EXEC, &data, sizeof(data), reqIdNew()); + ipc_fmt_send(IPC_SND_CLOCK_CTRL, IPC_TYPE_EXEC, &data, sizeof(data), ril_request_id_get()); } void srs_snd_set_call_volume(struct srs_message *message) @@ -95,7 +95,7 @@ void srs_snd_set_call_volume(struct srs_message *message) volume_ctrl.type = srs2ipc_call_type(call_volume->type); volume_ctrl.volume = call_volume->volume; - ipc_fmt_send(IPC_SND_SPKR_VOLUME_CTRL, IPC_TYPE_SET, (void *) &volume_ctrl, sizeof(volume_ctrl), reqIdNew()); + ipc_fmt_send(IPC_SND_SPKR_VOLUME_CTRL, IPC_TYPE_SET, (void *) &volume_ctrl, sizeof(volume_ctrl), ril_request_id_get()); } void srs_snd_set_call_audio_path(struct srs_message *message) @@ -105,5 +105,5 @@ void srs_snd_set_call_audio_path(struct srs_message *message) LOGD("Audio path to: 0x%x\n", path); - ipc_fmt_send(IPC_SND_AUDIO_PATH_CTRL, IPC_TYPE_SET, (void *) &path, sizeof(path), reqIdNew()); + ipc_fmt_send(IPC_SND_AUDIO_PATH_CTRL, IPC_TYPE_SET, (void *) &path, sizeof(path), ril_request_id_get()); } @@ -199,12 +199,12 @@ static int srs_read_loop(struct ril_client *client) return -1; } - if(client->object == NULL) { - LOGE("client object is NULL, aborting!"); + if(client->data == NULL) { + LOGE("client data is NULL, aborting!"); return -1; } - int server_fd = ((int*)client->object)[0]; + int server_fd = ((int*)client->data)[0]; while(1) { if(server_fd < 0) { @@ -252,7 +252,7 @@ static int srs_create(struct ril_client *client) goto fail; } - client->object = (void *) srs_server; + client->data = (void *) srs_server; if((*srs_server = srs_server_open()) < 0) { LOGE("%s: samsung-ril-socket server open failed", __FUNCTION__); goto fail; @@ -273,7 +273,7 @@ static int srs_destroy(struct ril_client *client) return 0; } - int *srs_server = (int*) client->object; + int *srs_server = (int*) client->data; if (!srs_server) { return 0; } @@ -33,13 +33,13 @@ void ipc_ss_ussd_complete(struct ipc_message_info *info) if(rc < 0) { LOGE("There was an error, aborting USSD request"); - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); - ril_state.ussd_state = 0; + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0); + ril_data.state.ussd_state = 0; return; } - RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, NULL, 0); + ril_request_complete(ril_request_get_token(info->aseq), RIL_E_SUCCESS, NULL, 0); } void ril_request_send_ussd(RIL_Token t, void *data, size_t datalen) @@ -52,7 +52,7 @@ void ril_request_send_ussd(RIL_Token t, void *data, size_t datalen) int message_size = 0xc0; - switch(ril_state.ussd_state) { + switch(ril_data.state.ussd_state) { case 0: case IPC_SS_USSD_NO_ACTION_REQUIRE: case IPC_SS_USSD_TERMINATED_BY_NET: @@ -64,7 +64,7 @@ void ril_request_send_ussd(RIL_Token t, void *data, size_t datalen) data_enc_len = ascii2gsm7(data, (unsigned char**)&data_enc, datalen); if(data_enc_len > message_size) { LOGE("USSD message size is too long, aborting"); - RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); free(data_enc); @@ -92,7 +92,7 @@ void ril_request_send_ussd(RIL_Token t, void *data, size_t datalen) if(data_enc_len > message_size) { LOGE("USSD message size is too long, aborting"); - RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); free(data_enc); @@ -117,14 +117,14 @@ void ril_request_send_ussd(RIL_Token t, void *data, size_t datalen) if(message == NULL) { LOGE("USSD message is empty, aborting"); - RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + ril_request_complete(t, RIL_E_GENERIC_FAILURE, NULL, 0); return; } - ipc_gen_phone_res_expect_to_func(reqGetId(t), IPC_SS_USSD, + ipc_gen_phone_res_expect_to_func(ril_request_get_id(t), IPC_SS_USSD, ipc_ss_ussd_complete); - ipc_fmt_send(IPC_SS_USSD, IPC_TYPE_EXEC, (void *) message, message_size, reqGetId(t)); + ipc_fmt_send(IPC_SS_USSD, IPC_TYPE_EXEC, (void *) message, message_size, ril_request_get_id(t)); } void ril_request_cancel_ussd(RIL_Token t, void *data, size_t datalen) @@ -134,11 +134,11 @@ void ril_request_cancel_ussd(RIL_Token t, void *data, size_t datalen) memset(&ussd, 0, sizeof(ussd)); ussd.state = IPC_SS_USSD_TERMINATED_BY_NET; - ril_state.ussd_state = IPC_SS_USSD_TERMINATED_BY_NET; + ril_data.state.ussd_state = IPC_SS_USSD_TERMINATED_BY_NET; - ipc_gen_phone_res_expect_to_complete(reqGetId(t), IPC_SS_USSD); + ipc_gen_phone_res_expect_to_complete(ril_request_get_id(t), IPC_SS_USSD); - ipc_fmt_send(IPC_SS_USSD, IPC_TYPE_EXEC, (void *) &ussd, sizeof(ussd), reqGetId(t)); + ipc_fmt_send(IPC_SS_USSD, IPC_TYPE_EXEC, (void *) &ussd, sizeof(ussd), ril_request_get_id(t)); } void ipc2ril_ussd_state(struct ipc_ss_ussd *ussd, char *message[2]) @@ -182,7 +182,7 @@ void ipc_ss_ussd(struct ipc_message_info *info) ipc2ril_ussd_state(ussd, message); - ril_state.ussd_state = ussd->state; + ril_data.state.ussd_state = ussd->state; if(ussd->length > 0 && info->length > 0 && info->data != NULL) { codingScheme = sms_get_coding_scheme(ussd->dcs); @@ -221,5 +221,5 @@ void ipc_ss_ussd(struct ipc_message_info *info) } } - RIL_onUnsolicitedResponse(RIL_UNSOL_ON_USSD, message, sizeof(message)); + ril_request_unsolicited(RIL_UNSOL_ON_USSD, message, sizeof(message)); } @@ -29,6 +29,44 @@ #include "samsung-ril.h" /** + * List + */ + +struct list_head *list_head_alloc(void *data, struct list_head *prev, struct list_head *next) +{ + struct list_head *list; + + list = calloc(1, sizeof(struct list_head)); + if(list == NULL) + return NULL; + + list->data = data; + list->prev = prev; + list->next = next; + + if(prev != NULL) + prev->next = list; + if(next != NULL) + next->prev = list; + + return list; +} + +void list_head_free(struct list_head *list) +{ + if(list == NULL) + return; + + if(list->next != NULL) + list->next->prev = list->prev; + if(list->prev != NULL) + list->prev->next = list->next; + + memset(list, 0, sizeof(struct list_head)); + free(list); +} + +/** * Converts a hexidecimal string to binary */ void hex2bin(const char *data, int length, unsigned char *buf) @@ -21,6 +21,15 @@ #ifndef _SAMSUNG_RIL_UTIL_H_ #define _SAMSUNG_RIL_UTIL_H_ +struct list_head { + struct list_head *prev; + struct list_head *next; + void *data; +}; + +struct list_head *list_head_alloc(void *data, struct list_head *prev, struct list_head *next); +void list_head_free(struct list_head *list); + void bin2hex(const unsigned char *data, int length, char *buf); void hex2bin(const char *data, int length, unsigned char *buf); int gsm72ascii(unsigned char *data, char **data_dec, int length); |