示例#1
0
static void ril_force_rat_mode(struct radio_data *rd, int pref)
{
	struct parcel rilp;

	if (pref == rd->ratmode)
		return;

	DBG("pref ril rat mode %d, ril current %d", pref, rd->ratmode);

	parcel_init(&rilp);
	parcel_w_int32(&rilp, 1);
	parcel_w_int32(&rilp, rd->ratmode);
	g_ril_send(rd->ril,
		RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE,
		rilp.data, rilp.size, NULL,
		NULL, g_free);
	parcel_free(&rilp);
}
示例#2
0
gboolean g_ril_request_sim_write_record(GRil *gril,
					const struct req_sim_write_record *req,
					struct parcel *rilp)
{
	char *hex_data;
	int p2;

	parcel_init(rilp);
	parcel_w_int32(rilp, CMD_UPDATE_RECORD);
	parcel_w_int32(rilp, req->fileid);

	g_ril_append_print_buf(gril, "(cmd=0x%02X,efid=0x%04X,",
				CMD_UPDATE_RECORD, req->fileid);

	if (set_path(gril, req->app_type, rilp, req->fileid,
			req->path, req->path_len) == FALSE)
		goto error;

	p2 = get_sim_record_access_p2(req->mode);
	hex_data = encode_hex(req->data, req->length, 0);

	parcel_w_int32(rilp, req->record);	/* P1 */
	parcel_w_int32(rilp, p2);		/* P2 (access mode) */
	parcel_w_int32(rilp, req->length);	/* P3 (Lc) */
	parcel_w_string(rilp, hex_data);	/* data */
	parcel_w_string(rilp, NULL);		/* pin2; only for FDN/BDN */
	parcel_w_string(rilp, req->aid_str);	/* AID (Application ID) */

	g_ril_append_print_buf(gril,
				"%s%d,%d,%d,%s,pin2=(null),aid=%s)",
				print_buf,
				req->record,
				p2,
				req->length,
				hex_data,
				req->aid_str);

	g_free(hex_data);

	return TRUE;

error:
	return FALSE;
}
示例#3
0
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);
	struct parcel rilp;
	int pref = rd->ratmode;
	int ret = 0;

	ofono_info("setting rat mode");

	parcel_init(&rilp);

	parcel_w_int32(&rilp, 1);			/* Number of params */

	switch (mode) {
	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_AUTO; /* according to UI design */
		break;
	case OFONO_RADIO_ACCESS_MODE_LTE:
		pref = PREF_NET_TYPE_LTE_ONLY;
	default:
		break;
	}

	parcel_w_int32(&rilp, pref);

	ret = g_ril_send(rd->ril, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE,
			rilp.data, rilp.size, ril_set_rat_cb,
			cbd, g_free);

	parcel_free(&rilp);

	if (ret <= 0) {
		ofono_error("unable to set rat mode");
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, data);
	}
}
示例#4
0
static void send_allow_data(struct cb_data *cbd, GRil *ril, int attached)
{
	ofono_gprs_cb_t cb = cbd->cb;
	struct parcel rilp;

	/* ALLOW_DATA payload: int[] with attach value */
	parcel_init(&rilp);
	parcel_w_int32(&rilp, 1);
	parcel_w_int32(&rilp, attached);

	g_ril_append_print_buf(ril, "(%d)", attached);

	if (g_ril_send(ril, RIL_REQUEST_ALLOW_DATA, &rilp,
					gprs_allow_data_cb, cbd, NULL) == 0) {
		ofono_error("%s: send failed", __func__);
		free_attach_cbd(cbd);
		CALLBACK_WITH_FAILURE(cb, cbd->data);
	}
}
示例#5
0
文件: sim.c 项目: impegoraro/ofono
static void ril_change_passwd(struct ofono_sim *sim,
				enum ofono_sim_password_type passwd_type,
				const char *old_passwd, const char *new_passwd,
				ofono_sim_lock_unlock_cb_t cb, void *data)
{
	struct sim_data *sd = ofono_sim_get_data(sim);
	struct cb_data *cbd = cb_data_new(cb, data);
	struct parcel rilp;
	int request = RIL_REQUEST_CHANGE_SIM_PIN;
	int ret = 0;

	sd->passwd_type = passwd_type;
	cbd->user = sd;

	parcel_init(&rilp);

	parcel_w_int32(&rilp, CHANGE_SIM_PIN_PARAMS);
	parcel_w_string(&rilp, (char *) old_passwd);
	parcel_w_string(&rilp, (char *) new_passwd);
	parcel_w_string(&rilp, sd->aid_str);

	if (passwd_type == OFONO_SIM_PASSWORD_SIM_PIN2)
		request = RIL_REQUEST_CHANGE_SIM_PIN2;
	else if (current_passwd)
		g_stpcpy(current_passwd, new_passwd);

	ret = g_ril_send(sd->ril, request, rilp.data, rilp.size,
			ril_pin_change_state_cb, cbd, g_free);

	g_ril_append_print_buf(sd->ril, "(old=%s,new=%s,aid=%s)",
				old_passwd, new_passwd,
				sd->aid_str);

	g_ril_print_request(sd->ril, ret, request);

	parcel_free(&rilp);

	if (ret <= 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, data);
	}
}
示例#6
0
void g_ril_request_dial(GRil *gril,
			const struct ofono_phone_number *ph,
			enum ofono_clir_option clir,
			struct parcel *rilp)
{
	parcel_init(rilp);

	/* Number to dial */
	parcel_w_string(rilp, phone_number_to_string(ph));
	/* CLIR mode */
	parcel_w_int32(rilp, clir);
	/* USS, empty string */
	/* TODO: Deal with USS properly */
	parcel_w_int32(rilp, 0);
	parcel_w_int32(rilp, 0);

	g_ril_append_print_buf(gril, "(%s,%d,0,0)",
				phone_number_to_string(ph),
				clir);
}
示例#7
0
void g_ril_request_set_uicc_subscription(GRil *gril, int slot_id,
					int app_index,
					int sub_id,
					int sub_status,
					struct parcel *rilp)
{
	parcel_init(rilp);

	parcel_w_int32(rilp, slot_id);
	parcel_w_int32(rilp, app_index);
	parcel_w_int32(rilp, sub_id);
	parcel_w_int32(rilp, sub_status);

	g_ril_append_print_buf(gril, "(%d, %d, %d, %d(%s))",
				slot_id,
				app_index,
				sub_id,
				sub_status,
				sub_status ? "ACTIVATE" : "DEACTIVATE");
}
示例#8
0
void g_ril_request_oem_hook_strings(GRil *gril, const char **strs, int num_str,
							struct parcel *rilp)
{
	int i;

	parcel_init(rilp);
	parcel_w_int32(rilp, num_str);

	g_ril_append_print_buf(gril, "(");

	for (i = 0; i < num_str; ++i) {
		parcel_w_string(rilp, strs[i]);

		if (i == num_str - 1)
			g_ril_append_print_buf(gril, "%s%s)",
							print_buf, strs[i]);
		else
			g_ril_append_print_buf(gril, "%s%s, ",
							print_buf, strs[i]);
	}
}
示例#9
0
文件: ussd.c 项目: dzemskov/ofono
static void ril_ussd_request(struct ofono_ussd *ussd, int dcs,
			const unsigned char *pdu, int len,
			ofono_ussd_cb_t cb, void *data)
{
	struct ussd_data *ud = ofono_ussd_get_data(ussd);
	struct cb_data *cbd = cb_data_new(cb, data, ussd);
	char *text;
	struct parcel rilp;
	int ret;

	text = ussd_decode(dcs, len, pdu);
	if (!text)
		goto error;

	parcel_init(&rilp);
	parcel_w_string(&rilp, text);

	g_ril_append_print_buf(ud->ril, "(%s)", text);

	ret = g_ril_send(ud->ril, RIL_REQUEST_SEND_USSD,
				&rilp, ril_ussd_cb, ussd, NULL);
	g_free(text);

	/*
	 * TODO: Is g_idle_add necessary?
	 * We do not wait for the SEND_USSD reply to do the callback, as some
	 * networks send it after sending one or more ON_USSD events. From the
	 * ofono core perspective, Initiate() does not return until one ON_USSD
	 * event is received: making here a successful callback just makes the
	 * core wait for that event.
	 */
	if (ret > 0) {
		g_idle_add(request_success, cbd);
		return;
	}

error:
	g_free(cbd);
	CALLBACK_WITH_FAILURE(cb, data);
}
示例#10
0
文件: sim.c 项目: impegoraro/ofono
static int ril_perso_change_state(struct ofono_sim *sim,
				enum ofono_sim_password_type passwd_type,
				int enable, const char *passwd,
				ofono_sim_lock_unlock_cb_t cb, void *data)
{
	struct sim_data *sd = ofono_sim_get_data(sim);
	struct cb_data *cbd = cb_data_new(cb, data);
	struct parcel rilp;
	int request = 0;
	int ret = 0;
	sd->passwd_type = passwd_type;
	cbd->user = sd;

	parcel_init(&rilp);

	switch (passwd_type) {
	case OFONO_SIM_PASSWORD_PHNET_PIN:
		if (enable) {
			DBG("Not supported, enable=%d", enable);
			goto end;
		}
		request = RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION;
		parcel_w_int32(&rilp, RIL_PERSOSUBSTATE_SIM_NETWORK);
		parcel_w_string(&rilp, (char *) passwd);
		break;
	default:
		DBG("Not supported, type=%d", passwd_type);
		goto end;
	}

	ret = g_ril_send(sd->ril, request,
				rilp.data, rilp.size, ril_pin_change_state_cb,
				cbd, g_free);

	g_ril_print_request(sd->ril, ret, request);

end:
	parcel_free(&rilp);
	return ret;
}
示例#11
0
文件: sim.c 项目: impegoraro/ofono
static void ril_pin_send_puk(struct ofono_sim *sim,
				const char *puk, const char *passwd,
				ofono_sim_lock_unlock_cb_t cb, void *data)
{
	struct sim_data *sd = ofono_sim_get_data(sim);
	struct cb_data *cbd = cb_data_new(cb, data);
	struct parcel rilp;
	int request = RIL_REQUEST_ENTER_SIM_PUK;
	int ret = 0;

	sd->passwd_type = OFONO_SIM_PASSWORD_SIM_PUK;
	cbd->user = sd;

	if (current_passwd)
		g_stpcpy(current_passwd, passwd);

	parcel_init(&rilp);

	parcel_w_int32(&rilp, ENTER_SIM_PUK_PARAMS);
	parcel_w_string(&rilp, (char *) puk);
	parcel_w_string(&rilp, (char *) passwd);
	parcel_w_string(&rilp, sd->aid_str);

	ret = g_ril_send(sd->ril, request,
			rilp.data, rilp.size, ril_pin_change_state_cb,
			cbd, g_free);

	g_ril_append_print_buf(sd->ril, "(puk=%s,pin=%s,aid=%s)",
				puk, passwd,
				sd->aid_str);

	g_ril_print_request(sd->ril, ret, request);

	parcel_free(&rilp);

	if (ret <= 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, data);
	}
}
示例#12
0
gboolean g_ril_request_sim_read_info(GRil *gril,
					const struct req_sim_read_info *req,
					struct parcel *rilp)
{
	parcel_init(rilp);

	parcel_w_int32(rilp, CMD_GET_RESPONSE);
	parcel_w_int32(rilp, req->fileid);

	g_ril_append_print_buf(gril,
				"(cmd=0x%.2X,efid=0x%.4X,",
				CMD_GET_RESPONSE,
				req->fileid);

	if (set_path(gril, req->app_type, rilp, req->fileid,
			req->path, req->path_len) == FALSE)
		goto error;

	parcel_w_int32(rilp, 0);           /* P1 */
	parcel_w_int32(rilp, 0);           /* P2 */

	/*
	 * TODO: review parameters values used by Android.
	 * The values of P1-P3 in this code were based on
	 * values used by the atmodem driver impl.
	 *
	 * NOTE:
	 * GET_RESPONSE_EF_SIZE_BYTES == 15; !255
	 */
	parcel_w_int32(rilp, 15);         /* P3 - max length */
	parcel_w_string(rilp, NULL);       /* data; only req'd for writes */
	parcel_w_string(rilp, NULL);       /* pin2; only req'd for writes */
	parcel_w_string(rilp, req->aid_str); /* AID (Application ID) */

	return TRUE;

error:
	return FALSE;
}
示例#13
0
文件: sim.c 项目: endocode/ofono
static void ril_set_facility_lock(struct ofono_sim *sim,
				enum ofono_sim_password_type passwd_type,
				int enable, const char *passwd,
				ofono_sim_lock_unlock_cb_t cb, void *data)
{
	struct sim_data *sd = ofono_sim_get_data(sim);
	struct cb_data *cbd;
	struct parcel rilp;

	sd->unlock_pending = FALSE;
	sd->passwd_type = passwd_type;

	if (passwd_type >= ARRAY_SIZE(clck_cpwd_fac) ||
			clck_cpwd_fac[passwd_type] == NULL)
		goto error;

	cbd = cb_data_new(cb, data, sim);

	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);

	g_ril_append_print_buf(sd->ril, "(%s,%d,%s,0,aid=%s)",
				clck_cpwd_fac[passwd_type], enable, passwd,
				sd->aid_str);

	if (g_ril_send(sd->ril, RIL_REQUEST_SET_FACILITY_LOCK, &rilp,
				ril_set_facility_lock_cb, cbd, g_free) > 0)
		return;

	g_free(cbd);
error:
	CALLBACK_WITH_FAILURE(cb, data);
}
示例#14
0
void g_ril_request_sms_cmgs(GRil *gril,
				const struct req_sms_cmgs *req,
				struct parcel *rilp)
{
	int smsc_len;
	char *tpdu;

	parcel_init(rilp);
	parcel_w_int32(rilp, 2);	/* Number of strings */

	/*
	 * SMSC address:
	 *
	 * smsc_len == 1, then zero-length SMSC was spec'd
	 * RILD expects a NULL string in this case instead
	 * of a zero-length string.
	 */
	smsc_len = req->pdu_len - req->tpdu_len;
	/* TODO: encode SMSC & write to parcel */
	if (smsc_len > 1)
		ofono_error("SMSC address specified (smsc_len %d); "
				"NOT-IMPLEMENTED", smsc_len);

	parcel_w_string(rilp, NULL); /* SMSC address; NULL == default */

	/*
	 * TPDU:
	 *
	 * 'pdu' is a raw hexadecimal string
	 *  encode_hex() turns it into an ASCII/hex UTF8 buffer
	 *  parcel_w_string() encodes utf8 -> utf16
	 */
	tpdu = encode_hex(req->pdu + smsc_len, req->tpdu_len, 0);
	parcel_w_string(rilp, tpdu);

	g_ril_append_print_buf(gril, "(%s)", tpdu);

	g_free(tpdu);
}
示例#15
0
文件: sim.c 项目: endocode/ofono
static void ril_change_passwd(struct ofono_sim *sim,
				enum ofono_sim_password_type passwd_type,
				const char *old_passwd, const char *new_passwd,
				ofono_sim_lock_unlock_cb_t cb, void *data)
{
	struct sim_data *sd = ofono_sim_get_data(sim);
	struct cb_data *cbd = cb_data_new(cb, data, sim);
	struct parcel rilp;
	int request;

	switch (passwd_type) {
	case OFONO_SIM_PASSWORD_SIM_PIN:
		request = RIL_REQUEST_CHANGE_SIM_PIN;
		break;
	case OFONO_SIM_PASSWORD_SIM_PIN2:
		request = RIL_REQUEST_CHANGE_SIM_PIN2;
		break;
	default:
		goto error;
	};

	parcel_init(&rilp);

	parcel_w_int32(&rilp, 3);
	parcel_w_string(&rilp, old_passwd);
	parcel_w_string(&rilp, new_passwd);
	parcel_w_string(&rilp, sd->aid_str);

	g_ril_append_print_buf(sd->ril, "(old=%s,new=%s,aid=%s)",
				old_passwd, new_passwd, sd->aid_str);

	if (g_ril_send(sd->ril, request, &rilp, ril_enter_sim_pin_cb,
			cbd, g_free) > 0)
		return;

error:
	g_free(cbd);
	CALLBACK_WITH_FAILURE(cb, data);
}
示例#16
0
文件: ril.c 项目: CODeRUS/ofono
static int ril_screen_state(struct ofono_modem *modem, ofono_bool_t state)
{
	struct ril_data *ril = ofono_modem_get_data(modem);
	struct parcel rilp;
	int request = RIL_REQUEST_SCREEN_STATE;
	guint ret;

	parcel_init(&rilp);
	parcel_w_int32(&rilp, 1);		/* size of array */
	parcel_w_int32(&rilp, state);	/* screen on/off */

	/* fire and forget i.e. not waiting for the callback*/
	ret = g_ril_send(ril->modem, request, rilp.data,
			 rilp.size, NULL, NULL, NULL);

	g_ril_append_print_buf(ril->modem, "(0)");
	g_ril_print_request(ril->modem, ret, request);

	parcel_free(&rilp);

	return 0;
}
示例#17
0
gboolean g_ril_request_deactivate_data_call(GRil *gril,
				const struct req_deactivate_data_call *req,
				struct parcel *rilp,
				struct ofono_error *error)
{
	gchar *cid_str = NULL;
	gchar *reason_str = NULL;

	if (req->reason != RIL_DEACTIVATE_DATA_CALL_NO_REASON &&
		req->reason != RIL_DEACTIVATE_DATA_CALL_RADIO_SHUTDOWN) {
		goto error;
	}

	parcel_init(rilp);
	parcel_w_int32(rilp, DEACTIVATE_DATA_CALL_NUM_PARAMS);

	cid_str = g_strdup_printf("%d", req->cid);
	parcel_w_string(rilp, cid_str);

	/*
	 * TODO: airplane-mode; change reason to '1',
	 * which means "radio power off".
	 */
	reason_str = g_strdup_printf("%d", req->reason);
	parcel_w_string(rilp, reason_str);

	g_ril_append_print_buf(gril, "(%s,%s)", cid_str, reason_str);

	g_free(cid_str);
	g_free(reason_str);

	OFONO_NO_ERROR(error);
	return TRUE;

error:
	OFONO_EINVAL(error);
	return FALSE;
}
示例#18
0
void g_ril_request_call_fwd(GRil *gril,	const struct req_call_fwd *req,
				struct parcel *rilp)
{
	parcel_init(rilp);

	parcel_w_int32(rilp, req->action);
	parcel_w_int32(rilp, req->type);
	parcel_w_int32(rilp, req->cls);

	g_ril_append_print_buf(gril, "(type: %d cls: %d ", req->type, req->cls);

	if (req->number != NULL) {
		parcel_w_int32(rilp, req->number->type);
		parcel_w_string(rilp, (char *) req->number->number);

		g_ril_append_print_buf(gril, "%s number type: %d number: "
					"%s time: %d) ", print_buf,
					req->number->type, req->number->number,
					req->time);
	} else {
		/*
		 * The following values have no real meaning for
		 * activation/deactivation/erasure actions, but
		 * apparently rild expects them, so fields need to
		 * be filled. Otherwise there is no response.
		 */

		parcel_w_int32(rilp, 0x81);		/* TOA unknown */
		parcel_w_string(rilp, "1234567890");
		g_ril_append_print_buf(gril, "%s number type: %d number: "
					"%s time: %d) ", print_buf,
					0x81, "1234567890",
					req->time);

	}

	parcel_w_int32(rilp, req->time);
}
示例#19
0
static void ril_call_volume_mute(struct ofono_call_volume *cv, int muted,
					ofono_call_volume_cb_t cb, void *data)
{
	struct cv_data *cvd = ofono_call_volume_get_data(cv);
	struct cb_data *cbd = cb_data_new(cb, data, cvd);
	struct parcel rilp;

	DBG("muted: %d", muted);

	parcel_init(&rilp);

	parcel_w_int32(&rilp, 1);
	parcel_w_int32(&rilp, muted);

	g_ril_append_print_buf(cvd->ril, "(%d)", muted);

	if (g_ril_send(cvd->ril, RIL_REQUEST_SET_MUTE, &rilp,
			volume_mute_cb, cbd, g_free) > 0)
		return;

	g_free(cbd);
	CALLBACK_WITH_FAILURE(cb, data);
}
示例#20
0
文件: sim.c 项目: endocode/ofono
static void ril_query_facility_lock(struct ofono_sim *sim,
					enum ofono_sim_password_type lock,
					ofono_query_facility_lock_cb_t cb,
					void *data)
{
	struct sim_data *sd = ofono_sim_get_data(sim);
	struct cb_data *cbd = cb_data_new(cb, data, sd);
	struct parcel rilp;

	parcel_init(&rilp);
	parcel_w_int32(&rilp, 4);	/* # of strings */
	parcel_w_string(&rilp, clck_cpwd_fac[lock]);
	parcel_w_string(&rilp, "");	/* Password is empty when not needed */
	parcel_w_string(&rilp, "0"); /* Class is "0" */
	parcel_w_string(&rilp, NULL); /* AID value is NULL */

	if (g_ril_send(sd->ril, RIL_REQUEST_QUERY_FACILITY_LOCK, &rilp,
			ril_query_facility_lock_cb, cbd, g_free) > 0)
		return;

	g_free(cbd);
	CALLBACK_WITH_FAILURE(cb, 0, data);
}
示例#21
0
文件: sim.c 项目: endocode/ofono
static void ril_read_imsi(struct ofono_sim *sim, ofono_sim_imsi_cb_t cb,
				void *data)
{
	static const int GET_IMSI_NUM_PARAMS = 1;
	struct sim_data *sd = ofono_sim_get_data(sim);
	struct cb_data *cbd = cb_data_new(cb, data, sd);
	struct parcel rilp;

	DBG("");

	parcel_init(&rilp);
	parcel_w_int32(&rilp, GET_IMSI_NUM_PARAMS);
	parcel_w_string(&rilp, sd->aid_str);

	g_ril_append_print_buf(sd->ril, "(%d,%s)",
					GET_IMSI_NUM_PARAMS, sd->aid_str);

	if (g_ril_send(sd->ril, RIL_REQUEST_GET_IMSI, &rilp,
			ril_imsi_cb, cbd, g_free) == 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, NULL, data);
	}
}
示例#22
0
static DBusMessage *set_rf_power_status(DBusMessage *msg,
					dbus_bool_t enable,
					void *data)
{
	struct ril_thermal_management *tm = data;
	struct ril_data *rd = ofono_modem_get_data(tm->modem);
	struct parcel rilp;

	int cmd_id;
	char buf[4];

	DBG("");

	if (tm->pending)
		return __ofono_error_busy(msg);

	parcel_init(&rilp);
	parcel_w_int32(&rilp, 2);
	/* RIL_OEM_HOOK_STRING_SET_RF_POWER_STATUS = 0x000000AC */
	cmd_id = 0x000000AC;
	sprintf(buf, "%d", cmd_id);
	parcel_w_string(&rilp, buf);

	memset(buf, 0, sizeof(buf));
	sprintf(buf, "%d", enable ? 1 : 0);
	parcel_w_string(&rilp, buf);

	g_ril_append_print_buf(rd->ril, "{cmd_id=0x%02X,arg=%s}", cmd_id, buf);

	if (g_ril_send(rd->ril, RIL_REQUEST_OEM_HOOK_STRINGS, &rilp,
			set_rf_power_status_cb, tm, NULL) == 0)
		return __ofono_error_failed(msg);

	tm->pending = dbus_message_ref(msg);

	return NULL;
}
示例#23
0
void g_ril_request_set_facility_lock(GRil *gril, const char *facility,
					int enable, const char *passwd,
					int services, struct parcel *rilp)
{
	char svcs_str[4];
	const char *enable_str;

	parcel_init(rilp);

	parcel_w_int32(rilp, 5);	/* # of strings */
	parcel_w_string(rilp, facility);
	if (enable)
		enable_str = "1";
	else
		enable_str = "0";
	parcel_w_string(rilp, enable_str);
	parcel_w_string(rilp, passwd);
	snprintf(svcs_str, sizeof(svcs_str), "%d", services);
	parcel_w_string(rilp, svcs_str);
	parcel_w_string(rilp, NULL);	/* AID (for FDN, not yet supported) */

	g_ril_append_print_buf(gril, "(%s,%s,%s,%s,(null))",
				facility, enable_str, passwd, svcs_str);
}
示例#24
0
void g_ril_request_set_call_waiting(GRil *gril,
					int enabled, int serviceclass,
					struct parcel *rilp)
{
	parcel_init(rilp);

	parcel_w_int32(rilp, 2);	/* Number of params */
	parcel_w_int32(rilp, enabled);	/* on/off */

	/*
	 * Modem seems to respond with error to all queries
	 * or settings made with bearer class
	 * BEARER_CLASS_DEFAULT. Design decision: If given
	 * class is BEARER_CLASS_DEFAULT let's map it to
	 * SERVICE_CLASS_VOICE effectively making it the
	 * default bearer.
	 */
	if (serviceclass == BEARER_CLASS_DEFAULT)
		serviceclass = BEARER_CLASS_VOICE;

	parcel_w_int32(rilp, serviceclass);	/* Service class */

	g_ril_append_print_buf(gril, "(%d, 0x%x)", enabled, serviceclass);
}
示例#25
0
文件: sim.c 项目: impegoraro/ofono
static void ril_pin_change_state(struct ofono_sim *sim,
				enum ofono_sim_password_type passwd_type,
				int enable, const char *passwd,
				ofono_sim_lock_unlock_cb_t cb, void *data)
{
	DBG("passwd_type=%d", passwd_type);
	struct sim_data *sd = ofono_sim_get_data(sim);
	struct cb_data *cbd = cb_data_new(cb, data);
	struct parcel rilp;
	int request = RIL_REQUEST_SET_FACILITY_LOCK;
	int ret = 0;

	sd->passwd_type = passwd_type;
	cbd->user = sd;

	parcel_init(&rilp);
	parcel_w_int32(&rilp, SET_FACILITY_LOCK_PARAMS);

	/*
	 * TODO: clean up the use of string literals &
	 * the multiple g_ril_append_print_buf() calls
	 * by using a table lookup as does the core sim code
	 */
	switch (passwd_type) {
	case OFONO_SIM_PASSWORD_SIM_PIN:
		if (current_passwd)
			g_stpcpy(current_passwd, passwd);
		g_ril_append_print_buf(sd->ril, "(SC,");
		parcel_w_string(&rilp, "SC");
		break;
	case OFONO_SIM_PASSWORD_PHSIM_PIN:
		g_ril_append_print_buf(sd->ril, "(PS,");
		parcel_w_string(&rilp, "PS");
		break;
	case OFONO_SIM_PASSWORD_PHFSIM_PIN:
		g_ril_append_print_buf(sd->ril, "(PF,");
		parcel_w_string(&rilp, "PF");
		break;
	case OFONO_SIM_PASSWORD_SIM_PIN2:
		g_ril_append_print_buf(sd->ril, "(P2,");
		parcel_w_string(&rilp, "P2");
		break;
	case OFONO_SIM_PASSWORD_PHNET_PIN:
		ret = ril_perso_change_state(sim, passwd_type, enable, passwd,
						cb, data);
		goto end;
	case OFONO_SIM_PASSWORD_PHNETSUB_PIN:
		g_ril_append_print_buf(sd->ril, "(PU,");
		parcel_w_string(&rilp, "PU");
		break;
	case OFONO_SIM_PASSWORD_PHSP_PIN:
		g_ril_append_print_buf(sd->ril, "(PP,");
		parcel_w_string(&rilp, "PP");
		break;
	case OFONO_SIM_PASSWORD_PHCORP_PIN:
		g_ril_append_print_buf(sd->ril, "(PC,");
		parcel_w_string(&rilp, "PC");
		break;
	default:
		goto end;
	}

	if (enable)
		parcel_w_string(&rilp, RIL_FACILITY_LOCK);
	else
		parcel_w_string(&rilp, RIL_FACILITY_UNLOCK);

	parcel_w_string(&rilp, (char *) passwd);

	/* TODO: make this a constant... */
	parcel_w_string(&rilp, "0");		/* class */

	parcel_w_string(&rilp, sd->aid_str);

	ret = g_ril_send(sd->ril, request,
				rilp.data, rilp.size, ril_pin_change_state_cb,
				cbd, g_free);

	g_ril_append_print_buf(sd->ril, "%s,%d,%s,0,aid=%s)",
				print_buf,
				enable,
				passwd,
				sd->aid_str);

	g_ril_print_request(sd->ril, ret, request);

end:
	parcel_free(&rilp);

	if (ret <= 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, data);
	}
}
示例#26
0
gboolean g_ril_request_setup_data_call(GRil *gril,
					const struct req_setup_data_call *req,
					struct parcel *rilp,
					struct ofono_error *error)
{
	const gchar *protocol_str;
	gchar *tech_str;
	gchar *auth_str;
	gchar *profile_str;
	int num_param = SETUP_DATA_CALL_PARAMS;

	DBG("");

	if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK)
		num_param = SETUP_DATA_CALL_PARAMS + 1;

	/*
	 * Radio technology to use: 0-CDMA, 1-GSM/UMTS, 2...
	 * values > 2 are (RADIO_TECH + 2)
	 */
	if (req->tech < 1 || req->tech > (RADIO_TECH_GSM + 2)) {
		ofono_error("%s: Invalid tech value: %d",
				__func__,
				req->tech);
		goto error;
	}

	/*
	 * TODO(OEM): This code doesn't currently support
	 * OEM data profiles.  If a use case exist, then
	 * this code will need to be modified.
	 */
	switch (req->data_profile) {
	case RIL_DATA_PROFILE_DEFAULT:
		profile_str = DATA_PROFILE_DEFAULT_STR;
		break;
	case RIL_DATA_PROFILE_TETHERED:
		profile_str = DATA_PROFILE_TETHERED_STR;
		break;
	case RIL_DATA_PROFILE_IMS:
		profile_str = DATA_PROFILE_IMS_STR;
		break;
	case RIL_DATA_PROFILE_FOTA:
		profile_str = DATA_PROFILE_FOTA_STR;
		break;
	case RIL_DATA_PROFILE_CBS:
		profile_str = DATA_PROFILE_CBS_STR;
		break;
	case RIL_DATA_PROFILE_MTK_MMS:
		if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) {
			profile_str = DATA_PROFILE_MTK_MMS_STR;
			break;
		}
	default:
		ofono_error("%s, invalid data_profile value: %d",
				__func__,
				req->data_profile);
		goto error;
	}

	if (req->apn == NULL)
		goto error;

	if (req->auth_type > RIL_AUTH_BOTH) {
		ofono_error("%s: Invalid auth type: %d",
				__func__,
				req->auth_type);
		goto error;
	}

	protocol_str = ril_ofono_protocol_to_ril_string(req->protocol);
	if (protocol_str == NULL) {
		ofono_error("%s: Invalid protocol: %d",
				__func__,
				req->protocol);
		goto error;
	}

	parcel_init(rilp);

	parcel_w_int32(rilp, num_param);

	tech_str = g_strdup_printf("%d", req->tech);
	parcel_w_string(rilp, tech_str);
	parcel_w_string(rilp, profile_str);
	parcel_w_string(rilp, req->apn);
	parcel_w_string(rilp, req->username);
	parcel_w_string(rilp, req->password);

	auth_str = g_strdup_printf("%d", req->auth_type);
	parcel_w_string(rilp, auth_str);
	parcel_w_string(rilp, protocol_str);

	g_ril_append_print_buf(gril,
				"(%s,%s,%s,%s,%s,%s,%s",
				tech_str,
				profile_str,
				req->apn,
				req->username,
				req->password,
				auth_str,
				protocol_str);

	if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) {
		/* MTK request_cid parameter */
		char cid_str[MAX_CID_DIGITS + 1];

		snprintf(cid_str, sizeof(cid_str), "%u", req->req_cid);
		parcel_w_string(rilp, cid_str);
		g_ril_append_print_buf(gril, "%s,%s", print_buf, cid_str);
	}

	g_ril_append_print_buf(gril, "%s)", print_buf);

	g_free(tech_str);
	g_free(auth_str);

	OFONO_NO_ERROR(error);
	return TRUE;

error:
        OFONO_EINVAL(error);
	return FALSE;
}
示例#27
0
gboolean g_ril_request_setup_data_call(GRil *gril,
					const struct req_setup_data_call *req,
					struct parcel *rilp,
					struct ofono_error *error)
{
	const gchar *protocol_str;
	gchar *tech_str;
	gchar *auth_str;
	gchar *profile_str;
	size_t apn_len;

	DBG("");

	if (req->tech < RADIO_TECH_GPRS || req->tech > RADIO_TECH_GSM) {
		ofono_error("%s: Invalid tech value: %d", __func__, req->tech);
		goto error;
	}

	/*
	 * TODO(OEM): This code doesn't currently support
	 * OEM data profiles.  If a use case exist, then
	 * this code will need to be modified.
	 */
	switch (req->data_profile) {
	case RIL_DATA_PROFILE_DEFAULT:
		profile_str = DATA_PROFILE_DEFAULT_STR;
		break;
	case RIL_DATA_PROFILE_TETHERED:
		profile_str = DATA_PROFILE_TETHERED_STR;
		break;
	case RIL_DATA_PROFILE_IMS:
		profile_str = DATA_PROFILE_IMS_STR;
		break;
	case RIL_DATA_PROFILE_FOTA:
		profile_str = DATA_PROFILE_FOTA_STR;
		break;
	case RIL_DATA_PROFILE_CBS:
		profile_str = DATA_PROFILE_CBS_STR;
		break;
	default:
		ofono_error("%s, invalid data_profile value: %d",
				__func__,
				req->data_profile);
		goto error;
	}

	if (req->apn == NULL)
		goto error;

	apn_len = strlen(req->apn);
	if (apn_len == 0 || apn_len > 100) {
		ofono_error("%s: invalid apn length: %d",
				__func__,
				(int) apn_len);
		goto error;
	}

	if (req->auth_type > RIL_AUTH_BOTH) {
		ofono_error("%s: Invalid auth type: %d",
				__func__,
				req->auth_type);
		goto error;
	}

	protocol_str = ril_ofono_protocol_to_ril_string(req->protocol);
	if (protocol_str == NULL) {
		ofono_error("%s: Invalid protocol: %d",
				__func__,
				req->protocol);
		goto error;
	}

	parcel_init(rilp);

	parcel_w_int32(rilp, SETUP_DATA_CALL_PARAMS);

	tech_str = g_strdup_printf("%d", req->tech);
	parcel_w_string(rilp, (char *) tech_str);
	parcel_w_string(rilp, (char *) profile_str);
	parcel_w_string(rilp, (char *) req->apn);
	parcel_w_string(rilp, (char *) req->username);
	parcel_w_string(rilp, (char *) req->password);

	auth_str = g_strdup_printf("%d", req->auth_type);
	parcel_w_string(rilp, (char *) auth_str);
	parcel_w_string(rilp, (char *) protocol_str);

	g_ril_append_print_buf(gril,
				"(%s,%s,%s,%s,%s,%s,%s)",
				tech_str,
				profile_str,
				req->apn,
				req->username,
				req->password,
				auth_str,
				protocol_str);

	g_free(tech_str);
	g_free(auth_str);

	OFONO_NO_ERROR(error);
	return TRUE;

error:
        OFONO_EINVAL(error);
	return FALSE;
}
示例#28
0
文件: sim.c 项目: endocode/ofono
static void ril_sim_read_info(struct ofono_sim *sim, int fileid,
				const unsigned char *path,
				unsigned int path_len,
				ofono_sim_file_info_cb_t cb, void *data)
{
	struct sim_data *sd = ofono_sim_get_data(sim);
	struct cb_data *cbd = cb_data_new(cb, data, sd);
	struct parcel rilp;
	char *hex_path;

	DBG("file %04x", fileid);

	hex_path = get_path(g_ril_vendor(sd->ril),
					sd->app_type, fileid, path, path_len);
	if (hex_path == NULL) {
		ofono_error("Couldn't build SIM read info request - NULL path");
		goto error;
	}

	parcel_init(&rilp);

	parcel_w_int32(&rilp, CMD_GET_RESPONSE);
	parcel_w_int32(&rilp, fileid);
	parcel_w_string(&rilp, hex_path);
	parcel_w_int32(&rilp, 0);           /* P1 */
	parcel_w_int32(&rilp, 0);           /* P2 */

	/*
	 * TODO: review parameters values used by Android.
	 * The values of P1-P3 in this code were based on
	 * values used by the atmodem driver impl.
	 *
	 * NOTE:
	 * GET_RESPONSE_EF_SIZE_BYTES == 15; !255
	 */
	parcel_w_int32(&rilp, 15);         /* P3 - max length */
	parcel_w_string(&rilp, NULL);       /* data; only req'd for writes */
	parcel_w_string(&rilp, NULL);       /* pin2; only req'd for writes */
	parcel_w_string(&rilp, sd->aid_str); /* AID (Application ID) */

	/*
	 * sessionId, specific to latest MTK modems (harmless for older ones).
	 * It looks like this field selects one or another SIM application, but
	 * we use only one at a time so using zero here seems safe.
	 */
	if (g_ril_vendor(sd->ril) == OFONO_RIL_VENDOR_MTK)
		parcel_w_int32(&rilp, 0);

	g_ril_append_print_buf(sd->ril, "(cmd=0x%.2X,efid=0x%.4X,path=%s,"
					"0,0,15,(null),pin2=(null),aid=%s)",
					CMD_GET_RESPONSE, fileid, hex_path,
					sd->aid_str);
	g_free(hex_path);

	if (g_ril_send(sd->ril, RIL_REQUEST_SIM_IO, &rilp,
				ril_file_info_cb, cbd, g_free) > 0)
		return;

error:
	g_free(cbd);
	CALLBACK_WITH_FAILURE(cb, -1, -1, -1, NULL,
				EF_STATUS_INVALIDATED, data);
}
示例#29
0
gboolean g_ril_request_pin_change_state(GRil *gril,
					const struct req_pin_change_state *req,
					struct parcel *rilp)
{
	const char *lock_type;

	/*
	 * TODO: clean up the use of string literals &
	 * the multiple g_ril_append_print_buf() calls
	 * by using a table lookup as does the core sim code
	 */
	switch (req->passwd_type) {
	case OFONO_SIM_PASSWORD_SIM_PIN:
		g_ril_append_print_buf(gril, "(SC,");
		lock_type = "SC";
		break;
	case OFONO_SIM_PASSWORD_PHSIM_PIN:
		g_ril_append_print_buf(gril, "(PS,");
		lock_type = "PS";
		break;
	case OFONO_SIM_PASSWORD_PHFSIM_PIN:
		g_ril_append_print_buf(gril, "(PF,");
		lock_type = "PF";
		break;
	case OFONO_SIM_PASSWORD_SIM_PIN2:
		g_ril_append_print_buf(gril, "(P2,");
		lock_type = "P2";
		break;
	case OFONO_SIM_PASSWORD_PHNET_PIN:
		g_ril_append_print_buf(gril, "(PN,");
		lock_type = "PN";
		break;
	case OFONO_SIM_PASSWORD_PHNETSUB_PIN:
		g_ril_append_print_buf(gril, "(PU,");
		lock_type = "PU";
		break;
	case OFONO_SIM_PASSWORD_PHSP_PIN:
		g_ril_append_print_buf(gril, "(PP,");
		lock_type = "PP";
		break;
	case OFONO_SIM_PASSWORD_PHCORP_PIN:
		g_ril_append_print_buf(gril, "(PC,");
		lock_type = "PC";
		break;
	default:
		ofono_error("%s: Invalid password type: %d",
				__func__,
				req->passwd_type);
		goto error;
	}

	parcel_init(rilp);
	parcel_w_int32(rilp, SET_FACILITY_LOCK_PARAMS);

	parcel_w_string(rilp, lock_type);

	if (req->enable)
		parcel_w_string(rilp, RIL_FACILITY_LOCK);
	else
		parcel_w_string(rilp, RIL_FACILITY_UNLOCK);

	parcel_w_string(rilp, req->passwd);

	/* TODO: make this a constant... */
	parcel_w_string(rilp, "0");		/* class */

	parcel_w_string(rilp, req->aid_str);

	g_ril_append_print_buf(gril, "(%s,%d,%s,0,aid=%s)",
				print_buf,
				req->enable,
				req->passwd,
				req->aid_str);

	return TRUE;

error:
	return FALSE;
}
示例#30
0
文件: sms.c 项目: miksa/ofono
static void ril_sms_notify(struct ril_msg *message, gpointer user_data)
{
	struct ofono_sms *sms = user_data;
	struct sms_data *sd = ofono_sms_get_data(sms);
	struct parcel rilp;
	char *ril_pdu;
	int ril_pdu_len;
	unsigned int smsc_len;
	long ril_buf_len;
	guchar *ril_data;
	int request = RIL_REQUEST_SMS_ACKNOWLEDGE;
	int ret;

	DBG("req: %d; data_len: %d", message->req, (int) message->buf_len);

	if (message->req != RIL_UNSOL_RESPONSE_NEW_SMS)
		goto error;


	ril_util_init_parcel(message, &rilp);

	ril_pdu = parcel_r_string(&rilp);
	if (ril_pdu == NULL)
		goto error;

	ril_pdu_len = strlen(ril_pdu);

	DBG("ril_pdu_len is %d", ril_pdu_len);
	ril_data = decode_hex(ril_pdu, ril_pdu_len, &ril_buf_len, -1);
	if (ril_data == NULL)
		goto error;

	/* 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.
	 */
	smsc_len = ril_data[0] + 1;
	DBG("smsc_len is %d", smsc_len);

	g_ril_append_print_buf(sd->ril, "(%s)", ril_pdu);
	g_ril_print_unsol(sd->ril, message);

	/* Last parameter is 'tpdu_len' ( substract SMSC length ) */
	ofono_sms_deliver_notify(sms, ril_data,
			ril_buf_len,
			ril_buf_len - smsc_len);

	/* Re-use rilp, so initilize */
	parcel_init(&rilp);
	parcel_w_int32(&rilp, 2); /* Number of int32 values in array */
	parcel_w_int32(&rilp, 1); /* Successful receipt */
	parcel_w_int32(&rilp, 0); /* error code */

	/* TODO: should ACK be sent for either of the error cases? */

	/* ACK the incoming NEW_SMS; ignore response so no cb needed */
	ret = g_ril_send(sd->ril, request,
			rilp.data,
			rilp.size,
			NULL, NULL, NULL);

	g_ril_append_print_buf(sd->ril, "(1,0)");
	g_ril_print_request(sd->ril, ret, request);

	parcel_free(&rilp);
	return;

error:
	ofono_error("Unable to parse NEW_SMS notification");
}