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
diff --git a/android/app/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java b/android/app/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java
index 17ceb9f..5aed5f1 100644
--- a/android/app/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java
+++ b/android/app/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java
@@ -970,10 +970,20 @@
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();
+ }
}
}