Compare commits

...

7 Commits

Author SHA1 Message Date
Slava Monich
08bae57a2b Merge branch 'jb49714' into 'master'
Register settings atom as soon as we have IMSI

See merge request mer-core/ofono!262
2020-04-23 09:08:23 +00:00
Slava Monich
1915aeda76 [ril] Register settings atom as soon as we have IMSI. Fixes JB#49714
There's no need to wait for modem to get powered on. This is just a user
setting - if it can't be applied right away, it will be applied later at
appropriate time.
2020-04-23 04:20:28 +03:00
Slava Monich
51bfb17cbc Merge branch 'modem_offline' into 'master'
Take modem offline when ril_modem is deleted

See merge request mer-core/ofono!260
2020-04-01 16:33:23 +00:00
Slava Monich
a83b553032 [ril] Stop repeating requests on RADIO_NOT_AVAILABLE. JB#49471
If the modem is powered off, this error is repeated indefinitely,
causing unnecessary wakeups.
2020-03-30 21:19:40 +03:00
Slava Monich
ec00abd62d [ril] Tweaked power state confirmation logic. JB#49471
Changed ril_radio_confirm_power_on() to send RADIO_POWER request even if
we think that modem is powered on. Some RILs change power state without
letting us know and that's what this function is for - to make sure that
power is on when we think that it's on.
2020-03-29 01:38:58 +02:00
Slava Monich
80924d5787 [ril] Take modem offline when ril_modem is deleted. JB#49471
Also, mobile data need to be disallowed before deleting the modem
object, so that power keep-on request could be submitted before
bringing the modem offline, to keep power on while data call is
being deactivated (if there was one).
2020-03-29 01:34:39 +02:00
Slava Monich
2bdd05aa31 [ril] Fixed ref vs unref mixup.
RilRadioCapsManager was never freed :/

That was leaving 472 bytes in 8 blocks still reachable on exit.
2020-03-20 18:30:40 +02:00
6 changed files with 67 additions and 26 deletions

View File

@@ -1,7 +1,8 @@
/* /*
* oFono - Open Source Telephony - RIL-based devices * oFono - Open Source Telephony - RIL-based devices
* *
* Copyright (C) 2016-2019 Jolla Ltd. * Copyright (C) 2016-2020 Jolla Ltd.
* Copyright (C) 2020 Open Mobile Platform LLC.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
@@ -344,11 +345,24 @@ static void ril_cell_info_set_rate_cb(GRilIoChannel *io, int status,
self->set_rate_id = 0; self->set_rate_id = 0;
} }
static gboolean ril_cell_info_retry(GRilIoRequest* request, int ril_status,
const void* response_data, guint response_len, void* user_data)
{
switch (ril_status) {
case RIL_E_SUCCESS:
case RIL_E_RADIO_NOT_AVAILABLE:
return FALSE;
default:
return TRUE;
}
}
static void ril_cell_info_query(struct ril_cell_info *self) static void ril_cell_info_query(struct ril_cell_info *self)
{ {
GRilIoRequest *req = grilio_request_new(); GRilIoRequest *req = grilio_request_new();
grilio_request_set_retry(req, RIL_RETRY_MS, MAX_RETRIES); grilio_request_set_retry(req, RIL_RETRY_MS, MAX_RETRIES);
grilio_request_set_retry_func(req, ril_cell_info_retry);
grilio_channel_cancel_request(self->io, self->query_id, FALSE); grilio_channel_cancel_request(self->io, self->query_id, FALSE);
self->query_id = grilio_channel_send_request_full(self->io, req, self->query_id = grilio_channel_send_request_full(self->io, req,
RIL_REQUEST_GET_CELL_INFO_LIST, ril_cell_info_list_cb, RIL_REQUEST_GET_CELL_INFO_LIST, ril_cell_info_list_cb,
@@ -362,6 +376,7 @@ static void ril_cell_info_set_rate(struct ril_cell_info *self)
(self->update_rate_ms > 0) ? self->update_rate_ms : INT_MAX); (self->update_rate_ms > 0) ? self->update_rate_ms : INT_MAX);
grilio_request_set_retry(req, RIL_RETRY_MS, MAX_RETRIES); grilio_request_set_retry(req, RIL_RETRY_MS, MAX_RETRIES);
grilio_request_set_retry_func(req, ril_cell_info_retry);
grilio_channel_cancel_request(self->io, self->set_rate_id, FALSE); grilio_channel_cancel_request(self->io, self->set_rate_id, FALSE);
self->set_rate_id = grilio_channel_send_request_full(self->io, req, self->set_rate_id = grilio_channel_send_request_full(self->io, req,
RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE,

View File

@@ -218,22 +218,21 @@ static void ril_modem_schedule_online_check(struct ril_modem_data *md)
static void ril_modem_update_radio_settings(struct ril_modem_data *md) static void ril_modem_update_radio_settings(struct ril_modem_data *md)
{ {
struct ril_modem *m = &md->modem; struct ril_modem *m = &md->modem;
if (m->radio->state == RADIO_STATE_ON && md->watch->imsi) { struct ofono_radio_settings *rs = ril_modem_radio_settings(m);
if (md->watch->imsi) {
/* radio-settings.c assumes that IMSI is available */ /* radio-settings.c assumes that IMSI is available */
if (!ril_modem_radio_settings(m)) { if (!rs) {
DBG_(md, "initializing radio settings interface"); DBG_(md, "initializing radio settings interface");
ofono_radio_settings_create(m->ofono, 0, ofono_radio_settings_create(m->ofono, 0,
RILMODEM_DRIVER, md); RILMODEM_DRIVER, md);
} }
} else if (rs) {
DBG_(md, "removing radio settings interface");
ofono_radio_settings_remove(rs);
} else { } else {
/* ofono core may remove radio settings atom internally */ /* ofono core may remove radio settings atom internally */
struct ofono_radio_settings *rs = ril_modem_radio_settings(m); DBG_(md, "radio settings interface is already gone");
if (rs) {
DBG_(md, "removing radio settings interface");
ofono_radio_settings_remove(rs);
} else {
DBG_(md, "radio settings interface is already gone");
}
} }
} }
@@ -242,7 +241,6 @@ static void ril_modem_radio_state_cb(struct ril_radio *radio, void *data)
struct ril_modem_data *md = data; struct ril_modem_data *md = data;
GASSERT(md->modem.radio == radio); GASSERT(md->modem.radio == radio);
ril_modem_update_radio_settings(md);
ril_modem_update_online_state(md); ril_modem_update_online_state(md);
} }
@@ -424,6 +422,7 @@ static void ril_modem_remove(struct ofono_modem *ofono)
ril_radio_remove_handler(modem->radio, md->radio_state_event_id); ril_radio_remove_handler(modem->radio, md->radio_state_event_id);
ril_radio_power_off(modem->radio, RADIO_POWER_TAG(md)); ril_radio_power_off(modem->radio, RADIO_POWER_TAG(md));
ril_radio_set_online(modem->radio, FALSE);
ril_radio_unref(modem->radio); ril_radio_unref(modem->radio);
ril_sim_settings_unref(modem->sim_settings); ril_sim_settings_unref(modem->sim_settings);

View File

@@ -2,7 +2,7 @@
* oFono - Open Source Telephony - RIL-based devices * oFono - Open Source Telephony - RIL-based devices
* *
* Copyright (C) 2015-2020 Jolla Ltd. * Copyright (C) 2015-2020 Jolla Ltd.
* Copyright (C) 2019 Open Mobile Platform LLC. * Copyright (C) 2019-2020 Open Mobile Platform LLC.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
@@ -419,6 +419,18 @@ static void ril_network_poll_data_state_cb(GRilIoChannel *io, int req_status,
} }
} }
static gboolean ril_network_retry(GRilIoRequest* request, int ril_status,
const void* response_data, guint response_len, void* user_data)
{
switch (ril_status) {
case RIL_E_SUCCESS:
case RIL_E_RADIO_NOT_AVAILABLE:
return FALSE;
default:
return TRUE;
}
}
static guint ril_network_poll_and_retry(struct ril_network *self, guint id, static guint ril_network_poll_and_retry(struct ril_network *self, guint id,
int code, GRilIoChannelResponseFunc fn) int code, GRilIoChannelResponseFunc fn)
{ {
@@ -431,6 +443,7 @@ static guint ril_network_poll_and_retry(struct ril_network *self, guint id,
GRilIoRequest *req = grilio_request_new(); GRilIoRequest *req = grilio_request_new();
grilio_request_set_retry(req, RIL_RETRY_SECS*1000, -1); grilio_request_set_retry(req, RIL_RETRY_SECS*1000, -1);
grilio_request_set_retry_func(req, ril_network_retry);
id = grilio_queue_send_request_full(priv->q, req, code, fn, id = grilio_queue_send_request_full(priv->q, req, code, fn,
NULL, self); NULL, self);
grilio_request_unref(req); grilio_request_unref(req);
@@ -998,22 +1011,22 @@ static void ril_network_query_pref_mode_cb(GRilIoChannel *io, int status,
struct ril_network_priv *priv = self->priv; struct ril_network_priv *priv = self->priv;
const enum ofono_radio_access_mode pref_mode = self->pref_mode; const enum ofono_radio_access_mode pref_mode = self->pref_mode;
/* This request never fails because in case of error it gets retried */
GASSERT(status == RIL_E_SUCCESS);
GASSERT(priv->query_rat_id); GASSERT(priv->query_rat_id);
priv->query_rat_id = 0; priv->query_rat_id = 0;
priv->rat = ril_network_parse_pref_resp(data, len);
self->pref_mode = ril_network_rat_to_mode(priv->rat); if (status == RIL_E_SUCCESS) {
DBG_(self, "rat mode %d (%s)", priv->rat, priv->rat = ril_network_parse_pref_resp(data, len);
self->pref_mode = ril_network_rat_to_mode(priv->rat);
DBG_(self, "rat mode %d (%s)", priv->rat,
ofono_radio_access_mode_to_string(self->pref_mode)); ofono_radio_access_mode_to_string(self->pref_mode));
if (self->pref_mode != pref_mode) { if (self->pref_mode != pref_mode) {
ril_network_emit(self, SIGNAL_PREF_MODE_CHANGED); ril_network_emit(self, SIGNAL_PREF_MODE_CHANGED);
} }
if (ril_network_can_set_pref_mode(self)) { if (ril_network_can_set_pref_mode(self)) {
ril_network_check_pref_mode(self, FALSE); ril_network_check_pref_mode(self, FALSE);
}
} }
} }
@@ -1023,6 +1036,7 @@ static void ril_network_query_pref_mode(struct ril_network *self)
GRilIoRequest *req = grilio_request_new(); GRilIoRequest *req = grilio_request_new();
grilio_request_set_retry(req, RIL_RETRY_SECS*1000, -1); 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, priv->query_rat_id, FALSE); grilio_queue_cancel_request(priv->q, priv->query_rat_id, FALSE);
priv->query_rat_id = grilio_queue_send_request_full(priv->q, req, priv->query_rat_id = grilio_queue_send_request_full(priv->q, req,
RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE,

View File

@@ -364,6 +364,7 @@ static void ril_plugin_remove_slot_handler(ril_slot *slot, int id)
static void ril_plugin_shutdown_slot(ril_slot *slot, gboolean kill_io) static void ril_plugin_shutdown_slot(ril_slot *slot, gboolean kill_io)
{ {
if (slot->modem) { if (slot->modem) {
ril_data_allow(slot->data, RIL_DATA_ROLE_NONE);
ril_modem_delete(slot->modem); ril_modem_delete(slot->modem);
/* The above call is expected to result in /* The above call is expected to result in
* ril_plugin_modem_removed getting called * ril_plugin_modem_removed getting called

View File

@@ -241,7 +241,19 @@ static void ril_radio_power_request(struct ril_radio *self, gboolean on,
void ril_radio_confirm_power_on(struct ril_radio *self) void ril_radio_confirm_power_on(struct ril_radio *self)
{ {
if (G_LIKELY(self) && ril_radio_power_should_be_on(self)) { if (G_LIKELY(self) && ril_radio_power_should_be_on(self)) {
ril_radio_power_request(self, TRUE, TRUE); struct ril_radio_priv *priv = self->priv;
if (priv->pending_id) {
if (!priv->next_state) {
/* Wait for the pending request to complete */
priv->next_state_valid = TRUE;
priv->next_state = TRUE;
DBG_(self, "on (queued)");
}
} else {
DBG_(self, "on");
ril_radio_submit_power_request(self, TRUE);
}
} }
} }

View File

@@ -1,7 +1,7 @@
/* /*
* oFono - Open Source Telephony - RIL-based devices * oFono - Open Source Telephony - RIL-based devices
* *
* Copyright (C) 2017-2018 Jolla Ltd. * Copyright (C) 2017-2020 Jolla Ltd.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
@@ -1414,7 +1414,7 @@ RilRadioCapsManager *ril_radio_caps_manager_ref(RilRadioCapsManager *self)
void ril_radio_caps_manager_unref(RilRadioCapsManager *self) void ril_radio_caps_manager_unref(RilRadioCapsManager *self)
{ {
if (G_LIKELY(self)) { if (G_LIKELY(self)) {
g_object_ref(RADIO_CAPS_MANAGER(self)); g_object_unref(RADIO_CAPS_MANAGER(self));
} }
} }