Commit e40811fb authored by Slava Monich's avatar Slava Monich

Merge branch 'gsm_when_radio_off' into 'master'

Add forceGsmWhenRadioOff config option

On some phones (such as Jolla C), even if the slot which has been
using LTE gets powered off, we still need to explicitly set its
preferred mode to GSM, to make LTE machinery available to the other
slot.

Some RILs don't like it when we do this.

See merge request mer-core/ofono!241
parents 53233b4d 8c543b05
......@@ -185,7 +185,6 @@ struct ril_data_request_allow_data {
gboolean allow;
};
static void ril_data_manager_check_data(struct ril_data_manager *dm);
static void ril_data_manager_check_network_mode(struct ril_data_manager *dm);
static void ril_data_call_deact_cid(struct ril_data *data, int cid);
static void ril_data_power_update(struct ril_data *self);
......@@ -1737,7 +1736,7 @@ static void ril_data_manager_switch_data_on(struct ril_data_manager *self,
}
}
static void ril_data_manager_check_data(struct ril_data_manager *self)
void ril_data_manager_check_data(struct ril_data_manager *self)
{
/*
* Don't do anything if there any requests pending.
......
......@@ -89,6 +89,7 @@ struct ril_data_manager;
struct ril_data_manager *ril_data_manager_new(enum ril_data_manager_flags flg);
struct ril_data_manager *ril_data_manager_ref(struct ril_data_manager *dm);
void ril_data_manager_unref(struct ril_data_manager *dm);
void ril_data_manager_check_data(struct ril_data_manager *dm);
void ril_data_manager_assert_data_on(struct ril_data_manager *dm);
typedef void (*ril_data_cb_t)(struct ril_data *data, void *arg);
......
......@@ -2,6 +2,7 @@
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2019 Jolla Ltd.
* Copyright (C) 2019 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
......@@ -110,6 +111,7 @@ struct ril_network_priv {
gboolean set_initial_attach_apn;
struct ofono_network_operator operator;
gboolean assert_rat;
gboolean force_gsm_when_radio_off;
gboolean use_data_profiles;
int mms_data_profile_id;
GSList *data_profiles;
......@@ -515,13 +517,12 @@ static enum ofono_radio_access_mode ril_network_actual_pref_mode
struct ril_network_priv *priv = self->priv;
/*
* On dual-SIM phones such as Jolla C only one slot at a time
* is allowed to use LTE. Even if the slot which has been using
* LTE gets powered off, we still need to explicitely set its
* preferred mode to GSM, to make LTE machinery available to
* the other slot. This sort of behaviour might not be necessary
* on some hardware and can (should) be made configurable when
* it becomes necessary.
* 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
* slot which has been using LTE gets powered off, we still
* need to explicitly set its preferred mode to GSM, to make
* LTE machinery available to the other slot. This behavior is
* configurable.
*/
const enum ofono_radio_access_mode max_pref_mode =
(priv->radio->state == RADIO_STATE_ON) ? self->max_pref_mode :
......@@ -902,39 +903,52 @@ static void ril_network_check_pref_mode(struct ril_network *self,
gboolean immediate)
{
struct ril_network_priv *priv = self->priv;
const enum ofono_radio_access_mode expected_mode =
ril_network_actual_pref_mode(self);
const enum ofono_radio_access_mode current_mode =
ril_network_rat_to_mode(priv->rat);
struct ril_radio *radio = priv->radio;
if (priv->timer[TIMER_FORCE_CHECK_PREF_MODE]) {
ril_network_stop_timer(self, TIMER_FORCE_CHECK_PREF_MODE);
/*
* TIMER_FORCE_CHECK_PREF_MODE is scheduled by
* ril_network_pref_mode_changed_cb and is meant
* to force radio tech check right now.
*/
immediate = TRUE;
}
/*
* 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
* slot which has been using LTE gets powered off, we still
* need to explicitly set its preferred mode to GSM, to make
* LTE machinery available to the other slot. This behavior is
* configurable.
*/
if (radio->state == RADIO_STATE_ON || priv->force_gsm_when_radio_off) {
const enum ofono_radio_access_mode expected =
ril_network_actual_pref_mode(self);
const enum ofono_radio_access_mode actual =
ril_network_rat_to_mode(priv->rat);
if (priv->timer[TIMER_FORCE_CHECK_PREF_MODE]) {
ril_network_stop_timer(self,
TIMER_FORCE_CHECK_PREF_MODE);
/*
* TIMER_FORCE_CHECK_PREF_MODE is scheduled by
* ril_network_pref_mode_changed_cb and is meant
* to force radio tech check right now.
*/
immediate = TRUE;
}
if (priv->rat >= 0 && current_mode != expected_mode) {
DBG_(self, "rat %d (%s), expected %s", priv->rat,
ofono_radio_access_mode_to_string(current_mode),
ofono_radio_access_mode_to_string(expected_mode));
}
if (priv->rat >= 0 && actual != expected) {
DBG_(self, "rat %d (%s), expected %s", priv->rat,
ofono_radio_access_mode_to_string(actual),
ofono_radio_access_mode_to_string(expected));
}
if (immediate) {
ril_network_stop_timer(self, TIMER_SET_RAT_HOLDOFF);
}
if (immediate) {
ril_network_stop_timer(self, TIMER_SET_RAT_HOLDOFF);
}
if (current_mode != expected_mode || priv->assert_rat) {
const int rat = ril_network_mode_to_rat(self, expected_mode);
if (actual != expected || priv->assert_rat) {
const int rat = ril_network_mode_to_rat(self, expected);
if (!priv->timer[TIMER_SET_RAT_HOLDOFF]) {
ril_network_set_pref_mode(self, rat);
} else {
/* OK, later */
DBG_(self, "need to set rat mode %d", rat);
if (!priv->timer[TIMER_SET_RAT_HOLDOFF]) {
ril_network_set_pref_mode(self, rat);
} else {
/* OK, later */
DBG_(self, "need to set rat mode %d", rat);
}
}
}
}
......@@ -1228,6 +1242,7 @@ struct ril_network *ril_network_new(const char *path, GRilIoChannel *io,
priv->lte_network_mode = config->lte_network_mode;
priv->umts_network_mode = config->umts_network_mode;
priv->network_mode_timeout = config->network_mode_timeout;
priv->force_gsm_when_radio_off = config->force_gsm_when_radio_off;
priv->use_data_profiles = config->use_data_profiles;
priv->mms_data_profile_id = config->mms_data_profile_id;
......
......@@ -89,6 +89,7 @@
#define RILMODEM_DEFAULT_RADIO_POWER_CYCLE TRUE
#define RILMODEM_DEFAULT_CONFIRM_RADIO_POWER_ON TRUE
#define RILMODEM_DEFAULT_NETWORK_SELECTION_MANUAL_0 TRUE
#define RILMODEM_DEFAULT_FORCE_GSM_WHEN_RADIO_OFF TRUE
#define RILMODEM_DEFAULT_USE_DATA_PROFILES FALSE
#define RILMODEM_DEFAULT_MMS_DATA_PROFILE_ID RIL_DATA_PROFILE_IMS
#define RILMODEM_DEFAULT_SLOT_FLAGS SAILFISH_SLOT_NO_FLAGS
......@@ -143,6 +144,7 @@
#define RILCONF_CONFIRM_RADIO_POWER_ON "confirmRadioPowerOn"
#define RILCONF_SINGLE_DATA_CONTEXT "singleDataContext"
#define RILCONF_NETWORK_SELECTION_MANUAL_0 "networkSelectionManual0"
#define RILCONF_FORCE_GSM_WHEN_RADIO_OFF "forceGsmWhenRadioOff"
#define RILCONF_USE_DATA_PROFILES "useDataProfiles"
#define RILCONF_MMS_DATA_PROFILE_ID "mmsDataProfileId"
#define RILCONF_DEVMON "deviceStateTracking"
......@@ -910,6 +912,7 @@ static void ril_plugin_radio_caps_cb(const struct ril_radio_capability *cap,
static void ril_plugin_manager_started(ril_plugin *plugin)
{
ril_plugin_drop_orphan_slots(plugin);
ril_data_manager_check_data(plugin->data_manager);
sailfish_slot_manager_started(plugin->handle);
}
......@@ -1195,6 +1198,8 @@ static ril_slot *ril_plugin_slot_new_take(char *transport,
RILMODEM_DEFAULT_QUERY_AVAILABLE_BAND_MODE;
config->network_selection_manual_0 =
RILMODEM_DEFAULT_NETWORK_SELECTION_MANUAL_0;
config->force_gsm_when_radio_off =
RILMODEM_DEFAULT_FORCE_GSM_WHEN_RADIO_OFF;
config->use_data_profiles = RILMODEM_DEFAULT_USE_DATA_PROFILES;
config->mms_data_profile_id = RILMODEM_DEFAULT_MMS_DATA_PROFILE_ID;
slot->timeout = RILMODEM_DEFAULT_TIMEOUT;
......@@ -1231,6 +1236,8 @@ static void ril_plugin_slot_apply_vendor_defaults(ril_slot *slot)
defaults.empty_pin_query = config->empty_pin_query;
defaults.mms_data_profile_id = config->mms_data_profile_id;
defaults.use_data_profiles = config->use_data_profiles;
defaults.force_gsm_when_radio_off =
config->force_gsm_when_radio_off;
defaults.query_available_band_mode =
config->query_available_band_mode;
......@@ -1241,6 +1248,8 @@ static void ril_plugin_slot_apply_vendor_defaults(ril_slot *slot)
config->empty_pin_query = defaults.empty_pin_query;
config->use_data_profiles = defaults.use_data_profiles;
config->mms_data_profile_id = defaults.mms_data_profile_id;
config->force_gsm_when_radio_off =
defaults.force_gsm_when_radio_off;
config->query_available_band_mode =
defaults.query_available_band_mode;
}
......@@ -1469,6 +1478,14 @@ static ril_slot *ril_plugin_parse_config_group(GKeyFile *file,
config->network_selection_manual_0 ? "yes" : "no");
}
/* forceGsmWhenRadioOff */
if (ril_config_get_boolean(file, group,
RILCONF_FORCE_GSM_WHEN_RADIO_OFF,
&config->force_gsm_when_radio_off)) {
DBG("%s: " RILCONF_FORCE_GSM_WHEN_RADIO_OFF " %s", group,
config->force_gsm_when_radio_off ? "yes" : "no");
}
/* useDataProfiles */
if (ril_config_get_boolean(file, group, RILCONF_USE_DATA_PROFILES,
&config->use_data_profiles)) {
......
......@@ -297,3 +297,11 @@ socket=/dev/socket/rild
# Default auto
#
#deviceStateTracking=auto
# On some phones (such as Jolla C), even if the slot which has been
# using LTE gets powered off, we still need to explicitely set its
# preferred mode to GSM, to make LTE machinery available to the other slot.
#
# Default true (false for MTK RILs)
#
#forceGsmWhenRadioOff=true
......@@ -2,6 +2,7 @@
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2019 Jolla Ltd.
* Copyright (C) 2019 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
......@@ -62,6 +63,7 @@ struct ril_slot_config {
gboolean enable_cbs;
gboolean enable_stk;
gboolean network_selection_manual_0;
gboolean force_gsm_when_radio_off;
gboolean use_data_profiles;
guint mms_data_profile_id;
GUtilInts *local_hangup_reasons;
......
......@@ -2,6 +2,7 @@
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2016-2019 Jolla Ltd.
* Copyright (C) 2019 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
......@@ -25,6 +26,7 @@ struct ril_vendor_defaults {
gboolean enable_stk;
gboolean query_available_band_mode;
gboolean use_data_profiles;
gboolean force_gsm_when_radio_off;
guint mms_data_profile_id;
};
......
......@@ -2,6 +2,7 @@
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2016-2019 Jolla Ltd.
* Copyright (C) 2019 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
......@@ -415,6 +416,7 @@ static void ril_vendor_mtk_get_defaults(struct ril_vendor_defaults *defaults)
defaults->query_available_band_mode = FALSE;
defaults->empty_pin_query = FALSE;
defaults->legacy_imei_query = TRUE;
defaults->force_gsm_when_radio_off = FALSE;
}
static void ril_vendor_mtk_base_init(RilVendorMtk *self, GRilIoChannel *io,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment