From 433104e9531f9ff4fef29c9f4b77346f1129ba9b Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Thu, 12 Nov 2015 11:58:26 -0600 Subject: rilmodem: Implement ril_pin_change_state inline --- drivers/rilmodem/sim.c | 53 +++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'drivers/rilmodem/sim.c') 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, -- cgit v1.2.3