summaryrefslogtreecommitdiffstats
path: root/misc.c
diff options
context:
space:
mode:
authorPaulK <contact@paulk.fr>2011-12-21 21:54:03 +0100
committerPaulK <contact@paulk.fr>2011-12-21 21:54:03 +0100
commit0091ceae5f7cbeeb42e3b43de3dcf8e500fe8752 (patch)
treedff5b107e7c51dcbb71d636fd6189d3570881a39 /misc.c
parentcb295e0a15c8bc5087a542f25bc369aecbecde80 (diff)
downloadhardware_ril_samsung-ril-0091ceae5f7cbeeb42e3b43de3dcf8e500fe8752.zip
hardware_ril_samsung-ril-0091ceae5f7cbeeb42e3b43de3dcf8e500fe8752.tar.gz
hardware_ril_samsung-ril-0091ceae5f7cbeeb42e3b43de3dcf8e500fe8752.tar.bz2
RIL rework: multi-client, more stable, added GPLv3 copyright notice
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c149
1 files changed, 106 insertions, 43 deletions
diff --git a/misc.c b/misc.c
index 68862f2..3ea54f0 100644
--- a/misc.c
+++ b/misc.c
@@ -1,26 +1,51 @@
+/**
+ * This file is part of samsung-ril.
+ *
+ * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com>
+ * Copyright (C) 2011 Paul Kocialkowski <contact@oaulk.fr>
+ *
+ * samsung-ril is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * samsung-ril is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with samsung-ril. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
#define LOG_TAG "RIL-MISC"
#include <utils/Log.h>
#include "samsung-ril.h"
+#include "util.h"
-extern const struct RIL_Env *rilenv;
-extern struct radio_state radio;
-extern struct ipc_client *ipc_client;
+// FIXME: there was a problem with IMEI handling *think hard*
-void respondNitz(void *data, int length)
+void ril_request_get_imei(RIL_Token t)
{
- struct ipc_misc_time_info *nitz = (struct ipc_misc_time_info*)data;
- char str[128];
+ char data;
- sprintf(str, "%02u/%02u/%02u,%02u:%02u:%02u+%02d,%02d",
- nitz->year, nitz->mon, nitz->day, nitz->hour, nitz->min, nitz->sec, nitz->tz, 0);
+ if(ril_state.radio_state != RADIO_STATE_OFF) {
+ data = IPC_MISC_ME_SN_SERIAL_NUM;
- RIL_onUnsolicitedResponse(RIL_UNSOL_NITZ_TIME_RECEIVED, str, strlen(str) + 1);
+ ipc_fmt_send(IPC_MISC_ME_SN, IPC_TYPE_GET, (unsigned char *) &data, sizeof(data), reqGetId(t));
+ } else {
+ ril_state.tokens.get_imei = t;
+ }
}
-// TODO: implement RIL_REQUEST_DEVICE_IDENTITY also
+void ril_request_get_imeisv(RIL_Token t)
+{
+ ril_state.tokens.get_imeisv = t;
+}
-void respondIMEI(RIL_Token t, void *data, int length)
+void ipc_misc_me_sn_imei(RIL_Token t, void *data, int length)
{
struct ipc_misc_me_sn *imei_info;
char imei[33];
@@ -28,7 +53,7 @@ void respondIMEI(RIL_Token t, void *data, int length)
imei_info = (struct ipc_misc_me_sn *) data;
- if(radio.tokens.get_imei != 0 && radio.tokens.get_imei != t)
+ if(ril_state.tokens.get_imei != 0 && ril_state.tokens.get_imei != t)
LOGE("IMEI tokens mismatch");
if(imei_info->length > 32)
@@ -44,24 +69,22 @@ void respondIMEI(RIL_Token t, void *data, int length)
/* IMEI */
RIL_onRequestComplete(t, RIL_E_SUCCESS, imei, sizeof(char *));
- radio.tokens.get_imei = 0;
+ ril_state.tokens.get_imei = 0;
/* IMEI SV */
- if(radio.tokens.get_imeisv != 0) {
- RIL_onRequestComplete(radio.tokens.get_imeisv, RIL_E_SUCCESS, imeisv, sizeof(char *));
- radio.tokens.get_imeisv = 0;
+ if(ril_state.tokens.get_imeisv != 0) {
+ RIL_onRequestComplete(ril_state.tokens.get_imeisv, RIL_E_SUCCESS, imeisv, sizeof(char *));
+ ril_state.tokens.get_imeisv = 0;
}
}
-void respondMeSn(RIL_Token t, void *data, int length)
+void ipc_misc_me_sn(struct ipc_message_info *info)
{
- struct ipc_misc_me_sn *me_sn_info;
-
- me_sn_info = (struct ipc_misc_me_sn *) data;
+ struct ipc_misc_me_sn *me_sn_info = (struct ipc_misc_me_sn *) info->data;
switch(me_sn_info->type) {
case IPC_MISC_ME_SN_SERIAL_NUM:
- respondIMEI(t, data, length);
+ ipc_misc_me_sn_imei(reqGetToken(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", me_sn_info->data);
@@ -69,41 +92,81 @@ void respondMeSn(RIL_Token t, void *data, int length)
}
}
-void requestIMEI(RIL_Token t)
+void ril_request_baseband_version(RIL_Token t)
{
- char data;
-
- if(radio.radio_state != RADIO_STATE_OFF) {
- data = IPC_MISC_ME_SN_SERIAL_NUM;
-
- ipc_client_send(ipc_client, IPC_MISC_ME_SN, IPC_TYPE_GET, (unsigned char *) &data, sizeof(data), getRequestId(t));
+ if(ril_state.radio_state != RADIO_STATE_OFF) {
+ ipc_fmt_send_get(IPC_MISC_ME_VERSION, reqGetId(t));
} else {
- radio.tokens.get_imei = t;
+ ril_state.tokens.baseband_version = t;
}
}
-void requestIMEISV(RIL_Token t)
+void ipc_misc_me_version(struct ipc_message_info *info)
{
- radio.tokens.get_imeisv = t;
+ char sw_version[33];
+ struct ipc_misc_me_version *version = (struct ipc_misc_me_version *) info->data;
+
+ memcpy(sw_version, version->sw_version, 32);
+ sw_version[32] = '\0';
+
+ RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, sw_version, sizeof(sw_version));
}
-void requestBasebandVersion(RIL_Token t)
+/**
+ * In: RIL_REQUEST_GET_IMSI
+ * Get the SIM IMSI
+ * Only valid when radio state is "RADIO_STATE_SIM_READY"
+ *
+ * Out: IPC_MISC_ME_IMSI
+ * Requests ME's IMSI
+ */
+void ril_request_get_imsi(RIL_Token t)
{
- if(radio.radio_state != RADIO_STATE_OFF) {
- ipc_client_send_get(IPC_MISC_ME_VERSION, getRequestId(t));
- } else {
- radio.tokens.baseband_version = t;
- }
+ ipc_fmt_send_get(IPC_MISC_ME_IMSI, reqGetId(t));
}
-void respondBasebandVersion(struct ipc_message_info *request)
+/**
+ * In: IPC_MISC_ME_IMSI
+ * Provides ME's IMSI
+ *
+ * Out: RIL_REQUEST_GET_IMSI
+ * Get the SIM IMSI
+ * Only valid when radio state is "RADIO_STATE_SIM_READY"
+ */
+void ipc_misc_me_imsi(struct ipc_message_info *info)
{
- char sw_version[33];
- struct ipc_misc_me_version *version = (struct ipc_misc_me_version*)request->data;
+ unsigned char *imsi_length;
+ char *imsi;
- memcpy(sw_version, version->sw_version, 32);
- sw_version[32] = '\0';
+ if(info->length < 1) {
+ LOGE("%s: zero data length", __FUNCTION__);
+ RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0);
+ return;
+ }
+
+ imsi_length = (unsigned char*) info->data;
+
+ if(((int) info->length) < *imsi_length + 1) {
+ LOGE("%s: missing IMSI data", __FUNCTION__);
+ RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_GENERIC_FAILURE, NULL, 0);
+ return;
+ }
+
+ /* Copy IMSI */
+ imsi = (char*) malloc(*imsi_length+1);
+ memcpy(imsi, ((unsigned char*) info->data) + 1, *imsi_length);
+ imsi[*imsi_length] = '\0';
- RIL_onRequestComplete(getToken(request->aseq), RIL_E_SUCCESS, sw_version, sizeof(sw_version));
+ RIL_onRequestComplete(reqGetToken(info->aseq), RIL_E_SUCCESS, imsi, *imsi_length+1);
}
+void ipc_misc_time_info(struct ipc_message_info *info)
+{
+ struct ipc_misc_time_info *nitz = (struct ipc_misc_time_info*) info->data;
+ char str[128];
+
+ sprintf(str, "%02u/%02u/%02u,%02u:%02u:%02u+%02d,%02d",
+ nitz->year, nitz->mon, nitz->day, nitz->hour, nitz->min, nitz->sec, nitz->tz, 0);
+
+ RIL_onUnsolicitedResponse(RIL_UNSOL_NITZ_TIME_RECEIVED, str, strlen(str) + 1);
+}