mirror of git://git.sysmocom.de/ofono
Read EFad and expose the IMSI MNC length (2-3)
This commit is contained in:
parent
9967c407fa
commit
6552bc668d
44
src/sim.c
44
src/sim.c
|
@ -76,6 +76,7 @@ struct sim_file_op {
|
|||
|
||||
struct ofono_sim {
|
||||
char *imsi;
|
||||
unsigned char mnc_length;
|
||||
GSList *own_numbers;
|
||||
GSList *new_numbers;
|
||||
gboolean ready;
|
||||
|
@ -154,6 +155,10 @@ static DBusMessage *sim_get_properties(DBusConnection *conn,
|
|||
ofono_dbus_dict_append(&dict, "SubscriberIdentity",
|
||||
DBUS_TYPE_STRING, &sim->imsi);
|
||||
|
||||
if (sim->mnc_length)
|
||||
ofono_dbus_dict_append(&dict, "MNCLength",
|
||||
DBUS_TYPE_BYTE, &sim->mnc_length);
|
||||
|
||||
own_numbers = get_own_numbers(sim->own_numbers);
|
||||
|
||||
ofono_dbus_dict_append_array(&dict, "SubscriberNumbers",
|
||||
|
@ -406,17 +411,56 @@ check:
|
|||
sim->new_numbers = NULL;
|
||||
}
|
||||
|
||||
static void sim_ad_read_cb(int ok,
|
||||
enum ofono_sim_file_structure structure,
|
||||
int length, int record,
|
||||
const unsigned char *data,
|
||||
int record_length, void *userdata)
|
||||
{
|
||||
struct ofono_sim *sim = userdata;
|
||||
DBusConnection *conn = ofono_dbus_get_connection();
|
||||
const char *path = __ofono_atom_get_path(sim->atom);
|
||||
int new_mnc_length;
|
||||
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
if (structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT)
|
||||
return;
|
||||
|
||||
if (length < 4)
|
||||
return;
|
||||
|
||||
new_mnc_length = data[3] & 0xf;
|
||||
|
||||
if (sim->mnc_length != new_mnc_length) {
|
||||
sim->mnc_length = new_mnc_length;
|
||||
|
||||
ofono_dbus_signal_property_changed(conn, path,
|
||||
SIM_MANAGER_INTERFACE,
|
||||
"MNCLength", DBUS_TYPE_BYTE,
|
||||
&sim->mnc_length);
|
||||
}
|
||||
}
|
||||
|
||||
static void sim_own_numbers_update(struct ofono_sim *sim)
|
||||
{
|
||||
ofono_sim_read(sim, SIM_EFMSISDN_FILEID,
|
||||
sim_msisdn_read_cb, sim);
|
||||
}
|
||||
|
||||
static void sim_mnc_length_update(struct ofono_sim *sim)
|
||||
{
|
||||
ofono_sim_read(sim, SIM_EFAD_FILEID,
|
||||
sim_ad_read_cb, sim);
|
||||
}
|
||||
|
||||
static void sim_ready(void *user)
|
||||
{
|
||||
struct ofono_sim *sim = user;
|
||||
|
||||
sim_own_numbers_update(sim);
|
||||
sim_mnc_length_update(sim);
|
||||
}
|
||||
|
||||
static void sim_imsi_cb(const struct ofono_error *error, const char *imsi,
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
enum sim_fileid {
|
||||
SIM_EFMSISDN_FILEID = 0x6f40,
|
||||
SIM_EFSPN_FILEID = 0x6f46,
|
||||
SIM_EFAD_FILEID = 0x6fad,
|
||||
SIM_EFPNN_FILEID = 0x6fc5,
|
||||
SIM_EFOPL_FILEID = 0x6fc6,
|
||||
SIM_EFMBDN_FILEID = 0x6fc7,
|
||||
|
|
Loading…
Reference in New Issue