static void ril_deactivate_data_call_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_gprs_context_cb_t cb = cbd->cb; struct ofono_gprs_context *gc = cbd->user; struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc); gint id = gcd->active_ctx_cid; ofono_info("deactivating data call"); /* Reply has no data... */ if (message->error == RIL_E_SUCCESS) { g_ril_print_response_no_args(gcd->ril, message); set_context_disconnected(gcd); /* If the deactivate was a result of a shutdown, * there won't be call back, so _deactivated() * needs to be called directly. */ if (cb) CALLBACK_WITH_SUCCESS(cb, cbd->data); else ofono_gprs_context_deactivated(gc, id); } else { ofono_error("%s: replay failure: %s", __func__, ril_error_to_string(message->error)); if (cb) CALLBACK_WITH_FAILURE(cb, cbd->data); } }
static void gprs_allow_data_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_gprs_cb_t cb = cbd->cb; struct gprs_attach_data *attach_data = cbd->user; struct ril_gprs_data *gd = attach_data->gd; g_ril_print_response_no_args(attach_data->ril, message); /* * We do not care if detaching the other slot fails. This happens in * turbo when the other slot is empty, for instance. */ if (attach_data->detaching_other_slot) { attach_data->ril = gd->ril; attach_data->detaching_other_slot = FALSE; send_allow_data(cbd, gd->ril, attach_data->set_attached); return; } if (message->error != RIL_E_SUCCESS) { ofono_error("%s: RIL error %s", __func__, ril_error_to_string(message->error)); CALLBACK_WITH_FAILURE(cb, cbd->data); free_attach_cbd(cbd); return; } gd->ofono_attached = attach_data->set_attached; CALLBACK_WITH_SUCCESS(cb, cbd->data); free_attach_cbd(cbd); }
static void mtk_sim_mode_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_modem_online_cb_t cb = cbd->cb; struct ofono_modem *modem = cbd->user; struct mtk_data *md = ofono_modem_get_data(modem); if (message->error == RIL_E_SUCCESS) { g_ril_print_response_no_args(md->ril, message); /* * Although the request was successful, radio state might not * have changed yet. So we wait for the upcoming radio event, * otherwise RIL requests that depend on radio state will fail. * If we are switching the 3G slot, we cannot really trust this * behaviour, so we add a failsafe timer. */ md->online_cb = cb; md->online_data = cbd->data; g_timeout_add(T_SIM_SWITCH_FAILSAFE_MS, sim_switch_failsafe, md); } else { ofono_error("%s: RIL error %s", __func__, ril_error_to_string(message->error)); CALLBACK_WITH_FAILURE(cb, cbd->data); exec_pending_online(md); } }
static void ril_pin_change_state_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_sim_lock_unlock_cb_t cb = cbd->cb; struct sim_data *sd = cbd->user; struct parcel rilp; int retry_count; int retries[OFONO_SIM_PASSWORD_INVALID]; int passwd_type; /* There is no reason to ask SIM status until * unsolicited sim status change indication * Looks like state does not change before that. */ passwd_type = sd->passwd_type; ril_util_init_parcel(message, &rilp); parcel_r_int32(&rilp); retry_count = parcel_r_int32(&rilp); retries[passwd_type] = retry_count; sd->retries[passwd_type] = retries[passwd_type]; DBG("result=%d passwd_type=%d retry_count=%d", message->error, passwd_type, retry_count); if (message->error == RIL_E_SUCCESS) { CALLBACK_WITH_SUCCESS(cb, cbd->data); g_ril_print_response_no_args(sd->ril, message); } else { if (current_passwd) g_stpcpy(current_passwd, defaultpasswd); CALLBACK_WITH_FAILURE(cb, cbd->data); } }
static void detach_received_cb(struct ril_msg *message, gpointer user_data) { struct mtk_data *md = user_data; if (message->error == RIL_E_SUCCESS) g_ril_print_response_no_args(md->ril, message); else ofono_error("%s: RIL error %s", __func__, ril_error_to_string(message->error)); }
static void poweron_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; struct ofono_modem *modem = cbd->user; struct mtk_data *md = ofono_modem_get_data(modem); ofono_modem_online_cb_t cb = cbd->cb; DBG(""); /* * MTK's rild behavior when a POWERON is sent to it is different * depending on whether a previous POWEROFF had been sent. When * the modem is initialized during device startup, POWERON is * sent without a prior POWEROFF, rild responds with an OK reply, * and the modem is brought up. Any subsequent POWERON requests * are sent whenever both modems have been offlined before ( meaning a * POWEROFF has been sent prior ). rild may respond to the POWERON * request, but will usually ( always? ) trigger a socket disconnect in * this case. * * This means there's a race condition between the POWERON reply * callback and the socket disconnect function ( which triggers a * SIM_MODE_SWITCH request ). In some cases rild is slower than * usual closing the socket, so we add a timeout to avoid following * the code path used when there is not a disconnection. Otherwise, * there would be a race and some requests would return errors due to * having been sent through the about-to-be-disconnected socket, leaving * ofono in an inconsistent state. So, we delay sending the * SIM_MODE_SWITCH for 1s, to allow the disconnect to happen when we * know that we have sent previously a POWEROFF. * * Also, I saw once that sending SIM_MODE while the * socket was being disconnected provoked a crash due to SIGPIPE being * issued. The timeout should also fix this. */ if (message->error == RIL_E_SUCCESS) { g_ril_print_response_no_args(md->ril, message); if (disconnect_expected) { if (not_disconn_cb_id != 0) g_source_remove(not_disconn_cb_id); not_disconn_cb_id = g_timeout_add(T_WAIT_DISCONN_MS, no_disconnect_case, cbd); } else { mtk_send_sim_mode(mtk_sim_mode_cb, cbd); } } else { ofono_error("%s RADIO_POWERON error %s", __func__, ril_error_to_string(message->error)); CALLBACK_WITH_FAILURE(cb, cbd->data); g_free(cbd); } }
static void set_trm_cb(struct ril_msg *message, gpointer user_data) { struct ofono_modem *modem = user_data; struct mtk_data *md = ofono_modem_get_data(modem); if (message->error != RIL_E_SUCCESS) { ofono_error("%s: RIL error %s", __func__, ril_error_to_string(message->error)); return; } g_ril_print_response_no_args(md->ril, message); }
static void set_ia_apn_cb(struct ril_msg *message, gpointer user_data) { struct ofono_radio_settings *rs = user_data; struct radio_data *rd = ofono_radio_settings_get_data(rs); if (message->error != RIL_E_SUCCESS) { ofono_error("%s: reply failure: %s", __func__, ril_error_to_string(message->error)); return; } g_ril_print_response_no_args(rd->ril, message); }
static void ril_set_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; struct ofono_call_settings *cs = cbd->user; struct settings_data *sd = ofono_call_settings_get_data(cs); ofono_call_settings_set_cb_t cb = cbd->cb; if (message->error == RIL_E_SUCCESS) { g_ril_print_response_no_args(sd->ril, message); CALLBACK_WITH_SUCCESS(cb, cbd->data); } else { CALLBACK_WITH_FAILURE(cb, cbd->data); } }
static void ril_ussd_cancel_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; struct ofono_ussd *ussd = cbd->user; struct ussd_data *ud = ofono_ussd_get_data(ussd); ofono_ussd_cb_t cb = cbd->cb; if (message->error == RIL_E_SUCCESS) { g_ril_print_response_no_args(ud->ril, message); CALLBACK_WITH_SUCCESS(cb, cbd->data); } else { CALLBACK_WITH_FAILURE(cb, cbd->data); } }
static void drop_data_call_cb(struct ril_msg *message, gpointer user_data) { struct ofono_gprs *gprs = user_data; struct ril_gprs_data *gd = ofono_gprs_get_data(gprs); if (message->error == RIL_E_SUCCESS) g_ril_print_response_no_args(gd->ril, message); else ofono_error("%s: RIL error %s", __func__, ril_error_to_string(message->error)); if (--(gd->pending_deact_req) == 0) ril_gprs_registration_status(gprs, NULL, NULL); }
static void ril_set_rat_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; struct ofono_radio_settings *rs = cbd->user; struct radio_data *rd = ofono_radio_settings_get_data(rs); ofono_radio_settings_rat_mode_set_cb_t cb = cbd->cb; if (message->error == RIL_E_SUCCESS) { g_ril_print_response_no_args(rd->ril, message); CALLBACK_WITH_SUCCESS(cb, cbd->data); } else { ofono_error("%s: rat mode setting failed", __func__); CALLBACK_WITH_FAILURE(cb, cbd->data); } }
static void ril_ussd_cb(struct ril_msg *message, gpointer user_data) { struct ofono_ussd *ussd = user_data; struct ussd_data *ud = ofono_ussd_get_data(ussd); /* * We fake an ON_USSD event if there was an error sending the request, * as core will be waiting for one to respond to the Initiate() call. * Note that we already made the callback (see ril_ussd_request()). */ if (message->error == RIL_E_SUCCESS) g_ril_print_response_no_args(ud->ril, message); else ofono_ussd_notify(ussd, OFONO_USSD_STATUS_NOT_SUPPORTED, 0, NULL, 0); }
static void mtk_set_fd_mode_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; struct set_fd_mode *user = cbd->user; struct ofono_radio_settings *rs = user->rst; struct radio_data *rsd = ofono_radio_settings_get_data(rs); ofono_radio_settings_fast_dormancy_set_cb_t cb = cbd->cb; if (message->error == RIL_E_SUCCESS) { g_ril_print_response_no_args(rsd->ril, message); ril_set_fast_dormancy(rs, user->on, cb, cbd->data); } else { CALLBACK_WITH_FAILURE(cb, cbd->data); } g_free(user); }
static void ril_display_state_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; struct ofono_radio_settings *rs = cbd->user; struct radio_data *rd = ofono_radio_settings_get_data(rs); ofono_radio_settings_fast_dormancy_set_cb_t cb = cbd->cb; if (message->error == RIL_E_SUCCESS) { g_ril_print_response_no_args(rd->ril, message); rd->fast_dormancy = rd->pending_fd; CALLBACK_WITH_SUCCESS(cb, cbd->data); } else { CALLBACK_WITH_FAILURE(cb, cbd->data); } }
static void ril_register_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_netreg_register_cb_t cb = cbd->cb; struct netreg_data *nd = cbd->user; struct ofono_error error; if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); g_ril_print_response_no_args(nd->ril, message); } else { decode_ril_error(&error, "FAIL"); } cb(&error, cbd->data); }
static void set_ia_apn_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_gprs_cb_t cb = cbd->cb; struct ofono_gprs *gprs = cbd->user; struct ril_gprs_data *gd = ofono_gprs_get_data(gprs); if (message->error != RIL_E_SUCCESS) { ofono_error("%s: reply failure: %s", __func__, ril_error_to_string(message->error)); CALLBACK_WITH_FAILURE(cb, cbd->data); return; } g_ril_print_response_no_args(gd->ril, message); CALLBACK_WITH_SUCCESS(cb, cbd->data); }
static void poweroff_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_modem_online_cb_t cb = cbd->cb; struct ofono_modem *modem = cbd->user; struct mtk_data *md = ofono_modem_get_data(modem); if (message->error == RIL_E_SUCCESS) { g_ril_print_response_no_args(md->ril, message); mtk_settings_remove(md->mtk_settings); CALLBACK_WITH_SUCCESS(cb, cbd->data); } else { ofono_error("%s: RIL error %s", __func__, ril_error_to_string(message->error)); CALLBACK_WITH_FAILURE(cb, cbd->data); } }
static void store_type_cb(struct ril_msg *message, gpointer user_data) { struct ofono_modem *modem = user_data; struct mtk_data *md = ofono_modem_get_data(modem); struct parcel rilp; int trm = 0; if (message->error != RIL_E_SUCCESS) { ofono_error("%s: RIL error %s", __func__, ril_error_to_string(message->error)); md->trm_pending = FALSE; return; } g_ril_print_response_no_args(md->ril, message); /* * Send SET_TRM, which reloads the FW. We do not know the meaning of the * magic TRM numbers (no source code for muxreport daemon). */ if (md->fw_type == MTK_MD_TYPE_LWG) { trm = 11; } else if (md->fw_type == MTK_MD_TYPE_LTG) { trm = 12; } else { ofono_error("%s: wrong modem type %d", __func__, md->fw_type); g_assert(FALSE); } g_mtk_request_set_trm(md->ril, trm, &rilp); if (g_ril_send(md->ril, MTK_RIL_REQUEST_SET_TRM, &rilp, set_trm_cb, modem, NULL) == 0) ofono_error("%s: failure sending request", __func__); /* * rild will close now the socket, and the response to SET_TRM might be * received before that or not. * Measurements showed that rild takes around 5 seconds to re-start, but * we use an 8 seconds timeout as times can vary and that value is also * compatible with krillin modem. */ }
static void sim_send_set_uicc_subscription_cb(struct ril_msg *message, gpointer user_data) { struct ofono_sim *sim = user_data; struct sim_data *sd = ofono_sim_get_data(sim); if (message->error == RIL_E_SUCCESS) { g_ril_print_response_no_args(sd->ril, message); } else { ofono_error("%s: RIL error %s", __func__, ril_error_to_string(message->error)); /* * Send RIL_REQUEST_GET_SIM_STATUS again. The reply will run * the app selection algorithm again, causing the request to * be re-sent. */ send_get_sim_status(sim); } }
static void volume_mute_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_call_volume_cb_t cb = cbd->cb; struct cv_data *cvd = cbd->user; struct ofono_error error; if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); g_ril_print_response_no_args(cvd->ril, message); } else { ofono_error("Could not set the ril mute state"); decode_ril_error(&error, "FAIL"); } cb(&error, cbd->data); }
static void ril_call_barring_set_passwd_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_call_barring_set_cb_t cb = cbd->cb; struct barring_data *bd = cbd->user; if (message->error != RIL_E_SUCCESS) { ofono_error("%s: set password failed, err: %s", __func__, ril_error_to_string(message->error)); goto error; } g_ril_print_response_no_args(bd->ril, message); CALLBACK_WITH_SUCCESS(cb, cbd->data); return; error: CALLBACK_WITH_FAILURE(cb, cbd->data); }
static void mtk_set_fd_mode_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; struct set_fd_mode *user = cbd->user; struct ofono_radio_settings *rs = user->rst; struct radio_data *rsd = ofono_radio_settings_get_data(rs); ofono_radio_settings_fast_dormancy_set_cb_t cb = cbd->cb; if (message->error == RIL_E_SUCCESS || message->error == RIL_E_RADIO_NOT_AVAILABLE) { if (message->error == RIL_E_RADIO_NOT_AVAILABLE) ofono_warn("Could not set fast dormancy " "as radio is not available"); g_ril_print_response_no_args(rsd->ril, message); ril_set_fast_dormancy(rs, user->on, cb, cbd->data); } else { CALLBACK_WITH_FAILURE(cb, cbd->data); } g_free(user); }
static void mtk_gprs_set_connect_type_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_gprs_cb_t cb = cbd->cb; struct gprs_attach_data *attach_data = cbd->user; struct ril_gprs_data *gd = attach_data->gd; if (message->error == RIL_E_SUCCESS) { g_ril_print_response_no_args(gd->ril, message); gd->ofono_attached = attach_data->set_attached; mtk_set_attach_state(gd->modem, gd->ofono_attached); CALLBACK_WITH_SUCCESS(cb, cbd->data); } else { ofono_error("%s: RIL error %s", __func__, ril_error_to_string(message->error)); CALLBACK_WITH_FAILURE(cb, cbd->data); } g_free(attach_data); }