summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2014-01-19 22:06:21 -0600
committerDenis Kenzior <denkenz@gmail.com>2014-10-20 13:40:28 -0500
commitab5b6d12172b36ad3d99b0fd7fa1e3896b8a9915 (patch)
tree9d550a904a1821d752944009ac1cbbb095ca74ad /src
parent7e3a6628fa2bc27c08c77537bd4d4eb0384a867c (diff)
downloadofono-ab5b6d12172b36ad3d99b0fd7fa1e3896b8a9915.tar.bz2
handsfree: Skeleton implementation of DDR
Distracted Driving Reduction or Enhanced Safety is implemented using HF indicator 0x0001
Diffstat (limited to 'src')
-rw-r--r--src/handsfree.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/handsfree.c b/src/handsfree.c
index 86fbd6d1..b22fc65e 100644
--- a/src/handsfree.c
+++ b/src/handsfree.c
@@ -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);