diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-03-13 14:30:52 -0700 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-03-13 16:10:53 -0700 |
commit | ad3202c2ed31b8cb6fc8193f159c8f26a31e4663 (patch) | |
tree | 2b3dc1cc3cb3304069538bb93218987f76325aab /binding/telephony-binding.c | |
parent | 44f6225edbb09693fb1182fc46480f033f6f4b69 (diff) |
binding: telephony: add online event for hfp status
To allow clients to detect if a phone/handsfree profile is connected.
Note this isn't inclusive of an actual phone call being active.
Bug-AGL: SPEC-2257
Change-Id: Ie3d014bf86ab9c02c3f2a8a18aa324648b05f0a6
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding/telephony-binding.c')
-rw-r--r-- | binding/telephony-binding.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/binding/telephony-binding.c b/binding/telephony-binding.c index a013196..c7feac6 100644 --- a/binding/telephony-binding.c +++ b/binding/telephony-binding.c @@ -35,6 +35,7 @@ static afb_event_t call_state_changed_event; static afb_event_t dialing_call_event; static afb_event_t incoming_call_event; static afb_event_t terminated_call_event; +static afb_event_t online_event; static void dial(afb_req_t request) { @@ -102,6 +103,14 @@ static void subscribe(afb_req_t request) afb_req_subscribe(request, incoming_call_event); } else if (!strcasecmp(value, "terminatedCall")) { afb_req_subscribe(request, terminated_call_event); + } else if (!strcasecmp(value, "online")) { + json_object *jresp = json_object_new_object(); + + afb_req_subscribe(request, online_event); + + json_object_object_add(jresp, "connected", + json_object_new_boolean(ofono_manager_get_default_modem_online())); + afb_event_push(online_event, jresp); } else { afb_req_fail(request, "failed", "Invalid event"); return; @@ -240,11 +249,21 @@ static void ofono_modem_signal_callback( ofono_manager_set_default_modem((const char *) address); if (ofono_manager_get_default_modem_valid()) { + json_object *jresp = json_object_new_object(); + ofono_init_default_modem(); + + json_object_object_add(jresp, "connected", json_object_new_boolean(TRUE)); + afb_event_push(online_event, jresp); } } else if (!g_strcmp0(ofono_manager_get_default_modem_address(), address)) { + json_object *jresp = json_object_new_object(); + AFB_NOTICE("Removing modem: (%s)", address); ofono_manager_invalidate_default_modem(); + + json_object_object_add(jresp, "connected", json_object_new_boolean(FALSE)); + afb_event_push(online_event, jresp); } g_free(address); @@ -286,6 +305,7 @@ static int ofono_init(afb_api_t api) dialing_call_event = afb_daemon_make_event("dialingCall"); incoming_call_event = afb_daemon_make_event("incomingCall"); terminated_call_event = afb_daemon_make_event("terminatedCall"); + online_event = afb_daemon_make_event("online"); /* Start the main loop thread */ pthread_create(&tid, NULL, main_loop_thread, NULL); |