Loading android/app/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java +23 −7 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import java.util.Arrays; import javax.obex.ServerRequestHandler; import javax.obex.ResponseCodes; import javax.obex.ApplicationParameter; import javax.obex.ServerOperation; import javax.obex.Operation; import javax.obex.HeaderSet; Loading Loading @@ -151,6 +152,8 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { public static int ORDER_BY_ALPHABETICAL = 1; public static boolean sIsAborted = false; public static class ContentType { public static final int PHONEBOOK = 1; Loading Loading @@ -236,6 +239,13 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } } @Override public int onAbort(HeaderSet request, HeaderSet reply) { if (D) Log.d(TAG, "onAbort(): enter."); sIsAborted = true; return ResponseCodes.OBEX_HTTP_OK; } @Override public int onPut(final Operation op) { if (D) Log.d(TAG, "onPut(): not support PUT request."); Loading Loading @@ -297,7 +307,8 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } @Override public int onGet(final Operation op) { public int onGet(Operation op) { sisAborted = false; HeaderSet request = null; HeaderSet reply = new HeaderSet(); String type = ""; Loading Loading @@ -525,7 +536,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } /** Form and Send an XML format String to client for Phone book listing */ private final int sendVcardListingXml(final int type, final Operation op, private final int sendVcardListingXml(final int type, Operation op, final int maxListCount, final int listStartOffset, final String searchValue, String searchAttr) { StringBuilder result = new StringBuilder(); Loading Loading @@ -659,7 +670,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } /** Function to send vcard data to client */ private final int pushBytes(final Operation op, final String vcardString) { private final int pushBytes(Operation op, final String vcardString) { if (vcardString == null) { Log.w(TAG, "vcardString is null!"); return ResponseCodes.OBEX_HTTP_OK; Loading @@ -682,6 +693,11 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { int outputBufferSize = op.getMaxPacketSize(); if (V) Log.v(TAG, "outputBufferSize = " + outputBufferSize); while (position != vcardStringLen) { if (sIsAborted) { ((ServerOperation)op).isAborted = true; sIsAborted = false; break; } if (V) timestamp = System.currentTimeMillis(); int readLength = outputBufferSize; if (vcardStringLen - position < outputBufferSize) { Loading Loading @@ -713,7 +729,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } private final int handleAppParaForResponse(AppParamValue appParamValue, int size, HeaderSet reply, final Operation op) { HeaderSet reply, Operation op) { byte[] misnum = new byte[1]; ApplicationParameter ap = new ApplicationParameter(); Loading Loading @@ -779,7 +795,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } private final int pullVcardListing(byte[] appParam, AppParamValue appParamValue, HeaderSet reply, final Operation op) { HeaderSet reply, Operation op) { String searchAttr = appParamValue.searchAttr.trim(); if (searchAttr == null || searchAttr.length() == 0) { Loading Loading @@ -840,7 +856,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } private final int pullVcardEntry(byte[] appParam, AppParamValue appParamValue, final Operation op, final String name, final String current_path) { Operation op, final String name, final String current_path) { if (name == null || name.length() < VCARD_NAME_SUFFIX_LENGTH) { if (D) Log.d(TAG, "Name is Null, or the length of name < 5 !"); return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE; Loading Loading @@ -894,7 +910,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } private final int pullPhonebook(byte[] appParam, AppParamValue appParamValue, HeaderSet reply, final Operation op, final String name) { Operation op, final String name) { // code start for passing PTS3.2 TC_PSE_PBD_BI_01_C if (name != null) { int dotIndex = name.indexOf("."); Loading android/app/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java +17 −5 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import javax.obex.ServerOperation; import javax.obex.Operation; import javax.obex.ResponseCodes; Loading Loading @@ -261,7 +262,7 @@ public class BluetoothPbapVcardManager { return numberList; } public final int composeAndSendCallLogVcards(final int type, final Operation op, public final int composeAndSendCallLogVcards(final int type, Operation op, final int startPoint, final int endPoint, final boolean vcardType21) { if (startPoint < 1 || startPoint > endPoint) { Log.e(TAG, "internal error: startPoint or endPoint is not correct."); Loading Loading @@ -322,7 +323,7 @@ public class BluetoothPbapVcardManager { return composeAndSendVCards(op, selection, vcardType21, null, false); } public final int composeAndSendPhonebookVcards(final Operation op, final int startPoint, public final int composeAndSendPhonebookVcards(Operation op, final int startPoint, final int endPoint, final boolean vcardType21, String ownerVCard) { if (startPoint < 1 || startPoint > endPoint) { Log.e(TAG, "internal error: startPoint or endPoint is not correct."); Loading Loading @@ -367,7 +368,7 @@ public class BluetoothPbapVcardManager { return composeAndSendVCards(op, selection, vcardType21, ownerVCard, true); } public final int composeAndSendPhonebookOneVcard(final Operation op, final int offset, public final int composeAndSendPhonebookOneVcard(Operation op, final int offset, final boolean vcardType21, String ownerVCard, int orderByWhat) { if (offset < 1) { Log.e(TAG, "Internal error: offset is not correct."); Loading Loading @@ -416,7 +417,7 @@ public class BluetoothPbapVcardManager { return composeAndSendVCards(op, selection, vcardType21, ownerVCard, true); } public final int composeAndSendVCards(final Operation op, final String selection, public final int composeAndSendVCards(Operation op, final String selection, final boolean vcardType21, String ownerVCard, boolean isContacts) { long timestamp = 0; if (V) timestamp = System.currentTimeMillis(); Loading @@ -439,6 +440,11 @@ public class BluetoothPbapVcardManager { } while (!composer.isAfterLast()) { if (BluetoothPbapObexServer.sIsAborted) { ((ServerOperation)op).isAborted = true; BluetoothPbapObexServer.sIsAborted = false; break; } if (!composer.createOneEntry()) { Log.e(TAG, "Failed to read a contact. Error reason: " + composer.getErrorReason()); Loading @@ -460,6 +466,11 @@ public class BluetoothPbapVcardManager { } while (!composer.isAfterLast()) { if (BluetoothPbapObexServer.sIsAborted) { ((ServerOperation)op).isAborted = true; BluetoothPbapObexServer.sIsAborted = false; break; } if (!composer.createOneEntry()) { Log.e(TAG, "Failed to read a contact. Error reason: " + composer.getErrorReason()); Loading Loading @@ -531,7 +542,8 @@ public class BluetoothPbapVcardManager { int position = 0; // Need while loop to handle the big vcard case while (position < (vcardStringLen - maxPacketSize)) { while (!BluetoothPbapObexServer.sIsAborted && position < (vcardStringLen - maxPacketSize)) { if (V) timestamp = System.currentTimeMillis(); String subStr = mVcardResults.toString().substring(position, Loading Loading
android/app/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java +23 −7 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import java.util.Arrays; import javax.obex.ServerRequestHandler; import javax.obex.ResponseCodes; import javax.obex.ApplicationParameter; import javax.obex.ServerOperation; import javax.obex.Operation; import javax.obex.HeaderSet; Loading Loading @@ -151,6 +152,8 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { public static int ORDER_BY_ALPHABETICAL = 1; public static boolean sIsAborted = false; public static class ContentType { public static final int PHONEBOOK = 1; Loading Loading @@ -236,6 +239,13 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } } @Override public int onAbort(HeaderSet request, HeaderSet reply) { if (D) Log.d(TAG, "onAbort(): enter."); sIsAborted = true; return ResponseCodes.OBEX_HTTP_OK; } @Override public int onPut(final Operation op) { if (D) Log.d(TAG, "onPut(): not support PUT request."); Loading Loading @@ -297,7 +307,8 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } @Override public int onGet(final Operation op) { public int onGet(Operation op) { sisAborted = false; HeaderSet request = null; HeaderSet reply = new HeaderSet(); String type = ""; Loading Loading @@ -525,7 +536,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } /** Form and Send an XML format String to client for Phone book listing */ private final int sendVcardListingXml(final int type, final Operation op, private final int sendVcardListingXml(final int type, Operation op, final int maxListCount, final int listStartOffset, final String searchValue, String searchAttr) { StringBuilder result = new StringBuilder(); Loading Loading @@ -659,7 +670,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } /** Function to send vcard data to client */ private final int pushBytes(final Operation op, final String vcardString) { private final int pushBytes(Operation op, final String vcardString) { if (vcardString == null) { Log.w(TAG, "vcardString is null!"); return ResponseCodes.OBEX_HTTP_OK; Loading @@ -682,6 +693,11 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { int outputBufferSize = op.getMaxPacketSize(); if (V) Log.v(TAG, "outputBufferSize = " + outputBufferSize); while (position != vcardStringLen) { if (sIsAborted) { ((ServerOperation)op).isAborted = true; sIsAborted = false; break; } if (V) timestamp = System.currentTimeMillis(); int readLength = outputBufferSize; if (vcardStringLen - position < outputBufferSize) { Loading Loading @@ -713,7 +729,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } private final int handleAppParaForResponse(AppParamValue appParamValue, int size, HeaderSet reply, final Operation op) { HeaderSet reply, Operation op) { byte[] misnum = new byte[1]; ApplicationParameter ap = new ApplicationParameter(); Loading Loading @@ -779,7 +795,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } private final int pullVcardListing(byte[] appParam, AppParamValue appParamValue, HeaderSet reply, final Operation op) { HeaderSet reply, Operation op) { String searchAttr = appParamValue.searchAttr.trim(); if (searchAttr == null || searchAttr.length() == 0) { Loading Loading @@ -840,7 +856,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } private final int pullVcardEntry(byte[] appParam, AppParamValue appParamValue, final Operation op, final String name, final String current_path) { Operation op, final String name, final String current_path) { if (name == null || name.length() < VCARD_NAME_SUFFIX_LENGTH) { if (D) Log.d(TAG, "Name is Null, or the length of name < 5 !"); return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE; Loading Loading @@ -894,7 +910,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler { } private final int pullPhonebook(byte[] appParam, AppParamValue appParamValue, HeaderSet reply, final Operation op, final String name) { Operation op, final String name) { // code start for passing PTS3.2 TC_PSE_PBD_BI_01_C if (name != null) { int dotIndex = name.indexOf("."); Loading
android/app/src/com/android/bluetooth/pbap/BluetoothPbapVcardManager.java +17 −5 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import javax.obex.ServerOperation; import javax.obex.Operation; import javax.obex.ResponseCodes; Loading Loading @@ -261,7 +262,7 @@ public class BluetoothPbapVcardManager { return numberList; } public final int composeAndSendCallLogVcards(final int type, final Operation op, public final int composeAndSendCallLogVcards(final int type, Operation op, final int startPoint, final int endPoint, final boolean vcardType21) { if (startPoint < 1 || startPoint > endPoint) { Log.e(TAG, "internal error: startPoint or endPoint is not correct."); Loading Loading @@ -322,7 +323,7 @@ public class BluetoothPbapVcardManager { return composeAndSendVCards(op, selection, vcardType21, null, false); } public final int composeAndSendPhonebookVcards(final Operation op, final int startPoint, public final int composeAndSendPhonebookVcards(Operation op, final int startPoint, final int endPoint, final boolean vcardType21, String ownerVCard) { if (startPoint < 1 || startPoint > endPoint) { Log.e(TAG, "internal error: startPoint or endPoint is not correct."); Loading Loading @@ -367,7 +368,7 @@ public class BluetoothPbapVcardManager { return composeAndSendVCards(op, selection, vcardType21, ownerVCard, true); } public final int composeAndSendPhonebookOneVcard(final Operation op, final int offset, public final int composeAndSendPhonebookOneVcard(Operation op, final int offset, final boolean vcardType21, String ownerVCard, int orderByWhat) { if (offset < 1) { Log.e(TAG, "Internal error: offset is not correct."); Loading Loading @@ -416,7 +417,7 @@ public class BluetoothPbapVcardManager { return composeAndSendVCards(op, selection, vcardType21, ownerVCard, true); } public final int composeAndSendVCards(final Operation op, final String selection, public final int composeAndSendVCards(Operation op, final String selection, final boolean vcardType21, String ownerVCard, boolean isContacts) { long timestamp = 0; if (V) timestamp = System.currentTimeMillis(); Loading @@ -439,6 +440,11 @@ public class BluetoothPbapVcardManager { } while (!composer.isAfterLast()) { if (BluetoothPbapObexServer.sIsAborted) { ((ServerOperation)op).isAborted = true; BluetoothPbapObexServer.sIsAborted = false; break; } if (!composer.createOneEntry()) { Log.e(TAG, "Failed to read a contact. Error reason: " + composer.getErrorReason()); Loading @@ -460,6 +466,11 @@ public class BluetoothPbapVcardManager { } while (!composer.isAfterLast()) { if (BluetoothPbapObexServer.sIsAborted) { ((ServerOperation)op).isAborted = true; BluetoothPbapObexServer.sIsAborted = false; break; } if (!composer.createOneEntry()) { Log.e(TAG, "Failed to read a contact. Error reason: " + composer.getErrorReason()); Loading Loading @@ -531,7 +542,8 @@ public class BluetoothPbapVcardManager { int position = 0; // Need while loop to handle the big vcard case while (position < (vcardStringLen - maxPacketSize)) { while (!BluetoothPbapObexServer.sIsAborted && position < (vcardStringLen - maxPacketSize)) { if (V) timestamp = System.currentTimeMillis(); String subStr = mVcardResults.toString().substring(position, Loading