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

Commit 6d4c5c8b authored by kschulz's avatar kschulz Committed by Zhihai Xu
Browse files

DO NOT MERGE MAP: fixed missing filtering on Priority

FilterPriority was ignored in the code as SMS does not have priority.
This fixes the support for the priority filter for sms + mms.
NOTICE: sms messages does not have priority and hence will return
an empty messagelisting if the client requests a list with priority
filter set til high-pri only.

Bug: 11168636
Change-Id: If028e47850323d20d1e9a23bc947782ae8da1df0
parent d3195daf
Loading
Loading
Loading
Loading
+42 −15
Original line number Original line Diff line number Diff line
@@ -38,6 +38,7 @@ import android.util.Log;


import com.android.bluetooth.map.BluetoothMapUtils.TYPE;
import com.android.bluetooth.map.BluetoothMapUtils.TYPE;
import com.google.android.mms.pdu.CharacterSets;
import com.google.android.mms.pdu.CharacterSets;
import com.google.android.mms.pdu.PduHeaders;


public class BluetoothMapContent {
public class BluetoothMapContent {
    private static final String TAG = "BluetoothMapContent";
    private static final String TAG = "BluetoothMapContent";
@@ -389,8 +390,15 @@ public class BluetoothMapContent {


    private void setPriority(BluetoothMapMessageListingElement e, Cursor c,
    private void setPriority(BluetoothMapMessageListingElement e, Cursor c,
        FilterInfo fi, BluetoothMapAppParams ap) {
        FilterInfo fi, BluetoothMapAppParams ap) {
        if ((ap.getParameterMask() & MASK_PRIORITY) != 0) {
        String priority = "no";
        String priority = "no";
        if ((ap.getParameterMask() & MASK_PRIORITY) != 0) {
            int pri = 0;
            if (fi.msgType == FilterInfo.TYPE_MMS) {
                pri = c.getInt(c.getColumnIndex(Mms.PRIORITY));
            }
            if (pri == PduHeaders.PRIORITY_HIGH) {
                priority = "yes";
            }
            if (D) Log.d(TAG, "setPriority: " + priority);
            if (D) Log.d(TAG, "setPriority: " + priority);
            e.setPriority(priority);
            e.setPriority(priority);
        }
        }
@@ -1051,6 +1059,23 @@ public class BluetoothMapContent {


        return where;
        return where;
    }
    }
    private String setWhereFilterPriority(BluetoothMapAppParams ap, FilterInfo fi) {
        String where = "";
        int pri = ap.getFilterPriority();
        /*only MMS have priority info */
        if(fi.msgType == FilterInfo.TYPE_MMS)
        {
            if(pri == 0x0002)
            {
                where += " AND " + Mms.PRIORITY + "<=" +
                    Integer.toString(PduHeaders.PRIORITY_NORMAL);
            }else if(pri == 0x0001) {
                where += " AND " + Mms.PRIORITY + "=" +
                    Integer.toString(PduHeaders.PRIORITY_HIGH);
            }
        }
        return where;
    }


    private String setWhereFilterRecipient(BluetoothMapAppParams ap,
    private String setWhereFilterRecipient(BluetoothMapAppParams ap,
        FilterInfo fi) {
        FilterInfo fi) {
@@ -1094,6 +1119,7 @@ public class BluetoothMapContent {
        where += setWhereFilterFolderType(folder, fi);
        where += setWhereFilterFolderType(folder, fi);
        where += setWhereFilterReadStatus(ap);
        where += setWhereFilterReadStatus(ap);
        where += setWhereFilterPeriod(ap, fi);
        where += setWhereFilterPeriod(ap, fi);
        where += setWhereFilterPriority(ap,fi);
        /* where += setWhereFilterOriginator(ap, fi); */
        /* where += setWhereFilterOriginator(ap, fi); */
        /* where += setWhereFilterRecipient(ap, fi); */
        /* where += setWhereFilterRecipient(ap, fi); */


@@ -1155,7 +1181,7 @@ public class BluetoothMapContent {


        if (smsSelected(fi, ap)) {
        if (smsSelected(fi, ap)) {
            fi.msgType = FilterInfo.TYPE_SMS;
            fi.msgType = FilterInfo.TYPE_SMS;

            if(ap.getFilterPriority() != 1){ /*SMS cannot have high priority*/
                String where = setWhereFilter(folder, fi, ap);
                String where = setWhereFilter(folder, fi, ap);


                Cursor c = mResolver.query(Sms.CONTENT_URI,
                Cursor c = mResolver.query(Sms.CONTENT_URI,
@@ -1172,6 +1198,7 @@ public class BluetoothMapContent {
                    c.close();
                    c.close();
                }
                }
            }
            }
        }


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