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

Commit 231682f6 authored by Pradeep Panigrahi's avatar Pradeep Panigrahi
Browse files

MAP: Bug fixes on Map Profile.

Added following bug fixes:

1) Optimize GET MessagesListing operation
Modify sqlite database query to fetch only 'MaxListCount'
elements starting from 'ListStartOffset' instead of
fetching the complete database and filter out,
when these parameters are specified in the GET
MessagesListing Request.

2) Change to set empty sender addressing in message listing
element if it is null.

3) set empty sender name in message lsiting element if null.

Change-Id: I27ba852628e0455905dcd6d37ee045da6b5afc77
CRs-fixed: 785977
parent 70f0c7b3
Loading
Loading
Loading
Loading
+42 −12
Original line number Diff line number Diff line
@@ -929,6 +929,10 @@ public class BluetoothMapContent {
                }

            }
            if( name ==null) {
               //set empty value
               name = "";
            }
            if (D) Log.d(TAG, "setSenderName: " + name);
            e.setSenderName(name);
        }
@@ -2213,7 +2217,16 @@ public class BluetoothMapContent {
            fi.msgType = FilterInfo.TYPE_EMAIL;

            String where = setWhereFilter(folder, fi, ap);
            Log.d(TAG, "where clause is = " + where);
            where+= " AND "+ Message.FLAG_LOADED_SELECTION;
            where+= " order by timeStamp desc ";
            //Fetch only maxListCount emails from  startOffset
            if(ap.getMaxListCount() > 0 && ap.getMaxListCount() < 65536) {
                where+=" LIMIT "+ap.getMaxListCount();
            }
            if(ap.getStartOffset() > 0 && ap.getStartOffset() < 65536) {
                where+=" OFFSET "+ap.getStartOffset();
            }
            if (V) Log.d(TAG, "where clause is = " + where);
            try {
                Cursor c = mResolver.query(uriEmail,
                EMAIL_PROJECTION, where + " AND " + Message.FLAG_LOADED_SELECTION, null, "timeStamp desc");
@@ -2239,7 +2252,8 @@ public class BluetoothMapContent {

        /* Enable this if post sorting and segmenting needed */
        bmList.sort();
        bmList.segment(ap.getMaxListCount(), ap.getStartOffset());
        //Handle OFFSET and MAXLISTCOUNT from DB query
        //bmList.segment(ap.getMaxListCount(), ap.getStartOffset());

        return bmList;
    }
@@ -2325,10 +2339,18 @@ public class BluetoothMapContent {
            fi.msgType = FilterInfo.TYPE_SMS;
            if(ap.getFilterPriority() != 1){ /*SMS cannot have high priority*/
                String where = setWhereFilter(folder, fi, ap);

                Cursor c = mResolver.query(Sms.CONTENT_URI,
                    SMS_PROJECTION, where, null, "date DESC");

                Cursor c =null;
                //Fetch only maxListCount messages from  startOffset
                if(ap.getStartOffset() > 0 && ap.getStartOffset() < 65536) {
                    c = mResolver.query(Sms.CONTENT_URI,
                        SMS_PROJECTION, where, null, "date DESC" + " limit " +
                            ap.getMaxListCount()+" offset "+ ap.getStartOffset());
                }else {
                    c = mResolver.query(Sms.CONTENT_URI,
                        SMS_PROJECTION, where, null, "date DESC" + " limit " +
                            ap.getMaxListCount());
                }
                if (V) Log.d(TAG, "where clause is = " + where);
                if (c != null) {
                    while (c.moveToNext()) {
                        if (matchAddresses(c, fi, ap)) {
@@ -2344,12 +2366,20 @@ public class BluetoothMapContent {

        if (mmsSelected(fi, ap)) {
            fi.msgType = FilterInfo.TYPE_MMS;

            String where = setWhereFilter(folder, fi, ap);
            where += " AND " + INTERESTED_MESSAGE_TYPE_CLAUSE;
            Cursor c = mResolver.query(Mms.CONTENT_URI,
                MMS_PROJECTION, where, null, "date DESC");

            Cursor c =null;
            //Fetch only maxListCount messages from  startOffset
            if(ap.getStartOffset() > 0 && ap.getStartOffset() < 65536) {
                c = mResolver.query(Mms.CONTENT_URI,
                    MMS_PROJECTION, where, null, "date DESC" + " limit " +
                        ap.getMaxListCount()+" offset "+ ap.getStartOffset());
            } else {
                c = mResolver.query(Mms.CONTENT_URI,
                    MMS_PROJECTION, where, null, "date DESC" + " limit " +
                        ap.getMaxListCount());
            }
            if (V) Log.d(TAG, "where clause is = " + where);
            if (c != null) {
                int cnt = 0;
                while (c.moveToNext()) {
@@ -2362,10 +2392,10 @@ public class BluetoothMapContent {
                c.close();
            }
        }

        /* Enable this if post sorting and segmenting needed */
        bmList.sort();
        bmList.segment(ap.getMaxListCount(), ap.getStartOffset());
        //Handle OFFSET and MAXLISTCOUNT from DB query
        //bmList.segment(ap.getMaxListCount(), ap.getStartOffset());

        return bmList;
    }
+1 −1
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ public class BluetoothMapMessageListingElement
         */
        this.senderAddressing = PhoneNumberUtils.extractNetworkPortion(senderAddressing);
        if(this.senderAddressing == null || this.senderAddressing.length() < 2){
            this.senderAddressing = "11"; // Ensure we have at least two digits to
            this.senderAddressing = ""; // Set empty value
        }
    }