Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78a09e15 authored by Andre Eisenbach's avatar Andre Eisenbach Committed by Gerrit Code Review
Browse files

Merge "PBAPS: Fix duplicate entries fetched from database"

parents c90db0f8 d799e680
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -835,7 +835,7 @@ public class BluetoothPbapVcardManager {

    /**
     * Get size of the cursor without duplicated contact id. This assumes the
     * given cursor is sorted by CONATCT_ID.
     * given cursor is sorted by CONTACT_ID.
     */
    private static final int getDistinctContactIdSize(Cursor cursor) {
        final int contactIdColumn = cursor.getColumnIndex(Data.CONTACT_ID);
@@ -858,14 +858,13 @@ public class BluetoothPbapVcardManager {

    /**
     * Append "display_name,contact_id" string array from cursor to ArrayList.
     * This assumes the given cursor is sorted by CONATCT_ID.
     * This assumes the given cursor is sorted by CONTACT_ID.
     */
    private static void appendDistinctNameIdList(ArrayList<String> resultList,
            String defaultName, Cursor cursor) {
        final int contactIdColumn = cursor.getColumnIndex(Data.CONTACT_ID);
        final int idColumn = cursor.getColumnIndex(Data._ID);
        final int nameColumn = cursor.getColumnIndex(Data.DISPLAY_NAME);
        long previousContactId = -1;
        cursor.moveToPosition(-1);
        while (cursor.moveToNext()) {
            final long contactId = cursor.getLong(contactIdColumn != -1 ? contactIdColumn : idColumn);
@@ -874,9 +873,9 @@ public class BluetoothPbapVcardManager {
                displayName = defaultName;
            }

            if (previousContactId != contactId) {
                previousContactId = contactId;
                resultList.add(displayName + "," + contactId);
            String newString = displayName + "," + contactId;
            if (!resultList.contains(newString)) {
                resultList.add(newString);
            }
        }
        if (V) {