[PBAP]Fix Duplicate enteries of contact in carkit 57/123257/1
authorNagaraj D R <nagaraj.dr@samsung.com>
Wed, 5 Apr 2017 05:26:43 +0000 (10:56 +0530)
committerNagaraj D R <nagaraj.dr@samsung.com>
Wed, 5 Apr 2017 05:35:07 +0000 (11:05 +0530)
[Problem] Every contact is duplicating in carkit phonebook
when connected with phone
Virtual path of SIM folder that contact-service uses is different
because of which "_bt_is_sim_addressbook" is failing always
and DUT ends up sending both phonebook entry and SIM entry
even when request was made only for phonebook or SIM

Change-Id: Ica28ec25c77a818d3471dcad9483e7cc845334d6

pb-agent/bluetooth_pb_agent.c
pb-agent/bluetooth_pb_vcard.h

index 134b4d4..ca53343 100644 (file)
@@ -1176,6 +1176,13 @@ next:
 
        contacts_list_destroy(recordList, true);
 
+       if (is_first_condition) {
+               ERR("ADDRESSBOOK NOT FOUND");
+               contacts_filter_destroy(filter);
+               contacts_query_destroy(query);
+               return NULL;
+       }
+
        status = contacts_query_set_filter(query, filter);
        if (status != CONTACTS_ERROR_NONE)
                ERR("Could not Apply Filter");
@@ -1463,6 +1470,10 @@ static void __bluetooth_pb_get_vcards(PbAgentData *agent, PhoneBookType pb_type,
        }
        INFO("Limit is = %d and offset is =%d\n", limit, offset);
 
+       if (query == NULL) {
+               ERR("Query is NULL");
+               return;
+       }
        /* When limit is passed as ZERO to contacts_db_get_records_with_query
         * API then this API will provide all available contacts in its database
         * (unrestricted). Now consider a case when client requests for
@@ -1549,6 +1560,11 @@ static void __bluetooth_pb_get_contact_list(PbAgentData *agent,
                g_free(name);
        }
 
+       if (query == NULL) {
+               ERR("Query is NULL");
+               return;
+       }
+
        status = contacts_db_get_records_with_query(query, -1, -1,
                                                                &record_list);
 
index 6e1b644..97fb014 100644 (file)
@@ -26,7 +26,7 @@
 
 #include <glib.h>
 
-#define SIM_ADDRESSBOOK_PREFIX "http://tizen.samsung.com/addressbook/sim"
+#define SIM_ADDRESSBOOK_PREFIX "http://tizen.org/addressbook/sim"
 
 typedef enum {
        PBAP_ADDRESSBOOK_PHONE,