summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2015-11-20 22:04:02 -0600
committerDenis Kenzior <denkenz@gmail.com>2015-11-20 22:05:22 -0600
commit4affc129c54de4c993cc4adc0687edde698f2925 (patch)
treea5765b1b087448bca35035b57185c372bc483c82
parent8e8b12b969008678a675938abc409c80c988aeef (diff)
downloadofono-4affc129c54de4c993cc4adc0687edde698f2925.tar.bz2
rilmodem: Implement ril_sim_update_binary inline
-rw-r--r--drivers/rilmodem/sim.c58
1 files changed, 39 insertions, 19 deletions
diff --git a/drivers/rilmodem/sim.c b/drivers/rilmodem/sim.c
index 284b60b4..06580095 100644
--- a/drivers/rilmodem/sim.c
+++ b/drivers/rilmodem/sim.c
@@ -61,6 +61,7 @@
#define CMD_READ_BINARY 176 /* 0xB0 */
#define CMD_READ_RECORD 178 /* 0xB2 */
#define CMD_GET_RESPONSE 192 /* 0xC0 */
+#define CMD_UPDATE_BINARY 214 /* 0xD6 */
/*
* Based on ../drivers/atmodem/sim.c.
@@ -523,34 +524,53 @@ static void ril_sim_update_binary(struct ofono_sim *sim, int fileid,
{
struct sim_data *sd = ofono_sim_get_data(sim);
struct cb_data *cbd = cb_data_new(cb, data, sd);
+ char *hex_path;
struct parcel rilp;
- struct req_sim_write_binary req;
- guint ret = 0;
+ char *hex_data;
+ int p1, p2;
DBG("file 0x%04x", fileid);
- req.app_type = sd->app_type;
- req.aid_str = sd->aid_str;
- req.fileid = fileid;
- req.path = path;
- req.path_len = path_len;
- req.start = start;
- req.length = length;
- req.data = value;
-
- if (!g_ril_request_sim_write_binary(sd->ril, &req, &rilp)) {
- ofono_error("%s: Couldn't build SIM write request", __func__);
+ hex_path = get_path(g_ril_vendor(sd->ril),
+ sd->app_type, fileid, path, path_len);
+ if (hex_path == NULL) {
+ ofono_error("Couldn't build SIM read info request - NULL path");
goto error;
}
- ret = g_ril_send(sd->ril, RIL_REQUEST_SIM_IO, &rilp,
- ril_file_write_cb, cbd, g_free);
+ p1 = start >> 8;
+ p2 = start & 0xff;
+ hex_data = encode_hex(value, length, 0);
+
+ parcel_init(&rilp);
+ parcel_w_int32(&rilp, CMD_UPDATE_BINARY);
+ parcel_w_int32(&rilp, fileid);
+ parcel_w_string(&rilp, hex_path);
+ parcel_w_int32(&rilp, p1); /* P1 */
+ parcel_w_int32(&rilp, p2); /* P2 */
+ parcel_w_int32(&rilp, length); /* P3 (Lc) */
+ parcel_w_string(&rilp, hex_data); /* data */
+ parcel_w_string(&rilp, NULL); /* pin2; only for FDN/BDN */
+ parcel_w_string(&rilp, sd->aid_str); /* AID (Application ID) */
+
+ /* sessionId, specific to latest MTK modems (harmless for older ones) */
+ if (g_ril_vendor(sd->ril) == OFONO_RIL_VENDOR_MTK)
+ parcel_w_int32(&rilp, 0);
+
+ g_ril_append_print_buf(sd->ril, "(cmd=0x%02X,efid=0x%04X,path=%s,"
+ "%d,%d,%d,%s,pin2=(null),aid=%s),",
+ CMD_UPDATE_BINARY, fileid, hex_path,
+ p1, p2, length, hex_data, sd->aid_str);
+ g_free(hex_path);
+ g_free(hex_data);
+
+ if (g_ril_send(sd->ril, RIL_REQUEST_SIM_IO, &rilp,
+ ril_file_write_cb, cbd, g_free) > 0)
+ return;
error:
- if (ret == 0) {
- g_free(cbd);
- CALLBACK_WITH_FAILURE(cb, data);
- }
+ g_free(cbd);
+ CALLBACK_WITH_FAILURE(cb, data);
}
static void update_record(struct ofono_sim *sim, int fileid,