static void sim_status_cb(struct ril_msg *message, gpointer user_data) { struct ofono_modem *modem = user_data; struct ril_data *ril = ofono_modem_get_data(modem); struct reply_sim_status *status; DBG(""); if (message->error != RIL_E_SUCCESS) { ril->sim_status_retries++; ofono_error("GET_SIM_STATUS request failed: %s; retries: %d", ril_error_to_string(message->error), ril->sim_status_retries); if (ril->sim_status_retries < MAX_SIM_STATUS_RETRIES) g_timeout_add_seconds(2, sim_status_retry, modem); else ofono_error("Max retries for GET_SIM_STATUS exceeded!"); } else { if ((status = g_ril_reply_parse_sim_status(ril->modem, message)) != NULL) { if (status->card_state == RIL_CARDSTATE_PRESENT) { DBG("Card PRESENT; num_apps: %d", status->num_apps); if (!ril->have_sim) { DBG("notify SIM inserted"); ril->have_sim = TRUE; ofono_sim_inserted_notify(ril->sim, TRUE); } } else { ofono_warn("Card NOT_PRESENT."); if (ril->have_sim) { DBG("notify SIM removed"); ril->have_sim = FALSE; ofono_sim_inserted_notify(ril->sim, FALSE); } } g_ril_reply_free_sim_status(status); } } }
static void set_query_cf_callback(const struct ofono_error *error, int total, const struct ofono_call_forwarding_condition *list, void *data) { struct ofono_call_forwarding *cf = data; GSList *l; DBusMessage *reply; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { ofono_error("Setting succeeded, but query failed"); cf->flags &= ~CALL_FORWARDING_FLAG_CACHED; reply = __ofono_error_failed(cf->pending); __ofono_dbus_pending_reply(&cf->pending, reply); return; } if (cf->query_next == cf->query_end) { reply = dbus_message_new_method_return(cf->pending); __ofono_dbus_pending_reply(&cf->pending, reply); } l = cf_cond_list_create(total, list); set_new_cond_list(cf, cf->query_next, l); DBG("%s conditions:", cf_type_lut[cf->query_next]); cf_cond_list_print(l); if (cf->query_next != cf->query_end) { cf->query_next++; set_query_next_cf_cond(cf); } }
/* * Indicate oFono that a SMS driver is ready for operation * * This is called after ofono_sms_create() was done and the modem * driver determined that a modem supports SMS correctly. Once this * call succeeds, the D-BUS interface for SMS goes live. */ void ofono_sms_register(struct ofono_sms *sms) { DBusConnection *conn = ofono_dbus_get_connection(); struct ofono_modem *modem = __ofono_atom_get_modem(sms->atom); const char *path = __ofono_atom_get_path(sms->atom); struct ofono_sim *sim; if (!g_dbus_register_interface(conn, path, OFONO_MESSAGE_MANAGER_INTERFACE, sms_manager_methods, sms_manager_signals, NULL, sms, NULL)) { ofono_error("Could not create %s interface", OFONO_MESSAGE_MANAGER_INTERFACE); return; } ofono_modem_add_interface(modem, OFONO_MESSAGE_MANAGER_INTERFACE); sms->mw_watch = __ofono_modem_add_atom_watch(modem, OFONO_ATOM_TYPE_MESSAGE_WAITING, mw_watch, sms, NULL); sms->netreg_watch = __ofono_modem_add_atom_watch(modem, OFONO_ATOM_TYPE_NETREG, netreg_watch, sms, NULL); sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem); /* * If we have a sim atom, we can uniquely identify the SIM, * otherwise create an sms assembly which doesn't backup the fragment * store. */ if (sim) { const char *imsi; imsi = ofono_sim_get_imsi(sim); sms->assembly = sms_assembly_new(imsi); sms->sr_assembly = status_report_assembly_new(imsi); sms_load_settings(sms, imsi); } else { sms->assembly = sms_assembly_new(NULL); sms->sr_assembly = status_report_assembly_new(NULL); sms->bearer = 3; /* Default to CS then PS */ } if (sms->driver->bearer_set) sms->driver->bearer_set(sms, sms->bearer, bearer_init_callback, sms); sms_restore_tx_queue(sms); sms->text_handlers = __ofono_watchlist_new(g_free); sms->datagram_handlers = __ofono_watchlist_new(g_free); __ofono_atom_register(sms->atom, sms_unregister); }
static void ril_nitz_notify(struct ril_msg *message, gpointer user_data) { struct ofono_netreg *netreg = user_data; struct netreg_data *nd = ofono_netreg_get_data(netreg); int year, mon, mday, hour, min, sec, dst, tzi; char tzs, tz[4]; gchar *nitz; if ((nitz = g_ril_unsol_parse_nitz(nd->ril, message)) == NULL) goto error; sscanf(nitz, "%u/%u/%u,%u:%u:%u%c%u,%u", &year, &mon, &mday, &hour, &min, &sec, &tzs, &tzi, &dst); sprintf(tz, "%c%d", tzs, tzi); nd->time.utcoff = atoi(tz) * 15 * 60; nd->time.dst = dst; nd->time.sec = sec; nd->time.min = min; nd->time.hour = hour; nd->time.mday = mday; nd->time.mon = mon; nd->time.year = 2000 + year; ofono_netreg_time_notify(netreg, &nd->time); g_free(nitz); return; error: ofono_error("%s: unable to notify ofono about NITZ", __func__); }
static void ril_cops_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_netreg_operator_cb_t cb = cbd->cb; struct netreg_data *nd = cbd->user; struct reply_operator *reply; struct ofono_network_operator op; if (message->error != RIL_E_SUCCESS) { ofono_error("%s: failed to retrive the current operator", __func__); goto error; } if ((reply = g_ril_reply_parse_operator(nd->ril, message)) == NULL) goto error; set_oper_name(reply, &op); extract_mcc_mnc(reply->numeric, op.mcc, op.mnc); /* Set to current */ op.status = OPERATOR_STATUS_CURRENT; op.tech = ril_tech_to_access_tech(nd->tech); CALLBACK_WITH_SUCCESS(cb, &op, cbd->data); g_ril_reply_free_operator(reply); return; error: CALLBACK_WITH_FAILURE(cb, NULL, cbd->data); }
static void setup_internal_mux(struct ofono_modem *modem) { struct ifx_data *data = ofono_modem_get_data(modem); int i; DBG(""); data->mux = g_at_mux_new_gsm0710_basic(data->device, data->frame_size); if (data->mux == NULL) goto error; if (getenv("OFONO_MUX_DEBUG")) g_at_mux_set_debug(data->mux, ifx_debug, "MUX: "); g_at_mux_start(data->mux); for (i = 0; i < NUM_DLC; i++) { GIOChannel *channel = g_at_mux_create_channel(data->mux); data->dlcs[i] = create_chat(channel, modem, dlc_prefixes[i]); if (data->dlcs[i] == NULL) { ofono_error("Failed to create channel"); goto error; } } /* wait for DLC creation to settle */ data->dlc_init_source = g_timeout_add(500, dlc_setup, modem); return; error: shutdown_device(data); ofono_modem_set_powered(modem, FALSE); }
static void sms_watch(struct ofono_atom *atom, enum ofono_atom_watch_condition cond, void *data) { struct push_notification *pn = data; DBusConnection *conn = ofono_dbus_get_connection(); if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) { g_dbus_unregister_interface(conn, ofono_modem_get_path(pn->modem), PUSH_NOTIFICATION_INTERFACE); return; } DBG("registered"); pn->sms = __ofono_atom_get_data(atom); if (!g_dbus_register_interface(conn, ofono_modem_get_path(pn->modem), PUSH_NOTIFICATION_INTERFACE, push_notification_methods, NULL, NULL, pn, push_notification_cleanup)) { ofono_error("Could not create %s interface", PUSH_NOTIFICATION_INTERFACE); return; } ofono_modem_add_interface(pn->modem, PUSH_NOTIFICATION_INTERFACE); }
struct parcel_str_array *g_ril_reply_oem_hook_strings(GRil *gril, const struct ril_msg *message) { struct parcel rilp; struct parcel_str_array *str_arr; int i; g_ril_init_parcel(message, &rilp); str_arr = parcel_r_str_array(&rilp); if (str_arr == NULL) { ofono_error("%s: no strings", __func__); goto out; } g_ril_append_print_buf(gril, "{"); for (i = 0; i < str_arr->num_str; ++i) { if (i + 1 == str_arr->num_str) g_ril_append_print_buf(gril, "%s%s}", print_buf, str_arr->str[i]); else g_ril_append_print_buf(gril, "%s%s, ", print_buf, str_arr->str[i]); } g_ril_print_response(gril, message); out: return str_arr; }
/* either oFono or Phone could request SLC connection */ static int service_level_connection(struct ofono_modem *modem, int fd) { struct hfp_data *data = ofono_modem_get_data(modem); GIOChannel *io; GAtSyntax *syntax; GAtChat *chat; io = g_io_channel_unix_new(fd); if (io == NULL) { ofono_error("Service level connection failed: %s (%d)", strerror(errno), errno); return -EIO; } syntax = g_at_syntax_new_gsm_permissive(); chat = g_at_chat_new(io, syntax); g_at_syntax_unref(syntax); g_io_channel_unref(io); if (chat == NULL) return -ENOMEM; g_at_chat_set_disconnect_function(chat, hfp_disconnected_cb, modem); if (getenv("OFONO_AT_DEBUG")) g_at_chat_set_debug(chat, hfp_debug, ""); data->info.chat = chat; hfp_slc_establish(&data->info, slc_established, slc_failed, modem); return -EINPROGRESS; }
static void ril_sms_on_sim_cb(int ok, int total_length, int record, const unsigned char *sdata, int length, void *userdata) { struct ril_sms_on_sim_req *cbd = userdata; struct ril_sms *sd = cbd->sd; /* * It seems when reading EFsms RIL returns the whole record including * the first status byte therefore we ignore that as we are only * interested of the following pdu */ /* The first octect in the pdu contains the SMSC address length * which is the X following octects it reads. We add 1 octet to * the read length to take into account this read octet in order * to calculate the proper tpdu length. */ if (ok) { unsigned int smsc_len = sdata[1] + 1; ofono_sms_deliver_notify(sd->sms, sdata + 1, length - 1, length - smsc_len - 1); ril_request_delete_sms_om_sim(sd, cbd->record); } else { ofono_error("cannot read sms from sim"); } ril_sms_on_sim_req_free(cbd); }
static int at_gprs_context_probe(struct ofono_gprs_context *gc, unsigned int vendor, void *data) { GAtChat *chat = data; struct gprs_context_data *gcd; struct stat st; DBG(""); if (stat(TUN_SYSFS_DIR, &st) < 0) { ofono_error("Missing support for TUN/TAP devices"); return -ENODEV; } gcd = g_try_new0(struct gprs_context_data, 1); if (gcd == NULL) return -ENOMEM; gcd->chat = g_at_chat_clone(chat); gcd->vendor = vendor; ofono_gprs_context_set_data(gc, gcd); chat = g_at_chat_get_slave(gcd->chat); if (chat == NULL) return 0; g_at_chat_register(chat, "+CGEV:", cgev_notify, FALSE, gc, NULL); return 0; }
static void ril_sms_submit_cb(GRilIoChannel *io, int status, const void *data, guint len, void *user_data) { struct ril_sms_cbd *cbd = user_data; ofono_sms_submit_cb_t cb = cbd->cb.submit; struct ofono_error error; int mr = 0; if (status == RIL_E_SUCCESS) { GRilIoParser rilp; int err = -1; grilio_parser_init(&rilp, data, len); /* TP-Message-Reference for GSM/ * BearerData MessageId for CDMA */ grilio_parser_get_int32(&rilp, &mr); grilio_parser_skip_string(&rilp); /* error: 3GPP 27.005, 3.2.5, -1 if unknown or not applicable */ grilio_parser_get_int32(&rilp, &err); DBG("sms msg ref: %d, error: %d", mr, err); ril_error_init_ok(&error); } else if (status == RIL_E_GENERIC_FAILURE) { ofono_info("not allowed by MO SMS control, do not retry"); error.type = OFONO_ERROR_TYPE_CMS; error.error = 500; } else { ofono_error("sms sending failed, retry"); ril_error_init_failure(&error); } cb(&error, mr, cbd->data); }
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); } }
void ril_gprs_set_ia_apn(struct ofono_gprs *gprs, const char *apn, enum ofono_gprs_proto proto, const char *user, const char *passwd, const char *mccmnc, ofono_gprs_cb_t cb, void *data) { struct ril_gprs_data *gd = ofono_gprs_get_data(gprs); struct cb_data *cbd; struct parcel rilp; if (!ofono_modem_get_boolean(gd->modem, MODEM_PROP_LTE_CAPABLE)) { CALLBACK_WITH_SUCCESS(cb, data); return; } cbd = cb_data_new(cb, data, gprs); g_ril_request_set_initial_attach_apn(gd->ril, apn, proto, user, passwd, mccmnc, &rilp); if (g_ril_send(gd->ril, RIL_REQUEST_SET_INITIAL_ATTACH_APN, &rilp, set_ia_apn_cb, cbd, g_free) == 0) { ofono_error("%s: failure sending request", __func__); g_free(cbd); CALLBACK_WITH_FAILURE(cb, data); } }
static gboolean parse_sim_io(GRil *ril, struct ril_msg *message, int *sw1, int *sw2, char **hex_response) { struct parcel rilp; /* * Minimum length of SIM_IO_Response is 12: * sw1 (int32) * sw2 (int32) * simResponse (string) */ if (message->buf_len < 12) { ofono_error("Invalid SIM IO reply: size too small (< 12): %u", message->buf_len); return FALSE; } g_ril_init_parcel(message, &rilp); *sw1 = parcel_r_int32(&rilp); *sw2 = parcel_r_int32(&rilp); *hex_response = parcel_r_string(&rilp); g_ril_append_print_buf(ril, "(sw1=0x%.2X,sw2=0x%.2X,%s)", *sw1, *sw2, *hex_response); g_ril_print_response(ril, message); if (rilp.malformed) { g_free(*hex_response); return FALSE; } return TRUE; }
static void set_currency(struct ofono_call_meter *cm, const char *value) { DBusConnection *conn; const char *path; const char *dbusval; if (strlen(value) > 3) { ofono_error("Currency reported with size > 3: %s", value); return; } if (!strcmp(cm->currency, value)) return; strncpy(cm->currency, value, 3); cm->currency[3] = '\0'; conn = ofono_dbus_get_connection(); path = __ofono_atom_get_path(cm->atom); dbusval = cm->currency; ofono_dbus_signal_property_changed(conn, path, OFONO_CALL_METER_INTERFACE, "Currency", DBUS_TYPE_STRING, &dbusval); }
static void ril_imsi_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_sim_imsi_cb_t cb = cbd->cb; struct sim_data *sd = cbd->user; struct parcel rilp; gchar *imsi; DBG(""); if (message->error != RIL_E_SUCCESS) { ofono_error("Reply failure: %s", ril_error_to_string(message->error)); goto error; } g_ril_init_parcel(message, &rilp); imsi = parcel_r_string(&rilp); g_ril_append_print_buf(sd->ril, "{%s}", imsi ? imsi : "NULL"); g_ril_print_response(sd->ril, message); if (imsi == NULL) goto error; CALLBACK_WITH_SUCCESS(cb, imsi, cbd->data); g_free(imsi); return; error: CALLBACK_WITH_FAILURE(cb, NULL, cbd->data); }
static void set_puct_query_callback(const struct ofono_error *error, const char *currency, double ppu, void *data) { struct ofono_call_meter *cm = data; DBusMessage *reply; if (cm->pending == NULL) return; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { ofono_error("Setting PUCT successful, but query was not"); cm->flags &= ~CALL_METER_FLAG_CACHED; __ofono_dbus_pending_reply(&cm->pending, __ofono_error_failed(cm->pending)); return; } reply = dbus_message_new_method_return(cm->pending); __ofono_dbus_pending_reply(&cm->pending, reply); set_currency(cm, currency); set_ppu(cm, ppu); }
int g_ril_reply_parse_query_call_waiting(GRil *gril, const struct ril_msg *message) { struct parcel rilp; int numint, enabled, cls; g_ril_init_parcel(message, &rilp); numint = parcel_r_int32(&rilp); if (numint < 1) { ofono_error("%s Wrong format", __func__); goto error; } enabled = parcel_r_int32(&rilp); if (enabled > 0) cls = parcel_r_int32(&rilp); else cls = 0; g_ril_append_print_buf(gril, "{%d,0x%x}", enabled, cls); g_ril_print_response(gril, message); return cls; error: return -1; }
static int hfp_ag_init(void) { DBusConnection *conn = ofono_dbus_get_connection(); if (DBUS_TYPE_UNIX_FD < 0) return -EBADF; /* Registers External Profile handler */ if (!g_dbus_register_interface(conn, HFP_AG_EXT_PROFILE_PATH, BLUEZ_PROFILE_INTERFACE, profile_methods, NULL, NULL, NULL, NULL)) { ofono_error("Register Profile interface failed: %s", HFP_AG_EXT_PROFILE_PATH); return -EIO; } sim_hash = g_hash_table_new(g_direct_hash, g_direct_equal); modemwatch_id = __ofono_modemwatch_add(modem_watch, NULL, NULL); __ofono_modem_foreach(call_modemwatch, NULL); connection_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, connection_destroy); return 0; }
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); }
int g_ril_unsol_parse_connected(GRil *gril, const struct ril_msg *message) { struct parcel rilp; int size; int version; DBG(""); g_ril_init_parcel(message, &rilp); size = parcel_r_int32(&rilp); version = parcel_r_int32(&rilp); /* * For something that looks like a bug we get an extra int in mtk2 * modems. RIL version is the second integer in this case. This * happens when we get duplicated connected events, which should * not happen either. In these cases the first event has the right * size, but not those appearing after. */ if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK2 && size > 1) version = parcel_r_int32(&rilp); if (rilp.malformed) { ofono_error("%s: malformed parcel", __func__); version = RIL_VERSION_UNSPECIFIED; } g_ril_append_print_buf(gril, "{size: %d, [%d]}", size, version); g_ril_print_unsol(gril, message); return version; }
static void ril_creg_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_netreg_status_cb_t cb = cbd->cb; struct netreg_data *nd = cbd->user; struct reply_reg_state *reply; DBG(""); if (message->error != RIL_E_SUCCESS) { ofono_error("%s: failed to pull registration state", __func__); goto error; } if ((reply = g_ril_reply_parse_voice_reg_state(nd->ril, message)) == NULL) goto error; nd->tech = reply->tech; CALLBACK_WITH_SUCCESS(cb, reply->status, reply->lac, reply->ci, ril_tech_to_access_tech(reply->tech), cbd->data); g_free(reply); return; error: CALLBACK_WITH_FAILURE(cb, -1, -1, -1, -1, cbd->data); }
static void cb_ss_query_next_lock_callback(const struct ofono_error *error, int status, void *data) { struct ofono_call_barring *cb = data; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { if (cb->ss_req_type != SS_CONTROL_TYPE_QUERY) ofono_error("Enabling/disabling Call Barring via SS " "successful, but query was not"); cb->flags &= ~CALL_BARRING_FLAG_CACHED; __ofono_dbus_pending_reply(&cb->pending, __ofono_error_failed(cb->pending)); return; } cb->new_locks[cb->query_next] = status; if (cb->query_next < cb->query_end) { cb->query_next += 1; cb_ss_query_next_lock(cb); return; } generate_ss_query_reply(cb); update_barrings(cb, BEARER_CLASS_VOICE); }
static void ril_strength_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_netreg_strength_cb_t cb = cbd->cb; struct netreg_data *nd = cbd->user; struct ofono_error error; int strength; if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); } else { ofono_error("Failed to retrive the signal strength"); goto error; } /* The g_ril_unsol* function handles both reply & unsolicited */ strength = g_ril_unsol_parse_signal_strength(nd->ril, message, nd->tech); cb(&error, strength, cbd->data); return; error: CALLBACK_WITH_FAILURE(cb, -1, cbd->data); }
static void gnss_register_agent_cb(const struct ofono_error *error, void *data) { DBusMessage *reply; struct ofono_gnss *gnss = data; DBG(""); if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { ofono_error("Enabling Location Reporting Failed"); reply = __ofono_error_failed(gnss->pending); if (gnss->posr_agent) gnss_agent_free(gnss->posr_agent); __ofono_dbus_pending_reply(&gnss->pending, reply); return; } reply = dbus_message_new_method_return(gnss->pending); __ofono_dbus_pending_reply(&gnss->pending, reply); gnss->enabled = TRUE; if (gnss->posr_agent == NULL) gnss->driver->set_position_reporting(gnss, FALSE, gnss_disable_posr_cb, gnss); }
void ofono_modem_remove_interface(struct ofono_modem *modem, const char *interface) { GSList *found; const char *feature; found = g_slist_find_custom(modem->interface_list, interface, (GCompareFunc) strcmp); if (found == NULL) { ofono_error("Interface %s not found on the interface_list", interface); return; } g_free(found->data); modem->interface_list = g_slist_remove(modem->interface_list, found->data); feature = get_feature(interface); if (feature) { found = g_slist_find_custom(modem->feature_list, feature, (GCompareFunc) strcmp); if (found) { g_free(found->data); modem->feature_list = g_slist_remove(modem->feature_list, found->data); } } if (modem->interface_update != 0) return; modem->interface_update = g_idle_add(trigger_interface_update, modem); }
static void ril_network_state_change(struct ril_msg *message, gpointer user_data) { struct ofono_netreg *netreg = user_data; struct netreg_data *nd = ofono_netreg_get_data(netreg); struct cb_data *cbd = cb_data_new(ril_creg_notify, netreg); int request = RIL_REQUEST_VOICE_REGISTRATION_STATE; int ret; cbd->user = nd; if (message->req != RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED) goto error; g_ril_print_unsol_no_args(nd->ril, message); ret = g_ril_send(nd->ril, request, NULL, 0, ril_creg_cb, cbd, g_free); /* For operator update ofono will use the current_operator cb * so we don't need to probe ril here */ g_ril_print_request_no_args(nd->ril, ret, request); if (ret > 0) return; error: ofono_error("Unable to request network state changed"); g_free(cbd); }
static void ril_set_rat_mode(struct ofono_radio_settings *rs, enum ofono_radio_access_mode mode, ofono_radio_settings_rat_mode_set_cb_t cb, void *data) { struct radio_data *rd = ofono_radio_settings_get_data(rs); struct cb_data *cbd = cb_data_new(cb, data, rs); struct parcel rilp; int pref = PREF_NET_TYPE_GSM_WCDMA; switch (mode) { case OFONO_RADIO_ACCESS_MODE_ANY: pref = PREF_NET_TYPE_LTE_GSM_WCDMA; break; case OFONO_RADIO_ACCESS_MODE_GSM: pref = PREF_NET_TYPE_GSM_ONLY; break; case OFONO_RADIO_ACCESS_MODE_UMTS: pref = PREF_NET_TYPE_GSM_WCDMA; break; case OFONO_RADIO_ACCESS_MODE_LTE: pref = PREF_NET_TYPE_LTE_GSM_WCDMA; break; } g_ril_request_set_preferred_network_type(rd->ril, pref, &rilp); if (g_ril_send(rd->ril, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, &rilp, ril_set_rat_cb, cbd, g_free) == 0) { ofono_error("%s: unable to set rat mode", __func__); g_free(cbd); CALLBACK_WITH_FAILURE(cb, data); } }
static void set_ia_apn(struct ofono_radio_settings *rs) { char mccmnc[OFONO_MAX_MCC_LENGTH + OFONO_MAX_MNC_LENGTH + 1]; struct radio_data *rd = ofono_radio_settings_get_data(rs); struct parcel rilp; struct ofono_gprs *gprs; const struct ofono_gprs_primary_context *ia_ctx; if ((rd->available_rats & OFONO_RADIO_ACCESS_MODE_LTE) == 0) return; gprs = __ofono_atom_find(OFONO_ATOM_TYPE_GPRS, rd->modem); if (gprs == NULL) return; /* Ask for APN data */ ia_ctx = ofono_gprs_get_ia_apn(gprs, mccmnc); if (ia_ctx == NULL) return; g_ril_request_set_initial_attach_apn(rd->ril, ia_ctx->apn, ia_ctx->proto, ia_ctx->username, ia_ctx->password, mccmnc, &rilp); if (g_ril_send(rd->ril, RIL_REQUEST_SET_INITIAL_ATTACH_APN, &rilp, set_ia_apn_cb, rs, NULL) == 0) ofono_error("%s: failure sending request", __func__); }