Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[ril] Select the best network for LTE. JB#49391
The radio caps manager will not do anything until the roles are assigned
to modems, so data manager must select the modem with highest capabilities
for LTE instead of the first one.
  • Loading branch information
d-grigorev authored and monich committed Jun 17, 2020
1 parent 944cd60 commit 56c488d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
35 changes: 20 additions & 15 deletions ofono/drivers/ril/ril_data.c
Expand Up @@ -2,7 +2,7 @@
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2016-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
* it under the terms of the GNU General Public License version 2 as
Expand Down Expand Up @@ -1721,34 +1721,39 @@ static void ril_data_manager_check_network_mode(struct ril_data_manager *self)

if ((self->flags & RIL_DATA_MANAGER_FORCE_GSM_ON_OTHER_SLOTS) &&
ril_data_manager_handover(self)) {
struct ril_network *lte_network = NULL;
int non_gsm_count = 0;
struct ril_network *lte_network = NULL, *best_network = NULL;
enum ofono_radio_access_mode best_mode =
OFONO_RADIO_ACCESS_MODE_ANY;

/*
* Count number of SIMs for which non-GSM mode is selected
*/
/* Find a SIM for internet access */
for (l= self->data_list; l; l = l->next) {
struct ril_data *data = l->data;
struct ril_data_priv *priv = data->priv;
struct ril_network *network = priv->network;
struct ril_sim_settings *sim = network->settings;
enum ofono_radio_access_mode mode;

if (sim->pref_mode != OFONO_RADIO_ACCESS_MODE_GSM) {
non_gsm_count++;
if ((priv->flags & RIL_DATA_FLAG_MAX_SPEED) &&
!lte_network) {
lte_network = network;
}
/* Select the first network with internet role */
if ((sim->pref_mode != OFONO_RADIO_ACCESS_MODE_GSM) &&
(priv->flags & RIL_DATA_FLAG_MAX_SPEED)) {
lte_network = network;
break;
}

/* At the same time, look for a suitable slot */
mode = ril_network_max_supported_mode(network);
if (mode > best_mode) {
best_network = network;
best_mode = mode;
}
}

/*
* If there's no SIM selected for internet access
* then choose the first slot for LTE.
* then use a slot with highest capabilities for LTE.
*/
if (!lte_network) {
struct ril_data *data = self->data_list->data;
lte_network = data->priv->network;
lte_network = best_network;
}

for (l= self->data_list; l; l = l->next) {
Expand Down
17 changes: 13 additions & 4 deletions ofono/drivers/ril/ril_network.c
Expand Up @@ -533,13 +533,23 @@ static int ril_network_mode_to_rat(struct ril_network *self,
}
}

static enum ofono_radio_access_mode ril_network_actual_pref_mode
enum ofono_radio_access_mode ril_network_max_supported_mode
(struct ril_network *self)
{
struct ril_sim_settings *settings = self->settings;
struct ril_network_priv *priv = self->priv;
const struct ril_radio_caps *caps = priv->caps;

return caps ? __ofono_radio_access_max_mode(caps->supported_modes) :
__ofono_radio_access_max_mode(settings->techs);
}

static enum ofono_radio_access_mode ril_network_actual_pref_mode
(struct ril_network *self)
{
struct ril_sim_settings *settings = self->settings;
struct ril_network_priv *priv = self->priv;

/*
* On most dual-SIM phones only one slot at a time is allowed
* to use LTE. On some phones (such as Jolla C), even if the
Expand All @@ -563,9 +573,8 @@ static enum ofono_radio_access_mode ril_network_actual_pref_mode
settings->pref_mode ? settings->pref_mode : max_pref_mode;

/* Do not try to set unsupported mode */
const enum ofono_radio_access_mode max_mode = caps ?
__ofono_radio_access_max_mode(caps->supported_modes) :
__ofono_radio_access_max_mode(settings->techs);
const enum ofono_radio_access_mode max_mode =
ril_network_max_supported_mode(self);

return pref_mode ? MIN(pref_mode, max_mode) : max_mode;
}
Expand Down
3 changes: 3 additions & 0 deletions ofono/drivers/ril/ril_network.h
Expand Up @@ -2,6 +2,7 @@
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2020 Jolla Ltd.
* Copyright (C) 2020 Open Mobile Platform LLC.
*
* 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
Expand Down Expand Up @@ -59,6 +60,8 @@ void ril_network_set_radio_caps(struct ril_network *net,
void ril_network_set_max_pref_mode(struct ril_network *net,
enum ofono_radio_access_mode max_pref_mode,
gboolean force_check);
enum ofono_radio_access_mode ril_network_max_supported_mode
(struct ril_network *self);
void ril_network_query_registration_state(struct ril_network *net);
gulong ril_network_add_operator_changed_handler(struct ril_network *net,
ril_network_cb_t cb, void *arg);
Expand Down

0 comments on commit 56c488d

Please sign in to comment.