private TYPE getType(Cursor c, FilterInfo fi) {
TYPE type = null;
+ if (V) Log.d(TAG, "getType: for filterMsgType" + fi.mMsgType);
if (fi.mMsgType == FilterInfo.TYPE_SMS) {
- if (fi.mPhoneType == TelephonyManager.PHONE_TYPE_GSM) {
- type = TYPE.SMS_GSM;
- } else if (fi.mPhoneType == TelephonyManager.PHONE_TYPE_CDMA) {
+ if (V) Log.d(TAG, "getType: phoneType for SMS " + fi.mPhoneType);
+ if (fi.mPhoneType == TelephonyManager.PHONE_TYPE_CDMA) {
type = TYPE.SMS_CDMA;
+ } else {
+ type = TYPE.SMS_GSM;
}
} else if (fi.mMsgType == FilterInfo.TYPE_MMS) {
type = TYPE.MMS;
Cursor tmpCursor = null;
for(int x=0;x<listSize;x++){
BluetoothMapMessageListingElement ele = list.get(x);
- if((ele.getType().equals(TYPE.SMS_GSM)||ele.getType().equals(TYPE.SMS_CDMA))
- && smsCursor != null){
+ /* If OBEX "GET" request header includes "ParameterMask" with 'Type' NOT set,
+ * then ele.getType() returns "null" even for a valid cursor.
+ * Avoid NullPointerException in equals() check when 'mType' value is "null" */
+ TYPE tmpType = ele.getType();
+ if (smsCursor!= null &&
+ ((TYPE.SMS_GSM).equals(tmpType) || (TYPE.SMS_CDMA).equals(tmpType))) {
tmpCursor = smsCursor;
fi.mMsgType = FilterInfo.TYPE_SMS;
- }else if(ele.getType().equals(TYPE.MMS) && mmsCursor != null){
+ } else if(mmsCursor != null && (TYPE.MMS).equals(tmpType)) {
tmpCursor = mmsCursor;
fi.mMsgType = FilterInfo.TYPE_MMS;
- }else if(ele.getType().equals(TYPE.EMAIL) && emailCursor != null){
+ } else if(emailCursor != null && ((TYPE.EMAIL).equals(tmpType))) {
tmpCursor = emailCursor;
fi.mMsgType = FilterInfo.TYPE_EMAIL;
- }else if(ele.getType().equals(TYPE.IM) && imCursor != null){
+ } else if(imCursor != null && ((TYPE.IM).equals(tmpType))) {
tmpCursor = imCursor;
fi.mMsgType = FilterInfo.TYPE_IM;
}
TelephonyManager tm = (TelephonyManager) mContext.getSystemService(
Context.TELEPHONY_SERVICE);
- if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) {
- smsType = TYPE.SMS_GSM;
- } else if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
+ if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
smsType = TYPE.SMS_CDMA;
+ } else {
+ smsType = TYPE.SMS_GSM;
}
return smsType;
if (oldFolder != null) {
xmlEvtReport.attribute("", "old_folder", oldFolder);
}
- xmlEvtReport.attribute("", "msg_type", msgType.name());
-
+ /* Avoid possible NPE for "msgType" "null" value. "msgType"
+ * is a implied attribute and will be set "null" for events
+ * like "memory full" or "memory available" */
+ if (msgType != null) {
+ xmlEvtReport.attribute("", "msg_type", msgType.name());
+ }
/* If MAP event report version is above 1.0 send
* extended event report parameters */
if (datetime != null) {
BluetoothMapUtils.stripInvalidChars(mRecipientName));
if(mRecipientAddressing != null)
xmlMsgElement.attribute(null, "recipient_addressing", mRecipientAddressing);
- if(mMsgTypeAppParamSet == true)
+ /* Avoid NPE for possible "null" value of mType */
+ if(mMsgTypeAppParamSet == true && mType != null)
xmlMsgElement.attribute(null, "type", mType.name());
if(mSize != -1)
xmlMsgElement.attribute(null, "size", Integer.toString(mSize));
*/
public static String getMapHandle(long cpHandle, TYPE messageType){
String mapHandle = "-1";
- switch(messageType)
- {
- case MMS:
- mapHandle = getLongAsString(cpHandle | HANDLE_TYPE_MMS_MASK);
- break;
- case SMS_GSM:
- mapHandle = getLongAsString(cpHandle | HANDLE_TYPE_SMS_GSM_MASK);
- break;
- case SMS_CDMA:
- mapHandle = getLongAsString(cpHandle | HANDLE_TYPE_SMS_CDMA_MASK);
- break;
- case EMAIL:
- mapHandle = getLongAsString(cpHandle | HANDLE_TYPE_EMAIL_MASK);
- break;
- case IM:
- mapHandle = getLongAsString(cpHandle | HANDLE_TYPE_IM_MASK);
- break;
- default:
- throw new IllegalArgumentException("Message type not supported");
+ /* Avoid NPE for possible "null" value of messageType */
+ if(messageType != null) {
+ switch(messageType)
+ {
+ case MMS:
+ mapHandle = getLongAsString(cpHandle | HANDLE_TYPE_MMS_MASK);
+ break;
+ case SMS_GSM:
+ mapHandle = getLongAsString(cpHandle | HANDLE_TYPE_SMS_GSM_MASK);
+ break;
+ case SMS_CDMA:
+ mapHandle = getLongAsString(cpHandle | HANDLE_TYPE_SMS_CDMA_MASK);
+ break;
+ case EMAIL:
+ mapHandle = getLongAsString(cpHandle | HANDLE_TYPE_EMAIL_MASK);
+ break;
+ case IM:
+ mapHandle = getLongAsString(cpHandle | HANDLE_TYPE_IM_MASK);
+ break;
+ case NONE:
+ break;
+ default:
+ throw new IllegalArgumentException("Message type not supported");
+ }
+ } else {
+ if(D)Log.e(TAG," Invalid messageType input");
}
return mapHandle;