mirror of
https://github.com/sailfishos/ofono
synced 2025-11-24 19:39:44 +08:00
Compare commits
34 Commits
mer/1.16+g
...
mer/1.16+g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97e34cc851 | ||
|
|
e558d48b6f | ||
|
|
aca873a5c4 | ||
|
|
a12e10e36f | ||
|
|
7cd3fb74d4 | ||
|
|
84289d83fd | ||
|
|
f826abdbc7 | ||
|
|
f6ac328110 | ||
|
|
8d46ababee | ||
|
|
07144c2dd5 | ||
|
|
0073dc7bfc | ||
|
|
297bdaba0f | ||
|
|
f14db3b2a6 | ||
|
|
4a0182616d | ||
|
|
bbdfc8f46d | ||
|
|
fbd59a8dc9 | ||
|
|
7eb6d5559a | ||
|
|
9a47510eb5 | ||
|
|
8fc7ae836f | ||
|
|
8c0f4f27eb | ||
|
|
b932bed519 | ||
|
|
db83ac369b | ||
|
|
e26df8a645 | ||
|
|
5144f3fa14 | ||
|
|
0d6459b9b0 | ||
|
|
10328e626d | ||
|
|
5b407d654a | ||
|
|
d88af05dc3 | ||
|
|
99cae6876f | ||
|
|
89e6593f9c | ||
|
|
8e9085f5ab | ||
|
|
c33a48ea0c | ||
|
|
3860230644 | ||
|
|
063234a433 |
@@ -575,6 +575,11 @@ builtin_cflags += @WSPCODEC_CFLAGS@
|
||||
builtin_libadd += @WSPCODEC_LIBS@
|
||||
endif
|
||||
|
||||
if LOGCONTROL
|
||||
builtin_modules += debuglog
|
||||
builtin_sources += plugins/debuglog.c
|
||||
endif
|
||||
|
||||
builtin_modules += sms_history
|
||||
builtin_sources += plugins/smshistory.c
|
||||
|
||||
|
||||
@@ -237,6 +237,11 @@ if (test "${enable_pushforwarder}" != "no"); then
|
||||
AC_SUBST(WSPCODEC_LIBS)
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(logcontrol,
|
||||
AC_HELP_STRING([--enable-logcontrol], [enable log control plugin]),
|
||||
[enable_logcontrol=${enableval}], [enable_logcontrol="no"])
|
||||
AM_CONDITIONAL(LOGCONTROL, test "${enable_logcontrol}" != "no")
|
||||
|
||||
if (test "${prefix}" = "NONE"); then
|
||||
dnl no prefix and no localstatedir, so default to /var
|
||||
if (test "$localstatedir" = '${prefix}/var'); then
|
||||
|
||||
28
ofono/doc/debuglog-api.txt
Normal file
28
ofono/doc/debuglog-api.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
Debug log control
|
||||
=================
|
||||
|
||||
Service org.ofono
|
||||
Interface org.ofono.DebugLog
|
||||
Object path /
|
||||
|
||||
Methods void Enable(string pattern)
|
||||
|
||||
Enables all logs that match the pattern.
|
||||
|
||||
void Disable(string pattern)
|
||||
|
||||
Disables all logs that match the pattern.
|
||||
|
||||
array(string,boolean) List()
|
||||
|
||||
Returns all available log names and their current
|
||||
states.
|
||||
|
||||
In order for Enable or Disable call to have any
|
||||
effect, the pattern must match one or more of
|
||||
these strings.
|
||||
|
||||
Signals Changed(string name, boolean enabled)
|
||||
|
||||
This signal indicates a changed log status of the
|
||||
given log module.
|
||||
@@ -292,20 +292,17 @@ void handle_sne(size_t len, const unsigned char *msg, char *sne)
|
||||
list_entry->data;
|
||||
|
||||
if (entry) {
|
||||
/* If one already exists,
|
||||
delete it */
|
||||
if (entry->sne)
|
||||
g_free(entry->sne);
|
||||
|
||||
DBG("Adding SNE to entry %d",
|
||||
phonebook_entry_nbr);
|
||||
DBG("name %s", entry->name);
|
||||
|
||||
g_free(entry->sne);
|
||||
entry->sne = sne;
|
||||
} else {
|
||||
g_free(sne);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
g_free(sne);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -401,7 +401,6 @@ gboolean ril_util_parse_sim_status(GRil *gril,
|
||||
}
|
||||
|
||||
for (i = 0; i < status->num_apps; i++) {
|
||||
DBG("processing app[%d]", i);
|
||||
apps[i] = g_try_new0(struct sim_app, 1);
|
||||
if (apps[i] == NULL) {
|
||||
ofono_error("Can't allocate app_data");
|
||||
@@ -411,8 +410,6 @@ gboolean ril_util_parse_sim_status(GRil *gril,
|
||||
apps[i]->app_type = parcel_r_int32(&rilp);
|
||||
apps[i]->app_state = parcel_r_int32(&rilp);
|
||||
|
||||
DBG("app[%d]: app_type: %d, app_state: %d", i,
|
||||
apps[i]->app_type, apps[i]->app_state);
|
||||
/*
|
||||
* Consider RIL_APPSTATE_ILLEGAL also READY. Even if app state
|
||||
* is RIL_APPSTATE_ILLEGAL (-1), ICC operations must be
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "util.h"
|
||||
|
||||
#include "gril.h"
|
||||
#include "grilrequest.h"
|
||||
#include "grilutil.h"
|
||||
#include "parcel.h"
|
||||
#include "ril_constants.h"
|
||||
@@ -519,44 +520,6 @@ static void ril_read_imsi(struct ofono_sim *sim, ofono_sim_imsi_cb_t cb,
|
||||
}
|
||||
}
|
||||
|
||||
void set_pin_lock_state(struct ofono_sim *sim, struct sim_app *app)
|
||||
{
|
||||
DBG("pin1:%u,pin2:%u", app->pin1_state, app->pin2_state);
|
||||
/*
|
||||
* Updates only pin and pin2 state. Other locks are not dealt here. For
|
||||
* that a RIL_REQUEST_QUERY_FACILITY_LOCK request should be used.
|
||||
*/
|
||||
switch (app->pin1_state) {
|
||||
case RIL_PINSTATE_ENABLED_NOT_VERIFIED:
|
||||
case RIL_PINSTATE_ENABLED_VERIFIED:
|
||||
case RIL_PINSTATE_ENABLED_BLOCKED:
|
||||
case RIL_PINSTATE_ENABLED_PERM_BLOCKED:
|
||||
ofono_set_pin_lock_state(sim, OFONO_SIM_PASSWORD_SIM_PIN, TRUE);
|
||||
break;
|
||||
case RIL_PINSTATE_DISABLED:
|
||||
ofono_set_pin_lock_state(
|
||||
sim, OFONO_SIM_PASSWORD_SIM_PIN, FALSE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (app->pin2_state) {
|
||||
case RIL_PINSTATE_ENABLED_NOT_VERIFIED:
|
||||
case RIL_PINSTATE_ENABLED_VERIFIED:
|
||||
case RIL_PINSTATE_ENABLED_BLOCKED:
|
||||
case RIL_PINSTATE_ENABLED_PERM_BLOCKED:
|
||||
ofono_set_pin_lock_state(
|
||||
sim, OFONO_SIM_PASSWORD_SIM_PIN2, TRUE);
|
||||
break;
|
||||
case RIL_PINSTATE_DISABLED:
|
||||
ofono_set_pin_lock_state(
|
||||
sim, OFONO_SIM_PASSWORD_SIM_PIN2, FALSE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void configure_active_app(struct sim_data *sd,
|
||||
struct sim_app *app,
|
||||
guint index)
|
||||
@@ -627,17 +590,83 @@ static void configure_active_app(struct sim_data *sd,
|
||||
}
|
||||
}
|
||||
|
||||
static void free_sim_state(struct sim_data *sd)
|
||||
{
|
||||
guint i = 0;
|
||||
|
||||
sd->passwd_state = OFONO_SIM_PASSWORD_INVALID;
|
||||
|
||||
for (i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++)
|
||||
sd->retries[i] = -1;
|
||||
|
||||
sd->removed = TRUE;
|
||||
sd->initialized = FALSE;
|
||||
}
|
||||
|
||||
static void sim_send_set_uicc_subscription(struct sim_data *sd, int slot_id,
|
||||
int app_index, int sub_id, int sub_status)
|
||||
{
|
||||
struct parcel rilp;
|
||||
|
||||
DBG("");
|
||||
|
||||
g_ril_request_set_uicc_subscription(sd->ril, slot_id, app_index,
|
||||
sub_id, sub_status, &rilp);
|
||||
|
||||
g_ril_send(sd->ril, RIL_REQUEST_SET_UICC_SUBSCRIPTION, rilp.data,
|
||||
rilp.size, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static int sim_select_uicc_subscription(struct sim_data *sim,
|
||||
struct sim_status *status, struct sim_app **apps)
|
||||
{
|
||||
int slot_id = 0;
|
||||
int selected_app = -1;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < status->num_apps; i++) {
|
||||
switch (apps[i]->app_type) {
|
||||
case RIL_APPTYPE_UNKNOWN:
|
||||
continue;
|
||||
case RIL_APPTYPE_USIM:
|
||||
case RIL_APPTYPE_RUIM:
|
||||
if (selected_app != -1) {
|
||||
switch (apps[selected_app]->app_type) {
|
||||
case RIL_APPTYPE_USIM:
|
||||
case RIL_APPTYPE_RUIM:
|
||||
break;
|
||||
default:
|
||||
selected_app = i;
|
||||
}
|
||||
} else {
|
||||
selected_app = i;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (selected_app == -1)
|
||||
selected_app = i;
|
||||
}
|
||||
}
|
||||
|
||||
DBG("Select app %d for subscription.", selected_app);
|
||||
|
||||
if (selected_app != -1)
|
||||
/* Number 1 means activates that app */
|
||||
sim_send_set_uicc_subscription(sim, slot_id, selected_app,
|
||||
slot_id, 1);
|
||||
|
||||
return selected_app;
|
||||
}
|
||||
|
||||
static void sim_status_cb(struct ril_msg *message, gpointer user_data)
|
||||
{
|
||||
struct ofono_sim *sim = user_data;
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
struct sim_app *apps[MAX_UICC_APPS];
|
||||
struct sim_status status;
|
||||
guint i = 0;
|
||||
guint search_index = -1;
|
||||
struct parcel rilp;
|
||||
|
||||
DBG("%p", message);
|
||||
DBG("");
|
||||
|
||||
if (ril_util_parse_sim_status(sd->ril, message, &status, apps) &&
|
||||
status.num_apps) {
|
||||
@@ -645,37 +674,38 @@ static void sim_status_cb(struct ril_msg *message, gpointer user_data)
|
||||
/* TODO(CDMA): need some kind of logic to
|
||||
* set the correct app_index,
|
||||
*/
|
||||
search_index = status.gsm_umts_index;
|
||||
int app_index = status.gsm_umts_index;
|
||||
|
||||
for (i = 0; i < status.num_apps; i++) {
|
||||
if (i == search_index &&
|
||||
apps[i]->app_type != RIL_APPTYPE_UNKNOWN) {
|
||||
current_active_app = apps[i]->app_type;
|
||||
configure_active_app(sd, apps[i], i);
|
||||
set_pin_lock_state(sim, apps[i]);
|
||||
break;
|
||||
}
|
||||
if (app_index < 0) {
|
||||
app_index = sim_select_uicc_subscription(sd,
|
||||
&status, apps);
|
||||
}
|
||||
if (app_index >= 0 && app_index < (int)status.num_apps &&
|
||||
apps[app_index]->app_type != RIL_APPTYPE_UNKNOWN) {
|
||||
current_active_app = apps[app_index]->app_type;
|
||||
configure_active_app(sd, apps[app_index], app_index);
|
||||
}
|
||||
|
||||
/*
|
||||
* ril_util_parse_sim_status returns true only when
|
||||
* card status is RIL_CARDSTATE_PRESENT so notify TRUE always.
|
||||
*
|
||||
* ofono_sim_inserted_notify skips and returns if
|
||||
* present/not_present status doesn't change from previous.
|
||||
*/
|
||||
ofono_sim_inserted_notify(sim, TRUE);
|
||||
|
||||
sd->removed = FALSE;
|
||||
|
||||
/* TODO: There doesn't seem to be any other
|
||||
* way to force the core SIM code to
|
||||
* recheck the PIN.
|
||||
* Wouldn't __ofono_sim_refresh be
|
||||
* more appropriate call here??
|
||||
* __ofono_sim_refresh(sim, NULL, TRUE, TRUE);
|
||||
*/
|
||||
__ofono_sim_recheck_pin(sim);
|
||||
if (sd->passwd_state != OFONO_SIM_PASSWORD_INVALID) {
|
||||
/*
|
||||
* ril_util_parse_sim_status returns true only when
|
||||
* card status is RIL_CARDSTATE_PRESENT,
|
||||
* ofono_sim_inserted_notify returns if status doesn't
|
||||
* change. So can notify core always in this branch.
|
||||
*/
|
||||
ofono_sim_inserted_notify(sim, TRUE);
|
||||
|
||||
/* TODO: There doesn't seem to be any other
|
||||
* way to force the core SIM code to
|
||||
* recheck the PIN.
|
||||
* Wouldn't __ofono_sim_refresh be
|
||||
* more appropriate call here??
|
||||
* __ofono_sim_refresh(sim, NULL, TRUE, TRUE);
|
||||
*/
|
||||
__ofono_sim_recheck_pin(sim);
|
||||
}
|
||||
|
||||
if (current_online_state == RIL_ONLINE_PREF) {
|
||||
|
||||
@@ -703,10 +733,9 @@ static void sim_status_cb(struct ril_msg *message, gpointer user_data)
|
||||
if (status.card_state == RIL_CARDSTATE_ABSENT) {
|
||||
ofono_info("%s: RIL_CARDSTATE_ABSENT", __func__);
|
||||
|
||||
ofono_sim_inserted_notify(sim, FALSE);
|
||||
free_sim_state(sd);
|
||||
|
||||
sd->removed = TRUE;
|
||||
sd->initialized = FALSE;
|
||||
ofono_sim_inserted_notify(sim, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -754,8 +783,6 @@ static void ril_query_passwd_state_cb(struct ril_msg *message, gpointer user_dat
|
||||
void *data = cbd->data;
|
||||
struct sim_app *apps[MAX_UICC_APPS];
|
||||
struct sim_status status;
|
||||
guint i = 0;
|
||||
guint search_index = -1;
|
||||
gint state = ofono_sim_get_state(sim);
|
||||
|
||||
if (ril_util_parse_sim_status(sd->ril, message, &status, apps) &&
|
||||
@@ -764,17 +791,14 @@ static void ril_query_passwd_state_cb(struct ril_msg *message, gpointer user_dat
|
||||
/* TODO(CDMA): need some kind of logic to
|
||||
* set the correct app_index,
|
||||
*/
|
||||
search_index = status.gsm_umts_index;
|
||||
int app_index = status.gsm_umts_index;
|
||||
|
||||
for (i = 0; i < status.num_apps; i++) {
|
||||
if (i == search_index &&
|
||||
apps[i]->app_type != RIL_APPTYPE_UNKNOWN) {
|
||||
current_active_app = apps[i]->app_type;
|
||||
configure_active_app(sd, apps[i], i);
|
||||
set_pin_lock_state(sim, apps[i]);
|
||||
break;
|
||||
}
|
||||
if (app_index >= 0 && app_index < (int)status.num_apps &&
|
||||
apps[app_index]->app_type != RIL_APPTYPE_UNKNOWN) {
|
||||
current_active_app = apps[app_index]->app_type;
|
||||
configure_active_app(sd, apps[app_index], app_index);
|
||||
}
|
||||
|
||||
ril_util_free_sim_apps(apps, status.num_apps);
|
||||
}
|
||||
DBG("passwd_state %u", sd->passwd_state);
|
||||
@@ -826,8 +850,9 @@ static void ril_pin_change_state_cb(struct ril_msg *message, gpointer user_data)
|
||||
struct sim_data *sd = cbd->user;
|
||||
struct parcel rilp;
|
||||
int retry_count;
|
||||
int retries[OFONO_SIM_PASSWORD_INVALID];
|
||||
int passwd_type;
|
||||
int i;
|
||||
|
||||
/* There is no reason to ask SIM status until
|
||||
* unsolicited sim status change indication
|
||||
* Looks like state does not change before that.
|
||||
@@ -837,8 +862,11 @@ static void ril_pin_change_state_cb(struct ril_msg *message, gpointer user_data)
|
||||
ril_util_init_parcel(message, &rilp);
|
||||
parcel_r_int32(&rilp);
|
||||
retry_count = parcel_r_int32(&rilp);
|
||||
retries[passwd_type] = retry_count;
|
||||
sd->retries[passwd_type] = retries[passwd_type];
|
||||
|
||||
for (i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++)
|
||||
sd->retries[i] = -1;
|
||||
|
||||
sd->retries[passwd_type] = retry_count;
|
||||
|
||||
DBG("result=%d passwd_type=%d retry_count=%d",
|
||||
message->error, passwd_type, retry_count);
|
||||
@@ -1110,7 +1138,7 @@ static gboolean ril_sim_register(gpointer user)
|
||||
send_get_sim_status(sim);
|
||||
|
||||
sd->idle_id = 0;
|
||||
sd->idle_id = g_ril_register(sd->ril,
|
||||
g_ril_register(sd->ril,
|
||||
RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED,
|
||||
(GRilNotifyFunc) ril_sim_status_changed, sim);
|
||||
return FALSE;
|
||||
@@ -1153,12 +1181,15 @@ static int ril_sim_probe(struct ofono_sim *sim, unsigned int vendor,
|
||||
|
||||
static void ril_sim_remove(struct ofono_sim *sim)
|
||||
{
|
||||
DBG("");
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
|
||||
ofono_sim_set_data(sim, NULL);
|
||||
|
||||
if (sd->idle_id > 0)
|
||||
if (sd->idle_id > 0) {
|
||||
g_source_remove(sd->idle_id);
|
||||
sd->idle_id = 0;
|
||||
}
|
||||
|
||||
g_free(sd->aid_str);
|
||||
g_free(sd->app_str);
|
||||
|
||||
@@ -51,9 +51,6 @@
|
||||
#define COMMAND_FLAG_EXPECT_PDU 0x1
|
||||
#define COMMAND_FLAG_EXPECT_SHORT_PROMPT 0x2
|
||||
|
||||
#define RILD_CMD_SOCKET "/dev/socket/rild"
|
||||
#define RILD_DBG_SOCKET "/dev/socket/rild-debug"
|
||||
|
||||
struct ril_request {
|
||||
gchar *data;
|
||||
guint data_len;
|
||||
@@ -807,7 +804,7 @@ static gboolean node_compare_by_group(struct ril_notify_node *node,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static struct ril_s *create_ril()
|
||||
static struct ril_s *create_ril(const char *sockpath)
|
||||
|
||||
{
|
||||
struct ril_s *ril;
|
||||
@@ -819,6 +816,10 @@ static struct ril_s *create_ril()
|
||||
GError *err = NULL;
|
||||
char *path = "/etc/ofono/ril_subscription.conf";
|
||||
|
||||
DBG("sockpath: %s", sockpath);
|
||||
if (!sockpath)
|
||||
return NULL;
|
||||
|
||||
ril = g_try_new0(struct ril_s, 1);
|
||||
if (ril == NULL)
|
||||
return ril;
|
||||
@@ -841,7 +842,7 @@ static struct ril_s *create_ril()
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_UNIX;
|
||||
strncpy(addr.sun_path, RILD_CMD_SOCKET, sizeof(addr.sun_path) - 1);
|
||||
strncpy(addr.sun_path, sockpath, sizeof(addr.sun_path) - 1);
|
||||
|
||||
if (connect(ril->sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
|
||||
ofono_error("%s: can't connect to RILD: %s (%d)\n",
|
||||
@@ -1074,15 +1075,16 @@ void g_ril_init_parcel(struct ril_msg *message, struct parcel *rilp)
|
||||
rilp->offset = 0;
|
||||
}
|
||||
|
||||
GRil *g_ril_new()
|
||||
GRil *g_ril_new(const char *sockpath)
|
||||
{
|
||||
DBG("");
|
||||
GRil *ril;
|
||||
|
||||
ril = g_try_new0(GRil, 1);
|
||||
if (ril == NULL)
|
||||
return NULL;
|
||||
|
||||
ril->parent = create_ril();
|
||||
ril->parent = create_ril(sockpath);
|
||||
if (ril->parent == NULL) {
|
||||
g_free(ril);
|
||||
return NULL;
|
||||
|
||||
@@ -93,7 +93,7 @@ extern char print_buf[];
|
||||
|
||||
void g_ril_init_parcel(struct ril_msg *message, struct parcel *rilp);
|
||||
|
||||
GRil *g_ril_new();
|
||||
GRil *g_ril_new(const char *sockpath);
|
||||
|
||||
GIOChannel *g_ril_get_channel(GRil *ril);
|
||||
GRilIO *g_ril_get_io(GRil *ril);
|
||||
|
||||
@@ -211,3 +211,24 @@ error:
|
||||
OFONO_EINVAL(error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void g_ril_request_set_uicc_subscription(GRil *gril, int slot_id,
|
||||
int app_index,
|
||||
int sub_id,
|
||||
int sub_status,
|
||||
struct parcel *rilp)
|
||||
{
|
||||
parcel_init(rilp);
|
||||
|
||||
parcel_w_int32(rilp, slot_id);
|
||||
parcel_w_int32(rilp, app_index);
|
||||
parcel_w_int32(rilp, sub_id);
|
||||
parcel_w_int32(rilp, sub_status);
|
||||
|
||||
g_ril_append_print_buf(gril, "(%d, %d, %d, %d(%s))",
|
||||
slot_id,
|
||||
app_index,
|
||||
sub_id,
|
||||
sub_status,
|
||||
sub_status ? "ACTIVATE" : "DEACTIVATE");
|
||||
}
|
||||
|
||||
@@ -56,6 +56,12 @@ gboolean g_ril_request_setup_data_call(GRil *gril,
|
||||
struct parcel *rilp,
|
||||
struct ofono_error *error);
|
||||
|
||||
void g_ril_request_set_uicc_subscription(GRil *gril, int slot_id,
|
||||
int app_index,
|
||||
int sub_id,
|
||||
int sub_status,
|
||||
struct parcel *rilp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -137,6 +137,7 @@ const char *ril_cardstate_to_string(int card_state)
|
||||
|
||||
const char *ril_error_to_string(int error)
|
||||
{
|
||||
static char unknown[24];
|
||||
switch (error) {
|
||||
case RIL_E_SUCCESS: return "SUCCESS";
|
||||
case RIL_E_RADIO_NOT_AVAILABLE: return "RADIO_NOT_AVAILABLE";
|
||||
@@ -157,7 +158,9 @@ const char *ril_error_to_string(int error)
|
||||
case RIL_E_MODE_NOT_SUPPORTED: return "MODE_NOT_SUPPORTED";
|
||||
case RIL_E_FDN_CHECK_FAILURE: return "FDN_CHECK_FAILURE";
|
||||
case RIL_E_ILLEGAL_SIM_OR_ME: return "ILLEGAL_SIM_OR_ME";
|
||||
default: return "<unknown errno>";
|
||||
default:
|
||||
snprintf(unknown, sizeof(unknown), "%d", error);
|
||||
return unknown;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +186,7 @@ const char *ril_pinstate_to_string(int pin_state)
|
||||
|
||||
const char *ril_request_id_to_string(int req)
|
||||
{
|
||||
static char unknown[24];
|
||||
switch (req) {
|
||||
case RIL_REQUEST_GET_SIM_STATUS:
|
||||
return "RIL_REQUEST_GET_SIM_STATUS";
|
||||
@@ -398,13 +402,17 @@ const char *ril_request_id_to_string(int req)
|
||||
return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU";
|
||||
case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS:
|
||||
return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
|
||||
case RIL_REQUEST_SET_UICC_SUBSCRIPTION:
|
||||
return "RIL_REQUEST_SET_UICC_SUBSCRIPTION";
|
||||
default:
|
||||
return "<INVALID>";
|
||||
snprintf(unknown, sizeof(unknown), "RIL_REQUEST_%d", req);
|
||||
return unknown;
|
||||
}
|
||||
}
|
||||
|
||||
const char *ril_unsol_request_to_string(int request)
|
||||
{
|
||||
static char unknown[24];
|
||||
switch (request) {
|
||||
case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
|
||||
return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
|
||||
@@ -477,7 +485,8 @@ const char *ril_unsol_request_to_string(int request)
|
||||
case RIL_UNSOL_SUPP_SVC_NOTIFICATION:
|
||||
return "UNSOL_SUPP_SVC_NOTIFICATION";
|
||||
default:
|
||||
return "<unknown request>";
|
||||
snprintf(unknown, sizeof(unknown), "UNSOL_%d", request);
|
||||
return unknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@
|
||||
#define RIL_REQUEST_MODIFY_QOS 115
|
||||
#define RIL_REQUEST_SUSPEND_QOS 116
|
||||
#define RIL_REQUEST_RESUME_QOS 117
|
||||
#define RIL_REQUEST_SET_UICC_SUBSCRIPTION 118
|
||||
#define RIL_REQUEST_SET_UICC_SUBSCRIPTION 122
|
||||
#define RIL_REQUEST_SET_DATA_SUBSCRIPTION 119
|
||||
#define RIL_REQUEST_GET_UICC_SUBSCRIPTION 120
|
||||
#define RIL_REQUEST_GET_DATA_SUBSCRIPTION 121
|
||||
|
||||
@@ -199,10 +199,6 @@ const unsigned char *ofono_sim_get_cphs_service_table(struct ofono_sim *sim);
|
||||
|
||||
enum ofono_sim_password_type ofono_sim_get_password_type(struct ofono_sim *sim);
|
||||
|
||||
void ofono_set_pin_lock_state(struct ofono_sim *sim,
|
||||
enum ofono_sim_password_type type,
|
||||
ofono_bool_t state);
|
||||
|
||||
unsigned int ofono_sim_add_state_watch(struct ofono_sim *sim,
|
||||
ofono_sim_state_event_cb_t cb,
|
||||
void *data, ofono_destroy_func destroy);
|
||||
|
||||
270
ofono/plugins/debuglog.c
Normal file
270
ofono/plugins/debuglog.c
Normal file
@@ -0,0 +1,270 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2015 Jolla Ltd. All rights reserved.
|
||||
* Contact: Slava Monich <slava.monich@jolla.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <gdbus.h>
|
||||
#include <string.h>
|
||||
|
||||
#define OFONO_API_SUBJECT_TO_CHANGE
|
||||
#include <ofono/plugin.h>
|
||||
#include <ofono/log.h>
|
||||
#include <ofono.h>
|
||||
|
||||
#define DEBUGLOG_INTERFACE OFONO_SERVICE ".DebugLog"
|
||||
#define DEBUGLOG_PATH "/"
|
||||
#define DEBUGLOG_CHANGED_SIGNAL "Changed"
|
||||
|
||||
static DBusConnection *connection = NULL;
|
||||
|
||||
extern struct ofono_debug_desc __start___debug[];
|
||||
extern struct ofono_debug_desc __stop___debug[];
|
||||
|
||||
static void debuglog_signal(DBusConnection *conn, const char *name,
|
||||
guint flags)
|
||||
{
|
||||
DBusMessage *signal = dbus_message_new_signal(DEBUGLOG_PATH,
|
||||
DEBUGLOG_INTERFACE, DEBUGLOG_CHANGED_SIGNAL);
|
||||
|
||||
if (signal) {
|
||||
DBusMessageIter iter;
|
||||
const dbus_bool_t on = (flags & OFONO_DEBUG_FLAG_PRINT) != 0;
|
||||
|
||||
dbus_message_iter_init_append(signal, &iter);
|
||||
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name);
|
||||
dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &on);
|
||||
g_dbus_send_message(conn, signal);
|
||||
}
|
||||
}
|
||||
|
||||
static GHashTable *debuglog_update_flags_hash(GHashTable *hash,
|
||||
const char *name, guint flags)
|
||||
{
|
||||
if (name) {
|
||||
gpointer key = (gpointer)name;
|
||||
guint value;
|
||||
if (!hash) {
|
||||
hash = g_hash_table_new_full(g_str_hash, g_str_equal,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
value = GPOINTER_TO_INT(g_hash_table_lookup(hash, key));
|
||||
value |= flags;
|
||||
g_hash_table_insert(hash, key, GINT_TO_POINTER(value));
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
static gboolean debuglog_match(const char* name, const char* pattern)
|
||||
{
|
||||
return name && g_pattern_match_simple(pattern, name);
|
||||
}
|
||||
|
||||
static void debuglog_update(DBusConnection *conn, const char* pattern,
|
||||
guint set_flags, guint clear_flags)
|
||||
{
|
||||
const guint flags = set_flags | clear_flags;
|
||||
struct ofono_debug_desc *start = __start___debug;
|
||||
struct ofono_debug_desc *stop = __stop___debug;
|
||||
struct ofono_debug_desc *desc;
|
||||
GHashTable *hash = NULL;
|
||||
|
||||
if (!start || !stop)
|
||||
return;
|
||||
|
||||
|
||||
for (desc = start; desc < stop; desc++) {
|
||||
const char *matched = NULL;
|
||||
|
||||
if (debuglog_match(desc->file, pattern)) {
|
||||
matched = desc->file;
|
||||
} else if (debuglog_match(desc->name, pattern)) {
|
||||
matched = desc->name;
|
||||
}
|
||||
|
||||
if (matched) {
|
||||
const guint old_flags = (desc->flags & flags);
|
||||
desc->flags |= set_flags;
|
||||
desc->flags &= ~clear_flags;
|
||||
if ((desc->flags & flags) != old_flags) {
|
||||
hash = debuglog_update_flags_hash(hash,
|
||||
matched, desc->flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hash) {
|
||||
GList *entry, *names = g_hash_table_get_keys(hash);
|
||||
|
||||
for (entry = names; entry; entry = entry->next) {
|
||||
debuglog_signal(conn, entry->data,
|
||||
GPOINTER_TO_INT(g_hash_table_lookup(
|
||||
hash, entry->data)));
|
||||
}
|
||||
|
||||
g_list_free(names);
|
||||
g_hash_table_destroy(hash);
|
||||
}
|
||||
}
|
||||
|
||||
static DBusMessage *debuglog_handle(DBusConnection *conn, DBusMessage *msg,
|
||||
guint set_flags, guint clear_flags)
|
||||
{
|
||||
const char *pattern;
|
||||
|
||||
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &pattern,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
debuglog_update(conn, pattern, set_flags, clear_flags);
|
||||
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
|
||||
} else {
|
||||
return __ofono_error_invalid_args(msg);
|
||||
}
|
||||
}
|
||||
|
||||
static DBusMessage *debuglog_enable(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
return debuglog_handle(conn, msg, OFONO_DEBUG_FLAG_PRINT, 0);
|
||||
}
|
||||
|
||||
static DBusMessage *debuglog_disable(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
return debuglog_handle(conn, msg, 0, OFONO_DEBUG_FLAG_PRINT);
|
||||
}
|
||||
|
||||
static gint debuglog_list_compare(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
return strcmp(a, b);
|
||||
}
|
||||
|
||||
static void debuglog_list_append(DBusMessageIter *iter, const char *name,
|
||||
guint flags)
|
||||
{
|
||||
DBusMessageIter entry;
|
||||
dbus_bool_t enabled = (flags & OFONO_DEBUG_FLAG_PRINT) != 0;
|
||||
|
||||
dbus_message_iter_open_container(iter, DBUS_TYPE_STRUCT, NULL, &entry);
|
||||
dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &name);
|
||||
dbus_message_iter_append_basic(&entry, DBUS_TYPE_BOOLEAN, &enabled);
|
||||
dbus_message_iter_close_container(iter, &entry);
|
||||
}
|
||||
|
||||
static DBusMessage *debuglog_list(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
DBusMessage *reply = dbus_message_new_method_return(msg);
|
||||
|
||||
if (reply) {
|
||||
struct ofono_debug_desc *start = __start___debug;
|
||||
struct ofono_debug_desc *stop = __stop___debug;
|
||||
DBusMessageIter iter, array;
|
||||
|
||||
dbus_message_iter_init_append(reply, &iter);
|
||||
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
|
||||
"(sb)", &array);
|
||||
|
||||
if (start && stop) {
|
||||
struct ofono_debug_desc *desc;
|
||||
GList *names, *entry;
|
||||
GHashTable *hash = g_hash_table_new_full(g_str_hash,
|
||||
g_str_equal, NULL, NULL);
|
||||
|
||||
for (desc = start; desc < stop; desc++) {
|
||||
debuglog_update_flags_hash(hash, desc->file,
|
||||
desc->flags);
|
||||
debuglog_update_flags_hash(hash, desc->name,
|
||||
desc->flags);
|
||||
}
|
||||
|
||||
names = g_list_sort(g_hash_table_get_keys(hash),
|
||||
debuglog_list_compare);
|
||||
for (entry = names; entry; entry = entry->next) {
|
||||
const char *name = entry->data;
|
||||
debuglog_list_append(&array, name,
|
||||
GPOINTER_TO_INT(g_hash_table_lookup(
|
||||
hash, name)));
|
||||
}
|
||||
|
||||
g_list_free(names);
|
||||
g_hash_table_destroy(hash);
|
||||
}
|
||||
|
||||
dbus_message_iter_close_container(&iter, &array);
|
||||
}
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
static const GDBusMethodTable debuglog_methods[] = {
|
||||
{ GDBUS_METHOD("Enable", GDBUS_ARGS({ "pattern", "s" }), NULL,
|
||||
debuglog_enable) },
|
||||
{ GDBUS_METHOD("Disable", GDBUS_ARGS({ "pattern", "s" }), NULL,
|
||||
debuglog_disable) },
|
||||
{ GDBUS_METHOD("List", NULL, GDBUS_ARGS({ "list", "a(sb)" }),
|
||||
debuglog_list) },
|
||||
{ },
|
||||
};
|
||||
|
||||
static const GDBusSignalTable debuglog_signals[] = {
|
||||
{ GDBUS_SIGNAL(DEBUGLOG_CHANGED_SIGNAL,
|
||||
GDBUS_ARGS({ "name", "s" }, { "enabled", "b" })) },
|
||||
{ }
|
||||
};
|
||||
|
||||
static int debuglog_init(void)
|
||||
{
|
||||
DBG("");
|
||||
|
||||
connection = ofono_dbus_get_connection();
|
||||
if (!connection)
|
||||
return -1;
|
||||
|
||||
if (!g_dbus_register_interface(connection, DEBUGLOG_PATH,
|
||||
DEBUGLOG_INTERFACE, debuglog_methods, debuglog_signals,
|
||||
NULL, NULL, NULL)) {
|
||||
ofono_error("debuglog: failed to register "
|
||||
DEBUGLOG_INTERFACE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void debuglog_exit(void)
|
||||
{
|
||||
DBG("");
|
||||
|
||||
if (connection) {
|
||||
g_dbus_unregister_interface(connection, DEBUGLOG_PATH,
|
||||
DEBUGLOG_INTERFACE);
|
||||
dbus_connection_unref(connection);
|
||||
connection = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
OFONO_PLUGIN_DEFINE(debuglog, "Debug log control interface",
|
||||
VERSION, OFONO_PLUGIN_PRIORITY_DEFAULT,
|
||||
debuglog_init, debuglog_exit)
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2012-2013 Jolla Ltd.
|
||||
* Copyright (C) 2012-2015 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
|
||||
@@ -32,12 +32,9 @@
|
||||
#include <ofono/plugin.h>
|
||||
#include <ofono/log.h>
|
||||
#include <ofono/nettime.h>
|
||||
#include <ofono/types.h>
|
||||
|
||||
#include "ofono.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
struct nt_data {
|
||||
gboolean time_available;
|
||||
gboolean time_pending;
|
||||
@@ -48,26 +45,32 @@ struct nt_data {
|
||||
int dst;
|
||||
int time_zone;
|
||||
|
||||
const char *mcc;
|
||||
const char *mnc;
|
||||
const char *path;
|
||||
char *mcc;
|
||||
char *mnc;
|
||||
char* path;
|
||||
DBusConnection *conn;
|
||||
};
|
||||
|
||||
static struct nt_data *ntd = NULL;
|
||||
|
||||
|
||||
static void init_time(void)
|
||||
static struct nt_data *nettime_new(const char *path)
|
||||
{
|
||||
ntd = g_new0(struct nt_data, 1);
|
||||
struct nt_data *ntd = g_new0(struct nt_data, 1);
|
||||
|
||||
ntd->time_available = FALSE;
|
||||
ntd->time_pending = FALSE;
|
||||
ntd->dst = 0;
|
||||
ntd->time_zone = 0;
|
||||
ntd->path = g_strdup(path);
|
||||
ntd->conn = dbus_connection_ref(ofono_dbus_get_connection());
|
||||
return ntd;
|
||||
}
|
||||
|
||||
static gboolean encode_time_format(const struct ofono_network_time *time,
|
||||
struct tm *tm)
|
||||
static void nettime_free(struct nt_data *ntd)
|
||||
{
|
||||
dbus_connection_unref(ntd->conn);
|
||||
g_free(ntd->path);
|
||||
g_free(ntd->mcc);
|
||||
g_free(ntd->mnc);
|
||||
g_free(ntd);
|
||||
}
|
||||
|
||||
static gboolean nettime_encode_time_format(struct tm *tm,
|
||||
const struct ofono_network_time *time)
|
||||
{
|
||||
if (time->year < 0)
|
||||
return FALSE;
|
||||
@@ -85,7 +88,7 @@ static gboolean encode_time_format(const struct ofono_network_time *time,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static time_t get_monotonic_time()
|
||||
static time_t nettime_get_monotonic_time()
|
||||
{
|
||||
struct timespec ts;
|
||||
memset(&ts, 0, sizeof(struct timespec));
|
||||
@@ -98,8 +101,7 @@ static time_t get_monotonic_time()
|
||||
return ts.tv_sec;
|
||||
}
|
||||
|
||||
static int fill_time_notification(DBusMessage *msg,
|
||||
struct nt_data *ntd)
|
||||
static int nettime_fill_time_notification(DBusMessage *msg, struct nt_data *ntd)
|
||||
{
|
||||
DBusMessageIter iter, iter_array;
|
||||
dbus_int64_t utc_long, received;
|
||||
@@ -150,22 +152,22 @@ static int fill_time_notification(DBusMessage *msg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static DBusMessage *get_network_time(DBusConnection *conn,
|
||||
static DBusMessage *nettime_get_network_time(DBusConnection *conn,
|
||||
DBusMessage *msg, void *data)
|
||||
{
|
||||
DBusMessage *reply;
|
||||
struct nt_data *ntd = data;
|
||||
DBusMessage *reply = dbus_message_new_method_return(msg);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (reply == NULL)
|
||||
return NULL;
|
||||
fill_time_notification(reply, ntd);
|
||||
if (reply) {
|
||||
nettime_fill_time_notification(reply, ntd);
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
||||
static const GDBusMethodTable nettime_methods[] = {
|
||||
{ GDBUS_METHOD("GetNetworkTime",
|
||||
NULL, GDBUS_ARGS({ "time", "a{sv}" }),
|
||||
get_network_time) },
|
||||
nettime_get_network_time) },
|
||||
{ }
|
||||
};
|
||||
|
||||
@@ -177,84 +179,90 @@ static const GDBusSignalTable nettime_signals[] = {
|
||||
|
||||
static int nettime_probe(struct ofono_nettime_context *context)
|
||||
{
|
||||
DBusConnection *conn = ofono_dbus_get_connection();
|
||||
const char *path = ofono_modem_get_path(context->modem);
|
||||
DBG("Network time probe for modem: %p (%s)", context->modem, path);
|
||||
init_time();
|
||||
if (!g_dbus_register_interface(conn, path,
|
||||
OFONO_NETWORK_TIME_INTERFACE, // name
|
||||
nettime_methods, // methods
|
||||
nettime_signals, // signals
|
||||
NULL, // GDBusPropertyTable *properties
|
||||
NULL, // user data
|
||||
NULL)) { // GDBusDestroyFunction destroy
|
||||
ofono_error("Network time: Could not register interface %s, path %s",
|
||||
OFONO_NETWORK_TIME_INTERFACE, path);
|
||||
return 1;
|
||||
} else {
|
||||
ofono_info("Network time: Registered interface %s, path %s",
|
||||
OFONO_NETWORK_TIME_INTERFACE, path);
|
||||
}
|
||||
struct nt_data *ntd = nettime_new(ofono_modem_get_path(context->modem));
|
||||
|
||||
ofono_modem_add_interface(context->modem, OFONO_NETWORK_TIME_INTERFACE);
|
||||
return 0;
|
||||
DBG("Network time probe for modem: %p (%s)", context->modem, ntd->path);
|
||||
if (g_dbus_register_interface(ntd->conn, ntd->path,
|
||||
OFONO_NETWORK_TIME_INTERFACE, nettime_methods,
|
||||
nettime_signals, NULL, ntd, NULL)) {
|
||||
context->data = ntd;
|
||||
ofono_info("Registered interface %s, path %s",
|
||||
OFONO_NETWORK_TIME_INTERFACE, ntd->path);
|
||||
ofono_modem_add_interface(context->modem,
|
||||
OFONO_NETWORK_TIME_INTERFACE);
|
||||
return 0;
|
||||
} else {
|
||||
ofono_error("Could not register interface %s, path %s",
|
||||
OFONO_NETWORK_TIME_INTERFACE, ntd->path);
|
||||
nettime_free(ntd);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void nettime_remove(struct ofono_nettime_context *context)
|
||||
{
|
||||
DBusConnection *conn = ofono_dbus_get_connection();
|
||||
const char *path = ofono_modem_get_path(context->modem);
|
||||
DBG("Network time remove for modem: %p (%s)", context->modem, path);
|
||||
if (!g_dbus_unregister_interface(conn, path, OFONO_NETWORK_TIME_INTERFACE)) {
|
||||
ofono_error("Network time: could not unregister interface %s, path %s",
|
||||
OFONO_NETWORK_TIME_INTERFACE, path);
|
||||
struct nt_data *ntd = context->data;
|
||||
|
||||
DBG("Network time remove for modem: %p (%s)", context->modem,
|
||||
ofono_modem_get_path(context->modem));
|
||||
ofono_modem_remove_interface(context->modem,
|
||||
OFONO_NETWORK_TIME_INTERFACE);
|
||||
if (!g_dbus_unregister_interface(ntd->conn, ntd->path,
|
||||
OFONO_NETWORK_TIME_INTERFACE)) {
|
||||
ofono_error("Network time: could not unregister interface %s"
|
||||
" for %s", OFONO_NETWORK_TIME_INTERFACE, ntd->path);
|
||||
}
|
||||
|
||||
ofono_modem_remove_interface(context->modem, OFONO_NETWORK_TIME_INTERFACE);
|
||||
g_free(ntd);
|
||||
nettime_free(ntd);
|
||||
}
|
||||
|
||||
static void send_signal(struct nt_data *ntd)
|
||||
static void nettime_send_signal(struct nt_data *ntd)
|
||||
{
|
||||
DBusConnection *conn = ofono_dbus_get_connection();
|
||||
DBusMessage *signal = dbus_message_new_signal(ntd->path,
|
||||
OFONO_NETWORK_TIME_INTERFACE,
|
||||
OFONO_NETWORK_TIME_INTERFACE,
|
||||
"NetworkTimeChanged");
|
||||
fill_time_notification(signal, ntd);
|
||||
g_dbus_send_message(conn, signal);
|
||||
|
||||
nettime_fill_time_notification(signal, ntd);
|
||||
g_dbus_send_message(ntd->conn, signal);
|
||||
}
|
||||
|
||||
static void nettime_info_received(struct ofono_nettime_context *context,
|
||||
struct ofono_network_time *info)
|
||||
{
|
||||
struct nt_data *ntd = context->data;
|
||||
struct ofono_netreg *netreg;
|
||||
const char *mcc;
|
||||
const char *mnc;
|
||||
struct tm t;
|
||||
|
||||
if (info == NULL)
|
||||
if (!ntd)
|
||||
return;
|
||||
|
||||
netreg = __ofono_atom_get_data(__ofono_modem_find_atom(
|
||||
context->modem, OFONO_ATOM_TYPE_NETREG));
|
||||
context->modem, OFONO_ATOM_TYPE_NETREG));
|
||||
mcc = ofono_netreg_get_mcc(netreg);
|
||||
mnc = ofono_netreg_get_mnc(netreg);
|
||||
|
||||
if (!(ofono_netreg_get_mcc(netreg) && ofono_netreg_get_mnc(netreg))) {
|
||||
if (!mcc || !mnc) {
|
||||
DBG("Incomplete network time received, ignoring");
|
||||
return;
|
||||
}
|
||||
|
||||
ntd->path = ofono_modem_get_path(context->modem);
|
||||
ntd->mcc = ofono_netreg_get_mcc(netreg);
|
||||
ntd->mnc = ofono_netreg_get_mnc(netreg);
|
||||
ntd->received = get_monotonic_time();
|
||||
g_free(ntd->mcc);
|
||||
g_free(ntd->mnc);
|
||||
ntd->mcc = g_strdup(mcc);
|
||||
ntd->mnc = g_strdup(mnc);
|
||||
ntd->received = nettime_get_monotonic_time();
|
||||
ntd->time_pending = TRUE;
|
||||
ntd->dst = info->dst;
|
||||
ntd->time_zone = info->utcoff;
|
||||
|
||||
ntd->time_available = encode_time_format(info, &t);
|
||||
if (ntd->time_available == TRUE)
|
||||
ntd->time_available = nettime_encode_time_format(&t, info);
|
||||
if (ntd->time_available) {
|
||||
ntd->nw_time_utc = timegm(&t);
|
||||
}
|
||||
|
||||
send_signal(ntd);
|
||||
DBG("modem: %p (%s)", context->modem, ofono_modem_get_path(context->modem));
|
||||
nettime_send_signal(ntd);
|
||||
DBG("modem: %p (%s)", context->modem, ntd->path);
|
||||
DBG("time: %04d-%02d-%02d %02d:%02d:%02d%c%02d:%02d (DST=%d)",
|
||||
info->year, info->mon, info->mday, info->hour,
|
||||
info->min, info->sec, info->utcoff > 0 ? '+' : '-',
|
||||
|
||||
@@ -86,6 +86,11 @@
|
||||
#define MCE_DISPLAY_DIM_STRING "dimmed"
|
||||
#define MCE_DISPLAY_OFF_STRING "off"
|
||||
|
||||
#define RILMODEM_CONF_FILE "/etc/ofono/ril_subscription.conf"
|
||||
#define RILSOCK_CONF_GROUP "cmdsocket"
|
||||
#define RILSOCK_CONF_PATH "path"
|
||||
#define DEFAULT_CMD_SOCK "/dev/socket/rild"
|
||||
|
||||
struct ril_data {
|
||||
GRil *modem;
|
||||
int power_on_retries;
|
||||
@@ -475,6 +480,45 @@ void ril_switchUser()
|
||||
|
||||
}
|
||||
|
||||
/* TODO: Reading RILD socket path by for now from rilmodem .conf file,
|
||||
* but change this later to StateFs when plans are more concrete.
|
||||
* return: Null-terminated path string. Ownership transferred.
|
||||
* */
|
||||
static char *ril_socket_path()
|
||||
{
|
||||
GError *err = NULL;
|
||||
GKeyFile *keyfile = NULL;
|
||||
char *res = NULL;
|
||||
|
||||
keyfile = g_key_file_new();
|
||||
g_key_file_set_list_separator(keyfile, ',');
|
||||
|
||||
if (!g_key_file_load_from_file(keyfile, RILMODEM_CONF_FILE, 0, &err)) {
|
||||
if (err) {
|
||||
DBG("conf load result: %s", err->message);
|
||||
g_error_free(err);
|
||||
}
|
||||
} else {
|
||||
if (g_key_file_has_group(keyfile, RILSOCK_CONF_GROUP)) {
|
||||
res = g_key_file_get_string(
|
||||
keyfile, RILSOCK_CONF_GROUP, RILSOCK_CONF_PATH, &err);
|
||||
if (err) {
|
||||
DBG("conf get result: %s", err->message);
|
||||
g_error_free(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_key_file_free(keyfile);
|
||||
|
||||
if (!res) {
|
||||
DBG("Falling back to default cmd sock path");
|
||||
res = g_strdup(DEFAULT_CMD_SOCK);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int create_gril(struct ofono_modem *modem)
|
||||
{
|
||||
DBG(" modem: %p", modem);
|
||||
@@ -483,7 +527,10 @@ static int create_gril(struct ofono_modem *modem)
|
||||
/* RIL expects user radio */
|
||||
ril_switchUser();
|
||||
|
||||
ril->modem = g_ril_new();
|
||||
char *path = ril_socket_path();
|
||||
ril->modem = g_ril_new(path);
|
||||
g_free(path);
|
||||
path = NULL;
|
||||
|
||||
g_ril_set_disconnect_function(ril->modem, gril_disconnected, modem);
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ struct ofono_modem {
|
||||
unsigned int call_ids;
|
||||
DBusMessage *pending;
|
||||
guint interface_update;
|
||||
ofono_bool_t features_update;
|
||||
ofono_bool_t powered;
|
||||
ofono_bool_t powered_pending;
|
||||
ofono_bool_t get_online;
|
||||
@@ -1247,6 +1248,9 @@ static gboolean trigger_interface_update(void *data)
|
||||
&interfaces);
|
||||
g_free(interfaces);
|
||||
|
||||
if (!modem->features_update)
|
||||
goto out;
|
||||
|
||||
features = g_new0(char *, g_slist_length(modem->feature_list) + 1);
|
||||
for (i = 0, l = modem->feature_list; l; l = l->next, i++)
|
||||
features[i] = l->data;
|
||||
@@ -1255,7 +1259,9 @@ static gboolean trigger_interface_update(void *data)
|
||||
"Features", DBUS_TYPE_STRING,
|
||||
&features);
|
||||
g_free(features);
|
||||
modem->features_update = FALSE;
|
||||
|
||||
out:
|
||||
modem->interface_update = 0;
|
||||
|
||||
return FALSE;
|
||||
@@ -1299,9 +1305,11 @@ void ofono_modem_add_interface(struct ofono_modem *modem,
|
||||
g_strdup(interface));
|
||||
|
||||
feature = get_feature(interface);
|
||||
if (feature)
|
||||
if (feature) {
|
||||
modem->features_update = TRUE;
|
||||
modem->feature_list = g_slist_prepend(modem->feature_list,
|
||||
g_strdup(feature));
|
||||
}
|
||||
|
||||
if (modem->interface_update != 0)
|
||||
return;
|
||||
@@ -1333,6 +1341,7 @@ void ofono_modem_remove_interface(struct ofono_modem *modem,
|
||||
(GCompareFunc) strcmp);
|
||||
if (found) {
|
||||
g_free(found->data);
|
||||
modem->features_update = TRUE;
|
||||
modem->feature_list =
|
||||
g_slist_remove(modem->feature_list,
|
||||
found->data);
|
||||
@@ -2071,6 +2080,7 @@ static void modem_unregister(struct ofono_modem *modem)
|
||||
if (modem->interface_update) {
|
||||
g_source_remove(modem->interface_update);
|
||||
modem->interface_update = 0;
|
||||
modem->features_update = FALSE;
|
||||
}
|
||||
|
||||
if (modem->lock_watch) {
|
||||
|
||||
@@ -2296,13 +2296,6 @@ enum ofono_sim_password_type ofono_sim_get_password_type(struct ofono_sim *sim)
|
||||
return sim->pin_type;
|
||||
}
|
||||
|
||||
void ofono_set_pin_lock_state(struct ofono_sim *sim,
|
||||
enum ofono_sim_password_type type,
|
||||
ofono_bool_t state)
|
||||
{
|
||||
sim->locked_pins[type] = state;
|
||||
}
|
||||
|
||||
const unsigned char *ofono_sim_get_cphs_service_table(struct ofono_sim *sim)
|
||||
{
|
||||
if (sim == NULL)
|
||||
@@ -2513,8 +2506,18 @@ void ofono_sim_inserted_notify(struct ofono_sim *sim, ofono_bool_t inserted)
|
||||
|
||||
if (inserted)
|
||||
sim_initialize(sim);
|
||||
else
|
||||
else {
|
||||
/*
|
||||
* Reset type to trigger property change signal after sim is
|
||||
* removed and inserted.
|
||||
* Can't reset in sim_free_main_state because it's called also
|
||||
* when sim state changes to OFONO_SIM_STATE_LOCKED_OUT
|
||||
* (PUK lock) if user fails to change PIN.
|
||||
*/
|
||||
sim->pin_type = OFONO_SIM_PASSWORD_NONE;
|
||||
|
||||
sim_free_state(sim);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int ofono_sim_add_state_watch(struct ofono_sim *sim,
|
||||
@@ -2763,6 +2766,10 @@ static void sim_pin_query_cb(const struct ofono_error *error,
|
||||
DBusConnection *conn = ofono_dbus_get_connection();
|
||||
const char *path = __ofono_atom_get_path(sim->atom);
|
||||
const char *pin_name;
|
||||
char **locked_pins;
|
||||
gboolean lock_changed;
|
||||
|
||||
DBG("sim->pin_type: %d, pin_type: %d", sim->pin_type, pin_type);
|
||||
|
||||
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
|
||||
ofono_error("Querying PIN authentication state failed");
|
||||
@@ -2777,9 +2784,24 @@ static void sim_pin_query_cb(const struct ofono_error *error,
|
||||
password_is_pin(pin_type) == FALSE)
|
||||
pin_type = puk2pin(pin_type);
|
||||
|
||||
if (pin_type != OFONO_SIM_PASSWORD_INVALID)
|
||||
if (pin_type != OFONO_SIM_PASSWORD_INVALID
|
||||
&& pin_type != OFONO_SIM_PASSWORD_NONE) {
|
||||
lock_changed = !sim->locked_pins[pin_type];
|
||||
|
||||
sim->locked_pins[pin_type] = TRUE;
|
||||
|
||||
if (lock_changed) {
|
||||
locked_pins = get_locked_pins(sim);
|
||||
|
||||
ofono_dbus_signal_array_property_changed(conn,
|
||||
path,
|
||||
OFONO_SIM_MANAGER_INTERFACE,
|
||||
"LockedPins", DBUS_TYPE_STRING,
|
||||
&locked_pins);
|
||||
|
||||
g_strfreev(locked_pins);
|
||||
}
|
||||
}
|
||||
ofono_dbus_signal_property_changed(conn, path,
|
||||
OFONO_SIM_MANAGER_INTERFACE,
|
||||
"PinRequired", DBUS_TYPE_STRING,
|
||||
|
||||
@@ -1369,8 +1369,7 @@ static void sms_dispatch(struct ofono_sms *sms, GSList *sms_list)
|
||||
|
||||
if (srcport == -1 || dstport == -1) {
|
||||
ofono_error("Got an 8-bit encoded message, however "
|
||||
"no valid src/address port, ignore");
|
||||
return;
|
||||
"no valid src/address port");
|
||||
}
|
||||
|
||||
buf = sms_decode_datagram(sms_list, &len);
|
||||
|
||||
@@ -65,6 +65,7 @@ autoreconf --force --install
|
||||
|
||||
%configure --disable-static \
|
||||
--enable-test \
|
||||
--enable-logcontrol \
|
||||
--with-systemdunitdir="/%{_lib}/systemd/system"
|
||||
|
||||
make %{?jobs:-j%jobs}
|
||||
|
||||
Reference in New Issue
Block a user