73
73
* The same applies to the app_type.
76
static void ril_pin_change_state(struct ofono_sim *sim,
77
enum ofono_sim_password_type passwd_type,
78
int enable, const char *passwd,
79
ofono_sim_lock_unlock_cb_t cb, void *data);
77
83
enum ofono_ril_vendor vendor;
85
91
enum ofono_sim_password_type passwd_state;
86
92
struct ofono_modem *modem;
87
93
ofono_sim_state_event_cb_t ril_state_watch;
94
ofono_bool_t unlock_pending;
97
struct change_state_cbd {
98
struct ofono_sim *sim;
99
enum ofono_sim_password_type passwd_type;
102
ofono_sim_lock_unlock_cb_t cb;
90
106
static void ril_file_info_cb(struct ril_msg *message, gpointer user_data)
790
806
struct cb_data *cbd = user_data;
791
807
ofono_sim_lock_unlock_cb_t cb = cbd->cb;
792
struct ofono_sim *sim = cbd->data;
793
struct sim_data *sd = cbd->user;
808
struct ofono_sim *sim = cbd->user;
809
struct sim_data *sd = ofono_sim_get_data(sim);
796
812
* There is no reason to ask SIM status until
824
840
static void ril_pin_send(struct ofono_sim *sim, const char *passwd,
825
841
ofono_sim_lock_unlock_cb_t cb, void *data)
844
* TODO: This function is supposed to enter the pending password, which
845
* might be also PIN2. So we must check the pending PIN in the future.
827
848
struct sim_data *sd = ofono_sim_get_data(sim);
828
struct cb_data *cbd = cb_data_new(cb, data, sd);
849
struct cb_data *cbd = cb_data_new(cb, data, sim);
829
850
struct parcel rilp;
831
852
sd->passwd_type = OFONO_SIM_PASSWORD_SIM_PIN;
866
static void enter_pin_done(const struct ofono_error *error, void *data)
868
struct change_state_cbd *csd = data;
869
struct sim_data *sd = ofono_sim_get_data(csd->sim);
871
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
872
ofono_error("%s: wrong password", __func__);
873
sd->unlock_pending = FALSE;
874
CALLBACK_WITH_FAILURE(csd->cb, csd->data);
876
ril_pin_change_state(csd->sim, csd->passwd_type, csd->enable,
877
csd->passwd, csd->cb, csd->data);
845
883
static void ril_pin_change_state(struct ofono_sim *sim,
846
enum ofono_sim_password_type passwd_type,
847
int enable, const char *passwd,
848
ofono_sim_lock_unlock_cb_t cb, void *data)
884
enum ofono_sim_password_type passwd_type,
885
int enable, const char *passwd,
886
ofono_sim_lock_unlock_cb_t cb, void *data)
850
888
struct sim_data *sd = ofono_sim_get_data(sim);
851
struct cb_data *cbd = cb_data_new(cb, data, sd);
852
890
struct parcel rilp;
853
891
struct req_pin_change_state req;
895
* If we want to unlock a password that has not been entered yet,
896
* we enter it before trying to unlock. We need sd->unlock_pending as
897
* the password still has not yet been refreshed when this function is
898
* called from enter_pin_done().
900
if (ofono_sim_get_password_type(sim) == passwd_type
901
&& enable == FALSE && sd->unlock_pending == FALSE) {
902
struct change_state_cbd *csd = g_malloc0(sizeof(*csd));
904
csd->passwd_type = passwd_type;
905
csd->enable = enable;
906
csd->passwd = passwd;
909
sd->unlock_pending = TRUE;
911
ril_pin_send(sim, passwd, enter_pin_done, csd);
916
sd->unlock_pending = FALSE;
918
cbd = cb_data_new(cb, data, sim);
856
920
sd->passwd_type = passwd_type;
858
922
req.aid_str = sd->aid_str;
882
946
ofono_sim_lock_unlock_cb_t cb, void *data)
884
948
struct sim_data *sd = ofono_sim_get_data(sim);
885
struct cb_data *cbd = cb_data_new(cb, data, sd);
949
struct cb_data *cbd = cb_data_new(cb, data, sim);
886
950
struct parcel rilp;
888
952
sd->passwd_type = OFONO_SIM_PASSWORD_SIM_PUK;
906
970
ofono_sim_lock_unlock_cb_t cb, void *data)
908
972
struct sim_data *sd = ofono_sim_get_data(sim);
909
struct cb_data *cbd = cb_data_new(cb, data, sd);
973
struct cb_data *cbd = cb_data_new(cb, data, sim);
910
974
struct parcel rilp;
911
975
int request = RIL_REQUEST_CHANGE_SIM_PIN;