Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 35ab5372 authored by Hemant Gupta's avatar Hemant Gupta
Browse files

MAP: Fix possible NullPointerException while GetMessagesListing

Fix possible NullPointerException while processing GetMessagesListing
on a MSE without a valid SIM , case wherein invalid  messageType value
occurs on MAP SMS/MMS Instance. Now by default SMS type is set to GSM.

Following basic PTS test cases and also other PTS cases dependent on
GetMessagesListing functionality fail without this fix:
TC_MSE_MMB_BV_11_I
TC_MSE_MMB_BV_20_I
TC_MSE_MMU_BV_02_I

Change-Id: I8ed0a2787534159342af88ec413a1c0407961d91
parent 5bd792aa
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -712,11 +712,13 @@ public class BluetoothMapContent {

    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;
@@ -2175,17 +2177,21 @@ public class BluetoothMapContent {
            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;
                }
+9 −5
Original line number Diff line number Diff line
@@ -435,10 +435,10 @@ public class BluetoothMapContentObserver {
        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;
@@ -729,8 +729,12 @@ public class BluetoothMapContentObserver {
                if (oldFolder != null) {
                    xmlEvtReport.attribute("", "old_folder", oldFolder);
                }
                /* 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) {
+2 −1
Original line number Diff line number Diff line
@@ -294,7 +294,8 @@ public class BluetoothMapMessageListingElement
                        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));
+26 −19
Original line number Diff line number Diff line
@@ -251,6 +251,8 @@ public class BluetoothMapUtils {
     */
    public static String getMapHandle(long cpHandle, TYPE messageType){
        String mapHandle = "-1";
        /* Avoid NPE for possible "null" value of messageType */
        if(messageType != null) {
            switch(messageType)
            {
                case MMS:
@@ -268,9 +270,14 @@ public class BluetoothMapUtils {
                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;

    }