mirror of git://git.sysmocom.de/ofono
rilmodem: Implement activate_primary inline
This commit is contained in:
parent
834816f458
commit
2dbd1ce771
|
@ -231,6 +231,14 @@ error:
|
||||||
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DATA_PROFILE_DEFAULT_STR "0"
|
||||||
|
#define DATA_PROFILE_TETHERED_STR "1"
|
||||||
|
#define DATA_PROFILE_IMS_STR "2"
|
||||||
|
#define DATA_PROFILE_FOTA_STR "3"
|
||||||
|
#define DATA_PROFILE_CBS_STR "4"
|
||||||
|
#define DATA_PROFILE_OEM_BASE_STR "1000"
|
||||||
|
#define DATA_PROFILE_MTK_MMS_STR "1001"
|
||||||
|
|
||||||
static void ril_gprs_context_activate_primary(struct ofono_gprs_context *gc,
|
static void ril_gprs_context_activate_primary(struct ofono_gprs_context *gc,
|
||||||
const struct ofono_gprs_primary_context *ctx,
|
const struct ofono_gprs_primary_context *ctx,
|
||||||
ofono_gprs_context_cb_t cb, void *data)
|
ofono_gprs_context_cb_t cb, void *data)
|
||||||
|
@ -242,16 +250,15 @@ static void ril_gprs_context_activate_primary(struct ofono_gprs_context *gc,
|
||||||
struct ofono_gprs *gprs = NULL;
|
struct ofono_gprs *gprs = NULL;
|
||||||
struct ril_gprs_data *gd = NULL;
|
struct ril_gprs_data *gd = NULL;
|
||||||
struct cb_data *cbd = cb_data_new(cb, data, gc);
|
struct cb_data *cbd = cb_data_new(cb, data, gc);
|
||||||
struct req_setup_data_call request;
|
|
||||||
struct parcel rilp;
|
struct parcel rilp;
|
||||||
struct ofono_error error;
|
char buf[256];
|
||||||
int ret = 0;
|
int num_param = 7;
|
||||||
|
int tech;
|
||||||
|
const char *profile;
|
||||||
|
int auth_type;
|
||||||
|
|
||||||
g_assert(gprs_atom != NULL);
|
|
||||||
gprs = __ofono_atom_get_data(gprs_atom);
|
gprs = __ofono_atom_get_data(gprs_atom);
|
||||||
g_assert(gprs != NULL);
|
|
||||||
gd = ofono_gprs_get_data(gprs);
|
gd = ofono_gprs_get_data(gprs);
|
||||||
g_assert(gd != NULL);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 0: CDMA 1: GSM/UMTS, 2...
|
* 0: CDMA 1: GSM/UMTS, 2...
|
||||||
|
@ -260,27 +267,34 @@ static void ril_gprs_context_activate_primary(struct ofono_gprs_context *gc,
|
||||||
DBG("*gc: %p activating cid: %d; curr_tech: %d", gc, ctx->cid,
|
DBG("*gc: %p activating cid: %d; curr_tech: %d", gc, ctx->cid,
|
||||||
gd->tech);
|
gd->tech);
|
||||||
|
|
||||||
|
parcel_init(&rilp);
|
||||||
|
|
||||||
|
if (g_ril_vendor(gcd->ril) == OFONO_RIL_VENDOR_MTK)
|
||||||
|
num_param += 1;
|
||||||
|
|
||||||
|
parcel_w_int32(&rilp, num_param);
|
||||||
|
|
||||||
if (gd->tech == RADIO_TECH_UNKNOWN) {
|
if (gd->tech == RADIO_TECH_UNKNOWN) {
|
||||||
ofono_error("%s: radio tech for apn: %s UNKNOWN!", __func__,
|
ofono_error("%s: radio tech for apn: %s UNKNOWN!", __func__,
|
||||||
gcd->apn);
|
gcd->apn);
|
||||||
request.tech = 1;
|
tech = 1;
|
||||||
} else {
|
} else if (gd->tech <= RADIO_TECH_GSM) {
|
||||||
request.tech = gd->tech + 2;
|
tech = gd->tech + 2;
|
||||||
}
|
} else
|
||||||
|
|
||||||
|
sprintf(buf, "%d", tech);
|
||||||
|
parcel_w_string(&rilp, buf);
|
||||||
|
|
||||||
|
profile = DATA_PROFILE_DEFAULT_STR;
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: add comments about tethering, other non-public
|
|
||||||
* profiles...
|
|
||||||
*/
|
|
||||||
if (g_ril_vendor(gcd->ril) == OFONO_RIL_VENDOR_MTK &&
|
if (g_ril_vendor(gcd->ril) == OFONO_RIL_VENDOR_MTK &&
|
||||||
gcd->type == OFONO_GPRS_CONTEXT_TYPE_MMS)
|
gcd->type == OFONO_GPRS_CONTEXT_TYPE_MMS)
|
||||||
request.data_profile = RIL_DATA_PROFILE_MTK_MMS;
|
profile = DATA_PROFILE_MTK_MMS_STR;
|
||||||
else
|
|
||||||
request.data_profile = RIL_DATA_PROFILE_DEFAULT;
|
|
||||||
|
|
||||||
request.apn = g_strdup(ctx->apn);
|
parcel_w_string(&rilp, profile);
|
||||||
request.username = g_strdup(ctx->username);
|
parcel_w_string(&rilp, ctx->apn);
|
||||||
request.password = g_strdup(ctx->password);
|
parcel_w_string(&rilp, ctx->username);
|
||||||
|
parcel_w_string(&rilp, ctx->password);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We do the same as in $AOSP/frameworks/opt/telephony/src/java/com/
|
* We do the same as in $AOSP/frameworks/opt/telephony/src/java/com/
|
||||||
|
@ -288,45 +302,42 @@ static void ril_gprs_context_activate_primary(struct ofono_gprs_context *gc,
|
||||||
* onConnect(), and use authentication or not depending on whether
|
* onConnect(), and use authentication or not depending on whether
|
||||||
* the user field is empty or not.
|
* the user field is empty or not.
|
||||||
*/
|
*/
|
||||||
if (request.username != NULL && request.username[0] != '\0')
|
if (ctx->username[0] != '\0')
|
||||||
request.auth_type = RIL_AUTH_BOTH;
|
auth_type = RIL_AUTH_BOTH;
|
||||||
else
|
else
|
||||||
request.auth_type = RIL_AUTH_NONE;
|
auth_type = RIL_AUTH_NONE;
|
||||||
|
|
||||||
request.protocol = ctx->proto;
|
sprintf(buf, "%d", auth_type);
|
||||||
request.req_cid = ctx->cid;
|
parcel_w_string(&rilp, buf);
|
||||||
|
|
||||||
if (g_ril_request_setup_data_call(gcd->ril,
|
parcel_w_string(&rilp, ril_util_gprs_proto_to_ril_string(ctx->proto));
|
||||||
&request,
|
|
||||||
&rilp,
|
if (g_ril_vendor(gcd->ril) == OFONO_RIL_VENDOR_MTK) {
|
||||||
&error) == FALSE) {
|
sprintf(buf, "%u", ctx->cid);
|
||||||
ofono_error("%s: couldn't build SETUP_DATA_CALL"
|
parcel_w_string(&rilp, buf);
|
||||||
" request for apn: %s.",
|
|
||||||
__func__, request.apn);
|
g_ril_append_print_buf(gcd->ril, "(%d,%s,%s,%s,%s,%d,%s,%u)",
|
||||||
goto error;
|
tech, profile, ctx->apn, ctx->username,
|
||||||
|
ctx->password, auth_type,
|
||||||
|
ril_util_gprs_proto_to_ril_string(ctx->proto),
|
||||||
|
ctx->cid);
|
||||||
|
} else
|
||||||
|
g_ril_append_print_buf(gcd->ril, "(%d,%s,%s,%s,%s,%d,%s)",
|
||||||
|
tech, profile, ctx->apn, ctx->username,
|
||||||
|
ctx->password, auth_type,
|
||||||
|
ril_util_gprs_proto_to_ril_string(ctx->proto));
|
||||||
|
|
||||||
|
if (g_ril_send(gcd->ril, RIL_REQUEST_SETUP_DATA_CALL, &rilp,
|
||||||
|
ril_setup_data_call_cb, cbd, g_free) > 0) {
|
||||||
|
gcd->apn = g_strdup(ctx->apn);
|
||||||
|
gcd->active_ctx_cid = ctx->cid;
|
||||||
|
gcd->state = STATE_ENABLING;
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gcd->active_ctx_cid = ctx->cid;
|
g_free(cbd);
|
||||||
gcd->state = STATE_ENABLING;
|
CALLBACK_WITH_FAILURE(cb, data);
|
||||||
gcd->apn = g_strdup(ctx->apn);
|
|
||||||
|
|
||||||
ret = g_ril_send(gcd->ril, RIL_REQUEST_SETUP_DATA_CALL, &rilp,
|
|
||||||
ril_setup_data_call_cb, cbd, g_free);
|
|
||||||
|
|
||||||
error:
|
|
||||||
g_free(request.apn);
|
|
||||||
g_free(request.username);
|
|
||||||
g_free(request.password);
|
|
||||||
|
|
||||||
if (ret == 0) {
|
|
||||||
ofono_error("%s: send SETUP_DATA_CALL failed for apn: %s.",
|
|
||||||
__func__, gcd->apn);
|
|
||||||
|
|
||||||
set_context_disconnected(gcd);
|
|
||||||
|
|
||||||
g_free(cbd);
|
|
||||||
CALLBACK_WITH_FAILURE(cb, data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean reset_modem(gpointer data)
|
static gboolean reset_modem(gpointer data)
|
||||||
|
|
Loading…
Reference in New Issue