summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/android/bluetooth/client/map/BluetoothMapBmessageParser.java17
-rw-r--r--src/android/bluetooth/client/map/BluetoothMapMessage.java8
-rw-r--r--src/android/bluetooth/client/map/BluetoothMasClient.java17
-rw-r--r--src/android/bluetooth/client/map/BluetoothMasRequest.java1
-rw-r--r--src/android/bluetooth/client/map/BluetoothMasRequestGetFolderListing.java4
-rw-r--r--src/android/bluetooth/client/map/BluetoothMasRequestGetMessagesListing.java15
6 files changed, 43 insertions, 19 deletions
diff --git a/src/android/bluetooth/client/map/BluetoothMapBmessageParser.java b/src/android/bluetooth/client/map/BluetoothMapBmessageParser.java
index fa3d817..ef75e7b 100644
--- a/src/android/bluetooth/client/map/BluetoothMapBmessageParser.java
+++ b/src/android/bluetooth/client/map/BluetoothMapBmessageParser.java
@@ -312,8 +312,16 @@ class BluetoothMapBmessageParser {
prop = mParser.next(true);
- if (prop != null && prop.equals(END_MSG)) {
- mBmsg.mMessage = new String(data, 0, messageLen);
+ if (prop != null) {
+ if (prop.equals(END_MSG)) {
+ mBmsg.mMessage = new String(data, 0, messageLen);
+ } else {
+ /* Handle possible exception for incorrect LENGTH value
+ * from MSE while parsing GET Message response */
+ Log.e(TAG, "Prop Invalid: "+ prop.toString());
+ Log.e(TAG, "Possible Invalid LENGTH value");
+ throw expected(END_MSG);
+ }
} else {
data = null;
@@ -322,6 +330,11 @@ class BluetoothMapBmessageParser {
* now we check if bMessage can be parsed if LENGTH is handled as
* number of characters instead of number of bytes
*/
+ if (offset < 0 || offset > remng.length()) {
+ /* Handle possible exception for incorrect LENGTH value
+ * from MSE while parsing GET Message response */
+ throw new ParseException("Invalid LENGTH value", mParser.pos());
+ }
Log.w(TAG, "byte LENGTH seems to be invalid, trying with char length");
diff --git a/src/android/bluetooth/client/map/BluetoothMapMessage.java b/src/android/bluetooth/client/map/BluetoothMapMessage.java
index 6c76bbe..5ce6c4b 100644
--- a/src/android/bluetooth/client/map/BluetoothMapMessage.java
+++ b/src/android/bluetooth/client/map/BluetoothMapMessage.java
@@ -91,8 +91,14 @@ public class BluetoothMapMessage {
}
mSubject = attrs.get("subject");
+ String dateTime = attrs.get("datetime");
+ //Handle possible NPE when not able to retreive datetime attribute
+ if(dateTime != null){
+ mDateTime = (new ObexTime(dateTime)).getTime();
+ } else {
+ mDateTime = null;
+ }
- mDateTime = (new ObexTime(attrs.get("datetime"))).getTime();
mSenderName = attrs.get("sender_name");
diff --git a/src/android/bluetooth/client/map/BluetoothMasClient.java b/src/android/bluetooth/client/map/BluetoothMasClient.java
index d6d2a1c..7f71693 100644
--- a/src/android/bluetooth/client/map/BluetoothMasClient.java
+++ b/src/android/bluetooth/client/map/BluetoothMasClient.java
@@ -453,13 +453,9 @@ public class BluetoothMasClient {
}
private void sendToClient(int event, boolean success, Object param) {
- if (success) {
- mCallback.obtainMessage(event, STATUS_OK, mMas.getMasInstanceId(), param)
- .sendToTarget();
- } else {
- mCallback.obtainMessage(event, STATUS_FAILED, mMas.getMasInstanceId(), null)
- .sendToTarget();
- }
+ // Send event, status and notification state for both sucess and failure case.
+ mCallback.obtainMessage(event, success ? STATUS_OK : STATUS_FAILED, mMas.getMasInstanceId(),
+ param).sendToTarget();
}
private class SocketConnectThread extends Thread {
@@ -547,8 +543,11 @@ public class BluetoothMasClient {
}
public void setPeriod(Date filterBegin, Date filterEnd) {
- periodBegin = (new ObexTime(filterBegin)).toString();
- periodEnd = (new ObexTime(filterEnd)).toString();
+ //Handle possible NPE for obexTime constructor utility
+ if(filterBegin != null )
+ periodBegin = (new ObexTime(filterBegin)).toString();
+ if(filterEnd != null)
+ periodEnd = (new ObexTime(filterEnd)).toString();
}
public void setReadStatus(byte readfilter) {
diff --git a/src/android/bluetooth/client/map/BluetoothMasRequest.java b/src/android/bluetooth/client/map/BluetoothMasRequest.java
index 658a344..0c9c29c 100644
--- a/src/android/bluetooth/client/map/BluetoothMasRequest.java
+++ b/src/android/bluetooth/client/map/BluetoothMasRequest.java
@@ -43,6 +43,7 @@ abstract class BluetoothMasRequest {
protected static final byte OAP_TAGID_NEW_MESSAGE = 0x0d;
protected static final byte OAP_TAGID_NOTIFICATION_STATUS = 0x0e;
protected static final byte OAP_TAGID_MAS_INSTANCE_ID = 0x0f;
+ protected static final byte OAP_TAGID_PARAMETER_MASK = 0x10;
protected static final byte OAP_TAGID_FOLDER_LISTING_SIZE = 0x11;
protected static final byte OAP_TAGID_MESSAGES_LISTING_SIZE = 0x12;
protected static final byte OAP_TAGID_SUBJECT_LENGTH = 0x13;
diff --git a/src/android/bluetooth/client/map/BluetoothMasRequestGetFolderListing.java b/src/android/bluetooth/client/map/BluetoothMasRequestGetFolderListing.java
index bd5a2dd..db22ada 100644
--- a/src/android/bluetooth/client/map/BluetoothMasRequestGetFolderListing.java
+++ b/src/android/bluetooth/client/map/BluetoothMasRequestGetFolderListing.java
@@ -43,8 +43,8 @@ final class BluetoothMasRequestGetFolderListing extends BluetoothMasRequest {
mHeaderSet.setHeader(HeaderSet.TYPE, TYPE);
ObexAppParameters oap = new ObexAppParameters();
-
- if (maxListCount > 0) {
+ // Allow GetFolderListing for maxListCount value 0 also.
+ if (maxListCount >= 0) {
oap.add(OAP_TAGID_MAX_LIST_COUNT, (short) maxListCount);
}
diff --git a/src/android/bluetooth/client/map/BluetoothMasRequestGetMessagesListing.java b/src/android/bluetooth/client/map/BluetoothMasRequestGetMessagesListing.java
index d5460f9..2ad167d 100644
--- a/src/android/bluetooth/client/map/BluetoothMasRequestGetMessagesListing.java
+++ b/src/android/bluetooth/client/map/BluetoothMasRequestGetMessagesListing.java
@@ -41,7 +41,6 @@ final class BluetoothMasRequestGetMessagesListing extends BluetoothMasRequest {
public BluetoothMasRequestGetMessagesListing(String folderName, int parameters,
BluetoothMasClient.MessagesFilter filter, int subjectLength, int maxListCount,
int listStartOffset) {
-
if (subjectLength < 0 || subjectLength > 255) {
throw new IllegalArgumentException("subjectLength should be [0..255]");
}
@@ -97,8 +96,14 @@ final class BluetoothMasRequestGetMessagesListing extends BluetoothMasRequest {
if (subjectLength != 0) {
oap.add(OAP_TAGID_SUBJECT_LENGTH, (byte) subjectLength);
}
-
- if (maxListCount != 0) {
+ /* Include parameterMask only when specific values are selected,
+ * to avoid IOT specific issue with no paramterMask header support.
+ */
+ if (parameters > 0 ) {
+ oap.add(OAP_TAGID_PARAMETER_MASK, parameters);
+ }
+ // Allow GetMessageListing for maxlistcount value 0 also.
+ if (maxListCount >= 0) {
oap.add(OAP_TAGID_MAX_LIST_COUNT, (short) maxListCount);
}
@@ -122,8 +127,8 @@ final class BluetoothMasRequestGetMessagesListing extends BluetoothMasRequest {
if (oap.exists(OAP_TAGID_MSE_TIME)) {
String mseTime = oap.getString(OAP_TAGID_MSE_TIME);
-
- mServerTime = (new ObexTime(mseTime)).getTime();
+ if(mseTime != null )
+ mServerTime = (new ObexTime(mseTime)).getTime();
}
}