diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-03-13 14:30:52 -0700 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-04-04 16:01:22 -0700 |
commit | c069dce1e2c6f9078cffc32a5df95ec364a2476c (patch) | |
tree | 6407ca4e693707ab63134ae5081dc07e54809490 /binding | |
parent | 020e5b1720c971380c3250580db5530dbe358627 (diff) |
binding: telephony: add online event for hfp statusguppy_7.0.4guppy_7.0.3guppy_7.0.2guppy_7.0.1guppy/7.0.4guppy/7.0.3guppy/7.0.2guppy/7.0.17.0.47.0.37.0.27.0.1guppy
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')
-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); |