Example #1
0
static void ril_rat_mode_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_radio_settings_rat_mode_query_cb_t cb = cbd->cb;
	struct ofono_radio_settings *rs = cbd->user;
	struct radio_data *rd = ofono_radio_settings_get_data(rs);
	int mode, pref;

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s: error %s", __func__,
				ril_error_to_string(message->error));
		CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
		return;
	}

	pref = g_ril_reply_parse_get_preferred_network_type(rd->ril, message);
	if (pref < 0) {
		ofono_error("%s: parse error", __func__);
		CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
		return;
	}

	switch (pref) {
	case PREF_NET_TYPE_GSM_WCDMA:
		mode = OFONO_RADIO_ACCESS_MODE_UMTS;
		break;
	case PREF_NET_TYPE_GSM_ONLY:
		mode = OFONO_RADIO_ACCESS_MODE_GSM;
		break;
	case PREF_NET_TYPE_LTE_GSM_WCDMA:
		mode = OFONO_RADIO_ACCESS_MODE_LTE;
		break;
	default:
		ofono_error("%s: Unexpected preferred network type (%d)",
				__func__, pref);
		mode = OFONO_RADIO_ACCESS_MODE_ANY;
		break;
	}

	CALLBACK_WITH_SUCCESS(cb, mode, cbd->data);
}
Example #2
0
static void ril_rat_mode_cb(struct ril_msg *message, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_radio_settings_rat_mode_query_cb_t cb = cbd->cb;
	struct ofono_radio_settings *rs = cbd->user;
	struct radio_data *rd = ofono_radio_settings_get_data(rs);
	int mode, pref;

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s: error %s", __func__,
				ril_error_to_string(message->error));
		goto error;
	}

	pref = g_ril_reply_parse_get_preferred_network_type(rd->ril, message);
	if (pref < 0) {
		ofono_error("%s: parse error", __func__);
		goto error;
	}

	/*
	 * GSM_WCDMA_AUTO -> ril.h: GSM/WCDMA (auto mode, according to PRL)
	 * PRL: preferred roaming list.
	 * This value is returned when selecting the slot as having 3G
	 * capabilities, so it is sort of the default for MTK modems.
	 */

	switch (pref) {
	case PREF_NET_TYPE_GSM_WCDMA:
	case PREF_NET_TYPE_GSM_WCDMA_AUTO:
		mode = OFONO_RADIO_ACCESS_MODE_UMTS;
		break;
	case PREF_NET_TYPE_GSM_ONLY:
		mode = OFONO_RADIO_ACCESS_MODE_GSM;
		break;
	case PREF_NET_TYPE_LTE_GSM_WCDMA:
		mode = OFONO_RADIO_ACCESS_MODE_LTE;
		break;
	default:
		ofono_error("%s: Unexpected preferred network type (%d)",
				__func__, pref);
		mode = OFONO_RADIO_ACCESS_MODE_ANY;
		break;
	}

	rd->rat_mode = mode;

	CALLBACK_WITH_SUCCESS(cb, mode, cbd->data);

	return;

error:
	/*
	 * If error, we assume GSM. This is preferable to not being able to
	 * access the radio settings properties. Midori returns error if we
	 * have not completed successfully a capability switch. This should
	 * not happen if there are no bugs in our implementation, but it is
	 * better to leave this here so system settings shows something that
	 * can be manually changed by the user, just in case.
	 */
	CALLBACK_WITH_SUCCESS(cb, OFONO_RADIO_ACCESS_MODE_GSM, cbd->data);
}