handsfree: Skeleton implementation of DDR

Distracted Driving Reduction or Enhanced Safety is implemented using HF
indicator 0x0001
This commit is contained in:
Denis Kenzior 2014-01-19 22:06:21 -06:00
parent 7e3a6628fa
commit ab5b6d1217
2 changed files with 46 additions and 2 deletions

View File

@ -234,8 +234,8 @@ static void chld_cb(gboolean ok, GAtResult *result, gpointer user_data)
info->ag_mpty_features = ag_mpty_feature;
if (info->ag_features & HFP_AG_FEATURE_HF_INDICATORS &&
info->hf_features & HFP_HF_FEATURE_HF_INDICATORS) {
if ((info->ag_features & HFP_AG_FEATURE_HF_INDICATORS) &&
(info->hf_features & HFP_HF_FEATURE_HF_INDICATORS)) {
slc_establish_data_ref(sed);
g_at_chat_send(info->chat, "AT+BIND=1", none_prefix,
bind_set_cb, sed, slc_establish_data_unref);

View File

@ -51,6 +51,8 @@ struct ofono_handsfree {
ofono_bool_t inband_ringing;
ofono_bool_t voice_recognition;
ofono_bool_t voice_recognition_pending;
ofono_bool_t ddr;
ofono_bool_t ddr_pending;
unsigned int ag_features;
unsigned int ag_chld_features;
unsigned char battchg;
@ -247,6 +249,10 @@ static DBusMessage *generate_get_properties_reply(struct ofono_handsfree *hf,
ofono_dbus_dict_append(&dict, "EchoCancelingNoiseReduction",
DBUS_TYPE_BOOLEAN, &hf->nrec);
if (hf->ag_features & HFP_AG_FEATURE_HF_INDICATORS)
ofono_dbus_dict_append(&dict, "DistractedDrivingReduction",
DBUS_TYPE_BOOLEAN, &hf->ddr);
voice_recognition = hf->voice_recognition;
ofono_dbus_dict_append(&dict, "VoiceRecognition", DBUS_TYPE_BOOLEAN,
&voice_recognition);
@ -359,6 +365,30 @@ static void voicerec_set_cb(const struct ofono_error *error, void *data)
&hf->voice_recognition);
}
static void ddr_set_cb(const struct ofono_error *error, void *data)
{
struct ofono_handsfree *hf = data;
DBusConnection *conn = ofono_dbus_get_connection();
const char *path = __ofono_atom_get_path(hf->atom);
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
__ofono_dbus_pending_reply(&hf->pending,
__ofono_error_failed(hf->pending));
return;
}
hf->ddr = hf->ddr_pending;
__ofono_dbus_pending_reply(&hf->pending,
dbus_message_new_method_return(hf->pending));
ofono_dbus_signal_property_changed(conn, path,
OFONO_HANDSFREE_INTERFACE,
"DistractedDrivingReduction",
DBUS_TYPE_BOOLEAN,
&hf->voice_recognition);
}
static void nrec_set_cb(const struct ofono_error *error, void *data)
{
struct ofono_handsfree *hf = data;
@ -437,6 +467,20 @@ static DBusMessage *handsfree_set_property(DBusConnection *conn,
hf->pending = dbus_message_ref(msg);
hf->driver->disable_nrec(hf, nrec_set_cb, hf);
} else if (g_str_equal(name, "DistractedDrivingReduction") == TRUE) {
if (!(hf->ag_features & HFP_AG_FEATURE_HF_INDICATORS))
return __ofono_error_not_supported(msg);
if (!hf->driver->hf_indicator)
return __ofono_error_not_implemented(msg);
if (hf->ddr == enabled)
return dbus_message_new_method_return(msg);
hf->pending = dbus_message_ref(msg);
hf->ddr_pending = enabled;
hf->driver->hf_indicator(hf, HFP_HF_INDICATOR_ENHANCED_SAFETY,
enabled, ddr_set_cb, hf);
} else
return __ofono_error_invalid_args(msg);