summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLixin Yue <L.X.YUE@motorola.com>2009-12-10 13:52:53 +0800
committerJaikumar Ganesh <jaikumar@google.com>2009-12-22 10:01:23 -0800
commita4508589f298c67fda54c344760ae39f0f375c11 (patch)
treeba9b4545b9e0363a50f472720769a0578e3c128c /src
parent6ef730f85e90a8246d06c7a58bb21eee5074945c (diff)
downloadandroid_packages_apps_Bluetooth-a4508589f298c67fda54c344760ae39f0f375c11.tar.gz
android_packages_apps_Bluetooth-a4508589f298c67fda54c344760ae39f0f375c11.tar.bz2
android_packages_apps_Bluetooth-a4508589f298c67fda54c344760ae39f0f375c11.zip
Update the error codes to be compatible with PBAP spec.
Catch IndexOutOfBoundsException and NullPointerException in Opp sendFile().
Diffstat (limited to 'src')
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java16
-rw-r--r--src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java16
2 files changed, 20 insertions, 12 deletions
diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
index 0b240f1c5..6efac93de 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
@@ -483,10 +483,11 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
}
}
} catch (IOException e) {
- status = BluetoothShare.STATUS_OBEX_DATA_ERROR;
- Log.e(TAG, "Error when sending file");
- Constants.updateShareStatus(mContext1, mInfo.mId, status);
- mCallback.removeMessages(BluetoothOppObexSession.MSG_CONNECT_TIMEOUT);
+ handleSendException(e.toString());
+ } catch (NullPointerException e) {
+ handleSendException(e.toString());
+ } catch (IndexOutOfBoundsException e) {
+ handleSendException(e.toString());
} finally {
try {
fileInfo.mInputStream.close();
@@ -526,6 +527,13 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
return status;
}
+ private void handleSendException(String exception) {
+ Log.e(TAG, "Error when sending file: " + exception);
+ int status = BluetoothShare.STATUS_OBEX_DATA_ERROR;
+ Constants.updateShareStatus(mContext1, mInfo.mId, status);
+ mCallback.removeMessages(BluetoothOppObexSession.MSG_CONNECT_TIMEOUT);
+ }
+
@Override
public void interrupt() {
super.interrupt();
diff --git a/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java b/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java
index bfadf70fb..4cc7914bc 100644
--- a/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java
+++ b/src/com/android/bluetooth/pbap/BluetoothPbapObexServer.java
@@ -277,7 +277,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
return ResponseCodes.OBEX_HTTP_FORBIDDEN;
} else {
Log.w(TAG, "path is not legal");
- return ResponseCodes.OBEX_HTTP_BAD_REQUEST;
+ return ResponseCodes.OBEX_HTTP_NOT_FOUND;
}
}
mCurrentPath = current_path_tmp;
@@ -318,7 +318,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
if (D) Log.d(TAG, "OnGet type is " + type + "; name is " + name);
if (type == null) {
- return ResponseCodes.OBEX_HTTP_BAD_REQUEST;
+ return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE;
}
// Accroding to specification,the name header could be omitted such as
// sony erriccsonHBH-DS980
@@ -350,7 +350,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
appParamValue.needTag = ContentType.COMBINED_CALL_HISTORY;
} else {
Log.w(TAG, "mCurrentpath is not valid path!!!");
- return ResponseCodes.OBEX_HTTP_BAD_REQUEST;
+ return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE;
}
if (D) Log.v(TAG, "onGet(): appParamValue.needTag=" + appParamValue.needTag);
} else {
@@ -381,7 +381,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
if (D) Log.v(TAG, "download combined calls request");
} else {
Log.w(TAG, "Input name doesn't contain valid info!!!");
- return ResponseCodes.OBEX_HTTP_BAD_REQUEST;
+ return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE;
}
}
@@ -402,7 +402,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
return pullPhonebook(appParam, appParamValue, reply, op, name);
} else {
Log.w(TAG, "unknown type request!!!");
- return ResponseCodes.OBEX_HTTP_BAD_REQUEST;
+ return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE;
}
}
@@ -843,7 +843,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
final 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_BAD_REQUEST;
+ return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE;
}
String strIndex = name.substring(0, name.length() - VCARD_NAME_SUFFIX_LENGTH + 1);
int intIndex = 0;
@@ -852,7 +852,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
intIndex = Integer.parseInt(strIndex);
} catch (NumberFormatException e) {
Log.e(TAG, "catch number format exception " + e.toString());
- return ResponseCodes.OBEX_HTTP_BAD_REQUEST;
+ return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE;
}
}
@@ -865,7 +865,7 @@ public class BluetoothPbapObexServer extends ServerRequestHandler {
boolean vcard21 = appParamValue.vcard21;
if (appParamValue.needTag == 0) {
Log.w(TAG, "wrong path!");
- return ResponseCodes.OBEX_HTTP_BAD_REQUEST;
+ return ResponseCodes.OBEX_HTTP_NOT_ACCEPTABLE;
} else if (appParamValue.needTag == ContentType.PHONEBOOK) {
if (intIndex < 0 || intIndex >= size) {
Log.w(TAG, "The requested vcard is not acceptable! name= " + name);