import javax.obex.ServerRequestHandler;
import javax.obex.ResponseCodes;
import javax.obex.ApplicationParameter;
+import javax.obex.ServerOperation;
import javax.obex.Operation;
import javax.obex.HeaderSet;
public static int ORDER_BY_ALPHABETICAL = 1;
+ public static boolean sIsAborted = false;
+
public static class ContentType {
public static final int PHONEBOOK = 1;
}
@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.");
return ResponseCodes.OBEX_HTTP_BAD_REQUEST;
}
@Override
- public int onGet(final Operation op) {
+ public int onGet(Operation op) {
+ sisAborted = false;
HeaderSet request = null;
HeaderSet reply = new HeaderSet();
String type = "";
}
/** 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();
}
/** 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;
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) {
}
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();
}
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) {
}
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;
}
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(".");
import java.io.OutputStream;
import java.util.ArrayList;
+import javax.obex.ServerOperation;
import javax.obex.Operation;
import javax.obex.ResponseCodes;
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.");
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.");
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.");
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();
}
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());
}
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());
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,