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

Commit ab6f2c5a authored by Sumit Deshmukh's avatar Sumit Deshmukh Committed by Hemant Gupta
Browse files

PBAP: Send remaining contacts instead of error on Contact deletion

Precondition: vCardFilter should not be null.

Usecase:
1) Establish PBAP Connection.
2) Start Pull Phonebook Operation.
3) Delete some latest created contact while pull
   phonebook operation is in progress.

Issue:
OBEX_HTTP_INTERNAL_ERROR is sent during contact download.

Root Cause:
If contact is deleted or not found after pull phonebook
operation is started, StringIndexOutOfBoundException causes
sending OBEX_HTTP_INTERNAL_ERROR.

Fix:
Skip deleted contact entry and send remaining contact without
sending OBEX_HTTP_INTERNAL_ERROR.

Test: Issue not seen as per above usecase.

Bug: 79447289
Change-Id: I357cce93e5ddfff62ad928864272257b18602d55
parent 5a7bd55f
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -344,6 +344,9 @@ public class BluetoothPbapVcardManager {
                        Log.e(TAG, "Failed to read a contact. Error reason: "
                                + composer.getErrorReason());
                        return nameList;
                    } else if (vcard.isEmpty()) {
                        Log.i(TAG, "Contact may have been deleted during operation");
                        continue;
                    }
                    if (V) {
                        Log.v(TAG, "Checking selected bits in the vcard composer" + vcard);
@@ -739,6 +742,9 @@ public class BluetoothPbapVcardManager {
                    Log.e(TAG,
                            "Failed to read a contact. Error reason: " + composer.getErrorReason());
                    return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
                } else if (vcard.isEmpty()) {
                    Log.i(TAG, "Contact may have been deleted during operation");
                    continue;
                }
                if (V) {
                    Log.v(TAG, "vCard from composer: " + vcard);
@@ -835,6 +841,9 @@ public class BluetoothPbapVcardManager {
                    Log.e(TAG,
                            "Failed to read a contact. Error reason: " + composer.getErrorReason());
                    return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
                } else if (vcard.isEmpty()) {
                    Log.i(TAG, "Contact may have been deleted during operation");
                    continue;
                }
                if (V) {
                    Log.v(TAG, "Checking selected bits in the vcard composer" + vcard);
@@ -921,14 +930,16 @@ public class BluetoothPbapVcardManager {
                        continue;
                    }
                    if (needSendBody == NEED_SEND_BODY) {
                        if (vcard != null) {
                            vcard = vcardfilter.apply(vcard, vcardType21);
                        }
                        if (vcard == null) {
                            Log.e(TAG, "Failed to read a contact. Error reason: "
                                    + composer.getErrorReason());
                            return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
                        } else if (vcard.isEmpty()) {
                            Log.i(TAG, "Call Log may have been deleted during operation");
                            continue;
                        }
                        vcard = vcardfilter.apply(vcard, vcardType21);

                        if (V) {
                            Log.v(TAG, "Vcard Entry:");
                            Log.v(TAG, vcard);