summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2019-01-29 18:20:52 -0800
committerMatt Ranostay <matt.ranostay@konsulko.com>2019-01-29 23:46:55 -0800
commitd2e0a671dff16409377ae8182e737bea8bcc724f (patch)
treefdb6efd08f374c2a9ea4b5d71a79902fc69e83e8
parent54bc2c77b9b2dffd9c4bc1a2b51c199252d5d575 (diff)
binding: bluetooth-pbap: cache contacts list on connection
Populating the contacts list can take several seconds for the OBEX transfer to complete. So to avoid phone UI delays service is started at startup, and populates a cached version of contacts for clients. Change-Id: I1687fc6bc075964b71be4515c5048bff1861b4ec Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r--binding/bluetooth-pbap-binding.c33
-rw-r--r--conf.d/wgt/config.xml.in2
2 files changed, 32 insertions, 3 deletions
diff --git a/binding/bluetooth-pbap-binding.c b/binding/bluetooth-pbap-binding.c
index 5a7c140..2765f61 100644
--- a/binding/bluetooth-pbap-binding.c
+++ b/binding/bluetooth-pbap-binding.c
@@ -39,6 +39,7 @@ static OrgBluezObexClient1 *client;
static OrgBluezObexSession1 *session;
static OrgBluezObexPhonebookAccess1 *phonebook;
static GHashTable *xfer_queue;
+static GMutex cached_mutex;
static GMutex xfer_queue_mutex;
static GHashTable *xfer_complete;
static GMutex xfer_complete_mutex;
@@ -47,6 +48,8 @@ static GMutex connected_mutex;
static gboolean connected = FALSE;
static afb_event_t status_event;
+json_object *cached_results = NULL;
+
#define PBAP_UUID "0000112f-0000-1000-8000-00805f9b34fb"
#define INTERNAL "int"
@@ -314,11 +317,20 @@ void contacts(afb_req_t request)
if (!parse_max_entries_parameter(request, &max_entries))
return;
- org_bluez_obex_phonebook_access1_call_select_sync(
+ g_mutex_lock(&cached_mutex);
+
+ if (max_entries == -1 && cached_results) {
+ jresp = cached_results;
+ json_object_get(jresp);
+ } else {
+ org_bluez_obex_phonebook_access1_call_select_sync(
phonebook, INTERNAL, CONTACTS, NULL, NULL);
- jresp = get_vcards(max_entries);
+ jresp = get_vcards(max_entries);
+ }
afb_req_success(request, jresp, "contacts");
+
+ g_mutex_unlock(&cached_mutex);
}
void entry(afb_req_t request)
@@ -602,6 +614,17 @@ static gboolean is_pbap_dev_and_init(struct json_object *dev)
AFB_NOTICE("PBAP device connected: %s", address);
+ g_mutex_lock(&cached_mutex);
+
+ if (cached_results)
+ json_object_put(cached_results);
+
+ /* probably should be made async */
+ org_bluez_obex_phonebook_access1_call_select_sync(
+ phonebook, INTERNAL, CONTACTS, NULL, NULL);
+ cached_results = get_vcards(-1);
+ g_mutex_unlock(&cached_mutex);
+
return TRUE;
}
break;
@@ -728,6 +751,12 @@ static void process_connection_event(afb_api_t api, struct json_object *object)
afb_event_push(status_event, jresp);
+ g_mutex_lock(&cached_mutex);
+ if (cached_results)
+ json_object_put(cached_results);
+ cached_results = NULL;
+ g_mutex_unlock(&cached_mutex);
+
AFB_NOTICE("PBAP device disconnected: %s", address);
}
diff --git a/conf.d/wgt/config.xml.in b/conf.d/wgt/config.xml.in
index 161a39f..21040c8 100644
--- a/conf.d/wgt/config.xml.in
+++ b/conf.d/wgt/config.xml.in
@@ -9,7 +9,7 @@
<feature name="urn:AGL:widget:required-permission">
<param name="urn:AGL:permission::public:hidden" value="required" />
- <param name="urn:AGL:permission::public:no-htdocs" value="required" />
+ <param name="urn:AGL:permission::system:run-by-default" value="required" />
<param name="http://tizen.org/privilege/internal/dbus" value="required" />
</feature>