summaryrefslogtreecommitdiffstats
path: root/drivers/rilmodem/sim.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2015-11-12 11:58:26 -0600
committerDenis Kenzior <denkenz@gmail.com>2015-11-12 11:58:26 -0600
commit433104e9531f9ff4fef29c9f4b77346f1129ba9b (patch)
treea6173fc6a273478922b0d027e8cddb4a35d7cf9c /drivers/rilmodem/sim.c
parenta6dcf26df11a2175e7526e2b23a93c64b9ba5697 (diff)
downloadofono-433104e9531f9ff4fef29c9f4b77346f1129ba9b.tar.bz2
rilmodem: Implement ril_pin_change_state inline
Diffstat (limited to 'drivers/rilmodem/sim.c')
-rw-r--r--drivers/rilmodem/sim.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/drivers/rilmodem/sim.c b/drivers/rilmodem/sim.c
index 96e4fffa..2ec05c7c 100644
--- a/drivers/rilmodem/sim.c
+++ b/drivers/rilmodem/sim.c
@@ -963,6 +963,19 @@ static void enter_pin_done(const struct ofono_error *error, void *data)
g_free(csd);
}
+static const char *const clck_cpwd_fac[] = {
+ [OFONO_SIM_PASSWORD_SIM_PIN] = "SC",
+ [OFONO_SIM_PASSWORD_SIM_PIN2] = "P2",
+ [OFONO_SIM_PASSWORD_PHSIM_PIN] = "PS",
+ [OFONO_SIM_PASSWORD_PHFSIM_PIN] = "PF",
+ [OFONO_SIM_PASSWORD_PHNET_PIN] = "PN",
+ [OFONO_SIM_PASSWORD_PHNETSUB_PIN] = "PU",
+ [OFONO_SIM_PASSWORD_PHSP_PIN] = "PP",
+ [OFONO_SIM_PASSWORD_PHCORP_PIN] = "PC",
+};
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
static void ril_pin_change_state(struct ofono_sim *sim,
enum ofono_sim_password_type passwd_type,
int enable, const char *passwd,
@@ -971,8 +984,6 @@ static void ril_pin_change_state(struct ofono_sim *sim,
struct sim_data *sd = ofono_sim_get_data(sim);
struct cb_data *cbd;
struct parcel rilp;
- struct req_pin_change_state req;
- int ret = 0;
/*
* If we want to unlock a password that has not been entered yet,
@@ -998,30 +1009,32 @@ static void ril_pin_change_state(struct ofono_sim *sim,
sd->unlock_pending = FALSE;
- cbd = cb_data_new(cb, data, sim);
+ if (passwd_type >= ARRAY_SIZE(clck_cpwd_fac) ||
+ clck_cpwd_fac[passwd_type] == NULL)
+ goto error;
- sd->passwd_type = passwd_type;
+ cbd = cb_data_new(cb, data, sim);
- req.aid_str = sd->aid_str;
- req.passwd_type = passwd_type;
- req.enable = enable;
- req.passwd = passwd;
+ parcel_init(&rilp);
+ parcel_w_int32(&rilp, 5);
+ parcel_w_string(&rilp, clck_cpwd_fac[passwd_type]);
+ parcel_w_string(&rilp, enable ? "1" : "0");
+ parcel_w_string(&rilp, passwd);
+ /* TODO: make this a constant... */
+ parcel_w_string(&rilp, "0"); /* class */
+ parcel_w_string(&rilp, sd->aid_str);
- if (!g_ril_request_pin_change_state(sd->ril,
- &req,
- &rilp)) {
- ofono_error("Couldn't build pin change state request");
- goto error;
- }
+ g_ril_append_print_buf(sd->ril, "(%s,%d,%s,0,aid=%s)",
+ clck_cpwd_fac[passwd_type], enable, passwd,
+ sd->aid_str);
- ret = g_ril_send(sd->ril, RIL_REQUEST_SET_FACILITY_LOCK, &rilp,
- ril_pin_change_state_cb, cbd, g_free);
+ if (g_ril_send(sd->ril, RIL_REQUEST_SET_FACILITY_LOCK, &rilp,
+ ril_pin_change_state_cb, cbd, g_free) > 0)
+ return;
+ g_free(cbd);
error:
- if (ret == 0) {
- g_free(cbd);
- CALLBACK_WITH_FAILURE(cb, data);
- }
+ CALLBACK_WITH_FAILURE(cb, data);
}
static void ril_pin_send_puk(struct ofono_sim *sim,