summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulK <contact@paulk.fr>2011-12-29 13:32:26 +0100
committerPaulK <contact@paulk.fr>2011-12-29 13:32:26 +0100
commit16fd5fb67ba755fa65253eaaf861f46dc1135147 (patch)
tree08e47d251aad8f430530beeb082ceb2a89387157
parent0091ceae5f7cbeeb42e3b43de3dcf8e500fe8752 (diff)
downloadhardware_replicant_libsamsung-ril-16fd5fb67ba755fa65253eaaf861f46dc1135147.tar.gz
hardware_replicant_libsamsung-ril-16fd5fb67ba755fa65253eaaf861f46dc1135147.tar.bz2
hardware_replicant_libsamsung-ril-16fd5fb67ba755fa65253eaaf861f46dc1135147.zip
Added preliminary RFS support, code cleanup, completed TODO list
-rw-r--r--call.c48
-rw-r--r--ipc.c177
-rw-r--r--ipc.h1
-rw-r--r--net.c81
-rw-r--r--samsung-ril.c84
-rw-r--r--samsung-ril.h13
-rw-r--r--sms.c56
7 files changed, 362 insertions, 98 deletions
diff --git a/call.c b/call.c
index 4a71e34..70b151e 100644
--- a/call.c
+++ b/call.c
@@ -25,6 +25,31 @@
#include "samsung-ril.h"
/**
+ * Format conversion utils
+ */
+
+unsigned char ipc2ril_call_list_entry_state(unsigned char call_state)
+{
+ switch(call_state) {
+ case IPC_CALL_LIST_ENTRY_STATE_ACTIVE:
+ return RIL_CALL_ACTIVE;
+ case IPC_CALL_LIST_ENTRY_STATE_HOLDING:
+ return RIL_CALL_HOLDING;
+ case IPC_CALL_LIST_ENTRY_STATE_DIALING:
+ return RIL_CALL_DIALING;
+ case IPC_CALL_LIST_ENTRY_STATE_ALERTING:
+ return RIL_CALL_ALERTING;
+ case IPC_CALL_LIST_ENTRY_STATE_INCOMING:
+ return RIL_CALL_INCOMING;
+ case IPC_CALL_LIST_ENTRY_STATE_WAITING:
+ return RIL_CALL_WAITING;
+ default:
+ LOGE("Unknown IPC_CALL_LIST_ENTRY_STATE!");
+ return -1;
+ }
+}
+
+/**
* In: RIL_UNSOL_CALL_RING
* Ring indication for an incoming call (eg, RING or CRING event).
*/
@@ -96,27 +121,6 @@ void ril_request_dial(RIL_Token t, void *data, size_t datalen)
RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
}
-unsigned char call_list_entry_state_ipc2ril(unsigned char call_state)
-{
- switch(call_state) {
- case IPC_CALL_LIST_ENTRY_STATE_ACTIVE:
- return RIL_CALL_ACTIVE;
- case IPC_CALL_LIST_ENTRY_STATE_HOLDING:
- return RIL_CALL_HOLDING;
- case IPC_CALL_LIST_ENTRY_STATE_DIALING:
- return RIL_CALL_DIALING;
- case IPC_CALL_LIST_ENTRY_STATE_ALERTING:
- return RIL_CALL_ALERTING;
- case IPC_CALL_LIST_ENTRY_STATE_INCOMING:
- return RIL_CALL_INCOMING;
- case IPC_CALL_LIST_ENTRY_STATE_WAITING:
- return RIL_CALL_WAITING;
- default:
- LOGE("Unknown IPC_CALL_LIST_ENTRY_STATE!");
- return -1;
- }
-}
-
/**
* In: RIL_REQUEST_GET_CURRENT_CALLS
* Requests current call list
@@ -158,7 +162,7 @@ void ipc_call_list(struct ipc_message_info *info)
memset(number_ril, 0, (entry->number_len + 1));
memcpy(number_ril, number, entry->number_len);
- call->state = call_list_entry_state_ipc2ril(entry->state);
+ call->state = ipc2ril_call_list_entry_state(entry->state);
call->index = (entry->idx+1);
call->toa = (entry->number_len > 0 && number[0] == '+') ? 145 : 129;
call->isMpty = entry->mpty;
diff --git a/ipc.c b/ipc.c
index 8bfeafc..5aa3f1b 100644
--- a/ipc.c
+++ b/ipc.c
@@ -25,11 +25,19 @@
#include "samsung-ril.h"
#include <radio.h>
+/**
+ * IPC shared
+ */
+
void ipc_log_handler(const char *message, void *user_data)
{
LOGD("ipc: %s", message);
}
+/**
+ * IPC FMT
+ */
+
void ipc_fmt_send(const unsigned short command, const char type, unsigned char *data, const int length, unsigned char mseq)
{
struct ipc_client *ipc_client;
@@ -46,9 +54,9 @@ void ipc_fmt_send(const unsigned short command, const char type, unsigned char *
ipc_client = ((struct ipc_client_object *) ipc_fmt_client->object)->ipc_client;
- pthread_mutex_lock(&(ipc_fmt_client->mutex));
+ RIL_CLIENT_LOCK(ipc_fmt_client);
ipc_client_send(ipc_client, command, type, data, length, mseq);
- pthread_mutex_unlock(&(ipc_fmt_client->mutex));
+ RIL_CLIENT_UNLOCK(ipc_fmt_client);
}
int ipc_fmt_read_loop(struct ril_client *client)
@@ -83,10 +91,14 @@ int ipc_fmt_read_loop(struct ril_client *client)
select(FD_SETSIZE, &fds, NULL, NULL, NULL);
if(FD_ISSET(ipc_client_fd, &fds)) {
+ RIL_CLIENT_LOCK(client);
if(ipc_client_recv(ipc_client, &info)) {
+ RIL_CLIENT_UNLOCK(client);
LOGE("IPC FMT recv failed, aborting!");
return -1;
}
+ RIL_CLIENT_UNLOCK(client);
+
LOGD("IPC FMT recv: aseq=0x%x mseq=0x%x data_length=%d\n", info.aseq, info.mseq, info.length);
ipc_fmt_dispatch(&info);
@@ -170,6 +182,8 @@ int ipc_fmt_create(struct ril_client *client)
return -1;
}
+ LOGD("IPC FMT client done");
+
return 0;
}
@@ -209,8 +223,167 @@ int ipc_fmt_destroy(struct ril_client *client)
return 0;
}
+/**
+ * IPC RFS
+ */
+
+int ipc_rfs_read_loop(struct ril_client *client)
+{
+ struct ipc_message_info info;
+ struct ipc_client *ipc_client;
+ int ipc_client_fd;
+ fd_set fds;
+
+ if(client == NULL) {
+ LOGE("client is NULL, aborting!");
+ return -1;
+ }
+
+ if(client->object == NULL) {
+ LOGE("client object 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;
+
+ FD_ZERO(&fds);
+ FD_SET(ipc_client_fd, &fds);
+
+ while(1) {
+ if(ipc_client_fd < 0) {
+ LOGE("IPC RFS client fd is negative, aborting!");
+ return -1;
+ }
+
+ select(FD_SETSIZE, &fds, NULL, NULL, NULL);
+
+ if(FD_ISSET(ipc_client_fd, &fds)) {
+ RIL_CLIENT_LOCK(client);
+ if(ipc_client_recv(ipc_client, &info)) {
+ RIL_CLIENT_UNLOCK(client);
+ LOGE("IPC RFS recv failed, aborting!");
+ return -1;
+ }
+ RIL_CLIENT_UNLOCK(client);
+
+ LOGD("IPC RFS recv: command=%d data_length=%d\n", info.type, info.length);
+
+ ipc_rfs_dispatch(&info);
+
+ if(info.data != NULL)
+ free(info.data);
+ }
+ }
+
+ return 0;
+}
+
+int ipc_rfs_create(struct ril_client *client)
+{
+ struct ipc_client_object *client_object;
+ 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->object = client_object;
+
+ ipc_client = (struct ipc_client *) client_object->ipc_client;
+
+ LOGD("Creating new RFS client");
+ ipc_client = ipc_client_new(IPC_CLIENT_TYPE_RFS);
+
+ if(ipc_client == NULL) {
+ LOGE("RFS client creation failed!");
+ return -1;
+ }
+
+ client_object->ipc_client = ipc_client;
+
+ LOGD("Setting log handler");
+ rc = ipc_client_set_log_handler(ipc_client, ipc_log_handler, NULL);
+
+ if(rc < 0) {
+ LOGE("Setting log handler failed!");
+ return -1;
+ }
+
+ //FIXME: ipc_client_set_handler
+
+ LOGD("Passing client->object->ipc_client fd as handlers data");
+ rc = ipc_client_set_all_handlers_data(ipc_client, &((struct ipc_client_object *) client->object)->ipc_client_fd);
+
+ if(rc < 0) {
+ LOGE("ipc_client_fd as handlers data failed!");
+ return -1;
+ }
+
+ LOGD("Client open...");
+ if(ipc_client_open(ipc_client)) {
+ LOGE("%s: failed to open ipc client", __FUNCTION__);
+ return -1;
+ }
+
+ ipc_client_fd = ((struct ipc_client_object *) client->object)->ipc_client_fd;
+
+ if(ipc_client_fd < 0) {
+ LOGE("%s: client_rfs_fd is negative, aborting", __FUNCTION__);
+ return -1;
+ }
+
+ LOGD("IPC RFS client done");
+
+ return 0;
+}
+
+
+int ipc_rfs_destroy(struct ril_client *client)
+{
+ struct ipc_client *ipc_client;
+ int ipc_client_fd;
+ int rc;
+
+ LOGD("Destrying ipc rfs client");
+
+ if(client == NULL) {
+ LOGE("client was already destroyed");
+ return 0;
+ }
+
+ if(client->object == NULL) {
+ LOGE("client object was already destroyed");
+ return 0;
+ }
+
+ ipc_client_fd = ((struct ipc_client_object *) client->object)->ipc_client_fd;
+
+ if(ipc_client_fd)
+ close(ipc_client_fd);
+
+ ipc_client = ((struct ipc_client_object *) client->object)->ipc_client;
+
+ if(ipc_client != NULL) {
+ ipc_client_close(ipc_client);
+ ipc_client_free(ipc_client);
+ }
+
+ free(client->object);
+
+ return 0;
+}
+
struct ril_client_funcs ipc_fmt_client_funcs = {
.create = ipc_fmt_create,
.destroy = ipc_fmt_destroy,
.read_loop = ipc_fmt_read_loop,
};
+
+struct ril_client_funcs ipc_rfs_client_funcs = {
+ .create = ipc_rfs_create,
+ .destroy = ipc_rfs_destroy,
+ .read_loop = ipc_rfs_read_loop,
+};
diff --git a/ipc.h b/ipc.h
index 5edc58d..c4c0529 100644
--- a/ipc.h
+++ b/ipc.h
@@ -39,6 +39,7 @@ struct ipc_client_object {
};
extern struct ril_client_funcs ipc_fmt_client_funcs;
+extern struct ril_client_funcs ipc_rfs_client_funcs;
void ipc_fmt_send(const unsigned short command, const char type, unsigned char *data, const int length, unsigned char mseq);
diff --git a/net.c b/net.c
index c4c43da..686f6e6 100644
--- a/net.c
+++ b/net.c
@@ -28,13 +28,13 @@
#define RIL_TOKEN_NET_DATA_WAITING (RIL_Token) 0xff
/**
- * NET Utility functions
+ * Format conversion utils
*/
/**
* Converts IPC network registration status to Android RIL format
*/
-unsigned char reg_state_ipc2ril(unsigned char reg_state)
+unsigned char ipc2ril_reg_state(unsigned char reg_state)
{
switch(reg_state) {
case IPC_NET_REGISTRATION_STATE_NONE:
@@ -58,7 +58,7 @@ unsigned char reg_state_ipc2ril(unsigned char reg_state)
/**
* Converts IPC network access technology to Android RIL format
*/
-unsigned char act_ipc2ril(unsigned char act)
+unsigned char ipc2ril_act(unsigned char act)
{
switch(act) {
case IPC_NET_ACCESS_TECHNOLOGY_GPRS:
@@ -77,7 +77,7 @@ unsigned char act_ipc2ril(unsigned char act)
/**
* Converts IPC GPRS network access technology to Android RIL format
*/
-unsigned char gprs_act_ipc2ril(unsigned char act)
+unsigned char ipc2ril_gprs_act(unsigned char act)
{
switch(act) {
case IPC_NET_ACCESS_TECHNOLOGY_GPRS:
@@ -96,7 +96,7 @@ unsigned char gprs_act_ipc2ril(unsigned char act)
/**
* Converts IPC preferred network type to Android RIL format
*/
-unsigned char modesel_ipc2ril(unsigned char mode)
+unsigned char ipc2ril_modesel(unsigned char mode)
{
switch(mode) {
case 0:
@@ -115,7 +115,7 @@ unsigned char modesel_ipc2ril(unsigned char mode)
/**
* Converts Android RIL preferred network type to IPC format
*/
-unsigned char modesel_ril2ipc(unsigned char mode)
+unsigned char ril2ipc_modesel(unsigned char mode)
{
switch(mode) {
case 1:
@@ -130,7 +130,7 @@ unsigned char modesel_ril2ipc(unsigned char mode)
/**
* Converts IPC PLMC to Android format
*/
-void plmn_ipc2ril(struct ipc_net_current_plmn *plmndata, char *response[3])
+void ipc2ril_plmn(struct ipc_net_current_plmn *plmndata, char *response[3])
{
char plmn[7];
@@ -150,27 +150,34 @@ void plmn_ipc2ril(struct ipc_net_current_plmn *plmndata, char *response[3])
/**
* Converts IPC reg state to Android format
*/
-void reg_state_resp_ipc2ril(struct ipc_net_regist *netinfo, char *response[15])
+void ipc2ril_reg_state_resp(struct ipc_net_regist *netinfo, char *response[15])
{
+ unsigned char reg_state = ipc2ril_reg_state(netinfo->reg_state);
+ unsigned char act = ipc2ril_act(netinfo->act);
+
memset(response, 0, sizeof(response));
- asprintf(&response[0], "%d", reg_state_ipc2ril(netinfo->reg_state));
+ asprintf(&response[0], "%d", reg_state);
asprintf(&response[1], "%x", netinfo->lac);
asprintf(&response[2], "%x", netinfo->cid);
- asprintf(&response[3], "%d", act_ipc2ril(netinfo->act));
+ if(act)
+ asprintf(&response[3], "%d", act);
}
/**
* Converts IPC GPRS reg state to Android format
*/
-void gprs_reg_state_resp_ipc2ril(struct ipc_net_regist *netinfo, char *response[4])
+void ipc2ril_gprs_reg_state_resp(struct ipc_net_regist *netinfo, char *response[4])
{
+ unsigned char reg_state = ipc2ril_reg_state(netinfo->reg_state);
+ unsigned char act = ipc2ril_gprs_act(netinfo->act);
+
memset(response, 0, sizeof(response));
- asprintf(&response[0], "%d", reg_state_ipc2ril(netinfo->reg_state));
+ asprintf(&response[0], "%d", reg_state);
asprintf(&response[1], "%x", netinfo->lac);
asprintf(&response[2], "%x", netinfo->cid);
- asprintf(&response[3], "%d", gprs_act_ipc2ril(netinfo->act));
+ asprintf(&response[3], "%d", act);
}
/**
@@ -179,7 +186,7 @@ void gprs_reg_state_resp_ipc2ril(struct ipc_net_regist *netinfo, char *response[
* to ask the modem new NET Regist and GPRS Net Regist states so act like we got
* these from modem NOTI too so we don't have to make the requests
*/
-void net_set_tokens_data_waiting(void)
+void ril_tokens_net_set_data_waiting(void)
{
ril_state.tokens.registration_state = RIL_TOKEN_NET_DATA_WAITING;
ril_state.tokens.gprs_registration_state = RIL_TOKEN_NET_DATA_WAITING;
@@ -189,7 +196,7 @@ void net_set_tokens_data_waiting(void)
/**
* Returns 1 if unsol data is waiting, 0 if not
*/
-int net_get_tokens_data_waiting(void)
+int ril_tokens_net_get_data_waiting(void)
{
return ril_state.tokens.registration_state == RIL_TOKEN_NET_DATA_WAITING || ril_state.tokens.gprs_registration_state == RIL_TOKEN_NET_DATA_WAITING || ril_state.tokens.operator == RIL_TOKEN_NET_DATA_WAITING;
}
@@ -197,9 +204,9 @@ int net_get_tokens_data_waiting(void)
/**
* Print net tokens values
*/
-void net_tokens_state_dump(void)
+void ril_tokens_net_state_dump(void)
{
- LOGD("NET_TOKENS_STATE_DUMP:\n\tril_state.tokens.registration_state = 0x%x\n\tril_state.tokens.gprs_registration_state = 0x%x\n\tril_state.tokens.operator = 0x%x\n", ril_state.tokens.registration_state, ril_state.tokens.gprs_registration_state, ril_state.tokens.operator);
+ LOGD("ril_tokens_net_state_dump:\n\tril_state.tokens.registration_state = 0x%x\n\tril_state.tokens.gprs_registration_state = 0x%x\n\tril_state.tokens.operator = 0x%x\n", ril_state.tokens.registration_state, ril_state.tokens.gprs_registration_state, ril_state.tokens.operator);
}
/**
@@ -269,7 +276,7 @@ void ril_request_operator(RIL_Token t)
LOGD("Got RILJ request for UNSOL data");
/* Send back the data we got UNSOL */
- plmn_ipc2ril(&(ril_state.plmndata), response);
+ ipc2ril_plmn(&(ril_state.plmndata), response);
RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response));
@@ -290,7 +297,7 @@ void ril_request_operator(RIL_Token t)
RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, response, sizeof(response));
}
- net_tokens_state_dump();
+ ril_tokens_net_state_dump();
}
/**
@@ -332,10 +339,10 @@ void ipc_net_current_plmn(struct ipc_message_info *message)
memcpy(&(ril_state.plmndata), plmndata, sizeof(struct ipc_net_current_plmn));
/* we already told RILJ to get the new data but it wasn't done yet */
- if(net_get_tokens_data_waiting() && ril_state.tokens.operator == RIL_TOKEN_NET_DATA_WAITING) {
+ if(ril_tokens_net_get_data_waiting() && ril_state.tokens.operator == RIL_TOKEN_NET_DATA_WAITING) {
LOGD("Updating Operator data in background");
} else {
- net_set_tokens_data_waiting();
+ ril_tokens_net_set_data_waiting();
RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, NULL, 0);
}
}
@@ -361,7 +368,7 @@ void ipc_net_current_plmn(struct ipc_message_info *message)
/* Better keeping it up to date */
memcpy(&(ril_state.plmndata), plmndata, sizeof(struct ipc_net_current_plmn));
- plmn_ipc2ril(plmndata, response);
+ ipc2ril_plmn(plmndata, response);
RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response));
@@ -379,7 +386,7 @@ void ipc_net_current_plmn(struct ipc_message_info *message)
break;
}
- net_tokens_state_dump();
+ ril_tokens_net_state_dump();
}
/**
@@ -400,7 +407,7 @@ void ril_request_registration_state(RIL_Token t)
LOGD("Got RILJ request for UNSOL data");
/* Send back the data we got UNSOL */
- reg_state_resp_ipc2ril(&(ril_state.netinfo), response);
+ ipc2ril_reg_state_resp(&(ril_state.netinfo), response);
RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response));
@@ -422,7 +429,7 @@ void ril_request_registration_state(RIL_Token t)
RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
}
- net_tokens_state_dump();
+ ril_tokens_net_state_dump();
}
/**
@@ -443,7 +450,7 @@ void ril_request_gprs_registration_state(RIL_Token t)
LOGD("Got RILJ request for UNSOL data");
/* Send back the data we got UNSOL */
- gprs_reg_state_resp_ipc2ril(&(ril_state.gprs_netinfo), response);
+ ipc2ril_gprs_reg_state_resp(&(ril_state.gprs_netinfo), response);
RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response));
@@ -466,7 +473,7 @@ void ril_request_gprs_registration_state(RIL_Token t)
RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
}
- net_tokens_state_dump();
+ ril_tokens_net_state_dump();
}
void ipc_net_regist_unsol(struct ipc_message_info *message)
@@ -486,10 +493,10 @@ void ipc_net_regist_unsol(struct ipc_message_info *message)
memcpy(&(ril_state.netinfo), netinfo, sizeof(struct ipc_net_regist));
/* we already told RILJ to get the new data but it wasn't done yet */
- if(net_get_tokens_data_waiting() && ril_state.tokens.registration_state == RIL_TOKEN_NET_DATA_WAITING) {
+ if(ril_tokens_net_get_data_waiting() && ril_state.tokens.registration_state == RIL_TOKEN_NET_DATA_WAITING) {
LOGD("Updating NetRegist data in background");
} else {
- net_set_tokens_data_waiting();
+ ril_tokens_net_set_data_waiting();
RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, NULL, 0);
}
break;
@@ -503,10 +510,10 @@ void ipc_net_regist_unsol(struct ipc_message_info *message)
memcpy(&(ril_state.gprs_netinfo), netinfo, sizeof(struct ipc_net_regist));
/* we already told RILJ to get the new data but it wasn't done yet */
- if(net_get_tokens_data_waiting() && ril_state.tokens.gprs_registration_state == RIL_TOKEN_NET_DATA_WAITING) {
+ if(ril_tokens_net_get_data_waiting() && ril_state.tokens.gprs_registration_state == RIL_TOKEN_NET_DATA_WAITING) {
LOGD("Updating GPRSNetRegist data in background");
} else {
- net_set_tokens_data_waiting();
+ ril_tokens_net_set_data_waiting();
RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, NULL, 0);
}
break;
@@ -515,7 +522,7 @@ void ipc_net_regist_unsol(struct ipc_message_info *message)
break;
}
- net_tokens_state_dump();
+ ril_tokens_net_state_dump();
}
void ipc_net_regist_sol(struct ipc_message_info *message)
@@ -536,7 +543,7 @@ void ipc_net_regist_sol(struct ipc_message_info *message)
/* Better keeping it up to date */
memcpy(&(ril_state.netinfo), netinfo, sizeof(struct ipc_net_regist));
- reg_state_resp_ipc2ril(netinfo, response);
+ ipc2ril_reg_state_resp(netinfo, response);
RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response));
@@ -555,7 +562,7 @@ void ipc_net_regist_sol(struct ipc_message_info *message)
/* Better keeping it up to date */
memcpy(&(ril_state.gprs_netinfo), netinfo, sizeof(struct ipc_net_regist));
- gprs_reg_state_resp_ipc2ril(netinfo, response);
+ ipc2ril_gprs_reg_state_resp(netinfo, response);
RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response));
@@ -571,7 +578,7 @@ void ipc_net_regist_sol(struct ipc_message_info *message)
break;
}
- net_tokens_state_dump();
+ ril_tokens_net_state_dump();
}
/**
@@ -690,7 +697,7 @@ void ril_request_get_preferred_network_type(RIL_Token t)
void ril_request_set_preffered_network_type(RIL_Token t, void *data, size_t datalen)
{
int ril_mode = *(int*)data;
- unsigned char ipc_mode = modesel_ril2ipc(ril_mode);
+ unsigned char ipc_mode = ril2ipc_modesel(ril_mode);
ipc_fmt_send(IPC_NET_MODE_SEL, IPC_TYPE_SET, &ipc_mode, sizeof(ipc_mode), reqGetId(t));
}
@@ -698,7 +705,7 @@ void ril_request_set_preffered_network_type(RIL_Token t, void *data, size_t data
void ipc_net_mode_sel(struct ipc_message_info *info)
{
unsigned char ipc_mode = *(unsigned char *) info->data;
- int ril_mode = modesel_ipc2ril(ipc_mode);
+ int ril_mode = ipc2ril_modesel(ipc_mode);
RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, &ril_mode, sizeof(int*));
}
diff --git a/samsung-ril.c b/samsung-ril.c
index a457b45..d3c7aa2 100644
--- a/samsung-ril.c
+++ b/samsung-ril.c
@@ -34,9 +34,21 @@
/**
* Samsung-RIL TODO:
* - add IPC_NET_SERVING_NETWORK
- * - client prefix first: ipc2ril_reg_state
- * - all these functions on the top
- * - use checked function before returning a token to RILJ
+ * - add RFS NV_DATA functions
+ * libsamsung-ipc: export nv_data functions as common
+ * - add data support
+ * - stabilize SMS
+ * - complete sound handling
+ * - USSD codes
+ * - full operators list
+ * - airplane mode: trace: sys nodes?
+ * - ipc_disp_icon_info: trace on RILJ & emulate RIl_REQUEST_SIGNAL_STRENGTH
+ * - look at /sys nodes for data and airplane
+ * - fails at killall zygote?
+ * - call with +33
+ * - gen phone res queue
+ * - SMS ret isn't NULL (tpid)
+ * - Android "0" net type (logs)!
*/
/**
@@ -91,7 +103,7 @@ RIL_Token ril_request_get_token(int id)
return ril_requests_tokens[id].token;
}
-int ril_request_is_valid(RIL_Token token)
+int ril_request_get_canceled(RIL_Token token)
{
int id;
@@ -103,6 +115,23 @@ int ril_request_is_valid(RIL_Token token)
return 0;
}
+void ril_request_set_canceled(RIL_Token token, int canceled)
+{
+ int id;
+
+ id = ril_request_get_id(token);
+
+ ril_requests_tokens[id].canceled = canceled;
+}
+
+void RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen)
+{
+ if(!ril_request_get_canceled(t))
+ RIL_onRequestCompleteReal(t, e, response, responselen);
+ else
+ RIL_onRequestCompleteReal(t, RIL_E_CANCELLED, response, responselen);
+}
+
/**
* RIL tokens
*/
@@ -240,6 +269,28 @@ void ipc_fmt_dispatch(struct ipc_message_info *info)
}
}
+void ipc_rfs_dispatch(struct ipc_message_info *info)
+{
+ struct ipc_rfs_io *rfs_io;
+
+ switch(IPC_COMMAND(info)) {
+ case IPC_RFS_NV_READ_ITEM:
+ LOGD("--> IPC_RFS_NV_READ_ITEM");
+ rfs_io = (struct ipc_rfs_io *) info->data;
+
+ LOGD("asking to read 0x%x bytes at offset 0x%x", rfs_io->length, rfs_io->offset);
+
+ break;
+ case IPC_RFS_NV_WRITE_ITEM:
+ LOGD("--> IPC_RFS_NV_WRITE_ITEM");
+
+ rfs_io = (struct ipc_rfs_io *) info->data;
+
+ LOGD("asking to write 0x%x bytes at offset 0x%x", rfs_io->length, rfs_io->offset);
+ break;
+ }
+}
+
void srs_dispatch(struct srs_message *message)
{
switch(message->command) {
@@ -400,7 +451,7 @@ int onSupports(int requestCode)
void onCancel(RIL_Token t)
{
- /* Todo */
+ ril_request_set_canceled(t, 1);
}
const char *getVersion(void)
@@ -439,6 +490,8 @@ const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc, char **a
memset(&(ril_state.tokens), 0, sizeof(struct ril_tokens));
ipc_fmt:
+ LOGD("Creating IPC FMT client");
+
ipc_fmt_client = ril_client_new(&ipc_fmt_client_funcs);
rc = ril_client_create(ipc_fmt_client);
@@ -457,9 +510,28 @@ ipc_fmt:
LOGD("IPC FMT client ready");
ipc_rfs:
- LOGD("Wait for the rest to be working before doing RFS");
+ LOGD("Creating IPC RFS client");
+
+ ipc_rfs_client = ril_client_new(&ipc_rfs_client_funcs);
+ rc = ril_client_create(ipc_rfs_client);
+
+ if(rc < 0) {
+ LOGE("IPC RFS client creation failed.");
+ goto srs;
+ }
+
+ rc = ril_client_thread_start(ipc_rfs_client);
+
+ if(rc < 0) {
+ LOGE("IPC RFS thread creation failed.");
+ goto srs;
+ }
+
+ LOGD("IPC RFS client ready");
srs:
+ LOGD("Creating SRS client");
+
srs_client = ril_client_new(&srs_client_funcs);
rc = ril_client_create(srs_client);
diff --git a/samsung-ril.h b/samsung-ril.h
index b34bc76..ab471aa 100644
--- a/samsung-ril.h
+++ b/samsung-ril.h
@@ -34,10 +34,10 @@
* Defines
*/
-#define RIL_onRequestComplete(t, e, response, responselen) ril_env->OnRequestComplete(t,e, response, responselen)
-#define RIL_onRequestCompleteIfValid(t, e, response, responselen) \
- if((ril_request_is_valid(t)) \
- RIL_onRequestComplete(t, e, response, responselen)
+#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)
@@ -117,7 +117,10 @@ struct ril_request_token {
int ril_request_id_new(void);
int ril_request_get_id(RIL_Token token);
RIL_Token ril_request_get_token(int id);
-int ril_request_is_valid(RIL_Token token);
+int ril_request_get_canceled(RIL_Token token);
+void ril_request_set_canceled(RIL_Token token, int canceled);
+
+void RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen);
/**
* RIL tokens
diff --git a/sms.c b/sms.c
index 9c0cf90..4b07de0 100644
--- a/sms.c
+++ b/sms.c
@@ -25,6 +25,34 @@
#include "samsung-ril.h"
#include "util.h"
+/**
+ * Format conversion utils
+ */
+
+unsigned short ril2ipc_sms_ack_error(int success, int failcause)
+{
+ if(success) {
+ return IPC_SMS_ACK_NO_ERROR;
+ } else {
+ switch(failcause) {
+ case 0xD3:
+ return IPC_SMS_ACK_PDA_FULL_ERROR;
+ default:
+ return IPC_SMS_ACK_UNSPEC_ERROR;
+ }
+ }
+}
+
+RIL_Errno ipc2ril_sms_ack_error(unsigned short error)
+{
+ switch(error) {
+ case IPC_SMS_ACK_NO_ERROR:
+ return RIL_E_SUCCESS;
+ default:
+ return RIL_E_GENERIC_FAILURE;
+ }
+}
+
void ipc_sms_incoming_msg(struct ipc_message_info *info)
{
struct ipc_sms_incoming_msg *msg = (struct ipc_sms_incoming_msg *) info->data;
@@ -56,30 +84,6 @@ exit:
free(resp);
}
-unsigned short sms_ack_error_ril2ipc(int success, int failcause)
-{
- if(success) {
- return IPC_SMS_ACK_NO_ERROR;
- } else {
- switch(failcause) {
- case 0xD3:
- return IPC_SMS_ACK_PDA_FULL_ERROR;
- default:
- return IPC_SMS_ACK_UNSPEC_ERROR;
- }
- }
-}
-
-RIL_Errno sms_ack_error_ipc2ril(unsigned short error)
-{
- switch(error) {
- case IPC_SMS_ACK_NO_ERROR:
- return RIL_E_SUCCESS;
- default:
- return RIL_E_GENERIC_FAILURE;
- }
-}
-
/**
* In: RIL_REQUEST_SMS_ACKNOWLEDGE
* Acknowledge successful or failed receipt of SMS previously indicated
@@ -100,7 +104,7 @@ void ril_request_sms_acknowledge(RIL_Token t, void *data, size_t datalen)
}
report_msg.type = IPC_SMS_TYPE_STATUS_REPORT;
- report_msg.error = sms_ack_error_ril2ipc(success, failcause);
+ report_msg.error = ril2ipc_sms_ack_error(success, failcause);
report_msg.msg_tpid = ril_state.msg_tpid_lock;
report_msg.unk = 0;
@@ -224,7 +228,7 @@ void ipc_sms_send_msg(struct ipc_message_info *info)
LOGD("RECV ack for msg_tpid %d\n", report_msg->msg_tpid);
- ril_ack_err = sms_ack_error_ipc2ril(report_msg->error);
+ ril_ack_err = ipc2ril_sms_ack_error(report_msg->error);
ril_state.tokens.send_sms = 0;