Compare commits

...

23 Commits

Author SHA1 Message Date
Tommi Kenakkala
297bdaba0f Merge pull request #293 from tkenakka/cherrypick-pin-upstr
[sim] Improve Emit LockedPins after pin_type is queried. MER#1082
2015-06-23 15:12:46 +03:00
Tommi Kenakkala
f14db3b2a6 Merge pull request #292 from tkenakka/sockpath
Read RILD command socket path from a conf file. MER#1107
2015-06-23 14:44:31 +03:00
Tommi Kenakkala
4a0182616d [ril] Read RILD socket path from a file at startup. MER#1107
This allows configuring at startup the socket path to which ril plugin
will connect to.
2015-06-23 11:44:48 +03:00
Tommi Kenakkala
bbdfc8f46d [sim] Improve Emit LockedPins after pin_type is queried. MER#1082
Merge additional upstreaming changes from upstream commit eebe2f3
to previous nemomobile ofono commit 10328e6
2015-06-23 11:38:10 +03:00
Tommi Kenakkala
fbd59a8dc9 [gril] Change oFono gril to take a socket path. MER#1107
This allows configuring at startup the socket path to which gril
will connect to.
2015-06-22 11:16:00 +03:00
Tommi Kenakkala
7eb6d5559a Merge pull request #291 from tkenakka/pin
[sim] Reset ofono pin state to none when card removed
2015-06-18 12:14:18 +03:00
Tommi Kenakkala
9a47510eb5 [sim] Coding conventions improvements for sim.c
Improves 10328e626d
2015-06-18 12:11:03 +03:00
Tommi Kenakkala
8fc7ae836f [sim] Reset pin state to none when card removed
Improves d88af05dc3
sim_get_properties would have problems with OFONO_SIM_PASSWORD_INVALID.
2015-06-18 12:11:03 +03:00
Tommi Kenakkala
8c0f4f27eb Merge pull request #290 from tkenakka/pin
Refactor rilmodem SIM PIN handling
2015-06-10 15:09:53 +03:00
Tommi Kenakkala
b932bed519 Merge pull request #288 from monich/features
Don't unnecessarily emit "Features" PropertyChanged signal
2015-06-10 15:08:34 +03:00
Tommi Kenakkala
db83ac369b Merge pull request #287 from monich/leak
Fix memory leak
2015-06-10 15:02:54 +03:00
Tommi Kenakkala
e26df8a645 [rilmodem] Minor sim related logging updates 2015-06-09 16:19:01 +03:00
Tommi Kenakkala
5144f3fa14 [rilmodem] Remove ofono_set_pin_lock_state. Contributes MER#1082
Core sets LockedPins when driver returns that a PIN query is
required.
2015-06-09 16:17:55 +03:00
Tommi Kenakkala
0d6459b9b0 [sim] Remove ofono_set_pin_lock_state. Contributes MER#1082 2015-06-09 16:17:44 +03:00
Tommi Kenakkala
10328e626d [sim] Emit LockedPins changed. Contributes MER#1082
org.ofono.SimManager "Present" is signalled by ofono_sim_inserted_notify,
but LockedPins and PinRequired are updated later by sim_pin_query_cb.
Without signalling a client does not know when LockedPins
becomes available.
2015-06-09 16:05:43 +03:00
Tommi Kenakkala
5b407d654a [rilmodem] Reset retry count on PIN state change
After this rilmodem driver reports retries only for the required PIN type
and does not remember counts for previous password types.
2015-06-09 16:05:43 +03:00
Tommi Kenakkala
d88af05dc3 [sim] Reset pin_type on card removal. Contributes MER#1083
With this the variable behind org.ofono.SimManager "PinRequired"
is reset when card is removed, allowing signalling property change
in sim_pin_query_cb when card is inserted back.
2015-06-09 16:05:43 +03:00
Tommi Kenakkala
99cae6876f [rilmodem] Reset rilmodem driver's PIN type on card removal. Contributes MER#1083
Getting the PIN state for a freshly inserted card takes a while,
without this change driver uses the old state until the new state
is known.
2015-06-09 16:05:43 +03:00
Tommi Kenakkala
89e6593f9c [rilmodem] Delay signalling SIM inserted until PIN state available
Delay ofono_sim_inserted_notify call to core until PIN state is parsed
from gsmumts application by rilmodem driver.
2015-06-09 16:05:43 +03:00
Tommi Kenakkala
8e9085f5ab Merge pull request #289 from tkenakka/simmgr
[rilmodem] Fix simmanager removal handling. Contributes to MER#928
2015-05-15 12:47:15 +03:00
Tommi Kenakkala
c33a48ea0c [rilmodem] Fix simmanager removal handling. Contributes to MER#928
Improves 7d0d72a.
2015-05-15 11:38:21 +03:00
Slava Monich
3860230644 [modem] Don't unnecessarily emit "Features" PropertyChanged signal
Not all interfaces have corresponding features, meaning that not every
interface addition or removal actually updates the feature list.
If nothing else, this reduces the number of D-Bus signals emitted.
2015-05-05 16:11:06 +03:00
Slava Monich
063234a433 [rilmodem] Fixed memory leak in handle_sne() 2015-05-05 15:51:12 +03:00
9 changed files with 150 additions and 99 deletions

View File

@@ -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);
}
}

View File

@@ -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

View File

@@ -519,44 +519,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,6 +589,19 @@ 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_status_cb(struct ril_msg *message, gpointer user_data)
{
struct ofono_sim *sim = user_data;
@@ -637,7 +612,7 @@ static void sim_status_cb(struct ril_msg *message, gpointer user_data)
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) {
@@ -652,30 +627,30 @@ static void sim_status_cb(struct ril_msg *message, gpointer user_data)
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;
}
}
/*
* 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 +678,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);
}
}
}
@@ -771,7 +745,6 @@ static void ril_query_passwd_state_cb(struct ril_msg *message, gpointer user_dat
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;
}
}
@@ -826,8 +799,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 +811,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 +1087,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 +1130,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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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,