mirror of
https://github.com/sailfishos/ofono
synced 2025-12-02 23:51:10 +08:00
Compare commits
3 Commits
mer/1.23+g
...
mer/1.23+g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c98d2f41c5 | ||
|
|
b279be4528 | ||
|
|
a7912fea39 |
@@ -151,6 +151,7 @@ builtin_sources += drivers/ril/ril_call_barring.c \
|
|||||||
drivers/ril/ril_devinfo.c \
|
drivers/ril/ril_devinfo.c \
|
||||||
drivers/ril/ril_devmon.c \
|
drivers/ril/ril_devmon.c \
|
||||||
drivers/ril/ril_devmon_auto.c \
|
drivers/ril/ril_devmon_auto.c \
|
||||||
|
drivers/ril/ril_devmon_combine.c \
|
||||||
drivers/ril/ril_devmon_ds.c \
|
drivers/ril/ril_devmon_ds.c \
|
||||||
drivers/ril/ril_devmon_ss.c \
|
drivers/ril/ril_devmon_ss.c \
|
||||||
drivers/ril/ril_devmon_ur.c \
|
drivers/ril/ril_devmon_ur.c \
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* oFono - Open Source Telephony - RIL-based devices
|
* 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.
|
* Copyright (C) 2019-2020 Open Mobile Platform LLC.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
@@ -186,6 +186,72 @@ gboolean ril_config_get_enum(GKeyFile *file, const char *group,
|
|||||||
return FALSE;
|
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,
|
GUtilInts *ril_config_get_ints(GKeyFile *file, const char *group,
|
||||||
const char *key)
|
const char *key)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* oFono - Open Source Telephony - RIL-based devices
|
* 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.
|
* Copyright (C) 2019-2020 Open Mobile Platform LLC.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
@@ -35,7 +35,12 @@ gboolean ril_config_get_flag(GKeyFile *file, const char *group,
|
|||||||
const char *key, int flag, int *flags);
|
const char *key, int flag, int *flags);
|
||||||
gboolean ril_config_get_enum(GKeyFile *file, const char *group,
|
gboolean ril_config_get_enum(GKeyFile *file, const char *group,
|
||||||
const char *key, int *result,
|
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,
|
GUtilInts *ril_config_get_ints(GKeyFile *file, const char *group,
|
||||||
const char *key);
|
const char *key);
|
||||||
char *ril_config_ints_to_string(GUtilInts *ints, char separator);
|
char *ril_config_ints_to_string(GUtilInts *ints, char separator);
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* oFono - Open Source Telephony - RIL-based devices
|
* 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
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
@@ -61,6 +62,11 @@ struct ril_devmon *ril_devmon_ur_new(void);
|
|||||||
*/
|
*/
|
||||||
struct ril_devmon *ril_devmon_auto_new(void);
|
struct ril_devmon *ril_devmon_auto_new(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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) */
|
/* Utilities (NULL tolerant) */
|
||||||
struct ril_devmon_io *ril_devmon_start_io(struct ril_devmon *devmon,
|
struct ril_devmon_io *ril_devmon_start_io(struct ril_devmon *devmon,
|
||||||
GRilIoChannel *channel, struct sailfish_cell_info *cell_info);
|
GRilIoChannel *channel, struct sailfish_cell_info *cell_info);
|
||||||
|
|||||||
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:
|
||||||
|
*/
|
||||||
@@ -179,11 +179,9 @@ enum ril_set_radio_cap_opt {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum ril_devmon_opt {
|
enum ril_devmon_opt {
|
||||||
RIL_DEVMON_NONE,
|
RIL_DEVMON_SS = 0x01,
|
||||||
RIL_DEVMON_AUTO,
|
RIL_DEVMON_DS = 0x02,
|
||||||
RIL_DEVMON_SS,
|
RIL_DEVMON_UR = 0x04
|
||||||
RIL_DEVMON_DS,
|
|
||||||
RIL_DEVMON_UR
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ril_plugin_identity {
|
struct ril_plugin_identity {
|
||||||
@@ -1707,26 +1705,32 @@ static ril_slot *ril_plugin_parse_config_group(GKeyFile *file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* deviceStateTracking */
|
/* deviceStateTracking */
|
||||||
if (ril_config_get_enum(file, group, RILCONF_DEVMON, &ival,
|
if (ril_config_get_mask(file, group, RILCONF_DEVMON, &ival,
|
||||||
"none", RIL_DEVMON_NONE,
|
|
||||||
"auto", RIL_DEVMON_AUTO,
|
|
||||||
"ds", RIL_DEVMON_DS,
|
"ds", RIL_DEVMON_DS,
|
||||||
"ss", RIL_DEVMON_SS,
|
"ss", RIL_DEVMON_SS,
|
||||||
"ur", RIL_DEVMON_UR, NULL)) {
|
"ur", RIL_DEVMON_UR, NULL) && ival) {
|
||||||
DBG("%s: " RILCONF_DEVMON " %s", group,
|
int n = 0;
|
||||||
ival == RIL_DEVMON_NONE ? "off" :
|
struct ril_devmon *devmon[3];
|
||||||
ival == RIL_DEVMON_DS ? "on" :
|
|
||||||
ival == RIL_DEVMON_SS ? "legacy" :
|
if (ival & RIL_DEVMON_DS) devmon[n++] = ril_devmon_ds_new();
|
||||||
ival == RIL_DEVMON_UR ? "filter" :
|
if (ival & RIL_DEVMON_SS) devmon[n++] = ril_devmon_ss_new();
|
||||||
"auto");
|
if (ival & RIL_DEVMON_UR) devmon[n++] = ril_devmon_ur_new();
|
||||||
if (ival != RIL_DEVMON_AUTO) {
|
DBG("%s: " RILCONF_DEVMON " 0x%x", group, ival);
|
||||||
/* Default is automatic, reallocate the object */
|
ril_devmon_free(slot->devmon);
|
||||||
ril_devmon_free(slot->devmon);
|
slot->devmon = ril_devmon_combine(devmon, n);
|
||||||
slot->devmon =
|
} else {
|
||||||
(ival == RIL_DEVMON_DS ? ril_devmon_ds_new() :
|
/* Try special values */
|
||||||
ival == RIL_DEVMON_SS ? ril_devmon_ss_new() :
|
sval = ril_config_get_string(file, group, RILCONF_DEVMON);
|
||||||
ival == RIL_DEVMON_UR ? ril_devmon_ur_new() :
|
if (sval) {
|
||||||
NULL);
|
if (!g_ascii_strcasecmp(sval, "none")) {
|
||||||
|
DBG("%s: " RILCONF_DEVMON " %s", group, sval);
|
||||||
|
ril_devmon_free(slot->devmon);
|
||||||
|
slot->devmon = NULL;
|
||||||
|
} else if (!g_ascii_strcasecmp(sval, "auto")) {
|
||||||
|
DBG("%s: " RILCONF_DEVMON " %s", group, sval);
|
||||||
|
/* This is the default */
|
||||||
|
}
|
||||||
|
g_free(sval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -308,6 +308,9 @@ socket=/dev/socket/rild
|
|||||||
# auto = Choose ss or ds based on the RIL version
|
# auto = Choose ss or ds based on the RIL version
|
||||||
# none = Disable device state management
|
# 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
|
# Default auto
|
||||||
#
|
#
|
||||||
#deviceStateTracking=auto
|
#deviceStateTracking=auto
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* oFono - Open Source Telephony
|
* oFono - Open Source Telephony
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018-2019 Jolla Ltd.
|
* Copyright (C) 2018-2020 Jolla Ltd.
|
||||||
* Copyright (C) 2019 Open Mobile Platform LLC.
|
* Copyright (C) 2019-2020 Open Mobile Platform LLC.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
@@ -377,6 +377,39 @@ static void test_get_enum(void)
|
|||||||
test_get_value(conf, test_get_enum_cb);
|
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 ==== */
|
/* ==== get_ints ==== */
|
||||||
|
|
||||||
static void test_get_ints_cb(GKeyFile *k)
|
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_boolean3"), test_get_boolean3);
|
||||||
g_test_add_func(TEST_("get_flag"), test_get_flag);
|
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_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_("get_ints"), test_get_ints);
|
||||||
g_test_add_func(TEST_("ints_to_string"), test_ints_to_string);
|
g_test_add_func(TEST_("ints_to_string"), test_ints_to_string);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user