[PATCH] sim: Add support for query facility lock
by Samrat Guha Niyogi
---
include/sim.h | 6 ++++++
src/sim.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+)
diff --git a/include/sim.h b/include/sim.h
index ed850f9..9470d4d 100644
--- a/include/sim.h
+++ b/include/sim.h
@@ -121,6 +121,9 @@ typedef void (*ofono_sim_lock_unlock_cb_t)(const struct ofono_error *error,
typedef void (*ofono_sim_locked_cb_t)(const struct ofono_error *error,
int locked, void *data);
+typedef void (*ofono_query_facility_lock_cb_t)(const struct ofono_error *error,
+ ofono_bool_t status, void *data);
+
struct ofono_sim_driver {
const char *name;
int (*probe)(struct ofono_sim *sim, unsigned int vendor, void *data);
@@ -173,6 +176,9 @@ struct ofono_sim_driver {
void (*query_locked)(struct ofono_sim *sim,
enum ofono_sim_password_type type,
ofono_sim_locked_cb_t cb, void *data);
+ void (*query_facility_lock)(struct ofono_sim *sim,
+ enum ofono_sim_password_type lock,
+ ofono_query_facility_lock_cb_t cb, void *data);
};
int ofono_sim_driver_register(const struct ofono_sim_driver *d);
diff --git a/src/sim.c b/src/sim.c
index 94d8840..aedc617 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -2449,6 +2449,60 @@ static void sim_free_state(struct ofono_sim *sim)
sim_free_main_state(sim);
}
+static void sim_query_fac_imsilock_cb(const struct ofono_error *error,
+ ofono_bool_t status,
+ void *data)
+{
+ struct ofono_sim *sim = data;
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = __ofono_atom_get_path(sim->atom);
+ char **locked_pins;
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ ofono_error("Querying Facility Lock for IMSI Lock failed");
+ return;
+ }
+
+ sim->locked_pins[OFONO_SIM_PASSWORD_PHSIM_PIN] = status;
+
+ 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);
+}
+
+static void sim_query_fac_networklock_cb(const struct ofono_error *error,
+ ofono_bool_t status,
+ void *data)
+{
+ struct ofono_sim *sim = data;
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = __ofono_atom_get_path(sim->atom);
+ char **locked_pins;
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ ofono_error("Querying Facility Lock for Network Lock failed");
+ return;
+ }
+
+ sim->locked_pins[OFONO_SIM_PASSWORD_PHNET_PIN] = status;
+
+ 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);
+}
+
void ofono_sim_inserted_notify(struct ofono_sim *sim, ofono_bool_t inserted)
{
if (sim->state == OFONO_SIM_STATE_RESETTING && inserted) {
@@ -2475,6 +2529,14 @@ void ofono_sim_inserted_notify(struct ofono_sim *sim, ofono_bool_t inserted)
call_state_watches(sim);
if (inserted) {
+ sim->driver->query_facility_lock(sim,
+ OFONO_SIM_PASSWORD_PHSIM_PIN,
+ sim_query_fac_imsilock_cb, sim);
+
+ sim->driver->query_facility_lock(sim,
+ OFONO_SIM_PASSWORD_PHNET_PIN,
+ sim_query_fac_networklock_cb, sim);
+
sim_initialize(sim);
} else {
sim->pin_type = OFONO_SIM_PASSWORD_NONE;
--
1.9.1
6 years, 3 months
[PATCH] sim: include changes for query facility lock
by Samrat Guha Niyogi
---
include/sim.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/sim.h b/include/sim.h
index ed850f9..9470d4d 100644
--- a/include/sim.h
+++ b/include/sim.h
@@ -121,6 +121,9 @@ typedef void (*ofono_sim_lock_unlock_cb_t)(const struct ofono_error *error,
typedef void (*ofono_sim_locked_cb_t)(const struct ofono_error *error,
int locked, void *data);
+typedef void (*ofono_query_facility_lock_cb_t)(const struct ofono_error *error,
+ ofono_bool_t status, void *data);
+
struct ofono_sim_driver {
const char *name;
int (*probe)(struct ofono_sim *sim, unsigned int vendor, void *data);
@@ -173,6 +176,9 @@ struct ofono_sim_driver {
void (*query_locked)(struct ofono_sim *sim,
enum ofono_sim_password_type type,
ofono_sim_locked_cb_t cb, void *data);
+ void (*query_facility_lock)(struct ofono_sim *sim,
+ enum ofono_sim_password_type lock,
+ ofono_query_facility_lock_cb_t cb, void *data);
};
int ofono_sim_driver_register(const struct ofono_sim_driver *d);
--
1.9.1
6 years, 3 months
[PATCH] sim: rilmodem driver support for query facility lock
by Samrat Guha Niyogi
---
drivers/rilmodem/sim.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/drivers/rilmodem/sim.c b/drivers/rilmodem/sim.c
index 02399ff..ba31446 100644
--- a/drivers/rilmodem/sim.c
+++ b/drivers/rilmodem/sim.c
@@ -1405,6 +1405,54 @@ static int ril_sim_probe(struct ofono_sim *sim, unsigned int vendor,
return 0;
}
+static void ril_query_facility_lock_cb(struct ril_msg *message, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_query_facility_lock_cb_t cb = cbd->cb;
+ struct sim_data *sd = cbd->user;
+ struct parcel rilp;
+ ofono_bool_t status;
+
+ if (message->error != RIL_E_SUCCESS)
+ goto error;
+
+ g_ril_init_parcel(message, &rilp);
+
+ status = (ofono_bool_t)parcel_r_int32(&rilp);
+
+ g_ril_append_print_buf(sd->ril, "{%d}", status);
+ g_ril_print_response(sd->ril, message);
+
+ CALLBACK_WITH_SUCCESS(cb, status, cbd->data);
+ return;
+
+error:
+ CALLBACK_WITH_FAILURE(cb, 0, cbd->data);
+}
+
+static void ril_query_facility_lock(struct ofono_sim *sim,
+ enum ofono_sim_password_type lock,
+ ofono_query_facility_lock_cb_t cb, void *data)
+{
+ struct sim_data *sd = ofono_sim_get_data(sim);
+ struct cb_data *cbd = cb_data_new(cb, data, sim);
+ struct parcel rilp;
+
+ parcel_init(&rilp);
+ parcel_w_int32(&rilp, 4); /* # of strings */
+ parcel_w_string(&rilp, clck_cpwd_fac[lock]);
+ parcel_w_string(&rilp, ""); /* Password is empty when not needed */
+ parcel_w_string(&rilp, "0"); /* Class is "0" */
+ parcel_w_string(&rilp, NULL); /* AID value is NULL */
+
+ if (g_ril_send(sd->ril, RIL_REQUEST_QUERY_FACILITY_LOCK, &rilp,
+ ril_query_facility_lock_cb, cbd, g_free) > 0)
+ return;
+
+ g_free(cbd);
+ CALLBACK_WITH_FAILURE(cb, 0, data);
+}
+
static void ril_sim_remove(struct ofono_sim *sim)
{
struct sim_data *sd = ofono_sim_get_data(sim);
@@ -1434,6 +1482,7 @@ static struct ofono_sim_driver driver = {
.reset_passwd = ril_pin_send_puk,
.change_passwd = ril_change_passwd,
.lock = ril_pin_change_state,
+ .query_facility_lock = ril_query_facility_lock,
/*
* TODO: Implmenting PIN/PUK support requires defining
* the following driver methods.
--
1.9.1
6 years, 3 months
[PATCH] doc/connman: fix doc error
by caiwen.zhang@intel.com
From: Caiwen Zhang <caiwen.zhang(a)intel.com>
---
doc/connman-api.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/connman-api.txt b/doc/connman-api.txt
index 1ce1d61..9220d0d 100644
--- a/doc/connman-api.txt
+++ b/doc/connman-api.txt
@@ -106,7 +106,7 @@ Properties boolean Attached [readonly]
GPRS service registration (if known).
Possible values are:
- "none", "gsm", "edge", "umts", "hsdpa", "hsupa",
+ "none", "gprs", "edge", "umts", "hsdpa", "hsupa",
"hspa" (HSDPA and HSUPA at the same time) and
"lte"
--
1.9.1
6 years, 3 months
[PATCH] Radio-setting: Add GSM and UMTS band
by Antara Borwankar
From: Antara Borwankar <antara.borwankar(a)gmail.com>
To add GSM band and UMTS band to persitent data
---
src/radio-settings.c | 100 ++++++++++++++++++++++++++++++++++-----------------
1 file changed, 68 insertions(+), 32 deletions(-)
diff --git a/src/radio-settings.c b/src/radio-settings.c
index 7bbd811..15d2f8e 100644
--- a/src/radio-settings.c
+++ b/src/radio-settings.c
@@ -72,7 +72,7 @@ static const char *radio_access_mode_to_string(enum ofono_radio_access_mode m)
case OFONO_RADIO_ACCESS_MODE_LTE:
return "lte";
default:
- return "";
+ return NULL;
}
}
@@ -114,7 +114,7 @@ static const char *radio_band_gsm_to_string(enum ofono_radio_band_gsm band)
return "1900";
}
- return "";
+ return NULL;
}
static gboolean radio_band_gsm_from_string(const char *str,
@@ -160,7 +160,7 @@ static const char *radio_band_umts_to_string(enum ofono_radio_band_umts band)
return "2100";
}
- return "";
+ return NULL;
}
static gboolean radio_band_umts_from_string(const char *str,
@@ -311,6 +311,12 @@ static void radio_set_band(struct ofono_radio_settings *rs)
OFONO_RADIO_SETTINGS_INTERFACE,
"GsmBand", DBUS_TYPE_STRING,
&str_band);
+
+ if (rs->settings) {
+ g_key_file_set_integer(rs->settings, SETTINGS_GROUP,
+ "GsmBand", rs->band_gsm);
+ storage_sync(rs->imsi, SETTINGS_STORE, rs->settings);
+ }
}
if (rs->band_umts != rs->pending_band_umts) {
@@ -321,8 +327,13 @@ static void radio_set_band(struct ofono_radio_settings *rs)
OFONO_RADIO_SETTINGS_INTERFACE,
"UmtsBand", DBUS_TYPE_STRING,
&str_band);
- }
+ if (rs->settings) {
+ g_key_file_set_integer(rs->settings, SETTINGS_GROUP,
+ "UmtsBand", rs->band_umts);
+ storage_sync(rs->imsi, SETTINGS_STORE, rs->settings);
+ }
+ }
}
static void radio_band_set_callback(const struct ofono_error *error,
@@ -368,6 +379,12 @@ static void radio_set_rat_mode(struct ofono_radio_settings *rs,
OFONO_RADIO_SETTINGS_INTERFACE,
"TechnologyPreference",
DBUS_TYPE_STRING, &str_mode);
+
+ if (rs->settings) {
+ g_key_file_set_integer(rs->settings, SETTINGS_GROUP,
+ "TechnologyPreference", rs->mode);
+ storage_sync(rs->imsi, SETTINGS_STORE, rs->settings);
+ }
}
static void radio_mode_set_callback(const struct ofono_error *error, void *data)
@@ -578,15 +595,7 @@ static DBusMessage *radio_set_property(DBusConnection *conn, DBusMessage *msg,
rs->pending_mode = mode;
rs->driver->set_rat_mode(rs, mode, radio_mode_set_callback, rs);
-
- if (rs->settings) {
- const char *mode_str;
- mode_str = radio_access_mode_to_string(mode);
- g_key_file_set_string(rs->settings, SETTINGS_GROUP,
- "TechnologyPreference", mode_str);
- storage_sync(rs->imsi, SETTINGS_STORE, rs->settings);
- }
-
+ /* will be saved in radiosettng on success response*/
return NULL;
} else if (g_strcmp0(property, "GsmBand") == 0) {
const char *value;
@@ -610,7 +619,7 @@ static DBusMessage *radio_set_property(DBusConnection *conn, DBusMessage *msg,
rs->driver->set_band(rs, band, rs->band_umts,
radio_band_set_callback, rs);
-
+ /* will be saved in radiosettng on success response*/
return NULL;
} else if (g_strcmp0(property, "UmtsBand") == 0) {
const char *value;
@@ -634,7 +643,7 @@ static DBusMessage *radio_set_property(DBusConnection *conn, DBusMessage *msg,
rs->driver->set_band(rs, rs->band_gsm, band,
radio_band_set_callback, rs);
-
+ /* will be saved in radiosettng on success response*/
return NULL;
} else if (g_strcmp0(property, "FastDormancy") == 0) {
dbus_bool_t value;
@@ -804,12 +813,21 @@ static void radio_mode_set_callback_at_reg(const struct ofono_error *error,
*/
ofono_radio_finish_register(rs);
}
+static void radio_band_set_callback_at_reg(const struct ofono_error *error,
+ void *data)
+{
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
+ DBG("Error setting radio access mode register time");
+ /*
+ * Continue with atom register even if request fail at modem
+ * ofono_radio_finish_register called by radio_mode_set_callback_at_reg
+ */
+}
static void radio_load_settings(struct ofono_radio_settings *rs,
const char *imsi)
{
GError *error;
- char *strmode;
rs->settings = storage_open(imsi, SETTINGS_STORE);
@@ -820,34 +838,46 @@ static void radio_load_settings(struct ofono_radio_settings *rs,
if (rs->settings == NULL) {
DBG("radiosetting storage open failed");
rs->mode = OFONO_RADIO_ACCESS_MODE_ANY;
+ rs->band_gsm = OFONO_RADIO_BAND_GSM_ANY;
+ rs->band_umts = OFONO_RADIO_BAND_UMTS_ANY;
return;
}
rs->imsi = g_strdup(imsi);
error = NULL;
- strmode = g_key_file_get_string(rs->settings, SETTINGS_GROUP,
- "TechnologyPreference", &error);
+ rs->band_gsm = g_key_file_get_integer(rs->settings, SETTINGS_GROUP,
+ "GsmBand", &error);
- if (error) {
- g_error_free(error);
- goto setdefault;
+ if (error || radio_band_gsm_to_string(rs->band_gsm) == NULL) {
+ rs->band_gsm = OFONO_RADIO_BAND_GSM_ANY;
+ g_key_file_set_integer(rs->settings, SETTINGS_GROUP,
+ "GsmBand", rs->band_gsm);
}
- if (radio_access_mode_from_string(strmode, &rs->mode) == FALSE) {
- DBG("Invalid rat mode in storage; Setting default");
- goto setdefault;
+ error = NULL;
+ rs->band_umts = g_key_file_get_integer(rs->settings, SETTINGS_GROUP,
+ "UmtsBand", &error);
+
+ if (error || radio_band_umts_to_string(rs->band_umts) == NULL) {
+ rs->band_umts = OFONO_RADIO_BAND_UMTS_ANY;
+ g_key_file_set_integer(rs->settings, SETTINGS_GROUP,
+ "UmtsBand", rs->band_umts);
}
- g_free(strmode);
- return;
+ error = NULL;
+ rs->mode = g_key_file_get_integer(rs->settings, SETTINGS_GROUP,
+ "TechnologyPreference", &error);
+
+ if (error || radio_access_mode_to_string(rs->mode) == NULL) {
+ rs->mode = OFONO_RADIO_ACCESS_MODE_ANY;
+ g_key_file_set_integer(rs->settings, SETTINGS_GROUP,
+ "TechnologyPreference", rs->mode);
+ }
-setdefault:
- rs->mode = OFONO_RADIO_ACCESS_MODE_ANY;
- g_key_file_set_string(rs->settings, SETTINGS_GROUP,
- "TechnologyPreference", "any");
- storage_sync(rs->imsi, SETTINGS_STORE, rs->settings);
- g_free(strmode);
+ DBG("TechnologyPreference: %d", rs->mode);
+ DBG("GsmBand: %d", rs->band_gsm);
+ DBG("UmtsBand: %d", rs->band_umts);
}
void ofono_radio_settings_register(struct ofono_radio_settings *rs)
@@ -860,6 +890,12 @@ void ofono_radio_settings_register(struct ofono_radio_settings *rs)
radio_load_settings(rs, ofono_sim_get_imsi(sim));
+ if (rs->driver->set_band == NULL)
+ goto finish;
+
+ rs->driver->set_band(rs, rs->band_gsm, rs->band_umts,
+ radio_band_set_callback_at_reg, rs);
+
if (rs->driver->set_rat_mode == NULL)
goto finish;
--
1.9.1
6 years, 3 months
[PATCH v2 0/2] [RFC] Clean up undefined function pointer casts
by John Ernberg
From: John Ernberg <john.ernberg(a)actia.se>
v2: Bump glib requirement to version 2.32 to gain access to g_queue_free_full,
this saves using a wrapper function to clean up the queue in the stk.
John Ernberg (2):
configure: Bump glib dependecy to 2.32
stk: clean up undefined function pointer casts
configure.ac | 4 ++--
src/stk.c | 6 ++----
2 files changed, 4 insertions(+), 6 deletions(-)
--
1.9.1
6 years, 3 months
[PATCH 0/5] Clean up atoms on modem_unregister
by John Ernberg
From: John Ernberg <john.ernberg(a)actia.se>
When using e.g. a USB modem and it's unplugged oFono may crash with a
SIGSEGV or SIGFPE due to atoms not getting cleaned up properly.
John Ernberg (5):
modem: clean up atoms on modem_unregister
bluez4: track and clean up atom watches
bluez5: track and clean up atom watches
push notification: track and clean up atom watches
smart messaging: track and clean up atom watches
plugins/dun_gw_bluez4.c | 24 ++++++++++++++++++++++--
plugins/dun_gw_bluez5.c | 24 ++++++++++++++++++++++--
plugins/hfp_ag_bluez4.c | 25 ++++++++++++++++++++++---
plugins/hfp_ag_bluez5.c | 36 +++++++++++++++++++++++++++++++-----
plugins/push-notification.c | 26 +++++++++++++++++++++++---
plugins/smart-messaging.c | 26 +++++++++++++++++++++++---
src/modem.c | 3 +++
7 files changed, 146 insertions(+), 18 deletions(-)
--
1.9.1
6 years, 3 months
[PATCH] rilmodem: Driver code to set band mode and value
by Samrat Guha Niyogi
From: Antara Borwankar <antara.borwankar(a)gmail.com>
set_band driver to set GSM band and UMTS band
---
drivers/rilmodem/radio-settings.c | 109 ++++++++++++++++++++++++++++++++++++++
1 file changed, 109 insertions(+)
diff --git a/drivers/rilmodem/radio-settings.c b/drivers/rilmodem/radio-settings.c
index 90b49c6..eb26902 100644
--- a/drivers/rilmodem/radio-settings.c
+++ b/drivers/rilmodem/radio-settings.c
@@ -64,6 +64,22 @@
#define MTK_PREF_NET_TYPE_LTE_GSM_TYPE (MTK_PREF_NET_TYPE_BASE + 5)
#define MTK_PREF_NET_TYPE_LTE_GSM_MMDC_TYPE (MTK_PREF_NET_TYPE_BASE + 6)
+/*GSM Band*/
+#define PREF_NET_BAND_GSM_AUTOMATIC 255
+#define PREF_NET_BAND_GSM850 6
+#define PREF_NET_BAND_GSM900_P 1
+#define PREF_NET_BAND_GSM900_E 2
+#define PREF_NET_BAND_GSM1800 4
+#define PREF_NET_BAND_GSM1900 5
+
+/*UMTS Band*/
+#define PREF_NET_BAND_UMTS_AUTOMATIC 255
+#define PREF_NET_BAND_UMTS_V 54
+#define PREF_NET_BAND_UMTS_VIII 57
+#define PREF_NET_BAND_UMTS_IV 53
+#define PREF_NET_BAND_UMTS_II 51
+#define PREF_NET_BAND_UMTS_I 50
+
struct radio_data {
GRil *ril;
gboolean fast_dormancy;
@@ -288,6 +304,98 @@ static void ril_query_available_rats(struct ofono_radio_settings *rs,
CALLBACK_WITH_SUCCESS(cb, available_rats, data);
}
+static void ril_set_band_cb(struct ril_msg *message, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ struct ofono_radio_settings *rs = cbd->user;
+ struct radio_data *rd = ofono_radio_settings_get_data(rs);
+ ofono_radio_settings_band_set_cb_t cb = cbd->cb;
+
+ if (message->error == RIL_E_SUCCESS) {
+ g_ril_print_response_no_args(rd->ril, message);
+
+ CALLBACK_WITH_SUCCESS(cb, cbd->data);
+ } else {
+ CALLBACK_WITH_FAILURE(cb, cbd->data);
+ }
+}
+
+static void ril_set_band(struct ofono_radio_settings *rs,
+ enum ofono_radio_band_gsm band_gsm,
+ enum ofono_radio_band_umts band_umts,
+ ofono_radio_settings_band_set_cb_t cb,
+ void *data)
+{
+ struct radio_data *rd = ofono_radio_settings_get_data(rs);
+ struct cb_data *cbd = cb_data_new(cb, data, rs);
+ struct parcel rilp;
+ char cmd_buf[9], gsm_band[4], umts_band[4];
+ /* RIL_OEM_HOOK_STRING_SET_BAND_PREFERENCE = 0x000000CE */
+ int cmd_id = 0x000000CE;
+ sprintf(cmd_buf, "%d", cmd_id);
+
+ switch (band_gsm) {
+ case OFONO_RADIO_BAND_GSM_ANY:
+ sprintf(gsm_band, "%d", PREF_NET_BAND_GSM_AUTOMATIC);
+ break;
+ case OFONO_RADIO_BAND_GSM_850:
+ sprintf(gsm_band, "%d", PREF_NET_BAND_GSM850);
+ break;
+ case OFONO_RADIO_BAND_GSM_900P:
+ sprintf(gsm_band, "%d", PREF_NET_BAND_GSM900_P);
+ break;
+ case OFONO_RADIO_BAND_GSM_900E:
+ sprintf(gsm_band, "%d", PREF_NET_BAND_GSM900_E);
+ break;
+ case OFONO_RADIO_BAND_GSM_1800:
+ sprintf(gsm_band, "%d", PREF_NET_BAND_GSM1800);
+ break;
+ case OFONO_RADIO_BAND_GSM_1900:
+ sprintf(gsm_band, "%d", PREF_NET_BAND_GSM1900);
+ break;
+ default:
+ CALLBACK_WITH_FAILURE(cb, data);
+ return;
+ }
+
+ switch (band_umts) {
+ case OFONO_RADIO_BAND_UMTS_ANY:
+ sprintf(umts_band, "%d", PREF_NET_BAND_UMTS_AUTOMATIC);
+ break;
+ case OFONO_RADIO_BAND_UMTS_850:
+ sprintf(umts_band, "%d", PREF_NET_BAND_UMTS_V);
+ break;
+ case OFONO_RADIO_BAND_UMTS_900:
+ sprintf(umts_band, "%d", PREF_NET_BAND_UMTS_VIII);
+ break;
+ case OFONO_RADIO_BAND_UMTS_1700AWS:
+ sprintf(umts_band, "%d", PREF_NET_BAND_UMTS_IV);
+ break;
+ case OFONO_RADIO_BAND_UMTS_1900:
+ sprintf(umts_band, "%d", PREF_NET_BAND_UMTS_II);
+ break;
+ case OFONO_RADIO_BAND_UMTS_2100:
+ sprintf(umts_band, "%d", PREF_NET_BAND_UMTS_I);
+ break;
+ default:
+ CALLBACK_WITH_FAILURE(cb, data);
+ return;
+ }
+
+ parcel_init(&rilp);
+ parcel_w_int32(&rilp, 3); /* Number of params */
+ parcel_w_string(&rilp, cmd_buf);
+ parcel_w_string(&rilp, gsm_band);
+ parcel_w_string(&rilp, umts_band);
+
+ if (g_ril_send(rd->ril, RIL_REQUEST_OEM_HOOK_STRINGS, &rilp,
+ ril_set_band_cb, cbd, g_free) > 0)
+ return;
+
+ g_free(cbd);
+ CALLBACK_WITH_FAILURE(cb,data);
+}
+
static void ril_delayed_register(const struct ofono_error *error,
void *user_data)
{
@@ -329,6 +437,7 @@ static struct ofono_radio_settings_driver driver = {
.remove = ril_radio_settings_remove,
.query_rat_mode = ril_query_rat_mode,
.set_rat_mode = ril_set_rat_mode,
+ .set_band = ril_set_band,
.query_fast_dormancy = ril_query_fast_dormancy,
.set_fast_dormancy = ril_set_fast_dormancy,
.query_available_rats = ril_query_available_rats
--
1.9.1
6 years, 3 months
[PATCH 00/24] [RFC] Don't rely on undefined behavior when casting function pointers
by John Ernberg
From: John Ernberg <john.ernberg(a)actia.se>
Casting between incompatible function pointer types is undefined.
While it works fine on x86, it's not a good idea to depend on this.
This RFC uses g_slist_free_full where possible, and when it's not works around
the casting using other means such as wrappers or fixing function parameters.
John Ernberg (24):
atmodem: don't rely on undefined behavior when casting function
pointers
hfpmodem: don't rely on undefined behavior when casting function
pointers
ifxmodem: don't rely on undefined behavior when casting function
pointers
ril: don't rely on undefined behavior when casting function pointers
stemodem: don't rely on undefined behavior when casting function
pointers
gatchat: don't rely on undefined behavior when casting function
pointers
bluez4: don't rely on undefined behavior when casting function
pointers
sm: don't rely on undefined behavior when casting function pointers
cbs: don't rely on undefined behavior when casting function pointers
cdma/sms: don't rely on undefined behavior when casting function
pointers
handsfree: don't rely on undefined behavior when casting function
pointers
modem: don't rely on undefined behavior when casting function pointers
network: don't rely on undefined behavior when casting function
pointers
phonebook: don't rely on undefined behavior when casting function
pointers
sim: don't rely on undefined behavior when casting function pointers
simfs: don't rely on undefined behavior when casting function pointers
simutil: don't rely on undefined behavior when casting function
pointers
sms: don't rely on undefined behavior when casting function pointers
smsutil: don't rely on undefined behavior when casting function
pointers
stk: don't rely on undefined behavior when casting function pointers
stkutil: don't rely on undefined behavior when casting function
pointers
ussd: don't rely on undefined behavior when casting function pointers
voicecall: don't rely on undefined behavior when casting function
pointers
unittest: don't rely on undefined behavior when casting function
pointers
drivers/atmodem/voicecall.c | 6 ++----
drivers/hfpmodem/voicecall.c | 6 ++----
drivers/ifxmodem/voicecall.c | 3 +--
drivers/rilmodem/voicecall.c | 6 ++----
drivers/stemodem/voicecall.c | 3 +--
gatchat/gatchat.c | 13 +++++--------
plugins/bluez4.c | 7 +++----
plugins/smart-messaging.c | 6 ++----
src/cbs.c | 27 +++++++++------------------
src/cdma-smsutil.c | 3 +--
src/handsfree.c | 3 +--
src/modem.c | 6 ++----
src/network.c | 3 +--
src/phonebook.c | 24 ++++++++++++++----------
src/sim.c | 29 ++++++++++-------------------
src/simfs.c | 6 +++---
src/simutil.c | 6 ++----
src/sms.c | 9 +++------
src/smsutil.c | 21 +++++++--------------
src/stk.c | 10 +++++++---
src/stkutil.c | 39 ++++++++++++---------------------------
src/ussd.c | 10 +++++-----
src/voicecall.c | 7 ++-----
unit/test-sms.c | 21 +++++++--------------
24 files changed, 104 insertions(+), 170 deletions(-)
--
1.9.1
6 years, 3 months
[PATCH] Radio-setting: Add GSM and UMTS band
by Samrat Guha Niyogi
From: Antara Borwankar <antara.borwankar(a)gmail.com>
To add GSM band and UMTS band to persitent data
---
src/radio-settings.c | 107 +++++++++++++++++++++++++++++++++++----------------
1 file changed, 73 insertions(+), 34 deletions(-)
diff --git a/src/radio-settings.c b/src/radio-settings.c
index 7bbd811..4ef0181 100644
--- a/src/radio-settings.c
+++ b/src/radio-settings.c
@@ -72,7 +72,7 @@ static const char *radio_access_mode_to_string(enum ofono_radio_access_mode m)
case OFONO_RADIO_ACCESS_MODE_LTE:
return "lte";
default:
- return "";
+ return NULL;
}
}
@@ -114,7 +114,7 @@ static const char *radio_band_gsm_to_string(enum ofono_radio_band_gsm band)
return "1900";
}
- return "";
+ return NULL;
}
static gboolean radio_band_gsm_from_string(const char *str,
@@ -160,7 +160,7 @@ static const char *radio_band_umts_to_string(enum ofono_radio_band_umts band)
return "2100";
}
- return "";
+ return NULL;
}
static gboolean radio_band_umts_from_string(const char *str,
@@ -311,6 +311,12 @@ static void radio_set_band(struct ofono_radio_settings *rs)
OFONO_RADIO_SETTINGS_INTERFACE,
"GsmBand", DBUS_TYPE_STRING,
&str_band);
+
+ if (rs->settings) {
+ g_key_file_set_integer(rs->settings, SETTINGS_GROUP,
+ "GsmBand", rs->band_gsm);
+ storage_sync(rs->imsi, SETTINGS_STORE, rs->settings);
+ }
}
if (rs->band_umts != rs->pending_band_umts) {
@@ -321,8 +327,13 @@ static void radio_set_band(struct ofono_radio_settings *rs)
OFONO_RADIO_SETTINGS_INTERFACE,
"UmtsBand", DBUS_TYPE_STRING,
&str_band);
+
+ if (rs->settings) {
+ g_key_file_set_integer(rs->settings, SETTINGS_GROUP,
+ "UmtsBand", rs->band_umts);
+ storage_sync(rs->imsi, SETTINGS_STORE, rs->settings);
+ }
}
-
}
static void radio_band_set_callback(const struct ofono_error *error,
@@ -368,6 +379,12 @@ static void radio_set_rat_mode(struct ofono_radio_settings *rs,
OFONO_RADIO_SETTINGS_INTERFACE,
"TechnologyPreference",
DBUS_TYPE_STRING, &str_mode);
+
+ if (rs->settings) {
+ g_key_file_set_integer(rs->settings, SETTINGS_GROUP,
+ "TechnologyPreference", rs->mode);
+ storage_sync(rs->imsi, SETTINGS_STORE, rs->settings);
+ }
}
static void radio_mode_set_callback(const struct ofono_error *error, void *data)
@@ -578,15 +595,7 @@ static DBusMessage *radio_set_property(DBusConnection *conn, DBusMessage *msg,
rs->pending_mode = mode;
rs->driver->set_rat_mode(rs, mode, radio_mode_set_callback, rs);
-
- if (rs->settings) {
- const char *mode_str;
- mode_str = radio_access_mode_to_string(mode);
- g_key_file_set_string(rs->settings, SETTINGS_GROUP,
- "TechnologyPreference", mode_str);
- storage_sync(rs->imsi, SETTINGS_STORE, rs->settings);
- }
-
+ /* will be saved in radiosettng on success response*/
return NULL;
} else if (g_strcmp0(property, "GsmBand") == 0) {
const char *value;
@@ -610,7 +619,7 @@ static DBusMessage *radio_set_property(DBusConnection *conn, DBusMessage *msg,
rs->driver->set_band(rs, band, rs->band_umts,
radio_band_set_callback, rs);
-
+ /* will be saved in radiosettng on success response*/
return NULL;
} else if (g_strcmp0(property, "UmtsBand") == 0) {
const char *value;
@@ -634,7 +643,7 @@ static DBusMessage *radio_set_property(DBusConnection *conn, DBusMessage *msg,
rs->driver->set_band(rs, rs->band_gsm, band,
radio_band_set_callback, rs);
-
+ /* will be saved in radiosettng on success response*/
return NULL;
} else if (g_strcmp0(property, "FastDormancy") == 0) {
dbus_bool_t value;
@@ -804,12 +813,22 @@ static void radio_mode_set_callback_at_reg(const struct ofono_error *error,
*/
ofono_radio_finish_register(rs);
}
+static void radio_band_set_callback_at_reg(const struct ofono_error *error,
+ void *data)
+{
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
+ DBG("Error setting radio access mode register time");
+ /*
+ * Continue with atom register even if request fail at modem
+ * ofono_radio_finish_register called by radio_mode_set_callback_at_reg
+ */
+}
static void radio_load_settings(struct ofono_radio_settings *rs,
const char *imsi)
{
GError *error;
- char *strmode;
+ gboolean issync = TRUE;
rs->settings = storage_open(imsi, SETTINGS_STORE);
@@ -820,34 +839,48 @@ static void radio_load_settings(struct ofono_radio_settings *rs,
if (rs->settings == NULL) {
DBG("radiosetting storage open failed");
rs->mode = OFONO_RADIO_ACCESS_MODE_ANY;
+ rs->band_gsm = OFONO_RADIO_BAND_GSM_ANY;
+ rs->band_umts = OFONO_RADIO_BAND_UMTS_ANY;
return;
}
rs->imsi = g_strdup(imsi);
error = NULL;
- strmode = g_key_file_get_string(rs->settings, SETTINGS_GROUP,
- "TechnologyPreference", &error);
-
- if (error) {
- g_error_free(error);
- goto setdefault;
+ rs->band_gsm = g_key_file_get_integer(rs->settings, SETTINGS_GROUP,
+ "GsmBand", &error);
+
+ if (error || radio_band_gsm_to_string(rs->band_gsm) == NULL) {
+ rs->band_gsm = OFONO_RADIO_BAND_GSM_ANY;
+ issync = FALSE;
+ g_key_file_set_integer(rs->settings, SETTINGS_GROUP,
+ "GsmBand", rs->band_gsm);
}
-
- if (radio_access_mode_from_string(strmode, &rs->mode) == FALSE) {
- DBG("Invalid rat mode in storage; Setting default");
- goto setdefault;
+
+ error = NULL;
+ rs->band_umts = g_key_file_get_integer(rs->settings, SETTINGS_GROUP,
+ "UmtsBand", &error);
+
+ if (error || radio_band_umts_to_string(rs->band_umts) == NULL) {
+ rs->band_umts = OFONO_RADIO_BAND_UMTS_ANY;
+ issync = FALSE;
+ g_key_file_set_integer(rs->settings, SETTINGS_GROUP,
+ "UmtsBand", rs->band_umts);
}
- g_free(strmode);
- return;
+ error = NULL;
+ rs->mode = g_key_file_get_integer(rs->settings, SETTINGS_GROUP,
+ "TechnologyPreference", &error);
-setdefault:
- rs->mode = OFONO_RADIO_ACCESS_MODE_ANY;
- g_key_file_set_string(rs->settings, SETTINGS_GROUP,
- "TechnologyPreference", "any");
- storage_sync(rs->imsi, SETTINGS_STORE, rs->settings);
- g_free(strmode);
+ if (error || radio_access_mode_to_string(rs->mode) == NULL) {
+ rs->mode = OFONO_RADIO_ACCESS_MODE_ANY;
+ issync = FALSE;
+ g_key_file_set_integer(rs->settings, SETTINGS_GROUP,
+ "TechnologyPreference", rs->mode);
+ }
+
+ if(issync == FALSE)
+ storage_sync(rs->imsi, SETTINGS_STORE, rs->settings);
}
void ofono_radio_settings_register(struct ofono_radio_settings *rs)
@@ -860,6 +893,12 @@ void ofono_radio_settings_register(struct ofono_radio_settings *rs)
radio_load_settings(rs, ofono_sim_get_imsi(sim));
+ if (rs->driver->set_band == NULL)
+ goto finish;
+
+ rs->driver->set_band(rs, rs->band_gsm, rs->band_umts,
+ radio_band_set_callback_at_reg, rs);
+
if (rs->driver->set_rat_mode == NULL)
goto finish;
--
1.9.1
6 years, 3 months