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

Commit 42affe35 authored by Hemant Gupta's avatar Hemant Gupta
Browse files

PBAP: Handle '-' in TEL field properly when custom TAG is used.

Precondition:
DUT has some contacts stored along with phonenumber(s) stored
with custom tag option.

Usecase:
1) Connect with carkit supporting PBAP
2) Send download phonebook from carkit

Expectation:
Carkit is able to show all phonebook contacts and numbers stored on DUT

Observation:
Carkit is unable to show some phonenumbers stored with custom tag option.

Issue:
For Contacts with custom Tel field, "-" is deleted from tag syntax.
Proper Format: X-TAG:<TEL_Number>
Received Format : XTAG:<TEL_Number>

Issue:
For Contacts with custom Tel field, "-" is deleted from tag syntax.
Proper Format: X-TAG:<TEL_Number>

Root Cause:
"-" is getting deleted from TEL number and "X-TAG" as well when
custom tag is used for contact.

Fix:
remove "-" only from TEL number without removing it from "X-TAG".

Test: Tested that carkit is able to show all contacts/numbers properly
stored even with custom fields.

Bug: 37712333
Change-Id: Id4cafa5de44e90a215c18053c872e9b40792eba3
parent c0fdf23a
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -970,10 +970,20 @@ public class BluetoothPbapVcardManager {
        String stripedVCard = "";
        for (int i = 0; i < attr.length; i++) {
            if (attr[i].startsWith("TEL")) {
                attr[i] = attr[i].replace("(", "");
                attr[i] = attr[i].replace(")", "");
                attr[i] = attr[i].replace("-", "");
                attr[i] = attr[i].replace(" ", "");
                String[] vTagAndTel = attr[i].split(":", 2);
                int telLenBefore = vTagAndTel[1].length();
                // Remove '-', '(', ')' or ' ' from TEL number
                vTagAndTel[1] = vTagAndTel[1].replace("-", "")
                                             .replace("(", "")
                                             .replace(")", "")
                                             .replace(" ", "");
                if (vTagAndTel[1].length() < telLenBefore) {
                    if (V) {
                        Log.v(TAG, "Fixing vCard TEL to " + vTagAndTel[1]);
                    }
                    attr[i] = new StringBuilder().append(vTagAndTel[0]).append(":")
                                                 .append(vTagAndTel[1]).toString();
                }
            }
        }