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

Commit c2adf575 authored by Christine Hallstrom's avatar Christine Hallstrom
Browse files

Don't send MAP new message events if older than one year

Don't send new message events for messages older than one year.

This is a resubmit of ag/20751100 that resolves crash when trying to access cursor on date.

Bug: 196731316
Test: QA, see b/196731316#comment174 + manual, connect to carkit and send and delete messages (mix of group MMS and SMS)
Ignore-AOSP-First: QPR2 change
Change-Id: I9cc1a44c5cf07a9ae2ca527489a5eba4f1b4d647
parent e62e68a3
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -1456,8 +1456,14 @@ 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)));
                                long timestamp = c.getLong(c.getColumnIndex(Sms.DATE));
                                String date = BluetoothMapUtils.getDateTimeString(timestamp);
                                if (BluetoothMapUtils.isDateTimeOlderThanOneYear(timestamp)) {
                                    // Skip sending new message events older than one year
                                    listChanged = false;
                                    msgListSms.remove(id);
                                    continue;
                                }
                                String subject = c.getString(c.getColumnIndex(Sms.BODY));
                                if (subject == null) {
                                    subject = "";
@@ -1625,8 +1631,14 @@ 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)));
                                long timestamp = c.getLong(c.getColumnIndex(Mms.DATE));
                                String date = BluetoothMapUtils.getDateTimeString(timestamp);
                                if (BluetoothMapUtils.isDateTimeOlderThanOneYear(timestamp)) {
                                    // Skip sending new message events older than one year
                                    listChanged = false;
                                    msgListMms.remove(id);
                                    continue;
                                }
                                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) {