コード例 #1
0
ファイル: grilrequest.c プロジェクト: jpakkane/ofono
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;
}
コード例 #2
0
ファイル: grilrequest.c プロジェクト: jpakkane/ofono
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, 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);

	g_free(tech_str);
	g_free(auth_str);

	OFONO_NO_ERROR(error);
	return TRUE;

error:
        OFONO_EINVAL(error);
	return FALSE;
}
コード例 #3
0
ファイル: sim.c プロジェクト: marttipiirainen/ofono
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_init(&rilp);
			parcel_w_int32(&rilp, 1);
			parcel_w_int32(&rilp, 1);

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

	/* TODO: if no SIM present, handle emergency calling. */
}
コード例 #4
0
ファイル: sim.c プロジェクト: marttipiirainen/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);
	}
}
コード例 #5
0
ファイル: sim.c プロジェクト: marttipiirainen/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);
	struct parcel rilp;
	int request = RIL_REQUEST_SIM_IO;
	guint ret;
	cbd->user = sd;

	parcel_init(&rilp);

	parcel_w_int32(&rilp, CMD_GET_RESPONSE);
	parcel_w_int32(&rilp, fileid);

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

	set_path(sd, &rilp, fileid, path, path_len);

	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) */

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

	g_ril_append_print_buf(sd->ril,
				"%s0,0,15,(null),pin2=(null),aid=%s)",
				print_buf,
				sd->aid_str);
	g_ril_print_request(sd->ril, ret, RIL_REQUEST_SIM_IO);

	parcel_free(&rilp);

	if (ret <= 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, -1, -1, -1, NULL,
				EF_STATUS_INVALIDATED, data);
	}
}