mirror of
https://github.com/sailfishos/ofono
synced 2025-11-26 20:31:06 +08:00
Compare commits
10 Commits
mer/1.20+g
...
mer/1.20+g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e267487f4 | ||
|
|
c8a774dfee | ||
|
|
b88518d0f3 | ||
|
|
b223ccc675 | ||
|
|
947a41a5fc | ||
|
|
e0b4e8694d | ||
|
|
c8db770c99 | ||
|
|
1534143e31 | ||
|
|
d9ad9caf30 | ||
|
|
71de574e87 |
@@ -24,7 +24,9 @@ pkginclude_HEADERS = include/log.h include/plugin.h include/history.h \
|
||||
include/sim-mnclength.h \
|
||||
include/handsfree-audio.h include/siri.h \
|
||||
include/sms-filter.h \
|
||||
include/netmon.h include/lte.h
|
||||
include/netmon.h include/lte.h \
|
||||
include/storage.h \
|
||||
gdbus/gdbus.h
|
||||
|
||||
nodist_pkginclude_HEADERS = include/version.h
|
||||
|
||||
@@ -1163,6 +1165,10 @@ include/ofono/version.h: include/version.h
|
||||
$(AM_V_at)$(MKDIR_P) include/ofono
|
||||
$(AM_V_GEN)$(LN_S) $(abs_top_builddir)/$< $@
|
||||
|
||||
include/ofono/gdbus.h: $(abs_top_srcdir)/gdbus/gdbus.h
|
||||
$(AM_V_at)$(MKDIR_P) include/ofono
|
||||
$(AM_V_GEN)$(LN_S) $< $@
|
||||
|
||||
include/ofono/%.h: $(abs_top_srcdir)/include/%.h
|
||||
$(AM_V_at)$(MKDIR_P) include/ofono
|
||||
$(AM_V_GEN)$(LN_S) $< $@
|
||||
|
||||
@@ -94,6 +94,7 @@ struct ril_data_priv {
|
||||
struct ril_network *network;
|
||||
struct ril_data_manager *dm;
|
||||
enum ril_data_priv_flags flags;
|
||||
struct ril_vendor_hook *vendor_hook;
|
||||
|
||||
struct ril_data_request *req_queue;
|
||||
struct ril_data_request *pending_req;
|
||||
@@ -535,11 +536,18 @@ static void ril_data_query_data_calls_cb(GRilIoChannel *io, int ril_status,
|
||||
struct ril_data *self = RIL_DATA(user_data);
|
||||
struct ril_data_priv *priv = self->priv;
|
||||
|
||||
/*
|
||||
* Only RIL_E_SUCCESS and RIL_E_RADIO_NOT_AVAILABLE are expected here,
|
||||
* all other errors are filtered out by ril_voicecall_clcc_retry()
|
||||
*/
|
||||
GASSERT(priv->query_id);
|
||||
priv->query_id = 0;
|
||||
if (ril_status == RIL_E_SUCCESS) {
|
||||
ril_data_set_calls(self, ril_data_call_list_parse(data, len,
|
||||
priv->options.data_call_format));
|
||||
} else {
|
||||
/* RADIO_NOT_AVAILABLE == no calls */
|
||||
ril_data_set_calls(self, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1162,6 +1170,18 @@ struct ril_data *ril_data_new(struct ril_data_manager *dm, const char *name,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean ril_data_poll_call_state_retry(GRilIoRequest* req,
|
||||
int ril_status, const void* resp_data, guint resp_len, void* user_data)
|
||||
{
|
||||
switch (ril_status) {
|
||||
case RIL_E_SUCCESS:
|
||||
case RIL_E_RADIO_NOT_AVAILABLE:
|
||||
return FALSE;
|
||||
default:
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void ril_data_poll_call_state(struct ril_data *self)
|
||||
{
|
||||
if (G_LIKELY(self)) {
|
||||
@@ -1171,6 +1191,8 @@ void ril_data_poll_call_state(struct ril_data *self)
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
grilio_request_set_retry(req, RIL_RETRY_SECS*1000, -1);
|
||||
grilio_request_set_retry_func(req,
|
||||
ril_data_poll_call_state_retry);
|
||||
priv->query_id =
|
||||
grilio_queue_send_request_full(priv->q, req,
|
||||
RIL_REQUEST_DATA_CALL_LIST,
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "ofono.h"
|
||||
#include "common.h"
|
||||
#include "mtu-watch.h"
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
#define OFONO_API_SUBJECT_TO_CHANGE
|
||||
#include <ofono/plugin.h>
|
||||
#include "storage.h"
|
||||
#include <ofono/storage.h>
|
||||
|
||||
#define OFONO_RADIO_ACCESS_MODE_ALL (OFONO_RADIO_ACCESS_MODE_GSM |\
|
||||
OFONO_RADIO_ACCESS_MODE_UMTS |\
|
||||
@@ -73,6 +73,7 @@
|
||||
#define RILMODEM_DEFAULT_DATA_CALL_RETRY_LIMIT 4
|
||||
#define RILMODEM_DEFAULT_DATA_CALL_RETRY_DELAY 200 /* ms */
|
||||
#define RILMODEM_DEFAULT_EMPTY_PIN_QUERY TRUE /* optimistic */
|
||||
#define RILMODEM_DEFAULT_LEGACY_IMEI_QUERY FALSE
|
||||
|
||||
/*
|
||||
* The convention is that the keys which can only appear in the [Settings]
|
||||
@@ -105,6 +106,7 @@
|
||||
#define RILCONF_DATA_CALL_RETRY_DELAY "dataCallRetryDelay"
|
||||
#define RILCONF_LOCAL_HANGUP_REASONS "localHangupReasons"
|
||||
#define RILCONF_REMOTE_HANGUP_REASONS "remoteHangupReasons"
|
||||
#define RILCONF_DEFAULT_LEGACY_IMEI_QUERY "legacyImeiQuery"
|
||||
|
||||
/* Modem error ids */
|
||||
#define RIL_ERROR_ID_RILD_RESTART "rild-restart"
|
||||
@@ -183,6 +185,7 @@ typedef struct sailfish_slot_impl {
|
||||
struct ril_sim_settings *sim_settings;
|
||||
struct ril_oem_raw *oem_raw;
|
||||
struct ril_data *data;
|
||||
gboolean legacy_imei_query;
|
||||
guint start_timeout;
|
||||
guint start_timeout_id;
|
||||
MceDisplay *display;
|
||||
@@ -440,6 +443,99 @@ static void ril_plugin_check_ready(ril_slot *slot)
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_plugin_get_imeisv_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
ril_slot *slot = user_data;
|
||||
char *imeisv = NULL;
|
||||
|
||||
GASSERT(slot->imei_req_id);
|
||||
slot->imei_req_id = 0;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
GRilIoParser rilp;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
imeisv = grilio_parser_get_utf8(&rilp);
|
||||
DBG("%s", imeisv);
|
||||
|
||||
/*
|
||||
* slot->imei should be either NULL (when we get connected
|
||||
* to rild the very first time) or match the already known
|
||||
* IMEI (if rild crashed and we have reconnected)
|
||||
*/
|
||||
if (slot->imeisv && imeisv && strcmp(slot->imeisv, imeisv)) {
|
||||
ofono_warn("IMEISV has changed \"%s\" -> \"%s\"",
|
||||
slot->imeisv, imeisv);
|
||||
}
|
||||
} else {
|
||||
ofono_error("Slot %u IMEISV query error: %s",
|
||||
slot->config.slot, ril_error_to_string(status));
|
||||
}
|
||||
|
||||
if (slot->imeisv) {
|
||||
/* We assume that IMEISV never changes */
|
||||
g_free(imeisv);
|
||||
} else {
|
||||
slot->imeisv = (imeisv ? imeisv : g_strdup(""));
|
||||
sailfish_manager_imeisv_obtained(slot->handle, slot->imeisv);
|
||||
}
|
||||
|
||||
ril_plugin_check_modem(slot);
|
||||
}
|
||||
|
||||
static void ril_plugin_get_imei_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
ril_slot *slot = user_data;
|
||||
char *imei = NULL;
|
||||
|
||||
GASSERT(slot->imei_req_id);
|
||||
slot->imei_req_id = 0;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
GRilIoParser rilp;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
imei = grilio_parser_get_utf8(&rilp);
|
||||
DBG("%s", imei);
|
||||
|
||||
/*
|
||||
* slot->imei should be either NULL (when we get connected
|
||||
* to rild the very first time) or match the already known
|
||||
* IMEI (if rild crashed and we have reconnected)
|
||||
*/
|
||||
if (slot->imei && imei && strcmp(slot->imei, imei)) {
|
||||
ofono_warn("IMEI has changed \"%s\" -> \"%s\"",
|
||||
slot->imei, imei);
|
||||
}
|
||||
|
||||
if (imei) {
|
||||
/* IMEI query was successful, fetch IMEISV too */
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
slot->imei_req_id =
|
||||
grilio_channel_send_request_full(slot->io,
|
||||
req, RIL_REQUEST_GET_IMEISV,
|
||||
ril_plugin_get_imeisv_cb, NULL, slot);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
} else {
|
||||
ofono_error("Slot %u IMEI query error: %s", slot->config.slot,
|
||||
ril_error_to_string(status));
|
||||
}
|
||||
|
||||
if (slot->imei) {
|
||||
/* We assume that IMEI never changes */
|
||||
g_free(imei);
|
||||
} else {
|
||||
slot->imei = imei ? imei : g_strdup_printf("%d", slot->index);
|
||||
sailfish_manager_imei_obtained(slot->handle, slot->imei);
|
||||
}
|
||||
|
||||
ril_plugin_check_modem(slot);
|
||||
ril_plugin_check_ready(slot);
|
||||
}
|
||||
|
||||
static void ril_plugin_device_identity_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
@@ -505,6 +601,28 @@ static void ril_plugin_device_identity_cb(GRilIoChannel *io, int status,
|
||||
ril_plugin_check_ready(slot);
|
||||
}
|
||||
|
||||
static void ril_plugin_start_imei_query(ril_slot *slot, gboolean blocking,
|
||||
int retries)
|
||||
{
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
/* There was a bug in libgrilio which was making request blocking
|
||||
* regardless of what we pass to grilio_request_set_blocking(),
|
||||
* that's why we don't call grilio_request_set_blocking() if
|
||||
* blocking is FALSE */
|
||||
if (blocking) grilio_request_set_blocking(req, TRUE);
|
||||
grilio_request_set_retry(req, RIL_RETRY_MS, retries);
|
||||
grilio_channel_cancel_request(slot->io, slot->imei_req_id, FALSE);
|
||||
slot->imei_req_id = (slot->legacy_imei_query ?
|
||||
grilio_channel_send_request_full(slot->io, req,
|
||||
RIL_REQUEST_GET_IMEI,
|
||||
ril_plugin_get_imei_cb, NULL, slot) :
|
||||
grilio_channel_send_request_full(slot->io, req,
|
||||
RIL_REQUEST_DEVICE_IDENTITY,
|
||||
ril_plugin_device_identity_cb, NULL, slot));
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static enum sailfish_sim_state ril_plugin_sim_state(ril_slot *slot)
|
||||
{
|
||||
const struct ril_sim_card_status *status = slot->sim_card->status;
|
||||
@@ -551,21 +669,11 @@ static void ril_plugin_sim_state_changed(struct ril_sim_card *card, void *data)
|
||||
* (this time, limited number).
|
||||
*
|
||||
* Some RILs fail RIL_REQUEST_DEVICE_IDENTITY until
|
||||
* the modem hasn't been properly initialized.
|
||||
* the modem has been properly initialized.
|
||||
*/
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
DBG("Giving slot %u last chance", slot->config.slot);
|
||||
grilio_request_set_retry(req, RIL_RETRY_MS,
|
||||
ril_plugin_start_imei_query(slot, FALSE,
|
||||
RIL_DEVICE_IDENTITY_RETRIES_LAST);
|
||||
grilio_channel_cancel_request(slot->io,
|
||||
slot->imei_req_id, FALSE);
|
||||
slot->imei_req_id =
|
||||
grilio_channel_send_request_full(slot->io,
|
||||
req, RIL_REQUEST_DEVICE_IDENTITY,
|
||||
ril_plugin_device_identity_cb,
|
||||
NULL, slot);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
slot->received_sim_status = TRUE;
|
||||
}
|
||||
@@ -814,7 +922,6 @@ static void ril_plugin_slot_connected(ril_slot *slot)
|
||||
ril_plugin *plugin = slot->plugin;
|
||||
const struct ril_plugin_settings *ps = &plugin->settings;
|
||||
const char *log_prefix = ril_plugin_log_prefix(slot);
|
||||
GRilIoRequest *req;
|
||||
|
||||
ofono_debug("%s version %u", (slot->name && slot->name[0]) ?
|
||||
slot->name : "RIL", slot->io->ril_version);
|
||||
@@ -826,19 +933,11 @@ static void ril_plugin_slot_connected(ril_slot *slot)
|
||||
* Modem will be registered after RIL_REQUEST_DEVICE_IDENTITY
|
||||
* successfully completes. By the time ofono starts, rild may
|
||||
* not be completely functional. Waiting until it responds to
|
||||
* RIL_REQUEST_DEVICE_IDENTITY (and retrying the request on
|
||||
* failure) gives rild time to finish whatever it's doing during
|
||||
* initialization.
|
||||
* RIL_REQUEST_DEVICE_IDENTITY (or RIL_REQUEST_GET_IMEI/SV)
|
||||
* and retrying the request on failure, (hopefully) gives rild
|
||||
* enough time to finish whatever it's doing during initialization.
|
||||
*/
|
||||
GASSERT(!slot->imei_req_id);
|
||||
req = grilio_request_new();
|
||||
/* Don't allow any other requests while this one is pending */
|
||||
grilio_request_set_blocking(req, TRUE);
|
||||
grilio_request_set_retry(req, RIL_RETRY_MS, -1);
|
||||
slot->imei_req_id = grilio_channel_send_request_full(slot->io,
|
||||
req, RIL_REQUEST_DEVICE_IDENTITY,
|
||||
ril_plugin_device_identity_cb, NULL, slot);
|
||||
grilio_request_unref(req);
|
||||
ril_plugin_start_imei_query(slot, TRUE, -1);
|
||||
|
||||
GASSERT(!slot->radio);
|
||||
slot->radio = ril_radio_new(slot->io);
|
||||
@@ -1051,6 +1150,7 @@ static ril_slot *ril_plugin_slot_new_take(char *sockpath, char *path,
|
||||
slot->config.enable_voicecall = RILMODEM_DEFAULT_ENABLE_VOICECALL;
|
||||
slot->timeout = RILMODEM_DEFAULT_TIMEOUT;
|
||||
slot->sim_flags = RILMODEM_DEFAULT_SIM_FLAGS;
|
||||
slot->legacy_imei_query = RILMODEM_DEFAULT_LEGACY_IMEI_QUERY;
|
||||
slot->start_timeout = RILMODEM_DEFAULT_START_TIMEOUT;
|
||||
slot->data_opt.allow_data = RILMODEM_DEFAULT_DATA_OPT;
|
||||
slot->data_opt.data_call_format = RILMODEM_DEFAULT_DATA_CALL_FORMAT;
|
||||
@@ -1295,6 +1395,14 @@ static ril_slot *ril_plugin_parse_config_group(GKeyFile *file,
|
||||
g_free(sval);
|
||||
}
|
||||
|
||||
/* legacyImeiQuery */
|
||||
if (ril_config_get_boolean(file, group,
|
||||
RILCONF_DEFAULT_LEGACY_IMEI_QUERY,
|
||||
&slot->legacy_imei_query)) {
|
||||
DBG("%s: " RILCONF_DEFAULT_LEGACY_IMEI_QUERY " %s", group,
|
||||
slot->legacy_imei_query ? "on" : "off");
|
||||
}
|
||||
|
||||
return slot;
|
||||
}
|
||||
|
||||
@@ -1556,7 +1664,7 @@ static void ril_plugin_set_storage_perm(const char *path,
|
||||
|
||||
static void ril_plugin_switch_identity(const struct ril_plugin_identity *id)
|
||||
{
|
||||
ril_plugin_set_storage_perm(STORAGEDIR, id);
|
||||
ril_plugin_set_storage_perm(ofono_storage_dir(), id);
|
||||
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) < 0) {
|
||||
ofono_error("prctl(PR_SET_KEEPCAPS) failed: %s",
|
||||
strerror(errno));
|
||||
|
||||
@@ -194,3 +194,11 @@ socket=/dev/socket/rild
|
||||
# The default is 20000 (20 seconds)
|
||||
#
|
||||
#startTimeout=20000
|
||||
|
||||
# This allows to use deprecated RIL_REQUEST_GET_IMEI instead of
|
||||
# RIL_REQUEST_DEVICE_IDENTITY to query IMEI from the modem. Some
|
||||
# RILs (e.g. MTK) still don't understand RIL_REQUEST_DEVICE_IDENTITY.
|
||||
#
|
||||
# Default is false (use RIL_REQUEST_DEVICE_IDENTITY)
|
||||
#
|
||||
#legacyImeiQuery=false
|
||||
|
||||
@@ -335,14 +335,18 @@ static void ril_voicecall_clcc_poll_cb(GRilIoChannel *io, int status,
|
||||
GASSERT(vd->clcc_poll_id);
|
||||
vd->clcc_poll_id = 0;
|
||||
|
||||
if (status != RIL_E_SUCCESS) {
|
||||
ofono_error("We are polling CLCC and received an error");
|
||||
ofono_error("All bets are off for call management");
|
||||
return;
|
||||
/*
|
||||
* Only RIL_E_SUCCESS and RIL_E_RADIO_NOT_AVAILABLE are expected here,
|
||||
* all other errors are filtered out by ril_voicecall_clcc_retry()
|
||||
*/
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
calls = ril_voicecall_parse_clcc(data, len);
|
||||
} else {
|
||||
/* RADIO_NOT_AVAILABLE == no calls */
|
||||
GASSERT(status == RIL_E_RADIO_NOT_AVAILABLE);
|
||||
calls = NULL;
|
||||
}
|
||||
|
||||
calls = ril_voicecall_parse_clcc(data, len);
|
||||
|
||||
n = calls;
|
||||
o = vd->calls;
|
||||
|
||||
@@ -436,12 +440,25 @@ static void ril_voicecall_clcc_poll_cb(GRilIoChannel *io, int status,
|
||||
vd->calls = calls;
|
||||
}
|
||||
|
||||
static gboolean ril_voicecall_clcc_retry(GRilIoRequest* req, 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_voicecall_clcc_poll(struct ril_voicecall *vd)
|
||||
{
|
||||
GASSERT(vd);
|
||||
if (!vd->clcc_poll_id) {
|
||||
GRilIoRequest* req = grilio_request_new();
|
||||
grilio_request_set_retry(req, RIL_RETRY_MS, -1);
|
||||
grilio_request_set_retry_func(req, ril_voicecall_clcc_retry);
|
||||
vd->clcc_poll_id = grilio_queue_send_request_full(vd->q,
|
||||
req, RIL_REQUEST_GET_CURRENT_CALLS,
|
||||
ril_voicecall_clcc_poll_cb, NULL, vd);
|
||||
|
||||
32
ofono/include/storage.h
Normal file
32
ofono/include/storage.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Telephony stack for Linux
|
||||
*
|
||||
* Copyright (C) 2017 Jolla Ltd. 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
|
||||
* 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 __OFONO_STORAGE_H
|
||||
#define __OFONO_STORAGE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
const char *ofono_config_dir(void);
|
||||
const char *ofono_storage_dir(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __OFONO_STORAGE_H */
|
||||
@@ -22,9 +22,8 @@
|
||||
#include <gutil_macros.h>
|
||||
#include <string.h>
|
||||
|
||||
#define OFONO_API_SUBJECT_TO_CHANGE
|
||||
#include "ofono.h"
|
||||
#include "storage.h"
|
||||
#include "src/ofono.h"
|
||||
#include "src/storage.h"
|
||||
|
||||
#include <sailfish_manager.h>
|
||||
#include <sailfish_cell_info.h>
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
#include <gutil_misc.h>
|
||||
#include <gutil_log.h>
|
||||
|
||||
#include "ofono.h"
|
||||
#include "common.h"
|
||||
#include "storage.h"
|
||||
#include "src/ofono.h"
|
||||
#include "src/common.h"
|
||||
#include "src/storage.h"
|
||||
|
||||
#define SAILFISH_SIM_INFO_STORE "cache"
|
||||
#define SAILFISH_SIM_INFO_STORE_GROUP "sim"
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <ofono/storage.h>
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
@@ -35,6 +37,16 @@
|
||||
|
||||
#include "storage.h"
|
||||
|
||||
const char *ofono_config_dir(void)
|
||||
{
|
||||
return CONFIGDIR;
|
||||
}
|
||||
|
||||
const char *ofono_storage_dir(void)
|
||||
{
|
||||
return STORAGEDIR;
|
||||
}
|
||||
|
||||
int create_dirs(const char *filename, const mode_t mode)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
Reference in New Issue
Block a user