forked from sailfishos/ofono
Compare commits
55 Commits
mer/1.23+g
...
mer/1.23+g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed62d38632 | ||
|
|
3f433c97c5 | ||
|
|
86d8149c79 | ||
|
|
f3eb9b868b | ||
|
|
4e067fa827 | ||
|
|
2ee5e4c827 | ||
|
|
1366e426be | ||
|
|
586c9b9262 | ||
|
|
83554e071a | ||
|
|
dc41c2d003 | ||
|
|
550d41ae37 | ||
|
|
60e4246d93 | ||
|
|
50619607b0 | ||
|
|
98b357f365 | ||
|
|
56c488d10c | ||
|
|
944cd603e8 | ||
|
|
77be0d5e98 | ||
|
|
d8dd20092c | ||
|
|
c7faa21172 | ||
|
|
98ffc61a03 | ||
|
|
f2b1625872 | ||
|
|
2d5a22284e | ||
|
|
9d742180ab | ||
|
|
f8b0ccc1b4 | ||
|
|
7a54bb8cbe | ||
|
|
56e0923dc3 | ||
|
|
6dfce4b5e9 | ||
|
|
4ec3568d71 | ||
|
|
9b2b7127ef | ||
|
|
1053577376 | ||
|
|
22197b5e04 | ||
|
|
3a358ddc9d | ||
|
|
53929f9f1a | ||
|
|
08bae57a2b | ||
|
|
1915aeda76 | ||
|
|
51bfb17cbc | ||
|
|
a83b553032 | ||
|
|
ec00abd62d | ||
|
|
80924d5787 | ||
|
|
2bdd05aa31 | ||
|
|
544f02e5a2 | ||
|
|
6d4638f9bf | ||
|
|
6584919e9d | ||
|
|
34fb44f4eb | ||
|
|
c98d2f41c5 | ||
|
|
b279be4528 | ||
|
|
a7912fea39 | ||
|
|
f291cea905 | ||
|
|
68f7d30b77 | ||
|
|
890a2697fe | ||
|
|
9568c8449b | ||
|
|
cf91be9742 | ||
|
|
087771dc0f | ||
|
|
645dfe47e5 | ||
|
|
68e8b02d3b |
@@ -151,8 +151,10 @@ builtin_sources += drivers/ril/ril_call_barring.c \
|
||||
drivers/ril/ril_devinfo.c \
|
||||
drivers/ril/ril_devmon.c \
|
||||
drivers/ril/ril_devmon_auto.c \
|
||||
drivers/ril/ril_devmon_combine.c \
|
||||
drivers/ril/ril_devmon_ds.c \
|
||||
drivers/ril/ril_devmon_ss.c \
|
||||
drivers/ril/ril_devmon_ur.c \
|
||||
drivers/ril/ril_ecclist.c \
|
||||
drivers/ril/ril_gprs.c \
|
||||
drivers/ril/ril_gprs_context.c \
|
||||
|
||||
@@ -189,8 +189,8 @@ CFLAGS="$CFLAGS $GLIBUTIL_CFLAGS"
|
||||
LIBS="$LIBS $GLIBUTIL_LIBS"
|
||||
|
||||
if (test "${enable_sailfish_rilmodem}" = "yes"); then
|
||||
PKG_CHECK_MODULES(GRILIO, libgrilio >= 1.0.35, dummy=yes,
|
||||
AC_MSG_ERROR(libgrilio >= 1.0.35 is required))
|
||||
PKG_CHECK_MODULES(GRILIO, libgrilio >= 1.0.38, dummy=yes,
|
||||
AC_MSG_ERROR(libgrilio >= 1.0.38 is required))
|
||||
PKG_CHECK_MODULES(LIBMCE, libmce-glib >= 1.0.6, dummy=yes,
|
||||
AC_MSG_ERROR(libmce-glib >= 1.0.6 is required))
|
||||
CFLAGS="$CFLAGS $GRILIO_CFLAGS $LIBMCE_CFLAGS"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
* Copyright (C) 2015-2020 Jolla Ltd.
|
||||
*
|
||||
* 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
|
||||
@@ -24,6 +24,7 @@ struct ril_cbs {
|
||||
GRilIoChannel *io;
|
||||
GRilIoQueue *q;
|
||||
char *log_prefix;
|
||||
guint register_id;
|
||||
gulong event_id;
|
||||
};
|
||||
|
||||
@@ -51,6 +52,12 @@ static struct ril_cbs_cbd *ril_cbs_cbd_new(struct ril_cbs *cd,
|
||||
return cbd;
|
||||
}
|
||||
|
||||
static gboolean ril_cbs_retry(GRilIoRequest *request, int ril_status,
|
||||
const void *resp_data, guint resp_len, void *user_data)
|
||||
{
|
||||
return ril_status == RIL_E_INVALID_STATE;
|
||||
}
|
||||
|
||||
static void ril_cbs_request_activation(struct ril_cbs *cd,
|
||||
gboolean activate, GRilIoChannelResponseFunc response,
|
||||
GDestroyNotify destroy, void* user_data)
|
||||
@@ -61,6 +68,9 @@ static void ril_cbs_request_activation(struct ril_cbs *cd,
|
||||
grilio_request_append_int32(req, activate ? 0 :1);
|
||||
|
||||
DBG_(cd, "%sactivating CB", activate ? "" : "de");
|
||||
grilio_request_set_retry_func(req, ril_cbs_retry);
|
||||
grilio_request_set_retry(req, RIL_CBS_CHECK_RETRY_MS,
|
||||
RIL_CBS_CHECK_RETRY_COUNT);
|
||||
grilio_queue_send_request_full(cd->q, req,
|
||||
RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
|
||||
response, destroy, user_data);
|
||||
@@ -97,6 +107,9 @@ static void ril_cbs_set_config(struct ril_cbs *cd, const char *topics,
|
||||
}
|
||||
|
||||
DBG_(cd, "configuring CB");
|
||||
grilio_request_set_retry_func(req, ril_cbs_retry);
|
||||
grilio_request_set_retry(req, RIL_CBS_CHECK_RETRY_MS,
|
||||
RIL_CBS_CHECK_RETRY_COUNT);
|
||||
grilio_queue_send_request_full(cd->q, req,
|
||||
RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG,
|
||||
response, destroy, user_data);
|
||||
@@ -144,27 +157,41 @@ static void ril_cbs_notify(GRilIoChannel *io, guint code,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_cbs *cd = user_data;
|
||||
GRilIoParser rilp;
|
||||
guint32 pdu_len;
|
||||
|
||||
GASSERT(code == RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS);
|
||||
DBG_(cd, "%u bytes", len);
|
||||
ofono_cbs_notify(cd->cbs, data, len);
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
if (grilio_parser_get_uint32(&rilp, &pdu_len)) {
|
||||
const void* pdu = grilio_parser_get_bytes(&rilp, pdu_len);
|
||||
|
||||
/*
|
||||
* By default assume that it's a length followed by the
|
||||
* binary PDU data.
|
||||
*/
|
||||
if (pdu && grilio_parser_bytes_remaining(&rilp) < 4) {
|
||||
DBG_(cd, "%u bytes", pdu_len);
|
||||
ofono_cbs_notify(cd->cbs, pdu, pdu_len);
|
||||
} else {
|
||||
/*
|
||||
* But I've seen cell broadcasts arriving without
|
||||
* the length, simply as a blob.
|
||||
*/
|
||||
ofono_cbs_notify(cd->cbs, data, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_cbs_probe_done_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
static gboolean ril_cbs_register(void *user_data)
|
||||
{
|
||||
struct ril_cbs *cd = user_data;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
DBG_(cd, "registering for CB");
|
||||
cd->event_id = grilio_channel_add_unsol_event_handler(cd->io,
|
||||
ril_cbs_notify, RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS,
|
||||
cd);
|
||||
ofono_cbs_register(cd->cbs);
|
||||
} else {
|
||||
DBG_(cd, "failed to query CB config");
|
||||
ofono_cbs_remove(cd->cbs);
|
||||
}
|
||||
DBG_(cd, "registering for CB");
|
||||
cd->register_id = 0;
|
||||
cd->event_id = grilio_channel_add_unsol_event_handler(cd->io,
|
||||
ril_cbs_notify, RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS, cd);
|
||||
ofono_cbs_register(cd->cbs);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static int ril_cbs_probe(struct ofono_cbs *cbs, unsigned int vendor,
|
||||
@@ -172,7 +199,6 @@ static int ril_cbs_probe(struct ofono_cbs *cbs, unsigned int vendor,
|
||||
{
|
||||
struct ril_modem *modem = data;
|
||||
struct ril_cbs *cd = g_try_new0(struct ril_cbs, 1);
|
||||
GRilIoRequest* req = grilio_request_new();
|
||||
|
||||
ofono_cbs_set_data(cbs, cd);
|
||||
cd->log_prefix = (modem->log_prefix && modem->log_prefix[0]) ?
|
||||
@@ -182,20 +208,7 @@ static int ril_cbs_probe(struct ofono_cbs *cbs, unsigned int vendor,
|
||||
DBG_(cd, "");
|
||||
cd->io = grilio_channel_ref(ril_modem_io(modem));
|
||||
cd->q = grilio_queue_new(cd->io);
|
||||
|
||||
/*
|
||||
* RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG often fails at startup
|
||||
* especially if other RIL requests are running in parallel. We may
|
||||
* have to retry a few times. Also, make it blocking in order to
|
||||
* improve the chance of success.
|
||||
*/
|
||||
grilio_request_set_retry(req, RIL_CBS_CHECK_RETRY_MS,
|
||||
RIL_CBS_CHECK_RETRY_COUNT);
|
||||
grilio_request_set_blocking(req, TRUE);
|
||||
grilio_queue_send_request_full(cd->q, req,
|
||||
RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG,
|
||||
ril_cbs_probe_done_cb, NULL, cd);
|
||||
grilio_request_unref(req);
|
||||
cd->register_id = g_idle_add(ril_cbs_register, cd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -204,6 +217,9 @@ static void ril_cbs_remove(struct ofono_cbs *cbs)
|
||||
struct ril_cbs *cd = ofono_cbs_get_data(cbs);
|
||||
|
||||
DBG_(cd, "");
|
||||
if (cd->register_id) {
|
||||
g_source_remove(cd->register_id);
|
||||
}
|
||||
ofono_cbs_set_data(cbs, NULL);
|
||||
grilio_channel_remove_handler(cd->io, cd->event_id);
|
||||
grilio_channel_unref(cd->io);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
* 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
|
||||
* 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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
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);
|
||||
self->query_id = grilio_channel_send_request_full(self->io, req,
|
||||
RIL_REQUEST_GET_CELL_INFO_LIST, ril_cell_info_list_cb,
|
||||
@@ -359,9 +373,10 @@ static void ril_cell_info_query(struct ril_cell_info *self)
|
||||
static void ril_cell_info_set_rate(struct ril_cell_info *self)
|
||||
{
|
||||
GRilIoRequest *req = grilio_request_array_int32_new(1,
|
||||
(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_func(req, ril_cell_info_retry);
|
||||
grilio_channel_cancel_request(self->io, self->set_rate_id, FALSE);
|
||||
self->set_rate_id = grilio_channel_send_request_full(self->io, req,
|
||||
RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2019 Jolla Ltd.
|
||||
* Copyright (C) 2019 Open Mobile Platform LLC.
|
||||
* Copyright (C) 2015-2020 Jolla Ltd.
|
||||
* 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
|
||||
@@ -186,6 +186,72 @@ gboolean ril_config_get_enum(GKeyFile *file, const char *group,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean ril_config_get_mask(GKeyFile *file, const char *group,
|
||||
const char *key, int *result,
|
||||
const char *name, int value, ...)
|
||||
{
|
||||
char *str = ril_config_get_string(file, group, key);
|
||||
gboolean ok = FALSE;
|
||||
|
||||
if (result) {
|
||||
*result = 0;
|
||||
}
|
||||
|
||||
if (str) {
|
||||
/*
|
||||
* Some people are thinking that # is a comment
|
||||
* anywhere on the line, not just at the beginning
|
||||
*/
|
||||
char *comment = strchr(str, '#');
|
||||
char **values, **ptr;
|
||||
|
||||
if (comment) *comment = 0;
|
||||
values = g_strsplit(str, "+", -1);
|
||||
|
||||
for (ok = TRUE, ptr = values; *ptr && ok; ptr++) {
|
||||
const char* found_str = NULL;
|
||||
const char* s = g_strstrip(*ptr);
|
||||
|
||||
if (!strcasecmp(s, name)) {
|
||||
found_str = name;
|
||||
if (result) {
|
||||
*result |= value;
|
||||
}
|
||||
} else {
|
||||
va_list args;
|
||||
const char* known;
|
||||
|
||||
va_start(args, value);
|
||||
while ((known = va_arg(args, char*)) != NULL) {
|
||||
const int bit = va_arg(args, int);
|
||||
|
||||
if (!strcasecmp(s, known)) {
|
||||
found_str = known;
|
||||
if (result) {
|
||||
*result |= bit;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
if (!found_str) {
|
||||
ofono_error("Unknown bit '%s' in %s", s, key);
|
||||
ok = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
g_strfreev(values);
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
if (!ok && result) {
|
||||
*result = 0;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
GUtilInts *ril_config_get_ints(GKeyFile *file, const char *group,
|
||||
const char *key)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2019 Jolla Ltd.
|
||||
* Copyright (C) 2019 Open Mobile Platform LLC.
|
||||
* Copyright (C) 2015-2020 Jolla Ltd.
|
||||
* 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
|
||||
@@ -35,7 +35,12 @@ gboolean ril_config_get_flag(GKeyFile *file, const char *group,
|
||||
const char *key, int flag, int *flags);
|
||||
gboolean ril_config_get_enum(GKeyFile *file, const char *group,
|
||||
const char *key, int *result,
|
||||
const char *name, int value, ...);
|
||||
const char *name, int value, ...)
|
||||
G_GNUC_NULL_TERMINATED;
|
||||
gboolean ril_config_get_mask(GKeyFile *file, const char *group,
|
||||
const char *key, int *result,
|
||||
const char *name, int value, ...)
|
||||
G_GNUC_NULL_TERMINATED;
|
||||
GUtilInts *ril_config_get_ints(GKeyFile *file, const char *group,
|
||||
const char *key);
|
||||
char *ril_config_ints_to_string(GUtilInts *ints, char separator);
|
||||
|
||||
@@ -375,6 +375,19 @@ enum ril_restricted_state {
|
||||
#define RIL_FACILITY_UNLOCK "0"
|
||||
#define RIL_FACILITY_LOCK "1"
|
||||
|
||||
/* See RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER (RIL_VERSION >= 15) */
|
||||
enum ril_unsolicited_response_filter {
|
||||
RIL_UR_SIGNAL_STRENGTH = 0x01,
|
||||
RIL_UR_FULL_NETWORK_STATE = 0x02,
|
||||
RIL_UR_DATA_CALL_DORMANCY_CHANGED = 0x04
|
||||
};
|
||||
|
||||
/* RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE result */
|
||||
enum ril_network_selection_mode {
|
||||
RIL_NETWORK_SELECTION_MODE_AUTO = 0,
|
||||
RIL_NETWORK_SELECTION_MODE_MANUAL = 1
|
||||
};
|
||||
|
||||
#endif /*__RIL_CONSTANTS_H */
|
||||
|
||||
/*
|
||||
|
||||
@@ -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
|
||||
@@ -81,6 +81,7 @@ typedef struct ril_data RilData;
|
||||
enum ril_data_io_event_id {
|
||||
IO_EVENT_DATA_CALL_LIST_CHANGED,
|
||||
IO_EVENT_RESTRICTED_STATE_CHANGED,
|
||||
IO_EVENT_EOF,
|
||||
IO_EVENT_COUNT
|
||||
};
|
||||
|
||||
@@ -192,6 +193,7 @@ struct ril_data_request_allow_data {
|
||||
|
||||
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_cancel_all_requests(struct ril_data *self);
|
||||
static void ril_data_power_update(struct ril_data *self);
|
||||
static void ril_data_signal_emit(struct ril_data *self, enum ril_data_signal id)
|
||||
{
|
||||
@@ -1230,6 +1232,17 @@ static void ril_data_settings_changed(struct ril_sim_settings *settings,
|
||||
ril_data_manager_check_network_mode(RIL_DATA(user_data)->priv->dm);
|
||||
}
|
||||
|
||||
static void ril_data_ril_disconnected_cb(GRilIoChannel *io, void *user_data)
|
||||
{
|
||||
struct ril_data *self = RIL_DATA(user_data);
|
||||
struct ril_data_priv *priv = self->priv;
|
||||
|
||||
DBG_(self, "disconnected");
|
||||
priv->flags = RIL_DATA_FLAG_NONE;
|
||||
priv->restricted_state = 0;
|
||||
ril_data_cancel_all_requests(self);
|
||||
}
|
||||
|
||||
static gint ril_data_compare_cb(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const struct ril_data *d1 = a;
|
||||
@@ -1289,6 +1302,9 @@ struct ril_data *ril_data_new(struct ril_data_manager *dm, const char *name,
|
||||
grilio_channel_add_unsol_event_handler(io,
|
||||
ril_data_restricted_state_changed_cb,
|
||||
RIL_UNSOL_RESTRICTED_STATE_CHANGED, self);
|
||||
priv->io_event_id[IO_EVENT_EOF] =
|
||||
grilio_channel_add_disconnected_handler(io,
|
||||
ril_data_ril_disconnected_cb, self);
|
||||
|
||||
priv->settings_event_id[SETTINGS_EVENT_IMSI_CHANGED] =
|
||||
ril_sim_settings_add_imsi_changed_handler(settings,
|
||||
@@ -1415,6 +1431,20 @@ static void ril_data_cancel_requests(struct ril_data *self,
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_data_cancel_all_requests(struct ril_data *self)
|
||||
{
|
||||
struct ril_data_priv *priv = self->priv;
|
||||
struct ril_data_request *req = priv->req_queue;
|
||||
|
||||
ril_data_request_do_cancel(priv->pending_req);
|
||||
while (req) {
|
||||
struct ril_data_request *next = req->next;
|
||||
|
||||
ril_data_request_do_cancel(req);
|
||||
req = next;
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_data_disallow(struct ril_data *self)
|
||||
{
|
||||
struct ril_data_priv *priv = self->priv;
|
||||
@@ -1586,24 +1616,11 @@ static void ril_data_dispose(GObject *object)
|
||||
struct ril_data *self = RIL_DATA(object);
|
||||
struct ril_data_priv *priv = self->priv;
|
||||
struct ril_data_manager *dm = priv->dm;
|
||||
struct ril_network *network = priv->network;
|
||||
struct ril_sim_settings *settings = network->settings;
|
||||
struct ril_data_request *req;
|
||||
|
||||
ril_sim_settings_remove_handlers(settings, priv->settings_event_id,
|
||||
G_N_ELEMENTS(priv->settings_event_id));
|
||||
grilio_channel_remove_all_handlers(priv->io, priv->io_event_id);
|
||||
grilio_queue_cancel_all(priv->q, FALSE);
|
||||
priv->query_id = 0;
|
||||
|
||||
ril_data_request_do_cancel(priv->pending_req);
|
||||
req = priv->req_queue;
|
||||
while (req) {
|
||||
struct ril_data_request *next = req->next;
|
||||
ril_data_request_do_cancel(req);
|
||||
req = next;
|
||||
}
|
||||
|
||||
ril_data_cancel_all_requests(self);
|
||||
dm->data_list = g_slist_remove(dm->data_list, self);
|
||||
ril_data_manager_check_data(dm);
|
||||
g_hash_table_destroy(priv->grab);
|
||||
@@ -1614,6 +1631,11 @@ static void ril_data_finalize(GObject *object)
|
||||
{
|
||||
struct ril_data *self = RIL_DATA(object);
|
||||
struct ril_data_priv *priv = self->priv;
|
||||
struct ril_network *network = priv->network;
|
||||
struct ril_sim_settings *settings = network->settings;
|
||||
|
||||
ril_sim_settings_remove_all_handlers(settings, priv->settings_event_id);
|
||||
grilio_channel_remove_all_handlers(priv->io, priv->io_event_id);
|
||||
|
||||
g_free(priv->log_prefix);
|
||||
grilio_queue_unref(priv->q);
|
||||
@@ -1699,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) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2019 Jolla Ltd.
|
||||
* Copyright (C) 2016-2020 Jolla Ltd.
|
||||
* Copyright (C) 2019 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -79,12 +79,6 @@ struct ril_data_options {
|
||||
unsigned int data_call_retry_delay_ms;
|
||||
};
|
||||
|
||||
enum ril_data_role {
|
||||
RIL_DATA_ROLE_NONE, /* Data not allowed */
|
||||
RIL_DATA_ROLE_MMS, /* Data is allowed at any speed */
|
||||
RIL_DATA_ROLE_INTERNET /* Data is allowed at full speed */
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2019 Jolla Ltd.
|
||||
* Copyright (C) 2019-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
|
||||
@@ -33,27 +34,34 @@ struct ril_devmon {
|
||||
GRilIoChannel *channel, struct sailfish_cell_info *cell_info);
|
||||
};
|
||||
|
||||
/* Cell info update intervals */
|
||||
#define RIL_CELL_INFO_INTERVAL_SHORT_MS (2000) /* 2 sec */
|
||||
#define RIL_CELL_INFO_INTERVAL_LONG_MS (30000) /* 30 sec */
|
||||
|
||||
/*
|
||||
* Legacy Device Monitor uses RIL_REQUEST_SCREEN_STATE to tell
|
||||
* the modem when screen turns on and off.
|
||||
*/
|
||||
struct ril_devmon *ril_devmon_ss_new(void);
|
||||
struct ril_devmon *ril_devmon_ss_new(const struct ril_slot_config *config);
|
||||
|
||||
/*
|
||||
* This Device Monitor uses RIL_REQUEST_SEND_DEVICE_STATE to let
|
||||
* the modem choose the right power saving strategy. It basically
|
||||
* mirrors the logic of Android's DeviceStateMonitor class.
|
||||
*/
|
||||
struct ril_devmon *ril_devmon_ds_new(void);
|
||||
struct ril_devmon *ril_devmon_ds_new(const struct ril_slot_config *config);
|
||||
|
||||
/*
|
||||
* This Device Monitor implementation controls network state updates
|
||||
* by sending SET_UNSOLICITED_RESPONSE_FILTER.
|
||||
*/
|
||||
struct ril_devmon *ril_devmon_ur_new(const struct ril_slot_config *config);
|
||||
|
||||
/*
|
||||
* This one selects the type based on the RIL version.
|
||||
*/
|
||||
struct ril_devmon *ril_devmon_auto_new(void);
|
||||
struct ril_devmon *ril_devmon_auto_new(const struct ril_slot_config *config);
|
||||
|
||||
/*
|
||||
* This one combines several methods. Takes ownership of ril_devmon objects.
|
||||
*/
|
||||
struct ril_devmon *ril_devmon_combine(struct ril_devmon *devmon[], guint n);
|
||||
|
||||
/* Utilities (NULL tolerant) */
|
||||
struct ril_devmon_io *ril_devmon_start_io(struct ril_devmon *devmon,
|
||||
|
||||
@@ -65,7 +65,7 @@ static void ril_devmon_auto_free(struct ril_devmon *devmon)
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
struct ril_devmon *ril_devmon_auto_new()
|
||||
struct ril_devmon *ril_devmon_auto_new(const struct ril_slot_config *config)
|
||||
{
|
||||
DevMon *self = g_new0(DevMon, 1);
|
||||
|
||||
@@ -78,8 +78,8 @@ struct ril_devmon *ril_devmon_auto_new()
|
||||
*/
|
||||
self->pub.free = ril_devmon_auto_free;
|
||||
self->pub.start_io = ril_devmon_auto_start_io;
|
||||
self->ss = ril_devmon_ss_new();
|
||||
self->ds = ril_devmon_ds_new();
|
||||
self->ss = ril_devmon_ss_new(config);
|
||||
self->ds = ril_devmon_ds_new(config);
|
||||
return &self->pub;
|
||||
}
|
||||
|
||||
|
||||
104
ofono/drivers/ril/ril_devmon_combine.c
Normal file
104
ofono/drivers/ril/ril_devmon_combine.c
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 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
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_devmon.h"
|
||||
|
||||
#include <ofono/log.h>
|
||||
|
||||
typedef struct ril_devmon_combine {
|
||||
struct ril_devmon pub;
|
||||
struct ril_devmon **impl;
|
||||
guint count;
|
||||
} DevMon;
|
||||
|
||||
typedef struct ril_devmon_combine_io {
|
||||
struct ril_devmon_io pub;
|
||||
struct ril_devmon_io **impl;
|
||||
guint count;
|
||||
} DevMonIo;
|
||||
|
||||
static inline DevMon *ril_devmon_combine_cast(struct ril_devmon *dm)
|
||||
{
|
||||
return G_CAST(dm, DevMon, pub);
|
||||
}
|
||||
|
||||
static inline DevMonIo *ril_devmon_ds_io_cast(struct ril_devmon_io *io)
|
||||
{
|
||||
return G_CAST(io, DevMonIo, pub);
|
||||
}
|
||||
|
||||
static void ril_devmon_combine_io_free(struct ril_devmon_io *io)
|
||||
{
|
||||
guint i;
|
||||
DevMonIo *self = ril_devmon_ds_io_cast(io);
|
||||
|
||||
for (i = 0; i < self->count; i++) {
|
||||
ril_devmon_io_free(self->impl[i]);
|
||||
}
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
static struct ril_devmon_io *ril_devmon_combine_start_io(struct ril_devmon *dm,
|
||||
GRilIoChannel *chan, struct sailfish_cell_info *ci)
|
||||
{
|
||||
guint i;
|
||||
DevMon *self = ril_devmon_combine_cast(dm);
|
||||
DevMonIo *io = g_malloc0(sizeof(DevMonIo) +
|
||||
sizeof(struct ril_devmon_io *) * self->count);
|
||||
|
||||
io->pub.free = ril_devmon_combine_io_free;
|
||||
io->impl = (struct ril_devmon_io**)(io + 1);
|
||||
io->count = self->count;
|
||||
for (i = 0; i < io->count; i++) {
|
||||
io->impl[i] = ril_devmon_start_io(self->impl[i], chan, ci);
|
||||
}
|
||||
return &io->pub;
|
||||
}
|
||||
|
||||
static void ril_devmon_combine_free(struct ril_devmon *dm)
|
||||
{
|
||||
DevMon *self = ril_devmon_combine_cast(dm);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < self->count; i++) {
|
||||
ril_devmon_free(self->impl[i]);
|
||||
}
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
struct ril_devmon *ril_devmon_combine(struct ril_devmon *dm[], guint n)
|
||||
{
|
||||
guint i;
|
||||
DevMon *self = g_malloc0(sizeof(DevMon) +
|
||||
sizeof(struct ril_devmon *) * n);
|
||||
|
||||
self->pub.free = ril_devmon_combine_free;
|
||||
self->pub.start_io = ril_devmon_combine_start_io;
|
||||
self->impl = (struct ril_devmon **)(self + 1);
|
||||
self->count = n;
|
||||
for (i = 0; i < n; i++) {
|
||||
self->impl[i] = dm[i];
|
||||
}
|
||||
return &self->pub;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -65,6 +65,8 @@ typedef struct ril_devmon_ds {
|
||||
MceBattery *battery;
|
||||
MceCharger *charger;
|
||||
MceDisplay *display;
|
||||
int cell_info_interval_short_ms;
|
||||
int cell_info_interval_long_ms;
|
||||
} DevMon;
|
||||
|
||||
typedef struct ril_devmon_ds_io {
|
||||
@@ -86,6 +88,8 @@ typedef struct ril_devmon_ds_io {
|
||||
gulong charger_event_id[CHARGER_EVENT_COUNT];
|
||||
gulong display_event_id[DISPLAY_EVENT_COUNT];
|
||||
guint req_id;
|
||||
int cell_info_interval_short_ms;
|
||||
int cell_info_interval_long_ms;
|
||||
} DevMonIo;
|
||||
|
||||
#define DBG_(self,fmt,args...) DBG("%s: " fmt, (self)->io->name, ##args)
|
||||
@@ -201,8 +205,8 @@ static void ril_devmon_ds_io_set_cell_info_update_interval(DevMonIo *self)
|
||||
(ril_devmon_ds_display_on(self->display) &&
|
||||
(ril_devmon_ds_charging(self->charger) ||
|
||||
ril_devmon_ds_battery_ok(self->battery))) ?
|
||||
RIL_CELL_INFO_INTERVAL_SHORT_MS :
|
||||
RIL_CELL_INFO_INTERVAL_LONG_MS);
|
||||
self->cell_info_interval_short_ms :
|
||||
self->cell_info_interval_long_ms);
|
||||
}
|
||||
|
||||
static void ril_devmon_ds_io_connman_cb(struct ril_connman *connman,
|
||||
@@ -303,6 +307,11 @@ static struct ril_devmon_io *ril_devmon_ds_start_io(struct ril_devmon *devmon,
|
||||
mce_display_add_state_changed_handler(self->display,
|
||||
ril_devmon_ds_io_display_cb, self);
|
||||
|
||||
self->cell_info_interval_short_ms =
|
||||
ds->cell_info_interval_short_ms;
|
||||
self->cell_info_interval_long_ms =
|
||||
ds->cell_info_interval_long_ms;
|
||||
|
||||
ril_devmon_ds_io_update_low_data(self);
|
||||
ril_devmon_ds_io_update_charging(self);
|
||||
ril_devmon_ds_io_set_cell_info_update_interval(self);
|
||||
@@ -320,7 +329,7 @@ static void ril_devmon_ds_free(struct ril_devmon *devmon)
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
struct ril_devmon *ril_devmon_ds_new()
|
||||
struct ril_devmon *ril_devmon_ds_new(const struct ril_slot_config *config)
|
||||
{
|
||||
DevMon *self = g_new0(DevMon, 1);
|
||||
|
||||
@@ -330,6 +339,10 @@ struct ril_devmon *ril_devmon_ds_new()
|
||||
self->battery = mce_battery_new();
|
||||
self->charger = mce_charger_new();
|
||||
self->display = mce_display_new();
|
||||
self->cell_info_interval_short_ms =
|
||||
config->cell_info_interval_short_ms;
|
||||
self->cell_info_interval_long_ms =
|
||||
config->cell_info_interval_long_ms;
|
||||
return &self->pub;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ typedef struct ril_devmon_ss {
|
||||
MceBattery *battery;
|
||||
MceCharger *charger;
|
||||
MceDisplay *display;
|
||||
int cell_info_interval_short_ms;
|
||||
int cell_info_interval_long_ms;
|
||||
} DevMon;
|
||||
|
||||
typedef struct ril_devmon_ss_io {
|
||||
@@ -65,6 +67,8 @@ typedef struct ril_devmon_ss_io {
|
||||
gulong charger_event_id[CHARGER_EVENT_COUNT];
|
||||
gulong display_event_id[DISPLAY_EVENT_COUNT];
|
||||
guint req_id;
|
||||
int cell_info_interval_short_ms;
|
||||
int cell_info_interval_long_ms;
|
||||
} DevMonIo;
|
||||
|
||||
inline static DevMon *ril_devmon_ss_cast(struct ril_devmon *pub)
|
||||
@@ -130,8 +134,8 @@ static void ril_devmon_ss_io_set_cell_info_update_interval(DevMonIo *self)
|
||||
sailfish_cell_info_set_update_interval(self->cell_info,
|
||||
(self->display_on && (ril_devmon_ss_charging(self->charger) ||
|
||||
ril_devmon_ss_battery_ok(self->battery))) ?
|
||||
RIL_CELL_INFO_INTERVAL_SHORT_MS :
|
||||
RIL_CELL_INFO_INTERVAL_LONG_MS);
|
||||
self->cell_info_interval_short_ms :
|
||||
self->cell_info_interval_long_ms);
|
||||
}
|
||||
|
||||
static void ril_devmon_ss_io_battery_cb(MceBattery *battery, void *user_data)
|
||||
@@ -212,6 +216,11 @@ static struct ril_devmon_io *ril_devmon_ss_start_io(struct ril_devmon *devmon,
|
||||
mce_display_add_state_changed_handler(self->display,
|
||||
ril_devmon_ss_io_display_cb, self);
|
||||
|
||||
self->cell_info_interval_short_ms =
|
||||
ss->cell_info_interval_short_ms;
|
||||
self->cell_info_interval_long_ms =
|
||||
ss->cell_info_interval_long_ms;
|
||||
|
||||
ril_devmon_ss_io_send_screen_state(self);
|
||||
ril_devmon_ss_io_set_cell_info_update_interval(self);
|
||||
return &self->pub;
|
||||
@@ -227,7 +236,7 @@ static void ril_devmon_ss_free(struct ril_devmon *devmon)
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
struct ril_devmon *ril_devmon_ss_new()
|
||||
struct ril_devmon *ril_devmon_ss_new(const struct ril_slot_config *config)
|
||||
{
|
||||
DevMon *self = g_new0(DevMon, 1);
|
||||
|
||||
@@ -236,6 +245,10 @@ struct ril_devmon *ril_devmon_ss_new()
|
||||
self->battery = mce_battery_new();
|
||||
self->charger = mce_charger_new();
|
||||
self->display = mce_display_new();
|
||||
self->cell_info_interval_short_ms =
|
||||
config->cell_info_interval_short_ms;
|
||||
self->cell_info_interval_long_ms =
|
||||
config->cell_info_interval_long_ms;
|
||||
return &self->pub;
|
||||
}
|
||||
|
||||
|
||||
267
ofono/drivers/ril/ril_devmon_ur.c
Normal file
267
ofono/drivers/ril/ril_devmon_ur.c
Normal file
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2019 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
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_devmon.h"
|
||||
|
||||
#include <ofono/log.h>
|
||||
#include <ofono/ril-constants.h>
|
||||
|
||||
#include <mce_battery.h>
|
||||
#include <mce_charger.h>
|
||||
#include <mce_display.h>
|
||||
|
||||
#include <grilio_channel.h>
|
||||
#include <grilio_request.h>
|
||||
|
||||
#include <gutil_macros.h>
|
||||
|
||||
#define RIL_UR_ENABLE_ALL (RIL_UR_SIGNAL_STRENGTH | \
|
||||
RIL_UR_FULL_NETWORK_STATE | \
|
||||
RIL_UR_DATA_CALL_DORMANCY_CHANGED)
|
||||
|
||||
enum ril_devmon_ur_battery_event {
|
||||
BATTERY_EVENT_VALID,
|
||||
BATTERY_EVENT_STATUS,
|
||||
BATTERY_EVENT_COUNT
|
||||
};
|
||||
|
||||
enum ril_devmon_ur_charger_event {
|
||||
CHARGER_EVENT_VALID,
|
||||
CHARGER_EVENT_STATE,
|
||||
CHARGER_EVENT_COUNT
|
||||
};
|
||||
|
||||
enum ril_devmon_ur_display_event {
|
||||
DISPLAY_EVENT_VALID,
|
||||
DISPLAY_EVENT_STATE,
|
||||
DISPLAY_EVENT_COUNT
|
||||
};
|
||||
|
||||
typedef struct ril_devmon_ur {
|
||||
struct ril_devmon pub;
|
||||
MceBattery *battery;
|
||||
MceCharger *charger;
|
||||
MceDisplay *display;
|
||||
int cell_info_interval_short_ms;
|
||||
int cell_info_interval_long_ms;
|
||||
} DevMon;
|
||||
|
||||
typedef struct ril_devmon_ur_io {
|
||||
struct ril_devmon_io pub;
|
||||
struct sailfish_cell_info *cell_info;
|
||||
MceBattery *battery;
|
||||
MceCharger *charger;
|
||||
MceDisplay *display;
|
||||
GRilIoChannel *io;
|
||||
gboolean display_on;
|
||||
gboolean unsol_filter_supported;
|
||||
gulong battery_event_id[BATTERY_EVENT_COUNT];
|
||||
gulong charger_event_id[CHARGER_EVENT_COUNT];
|
||||
gulong display_event_id[DISPLAY_EVENT_COUNT];
|
||||
guint req_id;
|
||||
int cell_info_interval_short_ms;
|
||||
int cell_info_interval_long_ms;
|
||||
} DevMonIo;
|
||||
|
||||
#define DBG_(self,fmt,args...) DBG("%s: " fmt, (self)->io->name, ##args)
|
||||
|
||||
inline static DevMon *ril_devmon_ur_cast(struct ril_devmon *pub)
|
||||
{
|
||||
return G_CAST(pub, DevMon, pub);
|
||||
}
|
||||
|
||||
inline static DevMonIo *ril_devmon_ur_io_cast(struct ril_devmon_io *pub)
|
||||
{
|
||||
return G_CAST(pub, DevMonIo, pub);
|
||||
}
|
||||
|
||||
static inline gboolean ril_devmon_ur_battery_ok(MceBattery *battery)
|
||||
{
|
||||
return battery->valid && battery->status >= MCE_BATTERY_OK;
|
||||
}
|
||||
|
||||
static inline gboolean ril_devmon_ur_charging(MceCharger *charger)
|
||||
{
|
||||
return charger->valid && charger->state == MCE_CHARGER_ON;
|
||||
}
|
||||
|
||||
static gboolean ril_devmon_ur_display_on(MceDisplay *display)
|
||||
{
|
||||
return display->valid && display->state != MCE_DISPLAY_STATE_OFF;
|
||||
}
|
||||
|
||||
static void ril_devmon_ur_io_unsol_response_filter_sent(GRilIoChannel *io,
|
||||
int status, const void *data, guint len,
|
||||
void *user_data)
|
||||
{
|
||||
DevMonIo *self = user_data;
|
||||
|
||||
self->req_id = 0;
|
||||
if (status == RIL_E_REQUEST_NOT_SUPPORTED) {
|
||||
/* This is a permanent failure */
|
||||
DBG_(self, "Unsolicited response filter is not supported");
|
||||
self->unsol_filter_supported = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_devmon_ur_io_set_unsol_response_filter(DevMonIo *self)
|
||||
{
|
||||
if (self->unsol_filter_supported) {
|
||||
const gint32 value = self->display_on ? RIL_UR_ENABLE_ALL : 0;
|
||||
GRilIoRequest *req = grilio_request_array_int32_new(1, value);
|
||||
|
||||
DBG_(self, "Setting unsolicited response filter: %u", value);
|
||||
|
||||
grilio_channel_cancel_request(self->io, self->req_id, FALSE);
|
||||
self->req_id =
|
||||
grilio_channel_send_request_full(self->io, req,
|
||||
RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER,
|
||||
ril_devmon_ur_io_unsol_response_filter_sent,
|
||||
NULL, self);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_devmon_ur_io_set_cell_info_update_interval(DevMonIo *self)
|
||||
{
|
||||
sailfish_cell_info_set_update_interval(self->cell_info,
|
||||
(self->display_on && (ril_devmon_ur_charging(self->charger) ||
|
||||
ril_devmon_ur_battery_ok(self->battery))) ?
|
||||
self->cell_info_interval_short_ms :
|
||||
self->cell_info_interval_long_ms);
|
||||
}
|
||||
|
||||
static void ril_devmon_ur_io_battery_cb(MceBattery *battery, void *user_data)
|
||||
{
|
||||
ril_devmon_ur_io_set_cell_info_update_interval(user_data);
|
||||
}
|
||||
|
||||
static void ril_devmon_ur_io_charger_cb(MceCharger *charger, void *user_data)
|
||||
{
|
||||
ril_devmon_ur_io_set_cell_info_update_interval(user_data);
|
||||
}
|
||||
|
||||
static void ril_devmon_ur_io_display_cb(MceDisplay *display, void *user_data)
|
||||
{
|
||||
DevMonIo *self = user_data;
|
||||
const gboolean display_on = ril_devmon_ur_display_on(display);
|
||||
|
||||
if (self->display_on != display_on) {
|
||||
self->display_on = display_on;
|
||||
ril_devmon_ur_io_set_unsol_response_filter(self);
|
||||
ril_devmon_ur_io_set_cell_info_update_interval(self);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_devmon_ur_io_free(struct ril_devmon_io *devmon_io)
|
||||
{
|
||||
DevMonIo *self = ril_devmon_ur_io_cast(devmon_io);
|
||||
|
||||
mce_battery_remove_all_handlers(self->battery, self->battery_event_id);
|
||||
mce_battery_unref(self->battery);
|
||||
|
||||
mce_charger_remove_all_handlers(self->charger, self->charger_event_id);
|
||||
mce_charger_unref(self->charger);
|
||||
|
||||
mce_display_remove_all_handlers(self->display, self->display_event_id);
|
||||
mce_display_unref(self->display);
|
||||
|
||||
grilio_channel_cancel_request(self->io, self->req_id, FALSE);
|
||||
grilio_channel_unref(self->io);
|
||||
|
||||
sailfish_cell_info_unref(self->cell_info);
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
static struct ril_devmon_io *ril_devmon_ur_start_io(struct ril_devmon *devmon,
|
||||
GRilIoChannel *io, struct sailfish_cell_info *cell_info)
|
||||
{
|
||||
DevMon *ur = ril_devmon_ur_cast(devmon);
|
||||
DevMonIo *self = g_new0(DevMonIo, 1);
|
||||
|
||||
self->pub.free = ril_devmon_ur_io_free;
|
||||
self->unsol_filter_supported = TRUE;
|
||||
self->io = grilio_channel_ref(io);
|
||||
self->cell_info = sailfish_cell_info_ref(cell_info);
|
||||
|
||||
self->battery = mce_battery_ref(ur->battery);
|
||||
self->battery_event_id[BATTERY_EVENT_VALID] =
|
||||
mce_battery_add_valid_changed_handler(self->battery,
|
||||
ril_devmon_ur_io_battery_cb, self);
|
||||
self->battery_event_id[BATTERY_EVENT_STATUS] =
|
||||
mce_battery_add_status_changed_handler(self->battery,
|
||||
ril_devmon_ur_io_battery_cb, self);
|
||||
|
||||
self->charger = mce_charger_ref(ur->charger);
|
||||
self->charger_event_id[CHARGER_EVENT_VALID] =
|
||||
mce_charger_add_valid_changed_handler(self->charger,
|
||||
ril_devmon_ur_io_charger_cb, self);
|
||||
self->charger_event_id[CHARGER_EVENT_STATE] =
|
||||
mce_charger_add_state_changed_handler(self->charger,
|
||||
ril_devmon_ur_io_charger_cb, self);
|
||||
|
||||
self->display = mce_display_ref(ur->display);
|
||||
self->display_on = ril_devmon_ur_display_on(self->display);
|
||||
self->display_event_id[DISPLAY_EVENT_VALID] =
|
||||
mce_display_add_valid_changed_handler(self->display,
|
||||
ril_devmon_ur_io_display_cb, self);
|
||||
self->display_event_id[DISPLAY_EVENT_STATE] =
|
||||
mce_display_add_state_changed_handler(self->display,
|
||||
ril_devmon_ur_io_display_cb, self);
|
||||
|
||||
self->cell_info_interval_short_ms =
|
||||
ur->cell_info_interval_short_ms;
|
||||
self->cell_info_interval_long_ms =
|
||||
ur->cell_info_interval_long_ms;
|
||||
|
||||
ril_devmon_ur_io_set_unsol_response_filter(self);
|
||||
ril_devmon_ur_io_set_cell_info_update_interval(self);
|
||||
return &self->pub;
|
||||
}
|
||||
|
||||
static void ril_devmon_ur_free(struct ril_devmon *devmon)
|
||||
{
|
||||
DevMon *self = ril_devmon_ur_cast(devmon);
|
||||
|
||||
mce_battery_unref(self->battery);
|
||||
mce_charger_unref(self->charger);
|
||||
mce_display_unref(self->display);
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
struct ril_devmon *ril_devmon_ur_new(const struct ril_slot_config *config)
|
||||
{
|
||||
DevMon *self = g_new0(DevMon, 1);
|
||||
|
||||
self->pub.free = ril_devmon_ur_free;
|
||||
self->pub.start_io = ril_devmon_ur_start_io;
|
||||
self->battery = mce_battery_new();
|
||||
self->charger = mce_charger_new();
|
||||
self->display = mce_display_new();
|
||||
self->cell_info_interval_short_ms =
|
||||
config->cell_info_interval_short_ms;
|
||||
self->cell_info_interval_long_ms =
|
||||
config->cell_info_interval_long_ms;
|
||||
return &self->pub;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2019 Jolla Ltd.
|
||||
* Copyright (C) 2015-2020 Jolla Ltd.
|
||||
* Copyright (C) 2019 Open Mobile Platform LLC.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
#include <ofono/watch.h>
|
||||
|
||||
#define MAX_PDP_CONTEXTS (2)
|
||||
#define ONLINE_TIMEOUT_SECS (15) /* 20 sec is hardcoded in ofono core */
|
||||
|
||||
enum ril_modem_power_state {
|
||||
@@ -219,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)
|
||||
{
|
||||
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 */
|
||||
if (!ril_modem_radio_settings(m)) {
|
||||
if (!rs) {
|
||||
DBG_(md, "initializing radio settings interface");
|
||||
ofono_radio_settings_create(m->ofono, 0,
|
||||
RILMODEM_DRIVER, md);
|
||||
}
|
||||
} else if (rs) {
|
||||
DBG_(md, "removing radio settings interface");
|
||||
ofono_radio_settings_remove(rs);
|
||||
} else {
|
||||
/* ofono core may remove radio settings atom internally */
|
||||
struct ofono_radio_settings *rs = ril_modem_radio_settings(m);
|
||||
if (rs) {
|
||||
DBG_(md, "removing radio settings interface");
|
||||
ofono_radio_settings_remove(rs);
|
||||
} else {
|
||||
DBG_(md, "radio settings interface is already gone");
|
||||
}
|
||||
DBG_(md, "radio settings interface is already gone");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +241,6 @@ static void ril_modem_radio_state_cb(struct ril_radio *radio, void *data)
|
||||
struct ril_modem_data *md = data;
|
||||
|
||||
GASSERT(md->modem.radio == radio);
|
||||
ril_modem_update_radio_settings(md);
|
||||
ril_modem_update_online_state(md);
|
||||
}
|
||||
|
||||
@@ -307,15 +304,22 @@ static void ril_modem_post_sim(struct ofono_modem *modem)
|
||||
ofono_sms_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
gprs = ofono_gprs_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
if (gprs) {
|
||||
int i;
|
||||
guint i;
|
||||
static const enum ofono_gprs_context_type ap_types[] = {
|
||||
OFONO_GPRS_CONTEXT_TYPE_INTERNET,
|
||||
OFONO_GPRS_CONTEXT_TYPE_MMS,
|
||||
OFONO_GPRS_CONTEXT_TYPE_IMS
|
||||
};
|
||||
|
||||
for (i = 0; i < MAX_PDP_CONTEXTS; i++) {
|
||||
/* Create a context for each type */
|
||||
for (i = 0; i < G_N_ELEMENTS(ap_types); i++) {
|
||||
struct ofono_gprs_context *gc =
|
||||
ofono_gprs_context_create(modem, 0,
|
||||
RILMODEM_DRIVER, md);
|
||||
if (gc == NULL)
|
||||
break;
|
||||
|
||||
ofono_gprs_context_set_type(gc, ap_types[i]);
|
||||
ofono_gprs_add_context(gprs, gc);
|
||||
}
|
||||
}
|
||||
@@ -417,7 +421,9 @@ static void ril_modem_remove(struct ofono_modem *ofono)
|
||||
ofono_modem_set_data(ofono, NULL);
|
||||
|
||||
ril_radio_remove_handler(modem->radio, md->radio_state_event_id);
|
||||
ril_radio_set_online(modem->radio, FALSE);
|
||||
ril_radio_power_off(modem->radio, RADIO_POWER_TAG(md));
|
||||
ril_radio_set_online(modem->radio, FALSE);
|
||||
ril_radio_unref(modem->radio);
|
||||
ril_sim_settings_unref(modem->sim_settings);
|
||||
|
||||
|
||||
@@ -20,10 +20,12 @@
|
||||
#include "ril_vendor.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "ofono.h"
|
||||
#include "common.h"
|
||||
#include "simutil.h"
|
||||
|
||||
#define REGISTRATION_TIMEOUT (100*1000) /* ms */
|
||||
#include <ofono/watch.h>
|
||||
|
||||
#define REGISTRATION_MAX_RETRIES (2)
|
||||
|
||||
enum ril_netreg_events {
|
||||
@@ -41,9 +43,11 @@ enum ril_netreg_network_events {
|
||||
struct ril_netreg {
|
||||
GRilIoChannel *io;
|
||||
GRilIoQueue *q;
|
||||
gboolean replace_strange_oper;
|
||||
gboolean network_selection_manual_0;
|
||||
int signal_strength_dbm_weak;
|
||||
int signal_strength_dbm_strong;
|
||||
struct ofono_watch *watch;
|
||||
struct ofono_netreg *netreg;
|
||||
struct ril_network *network;
|
||||
struct ril_vendor *vendor;
|
||||
@@ -53,6 +57,7 @@ struct ril_netreg {
|
||||
guint current_operator_id;
|
||||
gulong ril_event_id[NETREG_RIL_EVENT_COUNT];
|
||||
gulong network_event_id[NETREG_NETWORK_EVENT_COUNT];
|
||||
int network_selection_timeout;
|
||||
};
|
||||
|
||||
struct ril_netreg_cbd {
|
||||
@@ -192,11 +197,74 @@ static void ril_netreg_current_operator(struct ofono_netreg *netreg,
|
||||
ril_netreg_cbd_free);
|
||||
}
|
||||
|
||||
static gboolean ril_netreg_strange(const struct ofono_network_operator *op,
|
||||
struct ofono_sim *sim)
|
||||
{
|
||||
gsize mcclen;
|
||||
|
||||
if (sim && op->status != OPERATOR_STATUS_CURRENT) {
|
||||
const char *spn = ofono_sim_get_spn(sim);
|
||||
const char *mcc = ofono_sim_get_mcc(sim);
|
||||
const char *mnc = ofono_sim_get_mnc(sim);
|
||||
|
||||
if (spn && mcc && mnc && !strcmp(op->name, spn) &&
|
||||
(strcmp(op->mcc, mcc) || strcmp(op->mnc, mnc))) {
|
||||
/*
|
||||
* Status is not "current", SPN matches the SIM, but
|
||||
* MCC and/or MNC don't (e.g. Sony Xperia X where all
|
||||
* operators could be reported with the same name
|
||||
* which equals SPN).
|
||||
*/
|
||||
DBG("%s %s%s (sim spn?)", op->name, op->mcc, op->mnc);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
mcclen = strlen(op->mcc);
|
||||
if (!strncmp(op->name, op->mcc, mcclen) &&
|
||||
!strcmp(op->name + mcclen, op->mnc)) {
|
||||
/* Some MediaTek RILs only report numeric operator name */
|
||||
DBG("%s %s%s (numeric?)", op->name, op->mcc, op->mnc);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void ril_netreg_process_operators(struct ril_netreg *nd,
|
||||
struct ofono_network_operator *ops, int nops)
|
||||
{
|
||||
if (nd->replace_strange_oper) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nops; i++) {
|
||||
struct ofono_network_operator *op = ops + i;
|
||||
struct ofono_gprs_provision_data *prov = NULL;
|
||||
int np = 0;
|
||||
|
||||
if (ril_netreg_strange(op, nd->watch->sim) &&
|
||||
__ofono_gprs_provision_get_settings(op->mcc,
|
||||
op->mnc, NULL, &prov, &np)) {
|
||||
/* Use the first entry */
|
||||
if (np > 0 && prov->provider_name &&
|
||||
prov->provider_name[0]) {
|
||||
DBG("%s %s%s -> %s", op->name, op->mcc,
|
||||
op->mnc, prov->provider_name);
|
||||
strncpy(op->name, prov->provider_name,
|
||||
OFONO_MAX_OPERATOR_NAME_LENGTH);
|
||||
}
|
||||
__ofono_gprs_provision_free_settings(prov, np);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_netreg_list_operators_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_netreg_cbd *cbd = user_data;
|
||||
ofono_netreg_operator_list_cb_t cb = cbd->cb.operator_list;
|
||||
struct ril_netreg *nd = cbd->nd;
|
||||
struct ofono_network_operator *list;
|
||||
struct ofono_error error;
|
||||
int noperators = 0, i;
|
||||
@@ -238,21 +306,23 @@ static void ril_netreg_list_operators_cb(GRilIoChannel *io, int status,
|
||||
}
|
||||
|
||||
/* Set the proper status */
|
||||
if (!strcmp(status, "available")) {
|
||||
list[i].status = OPERATOR_STATUS_AVAILABLE;
|
||||
if (!status) {
|
||||
op->status = OPERATOR_STATUS_UNKNOWN;
|
||||
} else if (!strcmp(status, "available")) {
|
||||
op->status = OPERATOR_STATUS_AVAILABLE;
|
||||
} else if (!strcmp(status, "current")) {
|
||||
list[i].status = OPERATOR_STATUS_CURRENT;
|
||||
op->status = OPERATOR_STATUS_CURRENT;
|
||||
} else if (!strcmp(status, "forbidden")) {
|
||||
list[i].status = OPERATOR_STATUS_FORBIDDEN;
|
||||
op->status = OPERATOR_STATUS_FORBIDDEN;
|
||||
} else {
|
||||
list[i].status = OPERATOR_STATUS_UNKNOWN;
|
||||
op->status = OPERATOR_STATUS_UNKNOWN;
|
||||
}
|
||||
|
||||
op->tech = -1;
|
||||
ok = ril_parse_mcc_mnc(numeric, op);
|
||||
if (ok) {
|
||||
if (op->tech < 0) {
|
||||
op->tech = cbd->nd->network->voice.access_tech;
|
||||
op->tech = nd->network->voice.access_tech;
|
||||
}
|
||||
DBG("[operator=%s, %s, %s, status: %s]", op->name,
|
||||
op->mcc, op->mnc, status);
|
||||
@@ -267,6 +337,7 @@ static void ril_netreg_list_operators_cb(GRilIoChannel *io, int status,
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
ril_netreg_process_operators(nd, list, noperators);
|
||||
cb(ril_error_ok(&error), noperators, list, cbd->data);
|
||||
} else {
|
||||
cb(ril_error_failure(&error), 0, NULL, cbd->data);
|
||||
@@ -301,18 +372,55 @@ static void ril_netreg_register_cb(GRilIoChannel *io, int status,
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_netreg_set_register_auto(struct ril_netreg *nd,
|
||||
ofono_netreg_register_cb_t cb, void *data)
|
||||
{
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
ofono_info("nw select automatic");
|
||||
grilio_request_set_timeout(req, nd->network_selection_timeout);
|
||||
grilio_request_set_retry(req, 0, REGISTRATION_MAX_RETRIES);
|
||||
grilio_queue_send_request_full(nd->q, req,
|
||||
RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC,
|
||||
ril_netreg_register_cb, ril_netreg_cbd_free,
|
||||
ril_netreg_cbd_new(nd, cb, data));
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_netreg_query_register_auto_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len,
|
||||
void *user_data)
|
||||
{
|
||||
struct ril_netreg_cbd *cbd = user_data;
|
||||
ofono_netreg_register_cb_t cb = cbd->cb.reg;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
GRilIoParser rilp;
|
||||
gint32 net_mode;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
if (grilio_parser_get_int32(&rilp, NULL) /* Array length */ &&
|
||||
grilio_parser_get_int32(&rilp, &net_mode) &&
|
||||
net_mode == RIL_NETWORK_SELECTION_MODE_AUTO) {
|
||||
struct ofono_error error;
|
||||
ofono_info("nw selection is already auto");
|
||||
cb(ril_error_ok(&error), cbd->data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ril_netreg_set_register_auto(cbd->nd, cb, cbd->data);
|
||||
}
|
||||
|
||||
static void ril_netreg_register_auto(struct ofono_netreg *netreg,
|
||||
ofono_netreg_register_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_netreg *nd = ril_netreg_get_data(netreg);
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
ofono_info("nw select automatic");
|
||||
grilio_request_set_timeout(req, REGISTRATION_TIMEOUT);
|
||||
grilio_request_set_retry(req, 0, REGISTRATION_MAX_RETRIES);
|
||||
grilio_queue_send_request_full(nd->q, req,
|
||||
RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC,
|
||||
ril_netreg_register_cb, ril_netreg_cbd_free,
|
||||
RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE,
|
||||
ril_netreg_query_register_auto_cb, ril_netreg_cbd_free,
|
||||
ril_netreg_cbd_new(nd, cb, data));
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
@@ -327,7 +435,7 @@ static void ril_netreg_register_manual(struct ofono_netreg *netreg,
|
||||
|
||||
ofono_info("nw select manual: %s%s%s", mcc, mnc, suffix);
|
||||
grilio_request_append_format(req, "%s%s%s", mcc, mnc, suffix);
|
||||
grilio_request_set_timeout(req, REGISTRATION_TIMEOUT);
|
||||
grilio_request_set_timeout(req, nd->network_selection_timeout);
|
||||
grilio_request_set_retry(req, 0, REGISTRATION_MAX_RETRIES);
|
||||
grilio_queue_send_request_full(nd->q, req,
|
||||
RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
|
||||
@@ -557,12 +665,15 @@ static int ril_netreg_probe(struct ofono_netreg *netreg, unsigned int vendor,
|
||||
DBG_(nd, "%p", netreg);
|
||||
nd->io = grilio_channel_ref(ril_modem_io(modem));
|
||||
nd->q = grilio_queue_new(nd->io);
|
||||
nd->watch = ofono_watch_new(ril_modem_get_path(modem));
|
||||
nd->vendor = ril_vendor_ref(modem->vendor);
|
||||
nd->network = ril_network_ref(modem->network);
|
||||
nd->netreg = netreg;
|
||||
nd->replace_strange_oper = config->replace_strange_oper;
|
||||
nd->network_selection_manual_0 = config->network_selection_manual_0;
|
||||
nd->signal_strength_dbm_weak = config->signal_strength_dbm_weak;
|
||||
nd->signal_strength_dbm_strong = config->signal_strength_dbm_strong;
|
||||
nd->network_selection_timeout = config->network_selection_timeout;
|
||||
|
||||
ofono_netreg_set_data(netreg, nd);
|
||||
nd->timer_id = g_idle_add(ril_netreg_register, nd);
|
||||
@@ -589,6 +700,7 @@ static void ril_netreg_remove(struct ofono_netreg *netreg)
|
||||
g_source_remove(nd->current_operator_id);
|
||||
}
|
||||
|
||||
ofono_watch_unref(nd->watch);
|
||||
ril_network_remove_all_handlers(nd->network, nd->network_event_id);
|
||||
ril_network_unref(nd->network);
|
||||
ril_vendor_unref(nd->vendor);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "ril_network.h"
|
||||
#include "ril_radio.h"
|
||||
#include "ril_radio_caps.h"
|
||||
#include "ril_sim_card.h"
|
||||
#include "ril_sim_settings.h"
|
||||
#include "ril_vendor.h"
|
||||
@@ -35,6 +36,7 @@
|
||||
#include <ofono/watch.h>
|
||||
#include <ofono/gprs.h>
|
||||
|
||||
#include "ofono.h"
|
||||
#include "common.h"
|
||||
|
||||
#define SET_PREF_MODE_HOLDOFF_SEC RIL_RETRY_SECS
|
||||
@@ -54,6 +56,12 @@ enum ril_network_radio_event {
|
||||
RADIO_EVENT_COUNT
|
||||
};
|
||||
|
||||
enum ril_network_radio_caps_mgr_events {
|
||||
RADIO_CAPS_MGR_TX_DONE,
|
||||
RADIO_CAPS_MGR_TX_ABORTED,
|
||||
RADIO_CAPS_MGR_EVENT_COUNT
|
||||
};
|
||||
|
||||
enum ril_network_sim_events {
|
||||
SIM_EVENT_STATUS_CHANGED,
|
||||
SIM_EVENT_IO_ACTIVE_CHANGED,
|
||||
@@ -62,7 +70,6 @@ enum ril_network_sim_events {
|
||||
|
||||
enum ril_network_unsol_event {
|
||||
UNSOL_EVENT_NETWORK_STATE,
|
||||
UNSOL_EVENT_RADIO_CAPABILITY,
|
||||
UNSOL_EVENT_COUNT
|
||||
};
|
||||
|
||||
@@ -90,6 +97,7 @@ struct ril_network_priv {
|
||||
GRilIoChannel *io;
|
||||
GRilIoQueue *q;
|
||||
struct ril_radio *radio;
|
||||
struct ril_radio_caps *caps;
|
||||
struct ril_sim_card *simcard;
|
||||
struct ril_vendor *vendor;
|
||||
struct ofono_watch *watch;
|
||||
@@ -106,6 +114,8 @@ struct ril_network_priv {
|
||||
gulong set_rat_id;
|
||||
gulong unsol_event_id[UNSOL_EVENT_COUNT];
|
||||
gulong settings_event_id;
|
||||
gulong supported_modes_event_id;
|
||||
gulong caps_mgr_event_id[RADIO_CAPS_MGR_EVENT_COUNT];
|
||||
gulong radio_event_id[RADIO_EVENT_COUNT];
|
||||
gulong simcard_event_id[SIM_EVENT_COUNT];
|
||||
gulong watch_ids[WATCH_EVENT_COUNT];
|
||||
@@ -125,7 +135,6 @@ enum ril_network_signal {
|
||||
SIGNAL_VOICE_STATE_CHANGED,
|
||||
SIGNAL_DATA_STATE_CHANGED,
|
||||
SIGNAL_PREF_MODE_CHANGED,
|
||||
SIGNAL_MAX_PREF_MODE_CHANGED,
|
||||
SIGNAL_COUNT
|
||||
};
|
||||
|
||||
@@ -133,7 +142,6 @@ enum ril_network_signal {
|
||||
#define SIGNAL_VOICE_STATE_CHANGED_NAME "ril-network-voice-state-changed"
|
||||
#define SIGNAL_DATA_STATE_CHANGED_NAME "ril-network-data-state-changed"
|
||||
#define SIGNAL_PREF_MODE_CHANGED_NAME "ril-network-pref-mode-changed"
|
||||
#define SIGNAL_MAX_PREF_MODE_CHANGED_NAME "ril-network-max-pref-mode-changed"
|
||||
|
||||
static guint ril_network_signals[SIGNAL_COUNT] = { 0 };
|
||||
|
||||
@@ -419,6 +427,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,
|
||||
int code, GRilIoChannelResponseFunc fn)
|
||||
{
|
||||
@@ -431,6 +451,7 @@ static guint ril_network_poll_and_retry(struct ril_network *self, guint 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);
|
||||
id = grilio_queue_send_request_full(priv->q, req, code, fn,
|
||||
NULL, self);
|
||||
grilio_request_unref(req);
|
||||
@@ -512,6 +533,17 @@ static int ril_network_mode_to_rat(struct ril_network *self,
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -535,9 +567,16 @@ static enum ofono_radio_access_mode ril_network_actual_pref_mode
|
||||
* and max_pref_mode are not ANY, we pick the smallest value.
|
||||
* Otherwise we take any non-zero value if there is one.
|
||||
*/
|
||||
return (settings->pref_mode && max_pref_mode) ?
|
||||
const enum ofono_radio_access_mode pref_mode =
|
||||
(settings->pref_mode && max_pref_mode) ?
|
||||
MIN(settings->pref_mode, max_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 =
|
||||
ril_network_max_supported_mode(self);
|
||||
|
||||
return pref_mode ? MIN(pref_mode, max_mode) : max_mode;
|
||||
}
|
||||
|
||||
static gboolean ril_network_need_initial_attach_apn(struct ril_network *self)
|
||||
@@ -548,9 +587,9 @@ static gboolean ril_network_need_initial_attach_apn(struct ril_network *self)
|
||||
|
||||
if (watch->gprs && radio->state == RADIO_STATE_ON) {
|
||||
switch (ril_network_actual_pref_mode(self)) {
|
||||
case OFONO_RADIO_ACCESS_MODE_ANY:
|
||||
case OFONO_RADIO_ACCESS_MODE_LTE:
|
||||
return TRUE;
|
||||
case OFONO_RADIO_ACCESS_MODE_ANY:
|
||||
case OFONO_RADIO_ACCESS_MODE_UMTS:
|
||||
case OFONO_RADIO_ACCESS_MODE_GSM:
|
||||
break;
|
||||
@@ -955,6 +994,14 @@ static void ril_network_check_pref_mode(struct ril_network *self,
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_network_assert_pref_mode(struct ril_network *self)
|
||||
{
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
priv->assert_rat = TRUE;
|
||||
ril_network_check_pref_mode(self, FALSE);
|
||||
}
|
||||
|
||||
static int ril_network_parse_pref_resp(const void *data, guint len)
|
||||
{
|
||||
GRilIoParser rilp;
|
||||
@@ -984,10 +1031,10 @@ static void ril_network_startup_query_pref_mode_cb(GRilIoChannel *io,
|
||||
}
|
||||
|
||||
/*
|
||||
* Unlike ril_network_query_pref_mode_cb, this one always
|
||||
* checks the preferred mode.
|
||||
* At startup, the device may have an inconsistency between
|
||||
* voice and data network modes, so it needs to be asserted.
|
||||
*/
|
||||
ril_network_check_pref_mode(self, FALSE);
|
||||
ril_network_assert_pref_mode(self);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -998,22 +1045,22 @@ static void ril_network_query_pref_mode_cb(GRilIoChannel *io, int status,
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
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);
|
||||
|
||||
priv->query_rat_id = 0;
|
||||
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,
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
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));
|
||||
|
||||
if (self->pref_mode != pref_mode) {
|
||||
ril_network_emit(self, SIGNAL_PREF_MODE_CHANGED);
|
||||
}
|
||||
if (self->pref_mode != pref_mode) {
|
||||
ril_network_emit(self, SIGNAL_PREF_MODE_CHANGED);
|
||||
}
|
||||
|
||||
if (ril_network_can_set_pref_mode(self)) {
|
||||
ril_network_check_pref_mode(self, FALSE);
|
||||
if (ril_network_can_set_pref_mode(self)) {
|
||||
ril_network_check_pref_mode(self, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1023,6 +1070,7 @@ static void ril_network_query_pref_mode(struct ril_network *self)
|
||||
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, priv->query_rat_id, FALSE);
|
||||
priv->query_rat_id = grilio_queue_send_request_full(priv->q, req,
|
||||
RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE,
|
||||
@@ -1039,19 +1087,79 @@ void ril_network_set_max_pref_mode(struct ril_network *self,
|
||||
DBG_(self, "rat mode %d (%s)", max_mode,
|
||||
ofono_radio_access_mode_to_string(max_mode));
|
||||
self->max_pref_mode = max_mode;
|
||||
ril_network_emit(self, SIGNAL_MAX_PREF_MODE_CHANGED);
|
||||
ril_network_check_initial_attach_apn(self);
|
||||
}
|
||||
ril_network_check_pref_mode(self, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
void ril_network_assert_pref_mode(struct ril_network *self, gboolean immediate)
|
||||
static void ril_network_supported_modes_handler(struct ril_radio_caps *caps,
|
||||
void *user_data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(user_data);
|
||||
|
||||
DBG_(self, "%s", ofono_radio_access_mode_to_string
|
||||
(caps->supported_modes));
|
||||
ril_network_check_pref_mode(self, TRUE);
|
||||
}
|
||||
|
||||
static void ril_network_radio_capability_tx_done_cb
|
||||
(struct ril_radio_caps_manager *mgr, void *user_data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(user_data);
|
||||
|
||||
DBG_(self, "");
|
||||
ril_network_assert_pref_mode(self);
|
||||
}
|
||||
|
||||
static void ril_network_release_radio_caps(struct ril_network *self)
|
||||
{
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
struct ril_radio_caps *caps = priv->caps;
|
||||
|
||||
if (caps) {
|
||||
ril_radio_caps_manager_remove_all_handlers(caps->mgr,
|
||||
priv->caps_mgr_event_id);
|
||||
ril_radio_caps_remove_handler(caps,
|
||||
priv->supported_modes_event_id);
|
||||
ril_radio_caps_unref(caps);
|
||||
|
||||
priv->caps = NULL;
|
||||
priv->supported_modes_event_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_network_attach_radio_caps(struct ril_network *self,
|
||||
struct ril_radio_caps *caps)
|
||||
{
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
priv->assert_rat = TRUE;
|
||||
ril_network_check_pref_mode(self, immediate);
|
||||
priv->caps = ril_radio_caps_ref(caps);
|
||||
priv->supported_modes_event_id =
|
||||
ril_radio_caps_add_supported_modes_handler(caps,
|
||||
ril_network_supported_modes_handler, self);
|
||||
priv->caps_mgr_event_id[RADIO_CAPS_MGR_TX_DONE] =
|
||||
ril_radio_caps_manager_add_tx_done_handler(caps->mgr,
|
||||
ril_network_radio_capability_tx_done_cb, self);
|
||||
priv->caps_mgr_event_id[RADIO_CAPS_MGR_TX_ABORTED] =
|
||||
ril_radio_caps_manager_add_tx_aborted_handler(caps->mgr,
|
||||
ril_network_radio_capability_tx_done_cb, self);
|
||||
}
|
||||
|
||||
void ril_network_set_radio_caps(struct ril_network *self,
|
||||
struct ril_radio_caps *caps)
|
||||
{
|
||||
if (self) {
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
if (priv->caps != caps) {
|
||||
ril_network_release_radio_caps(self);
|
||||
if (caps) {
|
||||
ril_network_attach_radio_caps(self, caps);
|
||||
}
|
||||
ril_network_check_pref_mode(self, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gulong ril_network_add_operator_changed_handler(struct ril_network *self,
|
||||
@@ -1082,13 +1190,6 @@ gulong ril_network_add_pref_mode_changed_handler(struct ril_network *self,
|
||||
SIGNAL_PREF_MODE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
gulong ril_network_add_max_pref_mode_changed_handler(struct ril_network *self,
|
||||
ril_network_cb_t cb, void *arg)
|
||||
{
|
||||
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
|
||||
SIGNAL_MAX_PREF_MODE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
void ril_network_remove_handler(struct ril_network *self, gulong id)
|
||||
{
|
||||
if (G_LIKELY(self) && G_LIKELY(id)) {
|
||||
@@ -1111,16 +1212,6 @@ static void ril_network_state_changed_cb(GRilIoChannel *io, guint code,
|
||||
ril_network_poll_state(self);
|
||||
}
|
||||
|
||||
static void ril_network_radio_capability_changed_cb(GRilIoChannel *io,
|
||||
guint code, const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(user_data);
|
||||
|
||||
DBG_(self, "");
|
||||
GASSERT(code == RIL_UNSOL_RADIO_CAPABILITY);
|
||||
ril_network_assert_pref_mode(self, FALSE);
|
||||
}
|
||||
|
||||
static void ril_network_radio_state_cb(struct ril_radio *radio, void *data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(data);
|
||||
@@ -1253,10 +1344,6 @@ struct ril_network *ril_network_new(const char *path, GRilIoChannel *io,
|
||||
grilio_channel_add_unsol_event_handler(priv->io,
|
||||
ril_network_state_changed_cb,
|
||||
RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, self);
|
||||
priv->unsol_event_id[UNSOL_EVENT_RADIO_CAPABILITY] =
|
||||
grilio_channel_add_unsol_event_handler(priv->io,
|
||||
ril_network_radio_capability_changed_cb,
|
||||
RIL_UNSOL_RADIO_CAPABILITY, self);
|
||||
|
||||
priv->radio_event_id[RADIO_EVENT_STATE_CHANGED] =
|
||||
ril_radio_add_state_changed_handler(priv->radio,
|
||||
@@ -1351,6 +1438,7 @@ static void ril_network_finalize(GObject *object)
|
||||
grilio_channel_remove_all_handlers(priv->io, priv->unsol_event_id);
|
||||
grilio_channel_unref(priv->io);
|
||||
grilio_queue_unref(priv->q);
|
||||
ril_network_release_radio_caps(self);
|
||||
ril_radio_remove_all_handlers(priv->radio, priv->radio_event_id);
|
||||
ril_radio_unref(priv->radio);
|
||||
ril_sim_card_remove_all_handlers(priv->simcard, priv->simcard_event_id);
|
||||
@@ -1372,7 +1460,6 @@ static void ril_network_class_init(RilNetworkClass *klass)
|
||||
RIL_NETWORK_SIGNAL(klass, VOICE_STATE);
|
||||
RIL_NETWORK_SIGNAL(klass, DATA_STATE);
|
||||
RIL_NETWORK_SIGNAL(klass, PREF_MODE);
|
||||
RIL_NETWORK_SIGNAL(klass, MAX_PREF_MODE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2019 Jolla Ltd.
|
||||
* 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
|
||||
@@ -21,6 +22,7 @@
|
||||
#include <glib-object.h>
|
||||
|
||||
struct ofono_network_operator;
|
||||
struct ril_radio_caps;
|
||||
|
||||
struct ril_registration_state {
|
||||
int status; /* enum network_registration_status */
|
||||
@@ -42,7 +44,6 @@ struct ril_network {
|
||||
struct ril_sim_settings *settings;
|
||||
};
|
||||
|
||||
struct ofono_sim;
|
||||
typedef void (*ril_network_cb_t)(struct ril_network *net, void *arg);
|
||||
|
||||
struct ril_network *ril_network_new(const char *path, GRilIoChannel *io,
|
||||
@@ -54,10 +55,13 @@ struct ril_network *ril_network_new(const char *path, GRilIoChannel *io,
|
||||
struct ril_network *ril_network_ref(struct ril_network *net);
|
||||
void ril_network_unref(struct ril_network *net);
|
||||
|
||||
void ril_network_set_radio_caps(struct ril_network *net,
|
||||
struct ril_radio_caps *caps);
|
||||
void ril_network_set_max_pref_mode(struct ril_network *net,
|
||||
enum ofono_radio_access_mode max_pref_mode,
|
||||
gboolean force_check);
|
||||
void ril_network_assert_pref_mode(struct ril_network *net, gboolean immediate);
|
||||
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);
|
||||
@@ -67,8 +71,6 @@ gulong ril_network_add_data_state_changed_handler(struct ril_network *net,
|
||||
ril_network_cb_t cb, void *arg);
|
||||
gulong ril_network_add_pref_mode_changed_handler(struct ril_network *net,
|
||||
ril_network_cb_t cb, void *arg);
|
||||
gulong ril_network_add_max_pref_mode_changed_handler(struct ril_network *net,
|
||||
ril_network_cb_t cb, void *arg);
|
||||
void ril_network_remove_handler(struct ril_network *net, gulong id);
|
||||
void ril_network_remove_handlers(struct ril_network *net, gulong *ids, int n);
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
* 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
|
||||
@@ -32,6 +33,11 @@ struct ril_oem_raw {
|
||||
|
||||
#define DBG_(oem,fmt,args...) DBG("%s" fmt, (oem)->log_prefix, ##args)
|
||||
|
||||
static void ril_oem_raw_send_done(void *msg)
|
||||
{
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
static void ril_oem_raw_send_cb(GRilIoChannel *io, int ril_status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
@@ -40,20 +46,13 @@ static void ril_oem_raw_send_cb(GRilIoChannel *io, int ril_status,
|
||||
|
||||
if (ril_status == RIL_E_SUCCESS) {
|
||||
DBusMessageIter it, array;
|
||||
const guchar* bytes = data;
|
||||
guint i;
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
dbus_message_iter_init_append(reply, &it);
|
||||
dbus_message_iter_open_container(&it, DBUS_TYPE_ARRAY,
|
||||
DBUS_TYPE_BYTE_AS_STRING, &array);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
guchar byte = bytes[i];
|
||||
dbus_message_iter_append_basic(&array, DBUS_TYPE_BYTE,
|
||||
&byte);
|
||||
}
|
||||
|
||||
dbus_message_iter_append_fixed_array(&array, DBUS_TYPE_BYTE,
|
||||
&data, len);
|
||||
dbus_message_iter_close_container(&it, &array);
|
||||
} else if (ril_status == GRILIO_STATUS_TIMEOUT) {
|
||||
DBG("Timed out");
|
||||
@@ -63,7 +62,7 @@ static void ril_oem_raw_send_cb(GRilIoChannel *io, int ril_status,
|
||||
reply = __ofono_error_failed(msg);
|
||||
}
|
||||
|
||||
__ofono_dbus_pending_reply(&msg, reply);
|
||||
g_dbus_send_message(ofono_dbus_get_connection(), reply);
|
||||
}
|
||||
|
||||
static DBusMessage *ril_oem_raw_send(DBusConnection *conn, DBusMessage *msg,
|
||||
@@ -72,6 +71,12 @@ static DBusMessage *ril_oem_raw_send(DBusConnection *conn, DBusMessage *msg,
|
||||
DBusMessageIter it;
|
||||
struct ril_oem_raw *oem = user_data;
|
||||
|
||||
if (!__ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
OFONO_DBUS_ACCESS_INTF_OEMRAW,
|
||||
OFONO_DBUS_ACCESS_OEMRAW_SEND, NULL)) {
|
||||
return __ofono_error_access_denied(msg);
|
||||
}
|
||||
|
||||
dbus_message_iter_init(msg, &it);
|
||||
if (dbus_message_iter_get_arg_type(&it) == DBUS_TYPE_ARRAY &&
|
||||
dbus_message_iter_get_element_type(&it) == DBUS_TYPE_BYTE) {
|
||||
@@ -94,7 +99,7 @@ static DBusMessage *ril_oem_raw_send(DBusConnection *conn, DBusMessage *msg,
|
||||
grilio_request_append_bytes(req, data, data_len);
|
||||
grilio_queue_send_request_full(oem->q, req,
|
||||
RIL_REQUEST_OEM_HOOK_RAW, ril_oem_raw_send_cb,
|
||||
NULL, dbus_message_ref(msg));
|
||||
ril_oem_raw_send_done, dbus_message_ref(msg));
|
||||
grilio_request_unref(req);
|
||||
return NULL;
|
||||
} else {
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
#define RILMODEM_DEFAULT_LTE_MODE PREF_NET_TYPE_LTE_GSM_WCDMA
|
||||
#define RILMODEM_DEFAULT_UMTS_MODE PREF_NET_TYPE_GSM_WCDMA_AUTO
|
||||
#define RILMODEM_DEFAULT_NETWORK_MODE_TIMEOUT (20*1000) /* ms */
|
||||
#define RILMODEM_DEFAULT_NETWORK_SELECTION_TIMEOUT (100*1000) /* ms */
|
||||
#define RILMODEM_DEFAULT_DBM_WEAK (-100) /* very weak, 0.0000000001 mW */
|
||||
#define RILMODEM_DEFAULT_DBM_STRONG (-60) /* strong signal, 0.000001 mW */
|
||||
#define RILMODEM_DEFAULT_ENABLE_VOICECALL TRUE
|
||||
@@ -93,11 +94,14 @@
|
||||
#define RILMODEM_DEFAULT_LEGACY_IMEI_QUERY FALSE
|
||||
#define RILMODEM_DEFAULT_RADIO_POWER_CYCLE TRUE
|
||||
#define RILMODEM_DEFAULT_CONFIRM_RADIO_POWER_ON TRUE
|
||||
#define RILMODEM_DEFAULT_REPLACE_STRANGE_OPER FALSE
|
||||
#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
|
||||
#define RILMODEM_DEFAULT_CELL_INFO_INTERVAL_SHORT_MS (2000) /* 2 sec */
|
||||
#define RILMODEM_DEFAULT_CELL_INFO_INTERVAL_LONG_MS (30000) /* 30 sec */
|
||||
|
||||
/* RIL socket transport name and parameters */
|
||||
#define RIL_TRANSPORT_MODEM "modem"
|
||||
@@ -134,6 +138,7 @@
|
||||
#define RILCONF_LTE_MODE "lteNetworkMode"
|
||||
#define RILCONF_UMTS_MODE "umtsNetworkMode"
|
||||
#define RILCONF_NETWORK_MODE_TIMEOUT "networkModeTimeout"
|
||||
#define RILCONF_NETWORK_SELECTION_TIMEOUT "networkSelectionTimeout"
|
||||
#define RILCONF_SIGNAL_STRENGTH_RANGE "signalStrengthRange"
|
||||
#define RILCONF_UICC_WORKAROUND "uiccWorkaround"
|
||||
#define RILCONF_ECCLIST_FILE "ecclistFile"
|
||||
@@ -149,11 +154,14 @@
|
||||
#define RILCONF_RADIO_POWER_CYCLE "radioPowerCycle"
|
||||
#define RILCONF_CONFIRM_RADIO_POWER_ON "confirmRadioPowerOn"
|
||||
#define RILCONF_SINGLE_DATA_CONTEXT "singleDataContext"
|
||||
#define RILCONF_REPLACE_STRANGE_OPER "replaceStrangeOperatorNames"
|
||||
#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"
|
||||
#define RILCONF_CELL_INFO_INTERVAL_SHORT_MS "cellInfoIntervalShortMs"
|
||||
#define RILCONF_CELL_INFO_INTERVAL_LONG_MS "cellInfoIntervalLongMs"
|
||||
|
||||
/* Modem error ids */
|
||||
#define RIL_ERROR_ID_RILD_RESTART "rild-restart"
|
||||
@@ -179,10 +187,9 @@ enum ril_set_radio_cap_opt {
|
||||
};
|
||||
|
||||
enum ril_devmon_opt {
|
||||
RIL_DEVMON_NONE,
|
||||
RIL_DEVMON_AUTO,
|
||||
RIL_DEVMON_SS,
|
||||
RIL_DEVMON_DS
|
||||
RIL_DEVMON_SS = 0x01,
|
||||
RIL_DEVMON_DS = 0x02,
|
||||
RIL_DEVMON_UR = 0x04
|
||||
};
|
||||
|
||||
struct ril_plugin_identity {
|
||||
@@ -227,6 +234,7 @@ typedef struct sailfish_slot_impl {
|
||||
struct ril_modem *modem;
|
||||
struct ril_radio *radio;
|
||||
struct ril_radio_caps *caps;
|
||||
struct ril_radio_caps_request *caps_req;
|
||||
struct ril_network *network;
|
||||
struct ril_sim_card *sim_card;
|
||||
struct ril_sim_settings *sim_settings;
|
||||
@@ -363,6 +371,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)
|
||||
{
|
||||
if (slot->modem) {
|
||||
ril_data_allow(slot->data, RIL_DATA_ROLE_NONE);
|
||||
ril_modem_delete(slot->modem);
|
||||
/* The above call is expected to result in
|
||||
* ril_plugin_modem_removed getting called
|
||||
@@ -382,12 +391,16 @@ static void ril_plugin_shutdown_slot(ril_slot *slot, gboolean kill_io)
|
||||
}
|
||||
|
||||
if (slot->cell_info) {
|
||||
sailfish_manager_set_cell_info(slot->handle, NULL);
|
||||
sailfish_cell_info_unref(slot->cell_info);
|
||||
slot->cell_info = NULL;
|
||||
}
|
||||
|
||||
if (slot->caps) {
|
||||
ril_radio_caps_unref(slot->caps);
|
||||
ril_network_set_radio_caps(slot->network, NULL);
|
||||
ril_radio_caps_request_free(slot->caps_req);
|
||||
ril_radio_caps_drop(slot->caps);
|
||||
slot->caps_req = NULL;
|
||||
slot->caps = NULL;
|
||||
}
|
||||
|
||||
@@ -901,7 +914,7 @@ static void ril_plugin_radio_caps_cb(const struct ril_radio_capability *cap,
|
||||
plugin->caps_manager = ril_radio_caps_manager_new
|
||||
(plugin->data_manager);
|
||||
plugin->caps_manager_event_id =
|
||||
ril_radio_caps_manager_add_aborted_handler(
|
||||
ril_radio_caps_manager_add_tx_aborted_handler(
|
||||
plugin->caps_manager,
|
||||
ril_plugin_caps_switch_aborted,
|
||||
plugin);
|
||||
@@ -909,9 +922,10 @@ static void ril_plugin_radio_caps_cb(const struct ril_radio_capability *cap,
|
||||
|
||||
GASSERT(!slot->caps);
|
||||
slot->caps = ril_radio_caps_new(plugin->caps_manager,
|
||||
ril_plugin_log_prefix(slot), slot->io, slot->data,
|
||||
slot->radio, slot->sim_card, slot->network,
|
||||
&slot->config, cap);
|
||||
ril_plugin_log_prefix(slot), slot->io, slot->watch,
|
||||
slot->data, slot->radio, slot->sim_card,
|
||||
slot->sim_settings, &slot->config, cap);
|
||||
ril_network_set_radio_caps(slot->network, slot->caps);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1039,13 +1053,13 @@ static void ril_plugin_slot_connected(ril_slot *slot)
|
||||
slot->path, slot->config.techs, slot->imei,
|
||||
slot->imeisv, ril_plugin_sim_state(slot),
|
||||
slot->slot_flags);
|
||||
sailfish_manager_set_cell_info(slot->handle, slot->cell_info);
|
||||
grilio_channel_set_enabled(slot->io, slot->handle->enabled);
|
||||
|
||||
/* Check if this was the last slot we were waiting for */
|
||||
ril_plugin_check_if_started(plugin);
|
||||
}
|
||||
|
||||
sailfish_manager_set_cell_info(slot->handle, slot->cell_info);
|
||||
ril_plugin_check_modem(slot);
|
||||
ril_plugin_check_ready(slot);
|
||||
}
|
||||
@@ -1061,8 +1075,11 @@ static void ril_plugin_slot_connected_cb(GRilIoChannel *io, void *user_data)
|
||||
static void ril_plugin_init_io(ril_slot *slot)
|
||||
{
|
||||
if (!slot->io) {
|
||||
slot->io = grilio_channel_new(ofono_ril_transport_connect
|
||||
(slot->transport_name, slot->transport_params));
|
||||
struct grilio_transport *transport =
|
||||
ofono_ril_transport_connect(slot->transport_name,
|
||||
slot->transport_params);
|
||||
|
||||
slot->io = grilio_channel_new(transport);
|
||||
if (slot->io) {
|
||||
ril_debug_trace_update(slot);
|
||||
ril_debug_dump_update(slot);
|
||||
@@ -1094,6 +1111,7 @@ static void ril_plugin_init_io(ril_slot *slot)
|
||||
slot);
|
||||
}
|
||||
}
|
||||
grilio_transport_unref(transport);
|
||||
}
|
||||
|
||||
if (!slot->io) {
|
||||
@@ -1139,6 +1157,8 @@ static void ril_plugin_slot_modem_changed(struct ofono_watch *w,
|
||||
|
||||
slot->modem = NULL;
|
||||
ril_data_allow(slot->data, RIL_DATA_ROLE_NONE);
|
||||
ril_radio_caps_request_free(slot->caps_req);
|
||||
slot->caps_req = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1194,6 +1214,8 @@ static ril_slot *ril_plugin_slot_new_take(char *transport,
|
||||
config->lte_network_mode = RILMODEM_DEFAULT_LTE_MODE;
|
||||
config->umts_network_mode = RILMODEM_DEFAULT_UMTS_MODE;
|
||||
config->network_mode_timeout = RILMODEM_DEFAULT_NETWORK_MODE_TIMEOUT;
|
||||
config->network_selection_timeout =
|
||||
RILMODEM_DEFAULT_NETWORK_SELECTION_TIMEOUT;
|
||||
config->signal_strength_dbm_weak = RILMODEM_DEFAULT_DBM_WEAK;
|
||||
config->signal_strength_dbm_strong = RILMODEM_DEFAULT_DBM_STRONG;
|
||||
config->empty_pin_query = RILMODEM_DEFAULT_EMPTY_PIN_QUERY;
|
||||
@@ -1205,12 +1227,17 @@ static ril_slot *ril_plugin_slot_new_take(char *transport,
|
||||
config->enable_stk = RILMODEM_DEFAULT_ENABLE_STK;
|
||||
config->query_available_band_mode =
|
||||
RILMODEM_DEFAULT_QUERY_AVAILABLE_BAND_MODE;
|
||||
config->replace_strange_oper = RILMODEM_DEFAULT_REPLACE_STRANGE_OPER;
|
||||
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;
|
||||
config->cell_info_interval_short_ms =
|
||||
RILMODEM_DEFAULT_CELL_INFO_INTERVAL_SHORT_MS;
|
||||
config->cell_info_interval_long_ms =
|
||||
RILMODEM_DEFAULT_CELL_INFO_INTERVAL_LONG_MS;
|
||||
slot->timeout = RILMODEM_DEFAULT_TIMEOUT;
|
||||
slot->sim_flags = RILMODEM_DEFAULT_SIM_FLAGS;
|
||||
slot->slot_flags = RILMODEM_DEFAULT_SLOT_FLAGS;
|
||||
@@ -1222,8 +1249,7 @@ static ril_slot *ril_plugin_slot_new_take(char *transport,
|
||||
RILMODEM_DEFAULT_DATA_CALL_RETRY_LIMIT;
|
||||
slot->data_opt.data_call_retry_delay_ms =
|
||||
RILMODEM_DEFAULT_DATA_CALL_RETRY_DELAY;
|
||||
|
||||
slot->devmon = ril_devmon_auto_new();
|
||||
slot->devmon = ril_devmon_auto_new(config);
|
||||
slot->watch = ofono_watch_new(dbus_path);
|
||||
slot->watch_event_id[WATCH_EVENT_MODEM] =
|
||||
ofono_watch_add_modem_changed_handler(slot->watch,
|
||||
@@ -1245,6 +1271,7 @@ 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.replace_strange_oper = config->replace_strange_oper;
|
||||
defaults.force_gsm_when_radio_off =
|
||||
config->force_gsm_when_radio_off;
|
||||
defaults.query_available_band_mode =
|
||||
@@ -1257,6 +1284,7 @@ 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->replace_strange_oper = defaults.replace_strange_oper;
|
||||
config->force_gsm_when_radio_off =
|
||||
defaults.force_gsm_when_radio_off;
|
||||
config->query_available_band_mode =
|
||||
@@ -1480,6 +1508,14 @@ static ril_slot *ril_plugin_parse_config_group(GKeyFile *file,
|
||||
config->enable_stk ? "yes" : "no");
|
||||
}
|
||||
|
||||
/* replaceStrangeOperatorNames */
|
||||
if (ril_config_get_boolean(file, group,
|
||||
RILCONF_REPLACE_STRANGE_OPER,
|
||||
&config->replace_strange_oper)) {
|
||||
DBG("%s: " RILCONF_REPLACE_STRANGE_OPER " %s", group,
|
||||
config->replace_strange_oper ? "yes" : "no");
|
||||
}
|
||||
|
||||
/* networkSelectionManual0 */
|
||||
if (ril_config_get_boolean(file, group,
|
||||
RILCONF_NETWORK_SELECTION_MANUAL_0,
|
||||
@@ -1566,6 +1602,14 @@ static ril_slot *ril_plugin_parse_config_group(GKeyFile *file,
|
||||
config->network_mode_timeout);
|
||||
}
|
||||
|
||||
/* networkSelectionTimeout */
|
||||
if (ril_config_get_integer(file, group,
|
||||
RILCONF_NETWORK_SELECTION_TIMEOUT,
|
||||
&config->network_selection_timeout)) {
|
||||
DBG("%s: " RILCONF_NETWORK_SELECTION_TIMEOUT " %d", group,
|
||||
config->network_selection_timeout);
|
||||
}
|
||||
|
||||
/* signalStrengthRange */
|
||||
ints = ril_config_get_ints(file, group, RILCONF_SIGNAL_STRENGTH_RANGE);
|
||||
if (gutil_ints_get_count(ints) == 2) {
|
||||
@@ -1705,24 +1749,59 @@ static ril_slot *ril_plugin_parse_config_group(GKeyFile *file,
|
||||
slot->legacy_imei_query ? "on" : "off");
|
||||
}
|
||||
|
||||
/* cellInfoIntervalShortMs */
|
||||
if (ril_config_get_integer(file, group,
|
||||
RILCONF_CELL_INFO_INTERVAL_SHORT_MS,
|
||||
&config->cell_info_interval_short_ms)) {
|
||||
DBG("%s: " RILCONF_CELL_INFO_INTERVAL_SHORT_MS " %d", group,
|
||||
config->cell_info_interval_short_ms);
|
||||
}
|
||||
|
||||
/* cellInfoIntervalLongMs */
|
||||
if (ril_config_get_integer(file, group,
|
||||
RILCONF_CELL_INFO_INTERVAL_LONG_MS,
|
||||
&config->cell_info_interval_long_ms)) {
|
||||
DBG("%s: " RILCONF_CELL_INFO_INTERVAL_LONG_MS " %d",
|
||||
group, config->cell_info_interval_long_ms);
|
||||
}
|
||||
|
||||
/* Replace devmon with a new one with applied settings */
|
||||
ril_devmon_free(slot->devmon);
|
||||
slot->devmon = NULL;
|
||||
|
||||
/* deviceStateTracking */
|
||||
if (ril_config_get_enum(file, group, RILCONF_DEVMON, &ival,
|
||||
"none", RIL_DEVMON_NONE,
|
||||
"auto", RIL_DEVMON_AUTO,
|
||||
if (ril_config_get_mask(file, group, RILCONF_DEVMON, &ival,
|
||||
"ds", RIL_DEVMON_DS,
|
||||
"ss", RIL_DEVMON_SS, NULL)) {
|
||||
DBG("%s: " RILCONF_DEVMON " %s", group,
|
||||
ival == RIL_DEVMON_NONE ? "off" :
|
||||
ival == RIL_DEVMON_DS ? "on" :
|
||||
ival == RIL_DEVMON_SS ? "legacy" :
|
||||
"auto");
|
||||
if (ival != RIL_DEVMON_AUTO) {
|
||||
/* Default is automatic, reallocate the object */
|
||||
ril_devmon_free(slot->devmon);
|
||||
slot->devmon =
|
||||
(ival == RIL_DEVMON_DS ? ril_devmon_ds_new() :
|
||||
ival == RIL_DEVMON_SS ? ril_devmon_ss_new() :
|
||||
NULL);
|
||||
"ss", RIL_DEVMON_SS,
|
||||
"ur", RIL_DEVMON_UR, NULL) && ival) {
|
||||
int n = 0;
|
||||
struct ril_devmon *devmon[3];
|
||||
|
||||
if (ival & RIL_DEVMON_DS) {
|
||||
devmon[n++] = ril_devmon_ds_new(config);
|
||||
}
|
||||
if (ival & RIL_DEVMON_SS) {
|
||||
devmon[n++] = ril_devmon_ss_new(config);
|
||||
}
|
||||
if (ival & RIL_DEVMON_UR) {
|
||||
devmon[n++] = ril_devmon_ur_new(config);
|
||||
}
|
||||
DBG("%s: " RILCONF_DEVMON " 0x%x", group, ival);
|
||||
slot->devmon = ril_devmon_combine(devmon, n);
|
||||
} else {
|
||||
/* Try special values */
|
||||
sval = ril_config_get_string(file, group, RILCONF_DEVMON);
|
||||
if (sval) {
|
||||
if (!g_ascii_strcasecmp(sval, "none")) {
|
||||
DBG("%s: " RILCONF_DEVMON " %s", group, sval);
|
||||
} else if (!g_ascii_strcasecmp(sval, "auto")) {
|
||||
DBG("%s: " RILCONF_DEVMON " %s", group, sval);
|
||||
slot->devmon = ril_devmon_auto_new(config);
|
||||
}
|
||||
g_free(sval);
|
||||
} else {
|
||||
/* This is the default */
|
||||
slot->devmon = ril_devmon_auto_new(config);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2153,10 +2232,24 @@ static void ril_plugin_manager_free(ril_plugin *plugin)
|
||||
|
||||
static void ril_slot_set_data_role(ril_slot *slot, enum sailfish_data_role r)
|
||||
{
|
||||
ril_data_allow(slot->data,
|
||||
enum ril_data_role role =
|
||||
(r == SAILFISH_DATA_ROLE_INTERNET) ? RIL_DATA_ROLE_INTERNET :
|
||||
(r == SAILFISH_DATA_ROLE_MMS) ? RIL_DATA_ROLE_MMS :
|
||||
RIL_DATA_ROLE_NONE);
|
||||
RIL_DATA_ROLE_NONE;
|
||||
ril_data_allow(slot->data, role);
|
||||
ril_radio_caps_request_free(slot->caps_req);
|
||||
if (role == RIL_DATA_ROLE_NONE) {
|
||||
slot->caps_req = NULL;
|
||||
} else {
|
||||
const enum ofono_radio_access_mode mode =
|
||||
(r == SAILFISH_DATA_ROLE_MMS) ?
|
||||
OFONO_RADIO_ACCESS_MODE_GSM :
|
||||
__ofono_radio_access_max_mode
|
||||
(slot->sim_settings->techs);
|
||||
|
||||
slot->caps_req = ril_radio_caps_request_new
|
||||
(slot->caps, mode, role);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_slot_enabled_changed(struct sailfish_slot_impl *s)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2017 Jolla Ltd.
|
||||
* Copyright (C) 2017-2020 Jolla Ltd.
|
||||
*
|
||||
* 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
|
||||
@@ -19,12 +19,16 @@
|
||||
#include "ril_types.h"
|
||||
|
||||
struct ril_data_manager;
|
||||
struct ril_sim_settings;
|
||||
struct ril_radio_caps;
|
||||
struct ril_radio_caps_manager;
|
||||
struct ril_radio_capability;
|
||||
struct ril_radio_caps_request;
|
||||
|
||||
typedef void (*ril_radio_caps_cb_t)(struct ril_radio_caps *caps, void *arg);
|
||||
typedef void (*ril_radio_caps_manager_cb_t)(struct ril_radio_caps_manager *mgr,
|
||||
void *user_data);
|
||||
|
||||
/* ril_radio_capability pointer is NULL if functionality is unsupported */
|
||||
typedef void (*ril_radio_caps_check_cb_t)
|
||||
(const struct ril_radio_capability *cap, void *user_data);
|
||||
@@ -39,21 +43,47 @@ struct ril_radio_caps_manager *ril_radio_caps_manager_new
|
||||
struct ril_radio_caps_manager *ril_radio_caps_manager_ref
|
||||
(struct ril_radio_caps_manager *mgr);
|
||||
void ril_radio_caps_manager_unref(struct ril_radio_caps_manager *mgr);
|
||||
gulong ril_radio_caps_manager_add_aborted_handler
|
||||
gulong ril_radio_caps_manager_add_tx_aborted_handler
|
||||
(struct ril_radio_caps_manager *mgr,
|
||||
ril_radio_caps_manager_cb_t cb, void *arg);
|
||||
gulong ril_radio_caps_manager_add_tx_done_handler
|
||||
(struct ril_radio_caps_manager *mgr,
|
||||
ril_radio_caps_manager_cb_t cb, void *arg);
|
||||
void ril_radio_caps_manager_remove_handler(struct ril_radio_caps_manager *mgr,
|
||||
gulong id);
|
||||
gulong id);
|
||||
void ril_radio_caps_manager_remove_handlers(struct ril_radio_caps_manager *mgr,
|
||||
gulong *ids, int count);
|
||||
#define ril_radio_caps_manager_remove_all_handlers(mgr, ids) \
|
||||
ril_radio_caps_manager_remove_handlers(mgr, ids, G_N_ELEMENTS(ids))
|
||||
|
||||
/* And one ril_radio_caps object per modem */
|
||||
|
||||
struct ril_radio_caps {
|
||||
struct ril_radio_caps_manager *mgr;
|
||||
enum ofono_radio_access_mode supported_modes;
|
||||
};
|
||||
|
||||
struct ril_radio_caps *ril_radio_caps_new(struct ril_radio_caps_manager *mgr,
|
||||
const char *log_prefix, GRilIoChannel *io,
|
||||
struct ofono_watch *watch,
|
||||
struct ril_data *data, struct ril_radio *radio,
|
||||
struct ril_sim_card *sim, struct ril_network *net,
|
||||
struct ril_sim_card *sim, struct ril_sim_settings *settings,
|
||||
const struct ril_slot_config *config,
|
||||
const struct ril_radio_capability *cap);
|
||||
struct ril_radio_caps *ril_radio_caps_ref(struct ril_radio_caps *caps);
|
||||
void ril_radio_caps_unref(struct ril_radio_caps *caps);
|
||||
void ril_radio_caps_drop(struct ril_radio_caps *caps);
|
||||
gulong ril_radio_caps_add_supported_modes_handler
|
||||
(struct ril_radio_caps *caps,
|
||||
ril_radio_caps_cb_t cb, void *arg);
|
||||
void ril_radio_caps_remove_handler(struct ril_radio_caps *caps, gulong id);
|
||||
|
||||
/* Data requests */
|
||||
|
||||
struct ril_radio_caps_request *ril_radio_caps_request_new
|
||||
(struct ril_radio_caps *caps, enum ofono_radio_access_mode mode,
|
||||
enum ril_data_role role);
|
||||
void ril_radio_caps_request_free(struct ril_radio_caps_request *req);
|
||||
|
||||
#endif /* RIL_RADIO_CAPS_H */
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2018 Jolla Ltd.
|
||||
* Copyright (C) 2016-2020 Jolla Ltd.
|
||||
*
|
||||
* 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
|
||||
@@ -45,6 +45,8 @@ gulong ril_sim_settings_add_pref_mode_changed_handler(struct ril_sim_settings *s
|
||||
void ril_sim_settings_remove_handler(struct ril_sim_settings *s, gulong id);
|
||||
void ril_sim_settings_remove_handlers(struct ril_sim_settings *s, gulong *ids,
|
||||
int count);
|
||||
#define ril_sim_settings_remove_all_handlers(s,ids) \
|
||||
ril_sim_settings_remove_handlers(s, ids, G_N_ELEMENTS(ids))
|
||||
|
||||
#endif /* RIL_SIM_SETTINGS_H */
|
||||
|
||||
|
||||
@@ -237,6 +237,13 @@ socket=/dev/socket/rild
|
||||
#
|
||||
#networkModeTimeout=20000
|
||||
|
||||
# Timeout for RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC and
|
||||
# RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL, in milliseconds.
|
||||
#
|
||||
# Default 100000 (100 seconds)
|
||||
#
|
||||
#networkSelectionTimeout=100000
|
||||
|
||||
# Comma-separated signal strength range, in dBm.
|
||||
#
|
||||
# These values are used for translating dBm values returned by the modem in
|
||||
@@ -275,6 +282,16 @@ socket=/dev/socket/rild
|
||||
#
|
||||
#singleDataContext=false
|
||||
|
||||
# With some RILs, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS returns strange
|
||||
# operator names, i.e. numeric MCC+MNC values or the same name for all
|
||||
# operators (which is actually SPN fetched from the SIM). Such strange
|
||||
# names can be replaced with operator names from MBPI database, based
|
||||
# on the operator's MCC and MNC. That may not be 100% accurate, though.
|
||||
#
|
||||
# Default false (i.e. trust RIL to report the actual names)
|
||||
#
|
||||
#replaceStrangeOperatorNames=false
|
||||
|
||||
# Configures whether +0 is added to MCCMNC string passed to
|
||||
# RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL. Some Qualcomm RILs
|
||||
# require it, some MediaTek RILs don't like it.
|
||||
@@ -302,9 +319,15 @@ socket=/dev/socket/rild
|
||||
#
|
||||
# ss = Use legacy device state management (RIL_REQUEST_SCREEN_STATE)
|
||||
# ds = Use newer device state management (RIL_REQUEST_SEND_DEVICE_STATE)
|
||||
# auto = Choose one of the above based on the RIL version
|
||||
# ur = Use URC filter (RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER)
|
||||
# This may be useful on devices with RIL version >= 15 if auto
|
||||
# method fails
|
||||
# auto = Choose ss or ds based on the RIL version
|
||||
# none = Disable device state management
|
||||
#
|
||||
# In addition to specifying ss, ds or ur method, one can specify a
|
||||
# combination of methods, e.g. ds+ur
|
||||
#
|
||||
# Default auto
|
||||
#
|
||||
#deviceStateTracking=auto
|
||||
@@ -316,3 +339,29 @@ socket=/dev/socket/rild
|
||||
# Default true (false for MTK RILs)
|
||||
#
|
||||
#forceGsmWhenRadioOff=true
|
||||
|
||||
# Configures a period between RIL_UNSOL_CELL_INFO_LIST events when the device
|
||||
# is awake. Possible values are:
|
||||
#
|
||||
# 0 = invoke RIL_UNSOL_CELL_INFO_LIST when any of the reported information
|
||||
# changes
|
||||
# 1..INT_MAX-1 (2147483646) = sets update period in milliseconds
|
||||
# negative value or INT_MAX = never issue a RIL_UNSOL_CELL_INFO_LIST
|
||||
#
|
||||
# On MediaTek devices the period of RIL_UNSOL_CELL_INFO_LIST events can't be
|
||||
# configured. The parameter RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE has
|
||||
# non-standard meaning:
|
||||
#
|
||||
# 0 = enable RIL_UNSOL_CELL_INFO_LIST
|
||||
# any other value = disable RIL_UNSOL_CELL_INFO_LIST
|
||||
#
|
||||
# Default 2000
|
||||
#
|
||||
#cellInfoIntervalShortMs=2000
|
||||
|
||||
# Configures period between RIL_UNSOL_CELL_INFO_LIST events when the device is
|
||||
# in a power saving mode. For possible values, look cellInfoIntervalShortMs.
|
||||
#
|
||||
# Default 30000
|
||||
#
|
||||
#cellInfoIntervalLongMs=30000
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <grilio_types.h>
|
||||
#include <gutil_macros.h>
|
||||
|
||||
struct ofono_watch;
|
||||
struct ofono_modem;
|
||||
struct ofono_sim;
|
||||
|
||||
@@ -49,12 +50,19 @@ struct ril_network;
|
||||
struct ril_sim_card;
|
||||
struct ril_vendor;
|
||||
|
||||
enum ril_data_role {
|
||||
RIL_DATA_ROLE_NONE, /* Mobile data not required */
|
||||
RIL_DATA_ROLE_MMS, /* Data is needed at any speed */
|
||||
RIL_DATA_ROLE_INTERNET /* Data is needed at full speed */
|
||||
};
|
||||
|
||||
struct ril_slot_config {
|
||||
guint slot;
|
||||
enum ofono_radio_access_mode techs;
|
||||
enum ril_pref_net_type lte_network_mode;
|
||||
enum ril_pref_net_type umts_network_mode;
|
||||
int network_mode_timeout;
|
||||
int network_selection_timeout;
|
||||
int signal_strength_dbm_weak;
|
||||
int signal_strength_dbm_strong;
|
||||
gboolean query_available_band_mode;
|
||||
@@ -64,12 +72,15 @@ struct ril_slot_config {
|
||||
gboolean enable_voicecall;
|
||||
gboolean enable_cbs;
|
||||
gboolean enable_stk;
|
||||
gboolean replace_strange_oper;
|
||||
gboolean network_selection_manual_0;
|
||||
gboolean force_gsm_when_radio_off;
|
||||
gboolean use_data_profiles;
|
||||
guint mms_data_profile_id;
|
||||
GUtilInts *local_hangup_reasons;
|
||||
GUtilInts *remote_hangup_reasons;
|
||||
int cell_info_interval_short_ms;
|
||||
int cell_info_interval_long_ms;
|
||||
};
|
||||
|
||||
#endif /* RIL_TYPES_H */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2019 Jolla Ltd.
|
||||
* Copyright (C) 2019 Open Mobile Platform LLC.
|
||||
* Copyright (C) 2016-2020 Jolla Ltd.
|
||||
* 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
|
||||
@@ -24,6 +24,7 @@ struct ril_vendor_defaults {
|
||||
gboolean legacy_imei_query;
|
||||
gboolean enable_cbs;
|
||||
gboolean enable_stk;
|
||||
gboolean replace_strange_oper;
|
||||
gboolean query_available_band_mode;
|
||||
gboolean use_data_profiles;
|
||||
gboolean force_gsm_when_radio_off;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2019 Jolla Ltd.
|
||||
* Copyright (C) 2019 Open Mobile Platform LLC.
|
||||
* Copyright (C) 2016-2020 Jolla Ltd.
|
||||
* 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
|
||||
@@ -509,6 +509,7 @@ static void ril_vendor_mtk_get_defaults(struct ril_vendor_defaults *defaults)
|
||||
defaults->empty_pin_query = FALSE;
|
||||
defaults->legacy_imei_query = TRUE;
|
||||
defaults->force_gsm_when_radio_off = FALSE;
|
||||
defaults->replace_strange_oper = TRUE;
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_base_init(RilVendorMtk *self, GRilIoChannel *io,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2019 Jolla Ltd.
|
||||
* Copyright (C) 2019-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
|
||||
@@ -25,7 +26,7 @@ extern "C" {
|
||||
enum ofono_dbus_access {
|
||||
OFONO_DBUS_ACCESS_DENY, /* Deny access */
|
||||
OFONO_DBUS_ACCESS_ALLOW, /* Allow access */
|
||||
OFONO_DBUS_ACCESS_DONT_CARE, /* No decision */
|
||||
OFONO_DBUS_ACCESS_DONT_CARE /* No decision */
|
||||
};
|
||||
|
||||
enum ofono_dbus_access_intf {
|
||||
@@ -38,6 +39,8 @@ enum ofono_dbus_access_intf {
|
||||
OFONO_DBUS_ACCESS_INTF_SIMMGR, /* org.ofono.SimManager */
|
||||
OFONO_DBUS_ACCESS_INTF_MODEM, /* org.ofono.Modem */
|
||||
OFONO_DBUS_ACCESS_INTF_RADIOSETTINGS, /* org.ofono.RadioSettings */
|
||||
OFONO_DBUS_ACCESS_INTF_STK, /* org.ofono.SimToolkit */
|
||||
OFONO_DBUS_ACCESS_INTF_OEMRAW, /* org.ofono.OemRaw */
|
||||
OFONO_DBUS_ACCESS_INTF_COUNT
|
||||
};
|
||||
|
||||
@@ -116,6 +119,18 @@ enum ofono_dbus_access_radiosettings_method {
|
||||
OFONO_DBUS_ACCESS_RADIOSETTINGS_METHOD_COUNT
|
||||
};
|
||||
|
||||
/* OFONO_DBUS_ACCESS_INTF_STK */
|
||||
enum ofono_dbus_access_stk_method {
|
||||
OFONO_DBUS_ACCESS_STK_REGISTER_AGENT,
|
||||
OFONO_DBUS_ACCESS_STK_METHOD_COUNT
|
||||
};
|
||||
|
||||
/* OFONO_DBUS_ACCESS_INTF_OEMRAW */
|
||||
enum ofono_dbus_access_oemraw_method {
|
||||
OFONO_DBUS_ACCESS_OEMRAW_SEND,
|
||||
OFONO_DBUS_ACCESS_OEMRAW_METHOD_COUNT
|
||||
};
|
||||
|
||||
#define OFONO_DBUS_ACCESS_PRIORITY_LOW (-100)
|
||||
#define OFONO_DBUS_ACCESS_PRIORITY_DEFAULT (0)
|
||||
#define OFONO_DBUS_ACCESS_PRIORITY_HIGH (100)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
* Copyright (C) 2015-2020 Jolla Ltd.
|
||||
*
|
||||
* 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
|
||||
@@ -60,6 +60,7 @@ const char *mbpi_database = MBPI_DATABASE;
|
||||
*/
|
||||
enum ofono_gprs_proto mbpi_default_internet_proto = OFONO_GPRS_PROTO_IPV4V6;
|
||||
enum ofono_gprs_proto mbpi_default_mms_proto = OFONO_GPRS_PROTO_IP;
|
||||
enum ofono_gprs_proto mbpi_default_ims_proto = OFONO_GPRS_PROTO_IPV4V6;
|
||||
enum ofono_gprs_proto mbpi_default_proto = OFONO_GPRS_PROTO_IP;
|
||||
enum ofono_gprs_auth_method mbpi_default_auth_method = OFONO_GPRS_AUTH_METHOD_ANY;
|
||||
|
||||
@@ -246,6 +247,9 @@ static void usage_start(GMarkupParseContext *context,
|
||||
} else if (strcmp(text, "mms") == 0) {
|
||||
apn->type = OFONO_GPRS_CONTEXT_TYPE_MMS;
|
||||
apn->proto = mbpi_default_mms_proto;
|
||||
} else if (strcmp(text, "ims") == 0) {
|
||||
apn->type = OFONO_GPRS_CONTEXT_TYPE_IMS;
|
||||
apn->proto = mbpi_default_ims_proto;
|
||||
} else if (strcmp(text, "wap") == 0)
|
||||
apn->type = OFONO_GPRS_CONTEXT_TYPE_WAP;
|
||||
else
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2013-2020 Jolla Ltd.
|
||||
*
|
||||
* 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
|
||||
@@ -22,6 +23,7 @@
|
||||
extern const char *mbpi_database;
|
||||
extern enum ofono_gprs_proto mbpi_default_internet_proto;
|
||||
extern enum ofono_gprs_proto mbpi_default_mms_proto;
|
||||
extern enum ofono_gprs_proto mbpi_default_ims_proto;
|
||||
extern enum ofono_gprs_proto mbpi_default_proto;
|
||||
extern enum ofono_gprs_auth_method mbpi_default_auth_method;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2013-2017 Jolla Ltd.
|
||||
* Copyright (C) 2013-2020 Jolla Ltd.
|
||||
*
|
||||
* 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
|
||||
@@ -136,38 +136,56 @@ static GSList *provision_pick_best_ap(GSList *list, const char *spn,
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns the list containing exactly one INTERNET and one MMS access point */
|
||||
/**
|
||||
* Returns the list containing INTERNET, MMS and IMS access points,
|
||||
* always all three of them and always in this order.
|
||||
*/
|
||||
static GSList *provision_normalize_apn_list(GSList *apns, const char *spn)
|
||||
{
|
||||
static const struct provision_ap_defaults internet_defaults =
|
||||
{ OFONO_GPRS_CONTEXT_TYPE_INTERNET, "Internet", "internet" };
|
||||
static const struct provision_ap_defaults mms_defaults =
|
||||
{ OFONO_GPRS_CONTEXT_TYPE_MMS, "MMS", "mms" };
|
||||
static const struct provision_ap_defaults ims_defaults =
|
||||
{ OFONO_GPRS_CONTEXT_TYPE_IMS, "IMS", "ims" };
|
||||
|
||||
GSList *internet_apns = NULL;
|
||||
GSList *mms_apns = NULL;
|
||||
GSList *ims_apns = NULL;
|
||||
|
||||
/* Split internet and mms apns, delete all others */
|
||||
/* Build separate apn list for each type */
|
||||
while (apns) {
|
||||
GSList *link = apns;
|
||||
struct ofono_gprs_provision_data *ap = link->data;
|
||||
|
||||
apns = g_slist_remove_link(apns, link);
|
||||
if (ap->type == OFONO_GPRS_CONTEXT_TYPE_INTERNET) {
|
||||
switch (ap->type) {
|
||||
case OFONO_GPRS_CONTEXT_TYPE_INTERNET:
|
||||
internet_apns = g_slist_concat(internet_apns, link);
|
||||
} else if (ap->type == OFONO_GPRS_CONTEXT_TYPE_MMS) {
|
||||
break;
|
||||
case OFONO_GPRS_CONTEXT_TYPE_MMS:
|
||||
mms_apns = g_slist_concat(mms_apns, link);
|
||||
} else {
|
||||
break;
|
||||
case OFONO_GPRS_CONTEXT_TYPE_IMS:
|
||||
ims_apns = g_slist_concat(ims_apns, link);
|
||||
break;
|
||||
default:
|
||||
g_slist_free_full(link, provision_free_ap);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Pick the best ap of each type and concatenate them */
|
||||
return g_slist_concat(
|
||||
provision_pick_best_ap(internet_apns, spn,
|
||||
mbpi_default_internet_proto, &internet_defaults),
|
||||
provision_pick_best_ap(mms_apns, spn,
|
||||
mbpi_default_mms_proto, &mms_defaults));
|
||||
/* Pick the best ap of each type */
|
||||
internet_apns = provision_pick_best_ap(internet_apns, spn,
|
||||
mbpi_default_internet_proto, &internet_defaults);
|
||||
mms_apns = provision_pick_best_ap(mms_apns, spn,
|
||||
mbpi_default_mms_proto, &mms_defaults);
|
||||
ims_apns = provision_pick_best_ap(ims_apns, spn,
|
||||
mbpi_default_ims_proto, &ims_defaults);
|
||||
|
||||
/* And concatenate them in the right order */
|
||||
return g_slist_concat(internet_apns, g_slist_concat(mms_apns,
|
||||
ims_apns));
|
||||
}
|
||||
|
||||
int provision_get_settings(const char *mcc, const char *mnc,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2013 Jolla Ltd. All rights reserved.
|
||||
* Copyright (C) 2020 Open Mobile Platform LLС. All rights reserved.
|
||||
*
|
||||
* 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
|
||||
@@ -26,6 +27,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <glib.h>
|
||||
#include <gdbus.h>
|
||||
|
||||
@@ -40,58 +42,42 @@
|
||||
|
||||
#define SMS_HISTORY_INTERFACE "org.ofono.SmsHistory"
|
||||
|
||||
gboolean sms_history_interface_registered = FALSE;
|
||||
|
||||
static const GDBusSignalTable sms_history_signals[] = {
|
||||
{ GDBUS_SIGNAL("StatusReport",
|
||||
GDBUS_ARGS({ "message", "s" }, { "Delivered", "a{b}" })) },
|
||||
{ }
|
||||
};
|
||||
|
||||
static void sms_history_cleanup(gpointer user)
|
||||
static int sms_history_probe(struct ofono_history_context *context)
|
||||
{
|
||||
struct ofono_modem *modem = user;
|
||||
DBG("modem %p", modem);
|
||||
ofono_modem_remove_interface(modem, SMS_HISTORY_INTERFACE);
|
||||
sms_history_interface_registered = FALSE;
|
||||
}
|
||||
|
||||
static gboolean sms_history_ensure_interface(
|
||||
struct ofono_modem *modem) {
|
||||
|
||||
if (sms_history_interface_registered)
|
||||
return TRUE;
|
||||
|
||||
/* Late initialization of the D-Bus interface */
|
||||
DBusConnection *conn = ofono_dbus_get_connection();
|
||||
if (conn == NULL)
|
||||
return FALSE;
|
||||
struct ofono_modem *modem = context->modem;
|
||||
|
||||
ofono_debug("SMS History Probe for modem: %p", modem);
|
||||
|
||||
if (!g_dbus_register_interface(conn,
|
||||
ofono_modem_get_path(modem),
|
||||
SMS_HISTORY_INTERFACE,
|
||||
NULL, sms_history_signals, NULL,
|
||||
modem, sms_history_cleanup)) {
|
||||
NULL, sms_history_signals,
|
||||
NULL, NULL, NULL)) {
|
||||
ofono_error("Could not create %s interface",
|
||||
SMS_HISTORY_INTERFACE);
|
||||
return FALSE;
|
||||
return -EIO;
|
||||
}
|
||||
sms_history_interface_registered = TRUE;
|
||||
|
||||
ofono_modem_add_interface(modem, SMS_HISTORY_INTERFACE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static int sms_history_probe(struct ofono_history_context *context)
|
||||
{
|
||||
ofono_debug("SMS History Probe for modem: %p", context->modem);
|
||||
sms_history_ensure_interface(context->modem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void sms_history_remove(struct ofono_history_context *context)
|
||||
{
|
||||
ofono_debug("SMS History Remove for modem: %p", context->modem);
|
||||
DBusConnection *conn = ofono_dbus_get_connection();
|
||||
struct ofono_modem *modem = context->modem;
|
||||
|
||||
ofono_debug("SMS History remove for modem: %p", modem);
|
||||
ofono_modem_remove_interface(modem, SMS_HISTORY_INTERFACE);
|
||||
g_dbus_unregister_interface(conn, ofono_modem_get_path(modem),
|
||||
SMS_HISTORY_INTERFACE);
|
||||
}
|
||||
|
||||
static void sms_history_sms_send_status(
|
||||
@@ -102,9 +88,6 @@ static void sms_history_sms_send_status(
|
||||
{
|
||||
DBG("");
|
||||
|
||||
if (!sms_history_ensure_interface(context->modem))
|
||||
return;
|
||||
|
||||
if ((s == OFONO_HISTORY_SMS_STATUS_DELIVERED)
|
||||
|| (s == OFONO_HISTORY_SMS_STATUS_DELIVER_FAILED)) {
|
||||
|
||||
@@ -174,4 +157,3 @@ static void sms_history_exit(void)
|
||||
OFONO_PLUGIN_DEFINE(sms_history, "SMS History Plugin",
|
||||
VERSION, OFONO_PLUGIN_PRIORITY_DEFAULT,
|
||||
sms_history_init, sms_history_exit)
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2019 Jolla Ltd.
|
||||
* Copyright (C) 2019-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
|
||||
@@ -41,6 +42,10 @@ const char *ofono_dbus_access_intf_name(enum ofono_dbus_access_intf intf)
|
||||
return OFONO_MODEM_INTERFACE;
|
||||
case OFONO_DBUS_ACCESS_INTF_RADIOSETTINGS:
|
||||
return OFONO_RADIO_SETTINGS_INTERFACE;
|
||||
case OFONO_DBUS_ACCESS_INTF_STK:
|
||||
return OFONO_STK_INTERFACE;
|
||||
case OFONO_DBUS_ACCESS_INTF_OEMRAW:
|
||||
return "org.ofono.OemRaw";
|
||||
case OFONO_DBUS_ACCESS_INTF_COUNT:
|
||||
break;
|
||||
}
|
||||
@@ -165,6 +170,22 @@ const char *ofono_dbus_access_method_name(enum ofono_dbus_access_intf intf,
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OFONO_DBUS_ACCESS_INTF_STK:
|
||||
switch ((enum ofono_dbus_access_stk_method)method) {
|
||||
case OFONO_DBUS_ACCESS_STK_REGISTER_AGENT:
|
||||
return "RegisterAgent";
|
||||
case OFONO_DBUS_ACCESS_STK_METHOD_COUNT:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OFONO_DBUS_ACCESS_INTF_OEMRAW:
|
||||
switch ((enum ofono_dbus_access_oemraw_method)method) {
|
||||
case OFONO_DBUS_ACCESS_OEMRAW_SEND:
|
||||
return "Send";
|
||||
case OFONO_DBUS_ACCESS_OEMRAW_METHOD_COUNT:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OFONO_DBUS_ACCESS_INTF_COUNT:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2015-2019 Jolla Ltd.
|
||||
* Copyright (C) 2015-2020 Jolla Ltd.
|
||||
*
|
||||
* 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
|
||||
@@ -2874,12 +2874,53 @@ static void provision_contexts(struct ofono_gprs *gprs, const char *mcc,
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
provision_context(&settings[i], gprs);
|
||||
for (i = 0; i < count; i++) {
|
||||
const struct ofono_gprs_provision_data *ap = settings + i;
|
||||
|
||||
if (!ofono_gprs_context_settings_by_type(gprs, ap->type)) {
|
||||
provision_context(ap, gprs);
|
||||
}
|
||||
}
|
||||
|
||||
__ofono_gprs_provision_free_settings(settings, count);
|
||||
}
|
||||
|
||||
static gboolean all_contexts_configured(struct ofono_gprs *gprs)
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
for (l = gprs->context_drivers; l; l = l->next) {
|
||||
struct ofono_gprs_context *gc = l->data;
|
||||
|
||||
if (gc->type != OFONO_GPRS_CONTEXT_TYPE_ANY &&
|
||||
!ofono_gprs_context_settings_by_type(gprs, gc->type)) {
|
||||
return FALSE; /* Not yet */
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void configure_remaining_contexts(struct ofono_gprs *gprs)
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
for (l = gprs->context_drivers; l; l = l->next) {
|
||||
struct ofono_gprs_context *gc = l->data;
|
||||
|
||||
if (gc->type != OFONO_GPRS_CONTEXT_TYPE_ANY &&
|
||||
!ofono_gprs_context_settings_by_type(gprs, gc->type)) {
|
||||
add_context(gprs, NULL, gc->type);
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure internet context is there */
|
||||
if (!ofono_gprs_context_settings_by_type(gprs,
|
||||
OFONO_GPRS_CONTEXT_TYPE_INTERNET)) {
|
||||
add_context(gprs, NULL, OFONO_GPRS_CONTEXT_TYPE_INTERNET);
|
||||
}
|
||||
}
|
||||
|
||||
static void remove_non_active_context(struct ofono_gprs *gprs,
|
||||
struct pri_context *ctx, DBusConnection *conn)
|
||||
{
|
||||
@@ -2960,8 +3001,7 @@ static DBusMessage *gprs_reset_contexts(DBusConnection *conn,
|
||||
provision_contexts(gprs, ofono_sim_get_mcc(sim),
|
||||
ofono_sim_get_mnc(sim), ofono_sim_get_spn(sim));
|
||||
|
||||
if (gprs->contexts == NULL) /* Automatic provisioning failed */
|
||||
add_context(gprs, NULL, OFONO_GPRS_CONTEXT_TYPE_INTERNET);
|
||||
configure_remaining_contexts(gprs);
|
||||
|
||||
for (l = gprs->contexts; l; l = l->next) {
|
||||
struct pri_context *ctx = l->data;
|
||||
@@ -3832,8 +3872,7 @@ static void ofono_gprs_finish_register(struct ofono_gprs *gprs)
|
||||
struct ofono_modem *modem = __ofono_atom_get_modem(gprs->atom);
|
||||
const char *path = __ofono_atom_get_path(gprs->atom);
|
||||
|
||||
if (gprs->contexts == NULL) /* Automatic provisioning failed */
|
||||
add_context(gprs, NULL, OFONO_GPRS_CONTEXT_TYPE_INTERNET);
|
||||
configure_remaining_contexts(gprs);
|
||||
|
||||
if (!g_dbus_register_interface(conn, path,
|
||||
OFONO_CONNECTION_MANAGER_INTERFACE,
|
||||
@@ -3856,56 +3895,14 @@ static void ofono_gprs_finish_register(struct ofono_gprs *gprs)
|
||||
__ofono_atom_register(gprs->atom, gprs_unregister);
|
||||
}
|
||||
|
||||
static gboolean mms_context_configured(struct ofono_gprs *gprs)
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
for (l = gprs->contexts; l; l = l->next) {
|
||||
struct pri_context *ctx = l->data;
|
||||
|
||||
if (ctx->type == OFONO_GPRS_CONTEXT_TYPE_MMS)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void provision_mms_context(struct ofono_gprs *gprs, const char *mcc,
|
||||
const char *mnc, const char *spn)
|
||||
{
|
||||
struct ofono_gprs_provision_data *settings;
|
||||
int count;
|
||||
int i;
|
||||
|
||||
if (__ofono_gprs_provision_get_settings(mcc, mnc, spn,
|
||||
&settings, &count) == FALSE) {
|
||||
ofono_warn("Provisioning failed");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (settings[i].type == OFONO_GPRS_CONTEXT_TYPE_MMS) {
|
||||
provision_context(&settings[i], gprs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
__ofono_gprs_provision_free_settings(settings, count);
|
||||
}
|
||||
|
||||
static void spn_read_cb(const char *spn, const char *dc, void *data)
|
||||
{
|
||||
struct ofono_gprs *gprs = data;
|
||||
struct ofono_modem *modem = __ofono_atom_get_modem(gprs->atom);
|
||||
struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem);
|
||||
|
||||
if (gprs->contexts == NULL) {
|
||||
provision_contexts(gprs, ofono_sim_get_mcc(sim),
|
||||
provision_contexts(gprs, ofono_sim_get_mcc(sim),
|
||||
ofono_sim_get_mnc(sim), spn);
|
||||
} else if (!mms_context_configured(gprs)) {
|
||||
provision_mms_context(gprs, ofono_sim_get_mcc(sim),
|
||||
ofono_sim_get_mnc(sim), spn);
|
||||
}
|
||||
|
||||
ofono_sim_remove_spn_watch(sim, &gprs->spn_watch);
|
||||
|
||||
@@ -3927,7 +3924,7 @@ void ofono_gprs_register(struct ofono_gprs *gprs)
|
||||
|
||||
gprs_load_settings(gprs, ofono_sim_get_imsi(sim));
|
||||
|
||||
if (mms_context_configured(gprs))
|
||||
if (all_contexts_configured(gprs))
|
||||
goto finish;
|
||||
|
||||
ofono_sim_add_spn_watch(sim, &gprs->spn_watch, spn_read_cb, gprs, NULL);
|
||||
|
||||
@@ -283,6 +283,10 @@ enum ofono_gprs_context_type __ofono_gprs_context_get_assigned_type(
|
||||
struct ofono_gprs_context *gc);
|
||||
|
||||
#include <ofono/radio-settings.h>
|
||||
|
||||
enum ofono_radio_access_mode __ofono_radio_access_max_mode(
|
||||
enum ofono_radio_access_mode modes);
|
||||
|
||||
#include <ofono/audio-settings.h>
|
||||
#include <ofono/ctm.h>
|
||||
#include <ofono/location-reporting.h>
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
|
||||
#include "ofono.h"
|
||||
|
||||
#pragma message("PLUGINDIR="PLUGINDIR)
|
||||
|
||||
static GSList *plugins = NULL;
|
||||
|
||||
struct ofono_plugin {
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
* Copyright (C) 2014-2020 Jolla Ltd.
|
||||
*
|
||||
* 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
|
||||
@@ -61,10 +62,22 @@ struct ofono_radio_settings {
|
||||
struct ofono_atom *atom;
|
||||
};
|
||||
|
||||
enum ofono_radio_access_mode __ofono_radio_access_max_mode(
|
||||
enum ofono_radio_access_mode mask)
|
||||
{
|
||||
return (mask & OFONO_RADIO_ACCESS_MODE_LTE) ?
|
||||
OFONO_RADIO_ACCESS_MODE_LTE :
|
||||
(mask & OFONO_RADIO_ACCESS_MODE_UMTS) ?
|
||||
OFONO_RADIO_ACCESS_MODE_UMTS :
|
||||
(mask & OFONO_RADIO_ACCESS_MODE_GSM) ?
|
||||
OFONO_RADIO_ACCESS_MODE_GSM :
|
||||
OFONO_RADIO_ACCESS_MODE_ANY;
|
||||
}
|
||||
|
||||
#define radio_access_mode_to_string ofono_radio_access_mode_to_string
|
||||
const char *ofono_radio_access_mode_to_string(enum ofono_radio_access_mode m)
|
||||
{
|
||||
switch (m) {
|
||||
switch (__ofono_radio_access_max_mode(m)) {
|
||||
case OFONO_RADIO_ACCESS_MODE_ANY:
|
||||
return "any";
|
||||
case OFONO_RADIO_ACCESS_MODE_GSM:
|
||||
@@ -76,6 +89,10 @@ const char *ofono_radio_access_mode_to_string(enum ofono_radio_access_mode m)
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
return (m == OFONO_RADIO_ACCESS_MODE_ANY) ? "any" :
|
||||
(m & OFONO_RADIO_ACCESS_MODE_LTE) ? "lte" :
|
||||
(m & OFONO_RADIO_ACCESS_MODE_UMTS) ? "umts" :
|
||||
(m & OFONO_RADIO_ACCESS_MODE_GSM) ? "gsm" : NULL;
|
||||
}
|
||||
#define radio_access_mode_from_string ofono_radio_access_mode_from_string
|
||||
ofono_bool_t ofono_radio_access_mode_from_string(const char *str,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2015-2020 Jolla Ltd.
|
||||
*
|
||||
* 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
|
||||
@@ -1757,7 +1758,7 @@ gboolean sms_udh_iter_init_from_cbs(const struct cbs *cbs,
|
||||
return FALSE;
|
||||
|
||||
hdr = cbs->ud;
|
||||
max_ud_len = 82;
|
||||
max_ud_len = cbs->udlen;
|
||||
|
||||
/* Must have at least one information-element if udhi is true */
|
||||
if (hdr[0] < 2)
|
||||
@@ -3856,8 +3857,8 @@ gboolean cbs_dcs_decode(guint8 dcs, gboolean *udhi, enum sms_class *cls,
|
||||
|
||||
gboolean cbs_decode(const unsigned char *pdu, int len, struct cbs *out)
|
||||
{
|
||||
/* CBS is always a fixed length of 88 bytes */
|
||||
if (len != 88)
|
||||
/* CBS is (almost) always a fixed length of 88 bytes */
|
||||
if (len < 6 || len > 88)
|
||||
return FALSE;
|
||||
|
||||
out->gs = (enum cbs_geo_scope) ((pdu[0] >> 6) & 0x03);
|
||||
@@ -3868,6 +3869,10 @@ gboolean cbs_decode(const unsigned char *pdu, int len, struct cbs *out)
|
||||
out->max_pages = pdu[5] & 0xf;
|
||||
out->page = (pdu[5] >> 4) & 0xf;
|
||||
|
||||
/* Allow the last fragment to be truncated */
|
||||
if (len != 88 && out->max_pages != out->page)
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
* If a mobile receives the code 0000 in either the first field or
|
||||
* the second field then it shall treat the CBS message exactly the
|
||||
@@ -3879,7 +3884,10 @@ gboolean cbs_decode(const unsigned char *pdu, int len, struct cbs *out)
|
||||
out->page = 1;
|
||||
}
|
||||
|
||||
memcpy(out->ud, pdu + 6, 82);
|
||||
out->udlen = (guint8)(len - 6);
|
||||
memcpy(out->ud, pdu + 6, out->udlen);
|
||||
if (out->udlen < 82)
|
||||
memset(out->ud + out->udlen, 0, 82 - out->udlen);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -4072,7 +4080,7 @@ char *cbs_decode_text(GSList *cbs_list, char *iso639_lang)
|
||||
if (iso639)
|
||||
bufsize -= 3;
|
||||
} else {
|
||||
bufsize += 82;
|
||||
bufsize += cbs->udlen;
|
||||
|
||||
if (iso639)
|
||||
bufsize -= 2;
|
||||
@@ -4089,7 +4097,7 @@ char *cbs_decode_text(GSList *cbs_list, char *iso639_lang)
|
||||
if (sms_udh_iter_init_from_cbs(cbs, &iter))
|
||||
taken = sms_udh_iter_get_udh_length(&iter) + 1;
|
||||
|
||||
unpack_7bit_own_buf(cbs->ud + taken, 82 - taken,
|
||||
unpack_7bit_own_buf(cbs->ud + taken, cbs->udlen - taken,
|
||||
taken, FALSE, 2,
|
||||
NULL, 0,
|
||||
(unsigned char *)iso639_lang);
|
||||
@@ -4122,7 +4130,7 @@ char *cbs_decode_text(GSList *cbs_list, char *iso639_lang)
|
||||
max_chars =
|
||||
sms_text_capacity_gsm(CBS_MAX_GSM_CHARS, taken);
|
||||
|
||||
unpack_7bit_own_buf(ud + taken, 82 - taken,
|
||||
unpack_7bit_own_buf(ud + taken, cbs->udlen - taken,
|
||||
taken, FALSE, max_chars,
|
||||
&written, 0, unpacked);
|
||||
|
||||
@@ -4156,7 +4164,7 @@ char *cbs_decode_text(GSList *cbs_list, char *iso639_lang)
|
||||
* the check here since the specification isn't clear
|
||||
*/
|
||||
} else {
|
||||
int num_ucs2_chars = (82 - taken) >> 1;
|
||||
int num_ucs2_chars = (cbs->udlen - taken) >> 1;
|
||||
int i = taken;
|
||||
int max_offset = taken + num_ucs2_chars * 2;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2015-2020 Jolla Ltd.
|
||||
*
|
||||
* 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
|
||||
@@ -398,6 +399,7 @@ struct cbs {
|
||||
guint8 dcs; /* 8 bits */
|
||||
guint8 max_pages; /* 4 bits */
|
||||
guint8 page; /* 4 bits */
|
||||
guint8 udlen;
|
||||
guint8 ud[82];
|
||||
};
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 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
|
||||
@@ -725,6 +727,12 @@ static DBusMessage *stk_register_agent(DBusConnection *conn,
|
||||
if (!dbus_validate_path(agent_path, NULL))
|
||||
return __ofono_error_invalid_format(msg);
|
||||
|
||||
if (!__ofono_dbus_access_method_allowed(dbus_message_get_sender(msg),
|
||||
OFONO_DBUS_ACCESS_INTF_STK,
|
||||
OFONO_DBUS_ACCESS_STK_REGISTER_AGENT,
|
||||
agent_path))
|
||||
return __ofono_error_access_denied(msg);
|
||||
|
||||
stk->default_agent = stk_agent_new(agent_path,
|
||||
dbus_message_get_sender(msg),
|
||||
FALSE);
|
||||
|
||||
@@ -349,12 +349,12 @@ static int tone_queue(struct ofono_voicecall *vc, const char *tone_str,
|
||||
|
||||
/*
|
||||
* Tones can be 0-9, *, #, A-D according to 27.007 C.2.11,
|
||||
* and p for Pause.
|
||||
* and p for Pause (also , for Pause as per ITU-T V.250 6.3.1.2).
|
||||
*/
|
||||
for (i = 0; tone_str[i]; i++)
|
||||
if (!g_ascii_isdigit(tone_str[i]) && tone_str[i] != 'p' &&
|
||||
tone_str[i] != 'P' && tone_str[i] != '*' &&
|
||||
tone_str[i] != '.' && tone_str[i] != ',' &&
|
||||
tone_str[i] != ',' &&
|
||||
tone_str[i] != '#' && (tone_str[i] < 'A' ||
|
||||
tone_str[i] > 'D'))
|
||||
return -EINVAL;
|
||||
@@ -4389,7 +4389,7 @@ static void tone_request_cb(const struct ofono_error *error, void *data)
|
||||
goto done;
|
||||
}
|
||||
|
||||
len = strspn(entry->left, "pP.,");
|
||||
len = strspn(entry->left, "pP,");
|
||||
entry->left += len;
|
||||
|
||||
done:
|
||||
@@ -4423,7 +4423,7 @@ static gboolean tone_request_run(gpointer user_data)
|
||||
if (entry == NULL)
|
||||
return FALSE;
|
||||
|
||||
len = strcspn(entry->left, "pP.,");
|
||||
len = strcspn(entry->left, "pP,");
|
||||
|
||||
if (len) {
|
||||
if (len > 8) /* Arbitrary length limit per request */
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2019 Jolla Ltd.
|
||||
* Copyright (C) 2019-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
|
||||
@@ -33,6 +34,12 @@ static enum ofono_dbus_access deny_method_access(const char *sender,
|
||||
return OFONO_DBUS_ACCESS_DENY;
|
||||
}
|
||||
|
||||
static enum ofono_dbus_access broken_method_access(const char *sender,
|
||||
enum ofono_dbus_access_intf intf, int method, const char *arg)
|
||||
{
|
||||
return (enum ofono_dbus_access)(-1);
|
||||
}
|
||||
|
||||
struct ofono_dbus_access_plugin access_inval;
|
||||
struct ofono_dbus_access_plugin access_dontcare = {
|
||||
.name = "DontCare",
|
||||
@@ -50,6 +57,12 @@ struct ofono_dbus_access_plugin access_deny = {
|
||||
.method_access = deny_method_access
|
||||
};
|
||||
|
||||
struct ofono_dbus_access_plugin access_broken = {
|
||||
.name = "Broken",
|
||||
.priority = OFONO_DBUS_ACCESS_PRIORITY_LOW,
|
||||
.method_access = broken_method_access
|
||||
};
|
||||
|
||||
/*==========================================================================*
|
||||
* Tests
|
||||
*==========================================================================*/
|
||||
@@ -103,6 +116,12 @@ static const struct test_method_name_data method_name_tests[] = {
|
||||
},{
|
||||
OFONO_DBUS_ACCESS_INTF_RADIOSETTINGS,
|
||||
OFONO_DBUS_ACCESS_RADIOSETTINGS_METHOD_COUNT
|
||||
},{
|
||||
OFONO_DBUS_ACCESS_INTF_STK,
|
||||
OFONO_DBUS_ACCESS_STK_METHOD_COUNT
|
||||
},{
|
||||
OFONO_DBUS_ACCESS_INTF_OEMRAW,
|
||||
OFONO_DBUS_ACCESS_OEMRAW_METHOD_COUNT
|
||||
}
|
||||
};
|
||||
|
||||
@@ -152,6 +171,13 @@ static void test_register()
|
||||
ofono_dbus_access_plugin_unregister(&access_deny);
|
||||
ofono_dbus_access_plugin_unregister(&access_dontcare);
|
||||
|
||||
/* And here too */
|
||||
g_assert(!ofono_dbus_access_plugin_register(&access_broken));
|
||||
g_assert(!ofono_dbus_access_plugin_register(&access_deny));
|
||||
g_assert(!__ofono_dbus_access_method_allowed(":1.0", 0, 1, NULL));
|
||||
ofono_dbus_access_plugin_unregister(&access_deny);
|
||||
ofono_dbus_access_plugin_unregister(&access_dontcare);
|
||||
|
||||
/* DontCare will allow everything */
|
||||
g_assert(!ofono_dbus_access_plugin_register(&access_dontcare));
|
||||
g_assert(__ofono_dbus_access_method_allowed(":1.0", 0, 1, NULL));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2014-2017 Jolla. All rights reserved.
|
||||
* Copyright (C) 2014-2020 Jolla. All rights reserved.
|
||||
*
|
||||
* 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
|
||||
@@ -105,21 +105,21 @@ static void test_provision(gconstpointer test_data)
|
||||
|
||||
g_assert(actual->type == expected->type);
|
||||
g_assert(actual->proto == expected->proto);
|
||||
g_assert(!g_strcmp0(actual->provider_name,
|
||||
expected->provider_name));
|
||||
g_assert(!g_strcmp0(actual->name, expected->name));
|
||||
g_assert_cmpstr(actual->provider_name, ==,
|
||||
expected->provider_name);
|
||||
g_assert_cmpstr(actual->name, ==, expected->name);
|
||||
g_assert(actual->provider_primary ==
|
||||
expected->provider_primary);
|
||||
g_assert(!g_strcmp0(actual->apn, expected->apn));
|
||||
g_assert(!g_strcmp0(actual->username,
|
||||
expected->username));
|
||||
g_assert(!g_strcmp0(actual->password,
|
||||
expected->password));
|
||||
g_assert_cmpstr(actual->apn, ==, expected->apn);
|
||||
g_assert_cmpstr(actual->username, ==,
|
||||
expected->username);
|
||||
g_assert_cmpstr(actual->password, ==,
|
||||
expected->password);
|
||||
g_assert(actual->auth_method == expected->auth_method);
|
||||
g_assert(!g_strcmp0(actual->message_proxy,
|
||||
expected->message_proxy));
|
||||
g_assert(!g_strcmp0(actual->message_center,
|
||||
expected->message_center));
|
||||
g_assert_cmpstr(actual->message_proxy, ==,
|
||||
expected->message_proxy);
|
||||
g_assert_cmpstr(actual->message_center, ==,
|
||||
expected->message_center);
|
||||
}
|
||||
} else {
|
||||
g_assert(!__ofono_gprs_provision_get_settings(test->mcc,
|
||||
@@ -212,6 +212,14 @@ static char telia_fi_message_center [] = "http://mms/";
|
||||
.apn = "mms", \
|
||||
.auth_method = OFONO_GPRS_AUTH_METHOD_NONE
|
||||
|
||||
/* Default IMS settings */
|
||||
#define DEFAULT_IMS_SETTINGS \
|
||||
.type = OFONO_GPRS_CONTEXT_TYPE_IMS, \
|
||||
.proto = OFONO_GPRS_PROTO_IPV4V6, \
|
||||
.name = "IMS", \
|
||||
.apn = "ims", \
|
||||
.auth_method = OFONO_GPRS_AUTH_METHOD_NONE
|
||||
|
||||
static const struct ofono_gprs_provision_data telia_fi_internet_mms_p[] = {
|
||||
{
|
||||
.type = OFONO_GPRS_CONTEXT_TYPE_INTERNET,
|
||||
@@ -231,7 +239,8 @@ static const struct ofono_gprs_provision_data telia_fi_internet_mms_p[] = {
|
||||
.auth_method = OFONO_GPRS_AUTH_METHOD_NONE,
|
||||
.message_proxy = telia_fi_message_proxy,
|
||||
.message_center = telia_fi_message_center
|
||||
}
|
||||
},
|
||||
{ DEFAULT_IMS_SETTINGS }
|
||||
};
|
||||
|
||||
static const struct ofono_gprs_provision_data telia_fi_internet_mms[] = {
|
||||
@@ -251,7 +260,8 @@ static const struct ofono_gprs_provision_data telia_fi_internet_mms[] = {
|
||||
.auth_method = OFONO_GPRS_AUTH_METHOD_NONE,
|
||||
.message_proxy = telia_fi_message_proxy,
|
||||
.message_center = telia_fi_message_center
|
||||
}
|
||||
},
|
||||
{ DEFAULT_IMS_SETTINGS }
|
||||
};
|
||||
|
||||
static const struct ofono_gprs_provision_data telia_fi_internet[] = {
|
||||
@@ -263,7 +273,8 @@ static const struct ofono_gprs_provision_data telia_fi_internet[] = {
|
||||
.apn = telia_fi_apn_internet,
|
||||
.auth_method = OFONO_GPRS_AUTH_METHOD_NONE
|
||||
},
|
||||
{ DEFAULT_MMS_SETTINGS }
|
||||
{ DEFAULT_MMS_SETTINGS },
|
||||
{ DEFAULT_IMS_SETTINGS }
|
||||
};
|
||||
|
||||
static const struct ofono_gprs_provision_data telia_fi_mms[] = {
|
||||
@@ -277,12 +288,14 @@ static const struct ofono_gprs_provision_data telia_fi_mms[] = {
|
||||
.auth_method = OFONO_GPRS_AUTH_METHOD_NONE,
|
||||
.message_proxy = telia_fi_message_proxy,
|
||||
.message_center = telia_fi_message_center
|
||||
}
|
||||
},
|
||||
{ DEFAULT_IMS_SETTINGS }
|
||||
};
|
||||
|
||||
static const struct ofono_gprs_provision_data default_settings[] = {
|
||||
{ DEFAILT_INTERNET_SETTINGS },
|
||||
{ DEFAULT_MMS_SETTINGS }
|
||||
{ DEFAULT_MMS_SETTINGS },
|
||||
{ DEFAULT_IMS_SETTINGS }
|
||||
};
|
||||
|
||||
static const struct ofono_gprs_provision_data no_auth_settings[] = {
|
||||
@@ -300,7 +313,8 @@ static const struct ofono_gprs_provision_data no_auth_settings[] = {
|
||||
.name = "MMS",
|
||||
.apn = "mms",
|
||||
.auth_method = OFONO_GPRS_AUTH_METHOD_NONE
|
||||
}
|
||||
},
|
||||
{ DEFAULT_IMS_SETTINGS }
|
||||
};
|
||||
|
||||
static const struct ofono_gprs_provision_data auth_settings[] = {
|
||||
@@ -318,7 +332,8 @@ static const struct ofono_gprs_provision_data auth_settings[] = {
|
||||
.apn = "mms",
|
||||
.password = "password",
|
||||
.auth_method = OFONO_GPRS_AUTH_METHOD_ANY
|
||||
}
|
||||
},
|
||||
{ DEFAULT_IMS_SETTINGS }
|
||||
};
|
||||
|
||||
static const struct ofono_gprs_provision_data settings_ip[] = {
|
||||
@@ -329,7 +344,8 @@ static const struct ofono_gprs_provision_data settings_ip[] = {
|
||||
.apn = "internet",
|
||||
.auth_method = OFONO_GPRS_AUTH_METHOD_NONE
|
||||
},
|
||||
{ DEFAULT_MMS_SETTINGS }
|
||||
{ DEFAULT_MMS_SETTINGS },
|
||||
{ DEFAULT_IMS_SETTINGS }
|
||||
};
|
||||
|
||||
static const struct ofono_gprs_provision_data settings_ipv6[] = {
|
||||
@@ -345,7 +361,8 @@ static const struct ofono_gprs_provision_data settings_ipv6[] = {
|
||||
.name = "MMS",
|
||||
.apn = "mms",
|
||||
.auth_method = OFONO_GPRS_AUTH_METHOD_NONE
|
||||
}
|
||||
},
|
||||
{ DEFAULT_IMS_SETTINGS }
|
||||
};
|
||||
|
||||
static const struct ofono_gprs_provision_data settings_ipv4v6[] = {
|
||||
@@ -356,7 +373,40 @@ static const struct ofono_gprs_provision_data settings_ipv4v6[] = {
|
||||
.name = "MMS",
|
||||
.apn = "mms",
|
||||
.auth_method = OFONO_GPRS_AUTH_METHOD_NONE
|
||||
}
|
||||
},
|
||||
{ DEFAULT_IMS_SETTINGS }
|
||||
};
|
||||
|
||||
static char beeline_provider_name [] = "Beeline";
|
||||
static const struct ofono_gprs_provision_data beeline_ims[] = {
|
||||
{
|
||||
.type = OFONO_GPRS_CONTEXT_TYPE_INTERNET,
|
||||
.proto = OFONO_GPRS_PROTO_IPV4V6,
|
||||
.provider_name = beeline_provider_name,
|
||||
.name = "Beeline Internet",
|
||||
.apn = "internet.beeline.ru",
|
||||
.username = "beeline",
|
||||
.password = "beeline",
|
||||
.auth_method = OFONO_GPRS_AUTH_METHOD_ANY
|
||||
}, {
|
||||
.type = OFONO_GPRS_CONTEXT_TYPE_MMS,
|
||||
.proto = OFONO_GPRS_PROTO_IP,
|
||||
.provider_name = beeline_provider_name,
|
||||
.name = "Beeline MMS",
|
||||
.apn = "mms.beeline.ru",
|
||||
.username = "beeline",
|
||||
.password = "beeline",
|
||||
.auth_method = OFONO_GPRS_AUTH_METHOD_PAP,
|
||||
.message_proxy = "192.168.94.23:8080",
|
||||
.message_center = "http://mms/"
|
||||
}, {
|
||||
.type = OFONO_GPRS_CONTEXT_TYPE_IMS,
|
||||
.proto = OFONO_GPRS_PROTO_IPV4V6,
|
||||
.provider_name = beeline_provider_name,
|
||||
.name = "Beeline IMS",
|
||||
.apn = "ims.beeline.ru",
|
||||
.auth_method = OFONO_GPRS_AUTH_METHOD_NONE
|
||||
}
|
||||
};
|
||||
|
||||
static char test_provider_name[] = "Test provider";
|
||||
@@ -382,7 +432,8 @@ static const struct ofono_gprs_provision_data test_username_password[] = {
|
||||
.auth_method = OFONO_GPRS_AUTH_METHOD_CHAP,
|
||||
.message_proxy = test_message_proxy,
|
||||
.message_center = test_message_center
|
||||
}
|
||||
},
|
||||
{ DEFAULT_IMS_SETTINGS }
|
||||
};
|
||||
|
||||
static const char telia_fi_internet_xml[] =
|
||||
@@ -806,6 +857,42 @@ static const struct provision_test_case test_cases[] = {
|
||||
.mnc = "91",
|
||||
.settings = telia_fi_mms,
|
||||
.count = G_N_ELEMENTS(telia_fi_mms)
|
||||
},{
|
||||
.name = TEST_SUITE "ims",
|
||||
.xml =
|
||||
"<serviceproviders format=\"2.0\">\n\
|
||||
<country code=\"ru\">\n\
|
||||
<provider>\n\
|
||||
<name>Beeline</name>\n\
|
||||
<gsm>\n\
|
||||
<network-id mcc=\"250\" mnc=\"99\"/>\n\
|
||||
<apn value=\"internet.beeline.ru\">\n\
|
||||
<usage type=\"internet\"/>\n\
|
||||
<name>Beeline Internet</name>\n\
|
||||
<username>beeline</username>\n\
|
||||
<password>beeline</password>\n\
|
||||
</apn>\n\
|
||||
<apn value=\"mms.beeline.ru\">\n\
|
||||
<usage type=\"mms\"/>\n\
|
||||
<name>Beeline MMS</name>\n\
|
||||
<authentication method=\"pap\"/>\n\
|
||||
<username>beeline</username>\n\
|
||||
<password>beeline</password>\n\
|
||||
<mmsc>http://mms/</mmsc>\n\
|
||||
<mmsproxy>192.168.94.23:8080</mmsproxy>\n\
|
||||
</apn>\n\
|
||||
<apn value=\"ims.beeline.ru\">\n\
|
||||
<usage type=\"ims\"/>\n\
|
||||
<name>Beeline IMS</name>\n\
|
||||
</apn>\n\
|
||||
</gsm>\n\
|
||||
</provider>\n\
|
||||
</country>\n\
|
||||
</serviceproviders>\n",
|
||||
.mcc = "250",
|
||||
.mnc = "99",
|
||||
.settings = beeline_ims,
|
||||
.count = G_N_ELEMENTS(beeline_ims)
|
||||
},{
|
||||
.name = TEST_SUITE "not_found_mcc",
|
||||
.xml = telia_fi_internet_xml,
|
||||
@@ -1297,3 +1384,11 @@ int main(int argc, char **argv)
|
||||
}
|
||||
return g_test_run();
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2018-2019 Jolla Ltd.
|
||||
* Copyright (C) 2019 Open Mobile Platform LLC.
|
||||
* Copyright (C) 2018-2020 Jolla Ltd.
|
||||
* 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
|
||||
@@ -377,6 +377,39 @@ static void test_get_enum(void)
|
||||
test_get_value(conf, test_get_enum_cb);
|
||||
}
|
||||
|
||||
/* ==== get_mask ==== */
|
||||
|
||||
static void test_get_mask_cb(GKeyFile *k)
|
||||
{
|
||||
int v = 0;
|
||||
|
||||
g_assert(!ril_config_get_mask(k, "g1", "k", NULL, "x",1, "y",2, NULL));
|
||||
g_assert(!ril_config_get_mask(k, "g1", "k", &v, "x",1, "y",2, NULL));
|
||||
g_assert_cmpint(v, ==, 0);
|
||||
|
||||
g_assert(ril_config_get_mask(k, "g", "k", NULL, "x",1, "y",2, NULL));
|
||||
g_assert(ril_config_get_mask(k, "g", "k", &v, "x",1, "y",2, NULL));
|
||||
g_assert_cmpint(v, ==, 1);
|
||||
|
||||
g_assert(ril_config_get_mask(k, "g", "k1", NULL, "x",1, "y",2, NULL));
|
||||
g_assert(ril_config_get_mask(k, "g", "k1", &v, "x",1, "y",2, NULL));
|
||||
g_assert_cmpint(v, ==, 3);
|
||||
|
||||
g_assert(!ril_config_get_mask(k, "g", "k2", NULL, "x",1, "y",2, NULL));
|
||||
g_assert(!ril_config_get_mask(k, "g", "k2", &v, "x",1, "y",2, NULL));
|
||||
g_assert_cmpint(v, ==, 0);
|
||||
}
|
||||
|
||||
static void test_get_mask(void)
|
||||
{
|
||||
static const char conf [] = "[g]\n"
|
||||
"k = x# comment\n"
|
||||
"k1 = x+y\n"
|
||||
"k2 = x+z+y\n";
|
||||
|
||||
test_get_value(conf, test_get_mask_cb);
|
||||
}
|
||||
|
||||
/* ==== get_ints ==== */
|
||||
|
||||
static void test_get_ints_cb(GKeyFile *k)
|
||||
@@ -451,6 +484,7 @@ int main(int argc, char *argv[])
|
||||
g_test_add_func(TEST_("get_boolean3"), test_get_boolean3);
|
||||
g_test_add_func(TEST_("get_flag"), test_get_flag);
|
||||
g_test_add_func(TEST_("get_enum"), test_get_enum);
|
||||
g_test_add_func(TEST_("get_mask"), test_get_mask);
|
||||
g_test_add_func(TEST_("get_ints"), test_get_ints);
|
||||
g_test_add_func(TEST_("ints_to_string"), test_ints_to_string);
|
||||
|
||||
|
||||
@@ -2,12 +2,11 @@ Name: ofono
|
||||
Summary: Open Source Telephony
|
||||
Version: 1.23
|
||||
Release: 1
|
||||
Group: Communications/Connectivity Adaptation
|
||||
License: GPLv2
|
||||
URL: https://git.sailfishos.org/mer-core/ofono
|
||||
Source: %{name}-%{version}.tar.bz2
|
||||
|
||||
%define libgrilio_version 1.0.35
|
||||
%define libgrilio_version 1.0.38
|
||||
%define libglibutil_version 1.0.30
|
||||
%define libmce_version 1.0.6
|
||||
|
||||
@@ -38,13 +37,13 @@ BuildRequires: pkgconfig(mobile-broadband-provider-info)
|
||||
BuildRequires: libtool
|
||||
BuildRequires: automake
|
||||
BuildRequires: autoconf
|
||||
BuildRequires: systemd
|
||||
|
||||
%description
|
||||
Telephony stack
|
||||
|
||||
%package devel
|
||||
Summary: Headers for oFono
|
||||
Group: Development/Libraries
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
|
||||
%description devel
|
||||
@@ -52,7 +51,6 @@ Development headers and libraries for oFono
|
||||
|
||||
%package tests
|
||||
Summary: Test Scripts for oFono
|
||||
Group: Development/Libraries
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
Requires: dbus-python3
|
||||
Requires: python3-gobject
|
||||
@@ -64,7 +62,6 @@ Scripts for testing oFono and its functionality
|
||||
|
||||
%package configs-mer
|
||||
Summary: Package to provide default configs for ofono
|
||||
Group: Development/Tools
|
||||
Provides: ofono-configs
|
||||
|
||||
%description configs-mer
|
||||
@@ -72,7 +69,6 @@ This package provides default configs for ofono
|
||||
|
||||
%package doc
|
||||
Summary: Documentation for %{name}
|
||||
Group: Documentation
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
|
||||
%description doc
|
||||
@@ -98,9 +94,9 @@ autoreconf --force --install
|
||||
--disable-add-remove-context \
|
||||
--disable-isimodem \
|
||||
--disable-qmimodem \
|
||||
--with-systemdunitdir="/%{_lib}/systemd/system"
|
||||
--with-systemdunitdir=%{_unitdir}
|
||||
|
||||
make %{_smp_mflags}
|
||||
%make_build
|
||||
|
||||
%check
|
||||
# run unit tests
|
||||
@@ -111,9 +107,9 @@ rm -rf %{buildroot}
|
||||
%make_install
|
||||
|
||||
mkdir -p %{buildroot}/%{_sysconfdir}/ofono/push_forwarder.d
|
||||
mkdir -p %{buildroot}/%{_lib}/systemd/system/network.target.wants
|
||||
mkdir -p %{buildroot}%{_unitdir}/network.target.wants
|
||||
mkdir -p %{buildroot}/var/lib/ofono
|
||||
ln -s ../ofono.service %{buildroot}/%{_lib}/systemd/system/network.target.wants/ofono.service
|
||||
ln -s ../ofono.service %{buildroot}%{_unitdir}/network.target.wants/ofono.service
|
||||
|
||||
mkdir -p %{buildroot}%{_docdir}/%{name}-%{version}
|
||||
install -m0644 -t %{buildroot}%{_docdir}/%{name}-%{version} \
|
||||
@@ -139,8 +135,8 @@ systemctl daemon-reload ||:
|
||||
%license COPYING
|
||||
%config %{_sysconfdir}/dbus-1/system.d/*.conf
|
||||
%{_sbindir}/*
|
||||
/%{_lib}/systemd/system/network.target.wants/ofono.service
|
||||
/%{_lib}/systemd/system/ofono.service
|
||||
%{_unitdir}/network.target.wants/ofono.service
|
||||
%{_unitdir}/ofono.service
|
||||
%dir %{_sysconfdir}/ofono/
|
||||
%dir %{_sysconfdir}/ofono/push_forwarder.d
|
||||
# This file is part of phonesim and not needed with ofono.
|
||||
|
||||
Reference in New Issue
Block a user