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

Commit 96229576 authored by Christine Hallstrom's avatar Christine Hallstrom Committed by Android (Google) Code Review
Browse files

Merge "Don't send new message events older than one year" into tm-qpr-dev

parents ae874fb7 d29d963f
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -1420,6 +1420,7 @@ public class BluetoothMapContentObserver {
                        int type = c.getInt(c.getColumnIndex(Sms.TYPE));
                        int threadId = c.getInt(c.getColumnIndex(Sms.THREAD_ID));
                        int read = c.getInt(c.getColumnIndex(Sms.READ));
                        long timestamp = c.getLong(c.getColumnIndex(Sms.DATE));

                        Msg msg = getMsgListSms().remove(id);

@@ -1427,6 +1428,10 @@ public class BluetoothMapContentObserver {
                         * a message deleted and/or MessageShift for messages deleted by the MCE. */

                        if (msg == null) {
                            if (BluetoothMapUtils.isDateTimeOlderThanOneYear(timestamp)) {
                                // Skip sending new message events older than one year
                                continue;
                            }
                            /* New message */
                            msg = new Msg(id, type, threadId, read);
                            msgListSms.put(id, msg);
@@ -1435,8 +1440,7 @@ public class BluetoothMapContentObserver {
                            if (mTransmitEvents && // extract contact details only if needed
                                    mMapEventReportVersion
                                            > BluetoothMapUtils.MAP_EVENT_REPORT_V10) {
                                String date = BluetoothMapUtils.getDateTimeString(
                                        c.getLong(c.getColumnIndex(Sms.DATE)));
                                String date = BluetoothMapUtils.getDateTimeString(timestamp);
                                String subject = c.getString(c.getColumnIndex(Sms.BODY));
                                if (subject == null) {
                                    subject = "";
@@ -1583,6 +1587,7 @@ public class BluetoothMapContentObserver {
                        // TODO: Go through code to see if we have an issue with mismatch in types
                        //       for threadId. Seems to be a long in DB??
                        int read = c.getInt(c.getColumnIndex(Mms.READ));
                        long timestamp = c.getLong(c.getColumnIndex(Mms.DATE));

                        Msg msg = getMsgListMms().remove(id);

@@ -1591,6 +1596,10 @@ public class BluetoothMapContentObserver {
                         * MCE.*/

                        if (msg == null) {
                            if (BluetoothMapUtils.isDateTimeOlderThanOneYear(timestamp)) {
                                // Skip sending new message events older than one year
                                continue;
                            }
                            /* New message - only notify on retrieve conf */
                            listChanged = true;
                            if (getMmsFolderName(type).equalsIgnoreCase(
@@ -1604,8 +1613,7 @@ public class BluetoothMapContentObserver {
                            if (mTransmitEvents && // extract contact details only if needed
                                    mMapEventReportVersion
                                            != BluetoothMapUtils.MAP_EVENT_REPORT_V10) {
                                String date = BluetoothMapUtils.getDateTimeString(
                                        c.getLong(c.getColumnIndex(Mms.DATE)));
                                String date = BluetoothMapUtils.getDateTimeString(timestamp);
                                String subject = c.getString(c.getColumnIndex(Mms.SUBJECT));
                                if (subject == null || subject.length() == 0) {
                                    /* Get subject from mms text body parts - if any exists */
+15 −0
Original line number Diff line number Diff line
@@ -677,6 +677,21 @@ public class BluetoothMapUtils {
        return format.format(cal.getTime());
    }

    static boolean isDateTimeOlderThanOneYear(long timestamp) {
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(timestamp);
        Calendar oneYearAgo = Calendar.getInstance();
        oneYearAgo.add(Calendar.YEAR, -1);
        if (cal.compareTo(oneYearAgo) > 0) {
            if (V) {
                Log.v(TAG, "isDateTimeOlderThanOneYear timestamp : " + timestamp
                        + " oneYearAgo: " + oneYearAgo);
            }
            return true;
        }
        return false;
    }

    static void savePeerSupportUtcTimeStamp(int remoteFeatureMask) {
        if ((remoteFeatureMask & MAP_FEATURE_DEFINED_TIMESTAMP_FORMAT_BIT)
                == MAP_FEATURE_DEFINED_TIMESTAMP_FORMAT_BIT) {