static void check_pin2_state(struct ofono_call_meter *cm) { struct ofono_atom *sim_atom; sim_atom = __ofono_modem_find_atom(__ofono_atom_get_modem(cm->atom), OFONO_ATOM_TYPE_SIM); if (sim_atom == NULL) return; __ofono_sim_recheck_pin(__ofono_atom_get_data(sim_atom)); }
static void sim_status_cb(struct ril_msg *message, gpointer user_data) { struct ofono_sim *sim = user_data; struct sim_data *sd = ofono_sim_get_data(sim); struct parcel rilp; int card_state; int universal_pin_state; int gsm_umts_app_index; int cdma_app_index; int ims_app_index; int num_apps; int i; int app_state; int perso_substate; DBG(""); g_ril_init_parcel(message, &rilp); card_state = parcel_r_int32(&rilp); /* * NOTE: * * The global pin_status is used for multi-application * UICC cards. For example, there are SIM cards that * can be used in both GSM and CDMA phones. Instead * of managed PINs for both applications, a global PIN * is set instead. It's not clear at this point if * such SIM cards are supported by ofono or RILD. */ universal_pin_state = parcel_r_int32(&rilp); gsm_umts_app_index = parcel_r_int32(&rilp); cdma_app_index = parcel_r_int32(&rilp); ims_app_index = parcel_r_int32(&rilp); num_apps = parcel_r_int32(&rilp); if (rilp.malformed) return; if (gsm_umts_app_index >= num_apps) return; DBG("[%d,%04d]< %s: card_state=%d,universal_pin_state=%d," "gsm_umts_index=%d,cdma_index=%d,ims_index=%d," "num_apps=%d", g_ril_get_slot(sd->ril), message->serial_no, "RIL_REQUEST_GET_SIM_STATUS", card_state, universal_pin_state, gsm_umts_app_index, cdma_app_index, ims_app_index, num_apps); switch (card_state) { case RIL_CARDSTATE_PRESENT: break; case RIL_CARDSTATE_ABSENT: ofono_sim_inserted_notify(sim, FALSE); return; default: ofono_error("%s: bad SIM state (%u)", __func__, card_state); return; } ofono_sim_inserted_notify(sim, TRUE); for (i = 0; i != gsm_umts_app_index; i++) { parcel_r_int32(&rilp); /* AppType */ parcel_r_int32(&rilp); /* AppState */ parcel_r_int32(&rilp); /* PersoSubstate */ parcel_skip_string(&rilp); /* AID */ parcel_skip_string(&rilp); /* App Label */ parcel_r_int32(&rilp); /* PIN1 Replaced */ parcel_r_int32(&rilp); /* PIN1 PinState */ parcel_r_int32(&rilp); /* PIN2 PinState */ if (rilp.malformed) return; } /* * We cache the current password state. Ideally this should be done * by issuing a GET_SIM_STATUS request from ril_query_passwd_state, * which is called by the core after sending a password, but * unfortunately the response to GET_SIM_STATUS is not reliable in mako * when sent just after sending the password. Some time is needed * before the modem refreshes its internal state, and when it does it * sends a SIM_STATUS_CHANGED event. In that moment we retrieve the * status and this function is executed. We call * __ofono_sim_recheck_pin as it is the only way to indicate the core * to call query_passwd_state again. An option that can be explored in * the future is wait before invoking core callback for send_passwd * until we know the real password state. */ sd->app_type = parcel_r_int32(&rilp); /* AppType */ app_state = parcel_r_int32(&rilp); /* AppState */ perso_substate = parcel_r_int32(&rilp); /* PersoSubstate */ switch (app_state) { case RIL_APPSTATE_PIN: sd->passwd_state = OFONO_SIM_PASSWORD_SIM_PIN; break; case RIL_APPSTATE_PUK: sd->passwd_state = OFONO_SIM_PASSWORD_SIM_PUK; break; case RIL_APPSTATE_SUBSCRIPTION_PERSO: switch (perso_substate) { case RIL_PERSOSUBSTATE_SIM_NETWORK: sd->passwd_state = OFONO_SIM_PASSWORD_PHNET_PIN; break; case RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET: sd->passwd_state = OFONO_SIM_PASSWORD_PHNETSUB_PIN; break; case RIL_PERSOSUBSTATE_SIM_CORPORATE: sd->passwd_state = OFONO_SIM_PASSWORD_PHCORP_PIN; break; case RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER: sd->passwd_state = OFONO_SIM_PASSWORD_PHSP_PIN; break; case RIL_PERSOSUBSTATE_SIM_SIM: sd->passwd_state = OFONO_SIM_PASSWORD_PHSIM_PIN; break; case RIL_PERSOSUBSTATE_SIM_NETWORK_PUK: sd->passwd_state = OFONO_SIM_PASSWORD_PHNET_PUK; break; case RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK: sd->passwd_state = OFONO_SIM_PASSWORD_PHNETSUB_PUK; break; case RIL_PERSOSUBSTATE_SIM_CORPORATE_PUK: sd->passwd_state = OFONO_SIM_PASSWORD_PHCORP_PUK; break; case RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK: sd->passwd_state = OFONO_SIM_PASSWORD_PHSP_PUK; break; case RIL_PERSOSUBSTATE_SIM_SIM_PUK: sd->passwd_state = OFONO_SIM_PASSWORD_PHFSIM_PUK; break; default: sd->passwd_state = OFONO_SIM_PASSWORD_NONE; break; }; break; case RIL_APPSTATE_READY: sd->passwd_state = OFONO_SIM_PASSWORD_NONE; break; case RIL_APPSTATE_UNKNOWN: case RIL_APPSTATE_DETECTED: default: sd->passwd_state = OFONO_SIM_PASSWORD_INVALID; break; } g_free(sd->aid_str); sd->aid_str = parcel_r_string(&rilp); /* AID */ DBG("[%d,%04d]< app_type: %d, passwd_state: %d, aid_str (AID): %s", g_ril_get_slot(sd->ril), message->serial_no, sd->app_type, sd->passwd_state, sd->aid_str); /* * Note: There doesn't seem to be any other way to force the core SIM * code to recheck the PIN. This call causes the core to call this * atom's query_passwd() function. */ __ofono_sim_recheck_pin(sim); }
static void sim_status_cb(struct ril_msg *message, gpointer user_data) { struct ofono_sim *sim = user_data; struct sim_data *sd = ofono_sim_get_data(sim); struct reply_sim_status *status; guint search_index; status = g_ril_reply_parse_sim_status(sd->ril, message); if (status == NULL) { ofono_error("%s: Cannot parse SIM status reply", __func__); return; } DBG("SIM status is %u", status->card_state); if (status->card_state == RIL_CARDSTATE_PRESENT) ofono_sim_inserted_notify(sim, TRUE); else if (status && status->card_state == RIL_CARDSTATE_ABSENT) ofono_sim_inserted_notify(sim, FALSE); else ofono_error("%s: bad SIM state (%u)", __func__, status->card_state); if (status->card_state == RIL_CARDSTATE_PRESENT) { /* * TODO(CDMA): need some kind of logic * to set the correct app_index */ search_index = status->gsm_umts_index; if (search_index > status->num_apps && sd->vendor == OFONO_RIL_VENDOR_QCOM_MSIM) { /* * On QCOM's multi SIM device, all index will be -1 * (but will wrap up to UINT_MAX because index is uint) * until we send RIL_REQUEST_SET_UICC_SUBSCRIPTION. * So, we need to figure out which app to use * and send that request out. */ search_index = sim_select_uicc_subscription(sim, status); } if (search_index < status->num_apps) { struct reply_sim_app *app = status->apps[search_index]; if (app->app_type != RIL_APPTYPE_UNKNOWN) { /* * We cache the current password state. Ideally * this should be done by issuing a * GET_SIM_STATUS request from * ril_query_passwd_state, which is called by * the core after sending a password, but * unfortunately the response to GET_SIM_STATUS * is not reliable in mako when sent just after * sending the password. Some time is needed * before the modem refreshes its internal * state, and when it does it sends a * SIM_STATUS_CHANGED event. In that moment we * retrieve the status and this function is * executed. We call __ofono_sim_recheck_pin as * it is the only way to indicate the core to * call query_passwd_state again. An option * that can be explored in the future is wait * before invoking core callback for send_passwd * until we know the real password state. */ configure_active_app(sd, app, search_index); DBG("passwd_state: %d", sd->passwd_state); /* * Note: There doesn't seem to be any other way * to force the core SIM code to recheck the * PIN. This call causes the core to call this * atom's query_passwd() function. */ __ofono_sim_recheck_pin(sim); } } } g_ril_reply_free_sim_status(status); }
static void sim_status_cb(struct ril_msg *message, gpointer user_data) { struct ofono_sim *sim = user_data; struct sim_data *sd = ofono_sim_get_data(sim); struct sim_app *apps[MAX_UICC_APPS]; struct sim_status status; guint i = 0; guint search_index = -1; struct parcel rilp; DBG(""); if (ril_util_parse_sim_status(sd->ril, message, &status, apps) && status.num_apps) { DBG("num_apps: %d gsm_umts_index: %d", status.num_apps, status.gsm_umts_index); /* TODO(CDMA): need some kind of logic to * set the correct app_index, */ search_index = status.gsm_umts_index; for (i = 0; i < status.num_apps; i++) { if (i == search_index && apps[i]->app_type != RIL_APPTYPE_UNKNOWN) { current_active_app = apps[i]->app_type; configure_active_app(sd, apps[i], i); set_pin_lock_state(sim, apps[i]); break; } } if (sd->sim_registered == FALSE) { ofono_sim_register(sim); sd->sim_registered = TRUE; } else { /* TODO: There doesn't seem to be any other * way to force the core SIM code to * recheck the PIN. * Wouldn't __ofono_sim_refresh be * more appropriate call here?? * __ofono_sim_refresh(sim, NULL, TRUE, TRUE); */ DBG("sd->card_state:%u", sd->card_state); if (sd->card_state != RIL_CARDSTATE_PRESENT) { ofono_sim_inserted_notify(sim, TRUE); sd->card_state = RIL_CARDSTATE_PRESENT; sd->removed = FALSE; } } if (current_passwd) { if (!strcmp(current_passwd, defaultpasswd)) { __ofono_sim_recheck_pin(sim); } else if (sd->passwd_state != OFONO_SIM_PASSWORD_SIM_PIN) { __ofono_sim_recheck_pin(sim); } else if (sd->passwd_state == OFONO_SIM_PASSWORD_SIM_PIN) { parcel_init(&rilp); parcel_w_int32(&rilp, ENTER_SIM_PIN_PARAMS); parcel_w_string(&rilp, current_passwd); parcel_w_string(&rilp, sd->aid_str); g_ril_send(sd->ril, RIL_REQUEST_ENTER_SIM_PIN, rilp.data, rilp.size, NULL, NULL, g_free); parcel_free(&rilp); } } else { __ofono_sim_recheck_pin(sim); } if (current_online_state == RIL_ONLINE_PREF) { parcel_init(&rilp); parcel_w_int32(&rilp, 1); parcel_w_int32(&rilp, 1); ofono_info("RIL_REQUEST_RADIO_POWER ON"); g_ril_send(sd->ril, RIL_REQUEST_RADIO_POWER, rilp.data, rilp.size, NULL, NULL, g_free); parcel_free(&rilp); current_online_state = RIL_ONLINE; } ril_util_free_sim_apps(apps, status.num_apps); } else { if (current_online_state == RIL_ONLINE) current_online_state = RIL_ONLINE_PREF; if (status.card_state == RIL_CARDSTATE_ABSENT) { DBG("sd->card_state:%u,status.card_state:%u,", sd->card_state, status.card_state); ofono_info("RIL_CARDSTATE_ABSENT"); ofono_sim_inserted_notify(sim, FALSE); if (sd->card_state == RIL_CARDSTATE_PRESENT) sd->removed = TRUE; sd->card_state = RIL_CARDSTATE_ABSENT; if (current_passwd) g_stpcpy(current_passwd, defaultpasswd); sd->initialized = FALSE; } } /* TODO: if no SIM present, handle emergency calling. */ }