[ofono-binder] Added ofono_ims_driver. JB#57408

This commit is contained in:
Slava Monich
2022-02-12 06:07:38 +02:00
parent e2fe5d81ed
commit acae089c5a
8 changed files with 287 additions and 2 deletions

View File

@@ -51,6 +51,7 @@ SRC = \
binder_devmon_if.c \
binder_gprs.c \
binder_gprs_context.c \
binder_ims.c \
binder_logger.c \
binder_modem.c \
binder_netreg.c \

View File

@@ -149,3 +149,11 @@
# Default all
#
#deviceStateTracking=all
# Comma-separated list of features to disable. The following values are
# allowed: cbs, data, netreg, pb, rat, auth, sms, stk, ussd, voice, ims,
# all.
#
# Default none (all supported features are enabled)
#
#disableFeatures=

View File

@@ -11,7 +11,7 @@ Source: %{name}-%{version}.tar.bz2
%define libgbinder_version 1.1.15
%define libgbinder_radio_version 1.4.8
%define libmce_version 1.0.6
%define ofono_version 1.28+git2
%define ofono_version 1.28+git3
BuildRequires: pkgconfig
BuildRequires: ofono-devel >= %{ofono_version}

231
src/binder_ims.c Normal file
View File

@@ -0,0 +1,231 @@
/*
* oFono - Open Source Telephony - binder based adaptation
*
* Copyright (C) 2022 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
* 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 "binder_ims.h"
#include "binder_log.h"
#include "binder_modem.h"
#include "binder_util.h"
#include <ofono/ims.h>
#include <radio_client.h>
#include <radio_request.h>
#include <radio_request_group.h>
#include <gbinder_reader.h>
enum binder_sms_events {
IMS_EVENT_IMS_NETWORK_STATE_CHANGED,
IMS_EVENT_COUNT
};
typedef struct binder_ims {
struct ofono_ims* ims;
gboolean registered;
int flags;
char* log_prefix;
RadioRequestGroup* g;
gulong event_id[IMS_EVENT_COUNT];
guint start_id;
} BinderIms;
#define DBG_(self,fmt,args...) DBG("%s" fmt, (self)->log_prefix, ##args)
static inline BinderIms* binder_ims_get_data(struct ofono_ims* ims)
{ return ofono_ims_get_data(ims); }
static
void
binder_ims_query_registration_state_cb(
RadioRequest* req,
RADIO_TX_STATUS status,
RADIO_RESP resp,
RADIO_ERROR error,
const GBinderReader* args,
gpointer user_data)
{
BinderIms* self = user_data;
if (status == RADIO_TX_STATUS_OK) {
if (resp == RADIO_RESP_GET_IMS_REGISTRATION_STATE) {
if (error == RADIO_ERROR_NONE) {
GBinderReader reader;
gboolean registered;
gint32 rat;
/*
* getImsRegistrationStateResponse(RadioResponseInfo info,
* bool isRegistered, RadioTechnologyFamily ratFamily)
*/
gbinder_reader_copy(&reader, args);
if (gbinder_reader_read_bool(&reader, &registered) &&
gbinder_reader_read_int32(&reader, &rat)) {
DBG_(self, "registered: %d, rat: 0x%08x", registered, rat);
if (self->registered != registered) {
self->registered = registered;
self->flags = registered ? OFONO_IMS_SMS_CAPABLE : 0;
ofono_ims_status_notify(self->ims, registered,
self->flags);
}
}
} else {
DBG_(self, "%s", binder_radio_error_string(error));
}
} else {
ofono_error("Unexpected getImsRegistrationState response %d",
resp);
}
}
}
static
void
binder_ims_query_registration_state(
BinderIms* self)
{
RadioRequest* req = radio_request_new2(self->g,
RADIO_REQ_GET_IMS_REGISTRATION_STATE, NULL,
binder_ims_query_registration_state_cb, NULL, self);
radio_request_submit(req);
radio_request_unref(req);
}
static
void
binder_ims_network_state_changed(
RadioClient* client,
RADIO_IND code,
const GBinderReader* args,
gpointer user_data)
{
BinderIms* self = user_data;
DBG_(self, "");
binder_ims_query_registration_state(self);
}
static
void
binder_ims_registration_status(
struct ofono_ims* ims,
ofono_ims_status_cb_t cb,
void* data)
{
BinderIms* self = binder_ims_get_data(ims);
struct ofono_error err;
cb(binder_error_ok(&err), self->registered, self->flags, data);
}
static
gboolean
binder_ims_start(
gpointer user_data)
{
BinderIms* self = user_data;
RadioClient* client = self->g->client;
DBG_(self, "");
GASSERT(self->start_id);
self->start_id = 0;
ofono_ims_register(self->ims);
/* Register event handlers */
self->event_id[IMS_EVENT_IMS_NETWORK_STATE_CHANGED] =
radio_client_add_indication_handler(client,
RADIO_IND_IMS_NETWORK_STATE_CHANGED,
binder_ims_network_state_changed, self);
/* Request the initial state */
binder_ims_query_registration_state(self);
return G_SOURCE_REMOVE;
}
static
int
binder_ims_probe(
struct ofono_ims* ims,
void* data)
{
BinderModem* modem = binder_modem_get_data(data);
BinderIms* self = g_new0(BinderIms, 1);
self->log_prefix = binder_dup_prefix(modem->log_prefix);
DBG_(self, "");
self->g = radio_request_group_new(modem->client); /* Keeps ref to client */
self->ims = ims;
self->start_id = g_idle_add(binder_ims_start, self);
ofono_ims_set_data(ims, self);
return 0;
}
static
void
binder_ims_remove(
struct ofono_ims* ims)
{
BinderIms* self = binder_ims_get_data(ims);
DBG_(self, "");
if (self->start_id) {
g_source_remove(self->start_id);
}
radio_client_remove_all_handlers(self->g->client, self->event_id);
radio_request_group_cancel(self->g);
radio_request_group_unref(self->g);
g_free(self->log_prefix);
g_free(self);
ofono_ims_set_data(ims, NULL);
}
/*==========================================================================*
* API
*==========================================================================*/
static const struct ofono_ims_driver binder_ims_driver = {
.name = BINDER_DRIVER,
.probe = binder_ims_probe,
.remove = binder_ims_remove,
.registration_status = binder_ims_registration_status
};
void
binder_ims_init()
{
ofono_ims_driver_register(&binder_ims_driver);
}
void
binder_ims_cleanup()
{
ofono_ims_driver_unregister(&binder_ims_driver);
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/

37
src/binder_ims.h Normal file
View File

@@ -0,0 +1,37 @@
/*
* oFono - Open Source Telephony - binder based adaptation
*
* Copyright (C) 2022 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
* 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.
*/
#ifndef BINDER_IMS_H
#define BINDER_IMS_H
#include "binder_types.h"
void
binder_ims_init(void)
BINDER_INTERNAL;
void
binder_ims_cleanup(void)
BINDER_INTERNAL;
#endif /* BINDER_IMS_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/

View File

@@ -31,6 +31,7 @@
#include <ofono/cell-info.h>
#include <ofono/devinfo.h>
#include <ofono/gprs.h>
#include <ofono/ims.h>
#include <ofono/message-waiting.h>
#include <ofono/modem.h>
#include <ofono/netmon.h>
@@ -377,6 +378,9 @@ binder_modem_post_online(
if (features & BINDER_FEATURE_USSD) {
ofono_ussd_create(ofono, 0, BINDER_DRIVER, ofono);
}
if (features & BINDER_FEATURE_IMS) {
ofono_ims_create(ofono, BINDER_DRIVER, ofono);
}
ofono_netmon_create(ofono, 0, "cellinfo", ofono);
}

View File

@@ -24,6 +24,7 @@
#include "binder_devmon.h"
#include "binder_gprs.h"
#include "binder_gprs_context.h"
#include "binder_ims.h"
#include "binder_log.h"
#include "binder_logger.h"
#include "binder_modem.h"
@@ -292,6 +293,7 @@ static const BinderPluginModule binder_plugin_modules[] = {
{ binder_devinfo_init, binder_devinfo_cleanup },
{ binder_gprs_context_init, binder_gprs_context_cleanup },
{ binder_gprs_init, binder_gprs_cleanup },
{ binder_ims_init, binder_ims_cleanup },
{ binder_modem_init, binder_modem_cleanup },
{ binder_netreg_init, binder_netreg_cleanup },
{ binder_radio_settings_init, binder_radio_settings_cleanup },
@@ -1406,6 +1408,7 @@ binder_plugin_create_slot(
"stk", BINDER_FEATURE_STK,
"ussd", BINDER_FEATURE_USSD,
"voice", BINDER_FEATURE_VOICE,
"ims", BINDER_FEATURE_IMS,
"all", BINDER_FEATURE_ALL, NULL) && ival) {
config->features &= ~ival;
DBG("%s: " BINDER_CONF_SLOT_DISABLE_FEATURES " 0x%04x", group, ival);

View File

@@ -45,7 +45,8 @@ typedef enum binder_feature_mask {
BINDER_FEATURE_STK = 0x0080, /* stk */
BINDER_FEATURE_USSD = 0x0100, /* ussd */
BINDER_FEATURE_VOICE = 0x0200, /* voice */
BINDER_FEATURE_ALL = 0x03ff /* all */
BINDER_FEATURE_IMS = 0x0400, /* ims */
BINDER_FEATURE_ALL = 0x07ff /* all */
} BINDER_FEATURE_MASK;
typedef struct binder_slot_config {