Skip to content

Commit

Permalink
Merge branch 'misc' into 'master'
Browse files Browse the repository at this point in the history
Miscellaneous mobile data issues

See merge request mer-core/ofono!280
  • Loading branch information
monich committed Apr 23, 2021
2 parents 0f4cdba + 6c289b1 commit bd836b4
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 24 deletions.
74 changes: 54 additions & 20 deletions ofono/drivers/ril/ril_data.c
@@ -1,7 +1,7 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2016-2020 Jolla Ltd.
* Copyright (C) 2016-2021 Jolla Ltd.
* Copyright (C) 2019-2020 Open Mobile Platform LLC.
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -1196,6 +1196,31 @@ static struct ril_data_request *ril_data_allow_new(struct ril_data *data,
return req;
}

static gboolean ril_data_allow_can_submit(struct ril_data *self)
{
if (self) {
switch (self->priv->options.allow_data) {
case RIL_ALLOW_DATA_ENABLED:
return TRUE;
case RIL_ALLOW_DATA_DISABLED:
case RIL_ALLOW_DATA_AUTO:
break;
}
}
return FALSE;
}

static gboolean ril_data_allow_submit_request(struct ril_data *data,
gboolean allow)
{
if (ril_data_allow_can_submit(data)) {
ril_data_request_queue(ril_data_allow_new(data, allow));
return TRUE;
} else {
return FALSE;
}
}

/*==========================================================================*
* ril_data
*==========================================================================*/
Expand Down Expand Up @@ -1226,6 +1251,22 @@ void ril_data_remove_handler(struct ril_data *self, gulong id)
}
}

static void ril_data_imsi_changed(struct ril_sim_settings *settings,
void *user_data)
{
struct ril_data *self = RIL_DATA(user_data);
struct ril_data_priv *priv = self->priv;

if (!settings->imsi) {
/*
* Most likely, SIM removal. In any case, no data requests
* make sense when IMSI is unavailable.
*/
ril_data_cancel_all_requests(self);
}
ril_data_manager_check_network_mode(priv->dm);
}

static void ril_data_settings_changed(struct ril_sim_settings *settings,
void *user_data)
{
Expand Down Expand Up @@ -1308,7 +1349,7 @@ struct ril_data *ril_data_new(struct ril_data_manager *dm, const char *name,

priv->settings_event_id[SETTINGS_EVENT_IMSI_CHANGED] =
ril_sim_settings_add_imsi_changed_handler(settings,
ril_data_settings_changed, self);
ril_data_imsi_changed, self);
priv->settings_event_id[SETTINGS_EVENT_PREF_MODE] =
ril_sim_settings_add_pref_mode_changed_handler(settings,
ril_data_settings_changed, self);
Expand Down Expand Up @@ -1466,10 +1507,8 @@ static void ril_data_disallow(struct ril_data *self)
*/
ril_data_deactivate_all(self);

if (priv->options.allow_data == RIL_ALLOW_DATA_ENABLED) {
/* Tell rild that the data is now disabled */
ril_data_request_queue(ril_data_allow_new(self, FALSE));
} else {
/* Tell rild that the data is now disabled */
if (!ril_data_allow_submit_request(self, FALSE)) {
priv->flags &= ~RIL_DATA_FLAG_ON;
GASSERT(!ril_data_allowed(self));
DBG_(self, "data off");
Expand Down Expand Up @@ -1779,12 +1818,14 @@ static void ril_data_manager_check_network_mode(struct ril_data_manager *self)

static struct ril_data *ril_data_manager_allowed(struct ril_data_manager *self)
{
GSList *l;
if (self) {
GSList *l;

for (l= self->data_list; l; l = l->next) {
struct ril_data *data = l->data;
if (data->priv->flags & RIL_DATA_FLAG_ALLOWED) {
return data;
for (l= self->data_list; l; l = l->next) {
struct ril_data *data = l->data;
if (data->priv->flags & RIL_DATA_FLAG_ALLOWED) {
return data;
}
}
}

Expand All @@ -1804,9 +1845,7 @@ static void ril_data_manager_switch_data_on(struct ril_data_manager *self,
ril_data_max_mode(data), TRUE);
}

if (priv->options.allow_data == RIL_ALLOW_DATA_ENABLED) {
ril_data_request_queue(ril_data_allow_new(data, TRUE));
} else {
if (!ril_data_allow_submit_request(data, TRUE)) {
priv->flags |= RIL_DATA_FLAG_ON;
GASSERT(ril_data_allowed(data));
DBG_(data, "data on");
Expand All @@ -1830,12 +1869,7 @@ void ril_data_manager_check_data(struct ril_data_manager *self)

void ril_data_manager_assert_data_on(struct ril_data_manager *self)
{
if (self) {
struct ril_data *data = ril_data_manager_allowed(self);
if (data) {
ril_data_request_queue(ril_data_allow_new(data, TRUE));
}
}
ril_data_allow_submit_request(ril_data_manager_allowed(self), TRUE);
}

/*
Expand Down
7 changes: 3 additions & 4 deletions ofono/drivers/ril/ril_network.c
Expand Up @@ -444,14 +444,13 @@ static guint ril_network_poll_and_retry(struct ril_network *self, guint id,
{
struct ril_network_priv *priv = self->priv;

if (id) {
/* Retry right away, don't wait for retry timeout to expire */
grilio_channel_retry_request(priv->io, id);
} else {
/* Don't wait for retry timeout to expire */
if (!id || !grilio_channel_retry_request(priv->io, id)) {
GRilIoRequest *req = grilio_request_new();

grilio_request_set_retry(req, RIL_RETRY_SECS*1000, -1);
grilio_request_set_retry_func(req, ril_network_retry);
grilio_queue_cancel_request(priv->q, id, FALSE);
id = grilio_queue_send_request_full(priv->q, req, code, fn,
NULL, self);
grilio_request_unref(req);
Expand Down

0 comments on commit bd836b4

Please sign in to comment.