From 9935a310a4f36c9f835c5c3aa2f604ddc36cabb1 Mon Sep 17 00:00:00 2001 From: Xiaodong Xu Date: Tue, 21 Dec 2010 11:52:59 +0100 Subject: [PATCH] Bluetooth: Add vCard version support for call history. Under current implementation, PSE only deliver call history under format VCard2.1 to PCE, this is not correct according to PBAP specification, which says "The PSE shall support both vCard2.1 and vCard3.0 versions and deliver the Entries to the PCE under the format version that is requested by the PCE." This fix is to make implementation following such PBAP specificaiton. Change-Id: Id0146d0887bad3bd066109ecd3be674b3106bced --- .../android/bluetooth/pbap/BluetoothPbapCallLogComposer.java | 11 +++++------ src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/com/android/bluetooth/pbap/BluetoothPbapCallLogComposer.java b/src/com/android/bluetooth/pbap/BluetoothPbapCallLogComposer.java index f395d214..b10ec2a0 100644 --- a/src/com/android/bluetooth/pbap/BluetoothPbapCallLogComposer.java +++ b/src/com/android/bluetooth/pbap/BluetoothPbapCallLogComposer.java @@ -152,7 +152,7 @@ public class BluetoothPbapCallLogComposer { } } - public boolean createOneEntry() { + public boolean createOneEntry(boolean vcardVer21) { if (mCursor == null || mCursor.isAfterLast()) { mErrorReason = FAILURE_REASON_NOT_INITIALIZED; return false; @@ -160,7 +160,7 @@ public class BluetoothPbapCallLogComposer { final String vcard; try { - vcard = createOneCallLogEntryInternal(); + vcard = createOneCallLogEntryInternal(vcardVer21); } catch (OutOfMemoryError error) { Log.e(TAG, "OutOfMemoryError occured. Ignore the entry"); System.gc(); @@ -184,10 +184,9 @@ public class BluetoothPbapCallLogComposer { return true; } - private String createOneCallLogEntryInternal() { - // We should not allow vCard composer to re-format phone numbers, since - // some characters are (inappropriately) removed and devices do not work fine. - final int vcardType = VCardConfig.VCARD_TYPE_V21_GENERIC | + private String createOneCallLogEntryInternal(boolean vcardVer21) { + final int vcardType = (vcardVer21 ? VCardConfig.VCARD_TYPE_V21_GENERIC : + VCardConfig.VCARD_TYPE_V30_GENERIC) | VCardConfig.FLAG_REFRAIN_PHONE_NUMBER_FORMATTING; final VCardBuilder builder = new VCardBuilder(vcardType); String name = mCursor.getString(CALLER_NAME_COLUMN_INDEX); diff --git a/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java b/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java index 118403bd..ac750ace 100644 --- a/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java +++ b/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java @@ -473,7 +473,7 @@ public class BluetoothPbapVcardManager { BluetoothPbapObexServer.sIsAborted = false; break; } - if (!composer.createOneEntry()) { + if (!composer.createOneEntry(vcardType21)) { Log.e(TAG, "Failed to read a contact. Error reason: " + composer.getErrorReason()); return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR; -- 2.11.0