Loading android/app/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java +14 −51 Original line number Diff line number Diff line Loading @@ -97,7 +97,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { private static final String[] LEGAL_PATH = { "/telecom", "/telecom/pb", "/telecom/fav", "/telecom/ich", "/telecom/och", "/telecom/mch", Loading @@ -107,7 +106,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { @SuppressWarnings("unused") private static final String[] LEGAL_PATH_WITH_SIM = { "/telecom", "/telecom/pb", "/telecom/fav", "/telecom/ich", "/telecom/och", "/telecom/mch", Loading Loading @@ -140,9 +138,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { // phone book private static final String PB = "pb"; // favorites private static final String FAV = "fav"; private static final String TELECOM_PATH = "/telecom"; private static final String ICH_PATH = "/telecom/ich"; Loading @@ -155,8 +150,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { private static final String PB_PATH = "/telecom/pb"; private static final String FAV_PATH = "/telecom/fav"; // type for list vcard objects private static final String TYPE_LISTING = "x-bt/vcard-listing"; Loading Loading @@ -219,8 +212,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { public static final int MISSED_CALL_HISTORY = 4; public static final int COMBINED_CALL_HISTORY = 5; public static final int FAVORITES = 6; } public BluetoothPbapObexServer(Handler callback, Context context, Loading Loading @@ -450,8 +441,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { if (mCurrentPath.equals(PB_PATH)) { appParamValue.needTag = ContentType.PHONEBOOK; } else if (mCurrentPath.equals(FAV_PATH)) { appParamValue.needTag = ContentType.FAVORITES; } else if (mCurrentPath.equals(ICH_PATH)) { appParamValue.needTag = ContentType.INCOMING_CALL_HISTORY; } else if (mCurrentPath.equals(OCH_PATH)) { Loading Loading @@ -489,11 +478,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { if (D) { Log.v(TAG, "download phonebook request"); } } else if (isNameMatchTarget(name, FAV)) { appParamValue.needTag = ContentType.FAVORITES; if (D) { Log.v(TAG, "download favorites request"); } } else if (isNameMatchTarget(name, ICH)) { appParamValue.needTag = ContentType.INCOMING_CALL_HISTORY; appParamValue.callHistoryVersionCounter = Loading Loading @@ -767,8 +751,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { result.append("<vCard-listing version=\"1.0\">"); // Phonebook listing request if ((appParamValue.needTag == ContentType.PHONEBOOK) || (appParamValue.needTag == ContentType.FAVORITES)) { if (appParamValue.needTag == ContentType.PHONEBOOK) { String type = ""; if (appParamValue.searchAttr.equals("0")) { type = "name"; Loading Loading @@ -965,7 +948,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { checkPbapFeatureSupport(mFolderVersionCounterbitMask); } boolean needSendPhonebookVersionCounters = false; if (isNameMatchTarget(name, PB) || isNameMatchTarget(name, FAV)) { if (isNameMatchTarget(name, PB)) { needSendPhonebookVersionCounters = checkPbapFeatureSupport(mFolderVersionCounterbitMask); } Loading Loading @@ -1209,12 +1192,11 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { if (appParamValue.needTag == 0) { Log.w(TAG, "wrong path!"); return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE; } else if ((appParamValue.needTag == ContentType.PHONEBOOK) || (appParamValue.needTag == ContentType.FAVORITES)) { } else if (appParamValue.needTag == ContentType.PHONEBOOK) { if (intIndex < 0 || intIndex >= size) { Log.w(TAG, "The requested vcard is not acceptable! name= " + name); return ResponseCodes.OBEX_HTTP_NOT_FOUND; } else if ((intIndex == 0) && (appParamValue.needTag == ContentType.PHONEBOOK)) { } else if (intIndex == 0) { // For PB_PATH, 0.vcf is the phone number of this phone. String ownerVcard = mVcardManager.getOwnerPhoneNumberVcard(vcard21, appParamValue.ignorefilter ? null : appParamValue.propertySelector); Loading Loading @@ -1270,49 +1252,30 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { int requestSize = pbSize >= appParamValue.maxListCount ? appParamValue.maxListCount : pbSize; /** * startIndex (resp., lastIndex) corresponds to the index of the first (resp., last) * vcard entry in the phonebook object. * PBAP v1.2.3: only pb starts indexing at 0.vcf (owner card), the other phonebook * objects (e.g., fav) start at 1.vcf. Additionally, the owner card is included in * pb's pbSize. This means pbSize corresponds to the index of the last vcf in the fav * phonebook object, but does not for the pb phonebook object. */ int startIndex = 1; int lastIndex = pbSize; if (appParamValue.needTag == BluetoothPbapObexServer.ContentType.PHONEBOOK) { startIndex = 0; lastIndex = pbSize - 1; } // [startPoint, endPoint] denote the range of vcf indices to send, inclusive. int startPoint = startIndex + appParamValue.listStartOffset; int endPoint = startPoint + requestSize - 1; if (appParamValue.listStartOffset < 0 || startPoint > lastIndex) { int startPoint = appParamValue.listStartOffset; if (startPoint < 0 || startPoint >= pbSize) { Log.w(TAG, "listStartOffset is not correct! " + startPoint); return ResponseCodes.OBEX_HTTP_OK; } if (endPoint > lastIndex) { endPoint = lastIndex; } // Limit the number of call log to CALLLOG_NUM_LIMIT if ((appParamValue.needTag != BluetoothPbapObexServer.ContentType.PHONEBOOK) && (appParamValue.needTag != BluetoothPbapObexServer.ContentType.FAVORITES)) { if (appParamValue.needTag != BluetoothPbapObexServer.ContentType.PHONEBOOK) { if (requestSize > CALLLOG_NUM_LIMIT) { requestSize = CALLLOG_NUM_LIMIT; } } int endPoint = startPoint + requestSize - 1; if (endPoint > pbSize - 1) { endPoint = pbSize - 1; } if (D) { Log.d(TAG, "pullPhonebook(): requestSize=" + requestSize + " startPoint=" + startPoint + " endPoint=" + endPoint); } boolean vcard21 = appParamValue.vcard21; boolean favorites = (appParamValue.needTag == BluetoothPbapObexServer.ContentType.FAVORITES); if ((appParamValue.needTag == BluetoothPbapObexServer.ContentType.PHONEBOOK) || favorites) { if (appParamValue.needTag == BluetoothPbapObexServer.ContentType.PHONEBOOK) { if (startPoint == 0) { String ownerVcard = mVcardManager.getOwnerPhoneNumberVcard(vcard21, appParamValue.ignorefilter ? null : appParamValue.propertySelector); Loading @@ -1322,13 +1285,13 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { return mVcardManager.composeAndSendPhonebookVcards(op, 1, endPoint, vcard21, ownerVcard, needSendBody, pbSize, appParamValue.ignorefilter, appParamValue.propertySelector, appParamValue.vCardSelector, appParamValue.vCardSelectorOperator, mVcardSelector, favorites); appParamValue.vCardSelectorOperator, mVcardSelector); } } else { return mVcardManager.composeAndSendPhonebookVcards(op, startPoint, endPoint, vcard21, null, needSendBody, pbSize, appParamValue.ignorefilter, appParamValue.propertySelector, appParamValue.vCardSelector, appParamValue.vCardSelectorOperator, mVcardSelector, favorites); appParamValue.vCardSelectorOperator, mVcardSelector); } } else { return mVcardManager.composeAndSendSelectedCallLogVcards(appParamValue.needTag, op, Loading android/app/src/com/android/bluetooth/pbap/BluetoothPbapService.java +1 −2 Original line number Diff line number Diff line Loading @@ -140,8 +140,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect private ObexServerSockets mServerSockets = null; private static final int SDP_PBAP_SERVER_VERSION = 0x0102; // PBAP v1.2.3, Sec. 7.1.2: local phonebook and favorites private static final int SDP_PBAP_SUPPORTED_REPOSITORIES = 0x0009; private static final int SDP_PBAP_SUPPORTED_REPOSITORIES = 0x0001; private static final int SDP_PBAP_SUPPORTED_FEATURES = 0x021F; /* PBAP will use Bluetooth notification ID from 1000000 (included) to 2000000 (excluded). Loading android/app/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java +8 −29 Original line number Diff line number Diff line Loading @@ -153,8 +153,7 @@ public class BluetoothPbapVcardManager { int size; switch (type) { case BluetoothPbapObexServer.ContentType.PHONEBOOK: case BluetoothPbapObexServer.ContentType.FAVORITES: size = getContactsSize(type); size = getContactsSize(); break; default: size = getCallHistorySize(type); Loading @@ -166,30 +165,16 @@ public class BluetoothPbapVcardManager { return size; } /** * Returns the number of contacts (i.e., vcf) in a phonebook object. * @param type specifies which phonebook object, e.g., pb, fav * @return */ public final int getContactsSize(final int type) { public final int getContactsSize() { final Uri myUri = DevicePolicyUtils.getEnterprisePhoneUri(mContext); Cursor contactCursor = null; String selectionClause = null; if (type == BluetoothPbapObexServer.ContentType.FAVORITES) { selectionClause = Phone.STARRED + " = 1"; } try { contactCursor = mResolver.query(myUri, new String[]{Phone.CONTACT_ID}, selectionClause, null, Phone.CONTACT_ID); contactCursor = mResolver.query(myUri, new String[]{Phone.CONTACT_ID}, null, null, Phone.CONTACT_ID); if (contactCursor == null) { return 0; } int contactsSize = getDistinctContactIdSize(contactCursor); if (type == BluetoothPbapObexServer.ContentType.PHONEBOOK) { contactsSize += 1; // pb has the 0.vcf owner's card } return contactsSize; return getDistinctContactIdSize(contactCursor) + 1; // always has the 0.vcf } catch (CursorWindowAllocationException e) { Log.e(TAG, "CursorWindowAllocationException while getting Contacts size"); } finally { Loading Loading @@ -566,7 +551,7 @@ public class BluetoothPbapVcardManager { final int composeAndSendPhonebookVcards(Operation op, final int startPoint, final int endPoint, final boolean vcardType21, String ownerVCard, int needSendBody, int pbSize, boolean ignorefilter, byte[] filter, byte[] vcardselector, String vcardselectorop, boolean vcardselect, boolean favorites) { boolean vcardselect) { if (startPoint < 1 || startPoint > endPoint) { Log.e(TAG, "internal error: startPoint or endPoint is not correct."); return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR; Loading @@ -577,15 +562,9 @@ public class BluetoothPbapVcardManager { Cursor contactIdCursor = new MatrixCursor(new String[]{ Phone.CONTACT_ID }); String selectionClause = null; if (favorites) { selectionClause = Phone.STARRED + " = 1"; } try { contactCursor = mResolver.query(myUri, PHONES_CONTACTS_PROJECTION, selectionClause, null, Phone.CONTACT_ID); contactCursor = mResolver.query(myUri, PHONES_CONTACTS_PROJECTION, null, null, Phone.CONTACT_ID); if (contactCursor != null) { contactIdCursor = ContactCursorFilter.filterByRange(contactCursor, startPoint, endPoint); Loading Loading
android/app/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java +14 −51 Original line number Diff line number Diff line Loading @@ -97,7 +97,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { private static final String[] LEGAL_PATH = { "/telecom", "/telecom/pb", "/telecom/fav", "/telecom/ich", "/telecom/och", "/telecom/mch", Loading @@ -107,7 +106,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { @SuppressWarnings("unused") private static final String[] LEGAL_PATH_WITH_SIM = { "/telecom", "/telecom/pb", "/telecom/fav", "/telecom/ich", "/telecom/och", "/telecom/mch", Loading Loading @@ -140,9 +138,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { // phone book private static final String PB = "pb"; // favorites private static final String FAV = "fav"; private static final String TELECOM_PATH = "/telecom"; private static final String ICH_PATH = "/telecom/ich"; Loading @@ -155,8 +150,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { private static final String PB_PATH = "/telecom/pb"; private static final String FAV_PATH = "/telecom/fav"; // type for list vcard objects private static final String TYPE_LISTING = "x-bt/vcard-listing"; Loading Loading @@ -219,8 +212,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { public static final int MISSED_CALL_HISTORY = 4; public static final int COMBINED_CALL_HISTORY = 5; public static final int FAVORITES = 6; } public BluetoothPbapObexServer(Handler callback, Context context, Loading Loading @@ -450,8 +441,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { if (mCurrentPath.equals(PB_PATH)) { appParamValue.needTag = ContentType.PHONEBOOK; } else if (mCurrentPath.equals(FAV_PATH)) { appParamValue.needTag = ContentType.FAVORITES; } else if (mCurrentPath.equals(ICH_PATH)) { appParamValue.needTag = ContentType.INCOMING_CALL_HISTORY; } else if (mCurrentPath.equals(OCH_PATH)) { Loading Loading @@ -489,11 +478,6 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { if (D) { Log.v(TAG, "download phonebook request"); } } else if (isNameMatchTarget(name, FAV)) { appParamValue.needTag = ContentType.FAVORITES; if (D) { Log.v(TAG, "download favorites request"); } } else if (isNameMatchTarget(name, ICH)) { appParamValue.needTag = ContentType.INCOMING_CALL_HISTORY; appParamValue.callHistoryVersionCounter = Loading Loading @@ -767,8 +751,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { result.append("<vCard-listing version=\"1.0\">"); // Phonebook listing request if ((appParamValue.needTag == ContentType.PHONEBOOK) || (appParamValue.needTag == ContentType.FAVORITES)) { if (appParamValue.needTag == ContentType.PHONEBOOK) { String type = ""; if (appParamValue.searchAttr.equals("0")) { type = "name"; Loading Loading @@ -965,7 +948,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { checkPbapFeatureSupport(mFolderVersionCounterbitMask); } boolean needSendPhonebookVersionCounters = false; if (isNameMatchTarget(name, PB) || isNameMatchTarget(name, FAV)) { if (isNameMatchTarget(name, PB)) { needSendPhonebookVersionCounters = checkPbapFeatureSupport(mFolderVersionCounterbitMask); } Loading Loading @@ -1209,12 +1192,11 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { if (appParamValue.needTag == 0) { Log.w(TAG, "wrong path!"); return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE; } else if ((appParamValue.needTag == ContentType.PHONEBOOK) || (appParamValue.needTag == ContentType.FAVORITES)) { } else if (appParamValue.needTag == ContentType.PHONEBOOK) { if (intIndex < 0 || intIndex >= size) { Log.w(TAG, "The requested vcard is not acceptable! name= " + name); return ResponseCodes.OBEX_HTTP_NOT_FOUND; } else if ((intIndex == 0) && (appParamValue.needTag == ContentType.PHONEBOOK)) { } else if (intIndex == 0) { // For PB_PATH, 0.vcf is the phone number of this phone. String ownerVcard = mVcardManager.getOwnerPhoneNumberVcard(vcard21, appParamValue.ignorefilter ? null : appParamValue.propertySelector); Loading Loading @@ -1270,49 +1252,30 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { int requestSize = pbSize >= appParamValue.maxListCount ? appParamValue.maxListCount : pbSize; /** * startIndex (resp., lastIndex) corresponds to the index of the first (resp., last) * vcard entry in the phonebook object. * PBAP v1.2.3: only pb starts indexing at 0.vcf (owner card), the other phonebook * objects (e.g., fav) start at 1.vcf. Additionally, the owner card is included in * pb's pbSize. This means pbSize corresponds to the index of the last vcf in the fav * phonebook object, but does not for the pb phonebook object. */ int startIndex = 1; int lastIndex = pbSize; if (appParamValue.needTag == BluetoothPbapObexServer.ContentType.PHONEBOOK) { startIndex = 0; lastIndex = pbSize - 1; } // [startPoint, endPoint] denote the range of vcf indices to send, inclusive. int startPoint = startIndex + appParamValue.listStartOffset; int endPoint = startPoint + requestSize - 1; if (appParamValue.listStartOffset < 0 || startPoint > lastIndex) { int startPoint = appParamValue.listStartOffset; if (startPoint < 0 || startPoint >= pbSize) { Log.w(TAG, "listStartOffset is not correct! " + startPoint); return ResponseCodes.OBEX_HTTP_OK; } if (endPoint > lastIndex) { endPoint = lastIndex; } // Limit the number of call log to CALLLOG_NUM_LIMIT if ((appParamValue.needTag != BluetoothPbapObexServer.ContentType.PHONEBOOK) && (appParamValue.needTag != BluetoothPbapObexServer.ContentType.FAVORITES)) { if (appParamValue.needTag != BluetoothPbapObexServer.ContentType.PHONEBOOK) { if (requestSize > CALLLOG_NUM_LIMIT) { requestSize = CALLLOG_NUM_LIMIT; } } int endPoint = startPoint + requestSize - 1; if (endPoint > pbSize - 1) { endPoint = pbSize - 1; } if (D) { Log.d(TAG, "pullPhonebook(): requestSize=" + requestSize + " startPoint=" + startPoint + " endPoint=" + endPoint); } boolean vcard21 = appParamValue.vcard21; boolean favorites = (appParamValue.needTag == BluetoothPbapObexServer.ContentType.FAVORITES); if ((appParamValue.needTag == BluetoothPbapObexServer.ContentType.PHONEBOOK) || favorites) { if (appParamValue.needTag == BluetoothPbapObexServer.ContentType.PHONEBOOK) { if (startPoint == 0) { String ownerVcard = mVcardManager.getOwnerPhoneNumberVcard(vcard21, appParamValue.ignorefilter ? null : appParamValue.propertySelector); Loading @@ -1322,13 +1285,13 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { return mVcardManager.composeAndSendPhonebookVcards(op, 1, endPoint, vcard21, ownerVcard, needSendBody, pbSize, appParamValue.ignorefilter, appParamValue.propertySelector, appParamValue.vCardSelector, appParamValue.vCardSelectorOperator, mVcardSelector, favorites); appParamValue.vCardSelectorOperator, mVcardSelector); } } else { return mVcardManager.composeAndSendPhonebookVcards(op, startPoint, endPoint, vcard21, null, needSendBody, pbSize, appParamValue.ignorefilter, appParamValue.propertySelector, appParamValue.vCardSelector, appParamValue.vCardSelectorOperator, mVcardSelector, favorites); appParamValue.vCardSelectorOperator, mVcardSelector); } } else { return mVcardManager.composeAndSendSelectedCallLogVcards(appParamValue.needTag, op, Loading
android/app/src/com/android/bluetooth/pbap/BluetoothPbapService.java +1 −2 Original line number Diff line number Diff line Loading @@ -140,8 +140,7 @@ public class BluetoothPbapService extends ProfileService implements IObexConnect private ObexServerSockets mServerSockets = null; private static final int SDP_PBAP_SERVER_VERSION = 0x0102; // PBAP v1.2.3, Sec. 7.1.2: local phonebook and favorites private static final int SDP_PBAP_SUPPORTED_REPOSITORIES = 0x0009; private static final int SDP_PBAP_SUPPORTED_REPOSITORIES = 0x0001; private static final int SDP_PBAP_SUPPORTED_FEATURES = 0x021F; /* PBAP will use Bluetooth notification ID from 1000000 (included) to 2000000 (excluded). Loading
android/app/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java +8 −29 Original line number Diff line number Diff line Loading @@ -153,8 +153,7 @@ public class BluetoothPbapVcardManager { int size; switch (type) { case BluetoothPbapObexServer.ContentType.PHONEBOOK: case BluetoothPbapObexServer.ContentType.FAVORITES: size = getContactsSize(type); size = getContactsSize(); break; default: size = getCallHistorySize(type); Loading @@ -166,30 +165,16 @@ public class BluetoothPbapVcardManager { return size; } /** * Returns the number of contacts (i.e., vcf) in a phonebook object. * @param type specifies which phonebook object, e.g., pb, fav * @return */ public final int getContactsSize(final int type) { public final int getContactsSize() { final Uri myUri = DevicePolicyUtils.getEnterprisePhoneUri(mContext); Cursor contactCursor = null; String selectionClause = null; if (type == BluetoothPbapObexServer.ContentType.FAVORITES) { selectionClause = Phone.STARRED + " = 1"; } try { contactCursor = mResolver.query(myUri, new String[]{Phone.CONTACT_ID}, selectionClause, null, Phone.CONTACT_ID); contactCursor = mResolver.query(myUri, new String[]{Phone.CONTACT_ID}, null, null, Phone.CONTACT_ID); if (contactCursor == null) { return 0; } int contactsSize = getDistinctContactIdSize(contactCursor); if (type == BluetoothPbapObexServer.ContentType.PHONEBOOK) { contactsSize += 1; // pb has the 0.vcf owner's card } return contactsSize; return getDistinctContactIdSize(contactCursor) + 1; // always has the 0.vcf } catch (CursorWindowAllocationException e) { Log.e(TAG, "CursorWindowAllocationException while getting Contacts size"); } finally { Loading Loading @@ -566,7 +551,7 @@ public class BluetoothPbapVcardManager { final int composeAndSendPhonebookVcards(Operation op, final int startPoint, final int endPoint, final boolean vcardType21, String ownerVCard, int needSendBody, int pbSize, boolean ignorefilter, byte[] filter, byte[] vcardselector, String vcardselectorop, boolean vcardselect, boolean favorites) { boolean vcardselect) { if (startPoint < 1 || startPoint > endPoint) { Log.e(TAG, "internal error: startPoint or endPoint is not correct."); return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR; Loading @@ -577,15 +562,9 @@ public class BluetoothPbapVcardManager { Cursor contactIdCursor = new MatrixCursor(new String[]{ Phone.CONTACT_ID }); String selectionClause = null; if (favorites) { selectionClause = Phone.STARRED + " = 1"; } try { contactCursor = mResolver.query(myUri, PHONES_CONTACTS_PROJECTION, selectionClause, null, Phone.CONTACT_ID); contactCursor = mResolver.query(myUri, PHONES_CONTACTS_PROJECTION, null, null, Phone.CONTACT_ID); if (contactCursor != null) { contactIdCursor = ContactCursorFilter.filterByRange(contactCursor, startPoint, endPoint); Loading