Loading android/app/src/com/android/bluetooth/map/BluetoothMapContentObserver.java +32 −12 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ import com.android.bluetooth.BluetoothMethodProxy; import com.android.bluetooth.BluetoothStatsLog; import com.android.bluetooth.Utils; import com.android.bluetooth.content_profiles.ContentProfileErrorReportUtils; import com.android.bluetooth.flags.Flags; import com.android.bluetooth.map.BluetoothMapUtils.TYPE; import com.android.bluetooth.map.BluetoothMapbMessageMime.MimePart; import com.android.bluetooth.mapapi.BluetoothMapContract; Loading @@ -74,6 +75,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; Loading @@ -92,6 +94,10 @@ public class BluetoothMapContentObserver { private static final boolean D = BluetoothMapService.DEBUG; private static final boolean V = BluetoothMapService.VERBOSE; // A message older than this will be ignored when notifying a new message. @VisibleForTesting static final Duration NEW_MESSAGE_DURATION_FOR_NOTIFICATION = Duration.ofDays(7); @VisibleForTesting static final String EVENT_TYPE_NEW = "NewMessage"; @VisibleForTesting Loading Loading @@ -1537,19 +1543,25 @@ public class BluetoothMapContentObserver { /* New message */ msg = new Msg(id, type, threadId, read); msgListSms.put(id, msg); listChanged = true; Event evt; if (mTransmitEvents && // extract contact details only if needed mMapEventReportVersion > BluetoothMapUtils.MAP_EVENT_REPORT_V10) { long timestamp = c.getLong(c.getColumnIndex(Sms.DATE)); String date = BluetoothMapUtils.getDateTimeString(timestamp); if (Flags.mapLimitNotification()) { if (BluetoothMapUtils.isDateTimeOlderThanDuration( timestamp, NEW_MESSAGE_DURATION_FOR_NOTIFICATION)) { msgListSms.remove(id); continue; } } else { if (BluetoothMapUtils.isDateTimeOlderThanOneYear(timestamp)) { // Skip sending message events older than one year listChanged = false; msgListSms.remove(id); continue; } } String subject = c.getString(c.getColumnIndex(Sms.BODY)); if (subject == null) { subject = ""; Loading Loading @@ -1591,6 +1603,7 @@ public class BluetoothMapContentObserver { evt = new Event(EVENT_TYPE_NEW, id, getSmsFolderName(type), null, mSmsType); } listChanged = true; sendEvent(evt); } else { /* Existing message */ Loading Loading @@ -1730,11 +1743,20 @@ public class BluetoothMapContentObserver { TimeUnit.SECONDS.toMillis( c.getLong(c.getColumnIndex(Mms.DATE))); String date = BluetoothMapUtils.getDateTimeString(timestamp); if (Flags.mapLimitNotification()) { if (BluetoothMapUtils.isDateTimeOlderThanDuration( timestamp, NEW_MESSAGE_DURATION_FOR_NOTIFICATION)) { msgListMms.remove(id); continue; } } else { if (BluetoothMapUtils.isDateTimeOlderThanOneYear(timestamp)) { // Skip sending new message events older than one year 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 */ Loading Loading @@ -3164,7 +3186,6 @@ public class BluetoothMapContentObserver { Uri uri = Mms.CONTENT_URI; synchronized (getMsgListMms()) { uri = mResolver.insert(uri, values); if (uri == null) { Loading Loading @@ -3412,7 +3433,6 @@ public class BluetoothMapContentObserver { public void sendMessage(PushMsgInfo msgInfo, String msgBody) { SmsManager smsMng = SmsManager.getDefault(); ArrayList<String> parts = smsMng.divideMessage(msgBody); msgInfo.parts = parts.size(); Loading android/app/src/com/android/bluetooth/map/BluetoothMapUtils.java +9 −2 Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ import java.nio.charset.CodingErrorAction; import java.nio.charset.IllegalCharsetNameException; import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.time.Duration; import java.time.Instant; import java.util.Arrays; import java.util.BitSet; import java.util.Calendar; Loading Loading @@ -759,7 +761,6 @@ public class BluetoothMapUtils { } } static String getDateTimeString(long timestamp) { SimpleDateFormat format = (mPeerSupportUtcTimeStamp) ? new SimpleDateFormat("yyyyMMdd'T'HHmmssZ") : new SimpleDateFormat("yyyyMMdd'T'HHmmss"); Loading @@ -785,6 +786,12 @@ public class BluetoothMapUtils { return false; } static boolean isDateTimeOlderThanDuration(long timestamp, Duration duration) { Instant nowMinusDuration = Instant.now().minus(duration); Instant dateTime = Instant.ofEpochMilli(timestamp); return dateTime.isBefore(nowMinusDuration); } static void savePeerSupportUtcTimeStamp(int remoteFeatureMask) { if ((remoteFeatureMask & MAP_FEATURE_DEFINED_TIMESTAMP_FORMAT_BIT) == MAP_FEATURE_DEFINED_TIMESTAMP_FORMAT_BIT) { Loading android/app/tests/unit/src/com/android/bluetooth/map/BluetoothMapContentObserverTest.java +128 −6 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.os.Handler; import android.os.Looper; import android.os.RemoteException; import android.os.UserManager; import android.platform.test.flag.junit.SetFlagsRule; import android.provider.ContactsContract; import android.provider.Telephony; import android.provider.Telephony.Mms; Loading @@ -43,6 +44,7 @@ import androidx.test.filters.MediumTest; import androidx.test.runner.AndroidJUnit4; import com.android.bluetooth.BluetoothMethodProxy; import com.android.bluetooth.flags.Flags; import com.android.bluetooth.map.BluetoothMapUtils.TYPE; import com.android.bluetooth.mapapi.BluetoothMapContract; import com.android.bluetooth.mapapi.BluetoothMapContract.MessageColumns; Loading @@ -64,6 +66,7 @@ import org.mockito.junit.MockitoRule; import java.io.IOException; import java.text.SimpleDateFormat; import java.time.Instant; import java.util.Calendar; import java.util.HashMap; import java.util.HashSet; Loading Loading @@ -119,6 +122,7 @@ public class BluetoothMapContentObserverTest { static final int TEST_LAST_ONLINE = 1; @Rule public MockitoRule mockitoRule = MockitoJUnit.rule(); @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Mock private BluetoothMnsObexClient mClient; Loading Loading @@ -1232,6 +1236,7 @@ public class BluetoothMapContentObserverTest { @Test public void handleMsgListChangesMms_withNonExistingOldMessage_andVersion12() { mSetFlagsRule.disableFlags(Flags.FLAG_MAP_LIMIT_NOTIFICATION); Calendar cal = Calendar.getInstance(); cal.add(Calendar.YEAR, -1); cal.add(Calendar.DATE, -1); Loading @@ -1257,7 +1262,59 @@ public class BluetoothMapContentObserverTest { mObserver.handleMsgListChangesMms(); Assert.assertEquals(mObserver.getMsgListMms().get(TEST_HANDLE_ONE), null); Assert.assertEquals(null, mObserver.getMsgListMms().get(TEST_HANDLE_ONE)); } @Test public void handleMsgListChangesMms_withNonExistingOldMessage_andVersion12_andOneWeekLimit() { mSetFlagsRule.enableFlags(Flags.FLAG_MAP_LIMIT_NOTIFICATION); Instant oldInstant = Instant.now() .minus(BluetoothMapContentObserver.NEW_MESSAGE_DURATION_FOR_NOTIFICATION); long timestampSec = oldInstant.getEpochSecond(); MatrixCursor cursor = new MatrixCursor( new String[] { Mms._ID, Mms.MESSAGE_BOX, Mms.MESSAGE_TYPE, Mms.THREAD_ID, Mms.READ, Mms.DATE, Mms.SUBJECT, Mms.PRIORITY, Mms.Addr.ADDRESS }); cursor.addRow( new Object[] { TEST_HANDLE_ONE, TEST_MMS_TYPE_ALL, TEST_MMS_MTYPE, TEST_THREAD_ID, TEST_READ_FLAG_ONE, timestampSec, TEST_SUBJECT, PduHeaders.PRIORITY_HIGH, null }); doReturn(cursor) .when(mMapMethodProxy) .contentResolverQuery(any(), any(), any(), any(), any(), any()); Map<Long, BluetoothMapContentObserver.Msg> map = new HashMap<>(); // Giving a different handle for msg below and cursor above makes handleMsgListChangesMms() BluetoothMapContentObserver.Msg msg = new BluetoothMapContentObserver.Msg( TEST_HANDLE_TWO, TEST_INBOX_FOLDER_ID, TEST_READ_FLAG_ONE); map.put(TEST_HANDLE_TWO, msg); mObserver.setMsgListMms(map, true); mObserver.mMapEventReportVersion = BluetoothMapUtils.MAP_EVENT_REPORT_V12; mObserver.handleMsgListChangesMms(); Assert.assertEquals(null, mObserver.getMsgListMms().get(TEST_HANDLE_ONE)); } @Test Loading Loading @@ -1465,14 +1522,79 @@ public class BluetoothMapContentObserverTest { @Test public void handleMsgListChangesSms_withNonExistingOldMessage_andVersion12() { mSetFlagsRule.disableFlags(Flags.FLAG_MAP_LIMIT_NOTIFICATION); Calendar cal = Calendar.getInstance(); cal.add(Calendar.YEAR, -1); cal.add(Calendar.DATE, -1); MatrixCursor cursor = new MatrixCursor(new String[] {Sms._ID, Sms.TYPE, Sms.THREAD_ID, Sms.READ, Sms.DATE, Sms.BODY, Sms.ADDRESS}); cursor.addRow(new Object[] {TEST_HANDLE_ONE, TEST_SMS_TYPE_ALL, TEST_THREAD_ID, TEST_READ_FLAG_ONE, cal.getTimeInMillis(), "", null}); MatrixCursor cursor = new MatrixCursor( new String[] { Sms._ID, Sms.TYPE, Sms.THREAD_ID, Sms.READ, Sms.DATE, Sms.BODY, Sms.ADDRESS }); cursor.addRow( new Object[] { TEST_HANDLE_ONE, TEST_SMS_TYPE_ALL, TEST_THREAD_ID, TEST_READ_FLAG_ONE, cal.getTimeInMillis(), "", null }); doReturn(cursor) .when(mMapMethodProxy) .contentResolverQuery(any(), any(), any(), any(), any(), any()); Map<Long, BluetoothMapContentObserver.Msg> map = new HashMap<>(); // Giving a different handle for msg below and cursor above makes handleMsgListChangesMms() // function for a non-existing message BluetoothMapContentObserver.Msg msg = new BluetoothMapContentObserver.Msg( TEST_HANDLE_TWO, TEST_SMS_TYPE_INBOX, TEST_READ_FLAG_ONE); map.put(TEST_HANDLE_TWO, msg); mObserver.setMsgListSms(map, true); mObserver.mMapEventReportVersion = BluetoothMapUtils.MAP_EVENT_REPORT_V12; mObserver.handleMsgListChangesSms(); Assert.assertEquals(null, mObserver.getMsgListSms().get(TEST_HANDLE_ONE)); } @Test public void handleMsgListChangesSms_withNonExistingOldMessage_andVersion12_andOneWeekLimit() { mSetFlagsRule.enableFlags(Flags.FLAG_MAP_LIMIT_NOTIFICATION); Instant oldInstant = Instant.now() .minus(BluetoothMapContentObserver.NEW_MESSAGE_DURATION_FOR_NOTIFICATION); MatrixCursor cursor = new MatrixCursor( new String[] { Sms._ID, Sms.TYPE, Sms.THREAD_ID, Sms.READ, Sms.DATE, Sms.BODY, Sms.ADDRESS }); cursor.addRow( new Object[] { TEST_HANDLE_ONE, TEST_SMS_TYPE_ALL, TEST_THREAD_ID, TEST_READ_FLAG_ONE, oldInstant.toEpochMilli(), "", null }); doReturn(cursor).when(mMapMethodProxy).contentResolverQuery(any(), any(), any(), any(), any(), any()); Loading @@ -1487,7 +1609,7 @@ public class BluetoothMapContentObserverTest { mObserver.handleMsgListChangesSms(); Assert.assertEquals(mObserver.getMsgListSms().get(TEST_HANDLE_ONE), null); Assert.assertEquals(null, mObserver.getMsgListSms().get(TEST_HANDLE_ONE)); } @Test Loading Loading
android/app/src/com/android/bluetooth/map/BluetoothMapContentObserver.java +32 −12 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ import com.android.bluetooth.BluetoothMethodProxy; import com.android.bluetooth.BluetoothStatsLog; import com.android.bluetooth.Utils; import com.android.bluetooth.content_profiles.ContentProfileErrorReportUtils; import com.android.bluetooth.flags.Flags; import com.android.bluetooth.map.BluetoothMapUtils.TYPE; import com.android.bluetooth.map.BluetoothMapbMessageMime.MimePart; import com.android.bluetooth.mapapi.BluetoothMapContract; Loading @@ -74,6 +75,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; Loading @@ -92,6 +94,10 @@ public class BluetoothMapContentObserver { private static final boolean D = BluetoothMapService.DEBUG; private static final boolean V = BluetoothMapService.VERBOSE; // A message older than this will be ignored when notifying a new message. @VisibleForTesting static final Duration NEW_MESSAGE_DURATION_FOR_NOTIFICATION = Duration.ofDays(7); @VisibleForTesting static final String EVENT_TYPE_NEW = "NewMessage"; @VisibleForTesting Loading Loading @@ -1537,19 +1543,25 @@ public class BluetoothMapContentObserver { /* New message */ msg = new Msg(id, type, threadId, read); msgListSms.put(id, msg); listChanged = true; Event evt; if (mTransmitEvents && // extract contact details only if needed mMapEventReportVersion > BluetoothMapUtils.MAP_EVENT_REPORT_V10) { long timestamp = c.getLong(c.getColumnIndex(Sms.DATE)); String date = BluetoothMapUtils.getDateTimeString(timestamp); if (Flags.mapLimitNotification()) { if (BluetoothMapUtils.isDateTimeOlderThanDuration( timestamp, NEW_MESSAGE_DURATION_FOR_NOTIFICATION)) { msgListSms.remove(id); continue; } } else { if (BluetoothMapUtils.isDateTimeOlderThanOneYear(timestamp)) { // Skip sending message events older than one year listChanged = false; msgListSms.remove(id); continue; } } String subject = c.getString(c.getColumnIndex(Sms.BODY)); if (subject == null) { subject = ""; Loading Loading @@ -1591,6 +1603,7 @@ public class BluetoothMapContentObserver { evt = new Event(EVENT_TYPE_NEW, id, getSmsFolderName(type), null, mSmsType); } listChanged = true; sendEvent(evt); } else { /* Existing message */ Loading Loading @@ -1730,11 +1743,20 @@ public class BluetoothMapContentObserver { TimeUnit.SECONDS.toMillis( c.getLong(c.getColumnIndex(Mms.DATE))); String date = BluetoothMapUtils.getDateTimeString(timestamp); if (Flags.mapLimitNotification()) { if (BluetoothMapUtils.isDateTimeOlderThanDuration( timestamp, NEW_MESSAGE_DURATION_FOR_NOTIFICATION)) { msgListMms.remove(id); continue; } } else { if (BluetoothMapUtils.isDateTimeOlderThanOneYear(timestamp)) { // Skip sending new message events older than one year 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 */ Loading Loading @@ -3164,7 +3186,6 @@ public class BluetoothMapContentObserver { Uri uri = Mms.CONTENT_URI; synchronized (getMsgListMms()) { uri = mResolver.insert(uri, values); if (uri == null) { Loading Loading @@ -3412,7 +3433,6 @@ public class BluetoothMapContentObserver { public void sendMessage(PushMsgInfo msgInfo, String msgBody) { SmsManager smsMng = SmsManager.getDefault(); ArrayList<String> parts = smsMng.divideMessage(msgBody); msgInfo.parts = parts.size(); Loading
android/app/src/com/android/bluetooth/map/BluetoothMapUtils.java +9 −2 Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ import java.nio.charset.CodingErrorAction; import java.nio.charset.IllegalCharsetNameException; import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.time.Duration; import java.time.Instant; import java.util.Arrays; import java.util.BitSet; import java.util.Calendar; Loading Loading @@ -759,7 +761,6 @@ public class BluetoothMapUtils { } } static String getDateTimeString(long timestamp) { SimpleDateFormat format = (mPeerSupportUtcTimeStamp) ? new SimpleDateFormat("yyyyMMdd'T'HHmmssZ") : new SimpleDateFormat("yyyyMMdd'T'HHmmss"); Loading @@ -785,6 +786,12 @@ public class BluetoothMapUtils { return false; } static boolean isDateTimeOlderThanDuration(long timestamp, Duration duration) { Instant nowMinusDuration = Instant.now().minus(duration); Instant dateTime = Instant.ofEpochMilli(timestamp); return dateTime.isBefore(nowMinusDuration); } static void savePeerSupportUtcTimeStamp(int remoteFeatureMask) { if ((remoteFeatureMask & MAP_FEATURE_DEFINED_TIMESTAMP_FORMAT_BIT) == MAP_FEATURE_DEFINED_TIMESTAMP_FORMAT_BIT) { Loading
android/app/tests/unit/src/com/android/bluetooth/map/BluetoothMapContentObserverTest.java +128 −6 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.os.Handler; import android.os.Looper; import android.os.RemoteException; import android.os.UserManager; import android.platform.test.flag.junit.SetFlagsRule; import android.provider.ContactsContract; import android.provider.Telephony; import android.provider.Telephony.Mms; Loading @@ -43,6 +44,7 @@ import androidx.test.filters.MediumTest; import androidx.test.runner.AndroidJUnit4; import com.android.bluetooth.BluetoothMethodProxy; import com.android.bluetooth.flags.Flags; import com.android.bluetooth.map.BluetoothMapUtils.TYPE; import com.android.bluetooth.mapapi.BluetoothMapContract; import com.android.bluetooth.mapapi.BluetoothMapContract.MessageColumns; Loading @@ -64,6 +66,7 @@ import org.mockito.junit.MockitoRule; import java.io.IOException; import java.text.SimpleDateFormat; import java.time.Instant; import java.util.Calendar; import java.util.HashMap; import java.util.HashSet; Loading Loading @@ -119,6 +122,7 @@ public class BluetoothMapContentObserverTest { static final int TEST_LAST_ONLINE = 1; @Rule public MockitoRule mockitoRule = MockitoJUnit.rule(); @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Mock private BluetoothMnsObexClient mClient; Loading Loading @@ -1232,6 +1236,7 @@ public class BluetoothMapContentObserverTest { @Test public void handleMsgListChangesMms_withNonExistingOldMessage_andVersion12() { mSetFlagsRule.disableFlags(Flags.FLAG_MAP_LIMIT_NOTIFICATION); Calendar cal = Calendar.getInstance(); cal.add(Calendar.YEAR, -1); cal.add(Calendar.DATE, -1); Loading @@ -1257,7 +1262,59 @@ public class BluetoothMapContentObserverTest { mObserver.handleMsgListChangesMms(); Assert.assertEquals(mObserver.getMsgListMms().get(TEST_HANDLE_ONE), null); Assert.assertEquals(null, mObserver.getMsgListMms().get(TEST_HANDLE_ONE)); } @Test public void handleMsgListChangesMms_withNonExistingOldMessage_andVersion12_andOneWeekLimit() { mSetFlagsRule.enableFlags(Flags.FLAG_MAP_LIMIT_NOTIFICATION); Instant oldInstant = Instant.now() .minus(BluetoothMapContentObserver.NEW_MESSAGE_DURATION_FOR_NOTIFICATION); long timestampSec = oldInstant.getEpochSecond(); MatrixCursor cursor = new MatrixCursor( new String[] { Mms._ID, Mms.MESSAGE_BOX, Mms.MESSAGE_TYPE, Mms.THREAD_ID, Mms.READ, Mms.DATE, Mms.SUBJECT, Mms.PRIORITY, Mms.Addr.ADDRESS }); cursor.addRow( new Object[] { TEST_HANDLE_ONE, TEST_MMS_TYPE_ALL, TEST_MMS_MTYPE, TEST_THREAD_ID, TEST_READ_FLAG_ONE, timestampSec, TEST_SUBJECT, PduHeaders.PRIORITY_HIGH, null }); doReturn(cursor) .when(mMapMethodProxy) .contentResolverQuery(any(), any(), any(), any(), any(), any()); Map<Long, BluetoothMapContentObserver.Msg> map = new HashMap<>(); // Giving a different handle for msg below and cursor above makes handleMsgListChangesMms() BluetoothMapContentObserver.Msg msg = new BluetoothMapContentObserver.Msg( TEST_HANDLE_TWO, TEST_INBOX_FOLDER_ID, TEST_READ_FLAG_ONE); map.put(TEST_HANDLE_TWO, msg); mObserver.setMsgListMms(map, true); mObserver.mMapEventReportVersion = BluetoothMapUtils.MAP_EVENT_REPORT_V12; mObserver.handleMsgListChangesMms(); Assert.assertEquals(null, mObserver.getMsgListMms().get(TEST_HANDLE_ONE)); } @Test Loading Loading @@ -1465,14 +1522,79 @@ public class BluetoothMapContentObserverTest { @Test public void handleMsgListChangesSms_withNonExistingOldMessage_andVersion12() { mSetFlagsRule.disableFlags(Flags.FLAG_MAP_LIMIT_NOTIFICATION); Calendar cal = Calendar.getInstance(); cal.add(Calendar.YEAR, -1); cal.add(Calendar.DATE, -1); MatrixCursor cursor = new MatrixCursor(new String[] {Sms._ID, Sms.TYPE, Sms.THREAD_ID, Sms.READ, Sms.DATE, Sms.BODY, Sms.ADDRESS}); cursor.addRow(new Object[] {TEST_HANDLE_ONE, TEST_SMS_TYPE_ALL, TEST_THREAD_ID, TEST_READ_FLAG_ONE, cal.getTimeInMillis(), "", null}); MatrixCursor cursor = new MatrixCursor( new String[] { Sms._ID, Sms.TYPE, Sms.THREAD_ID, Sms.READ, Sms.DATE, Sms.BODY, Sms.ADDRESS }); cursor.addRow( new Object[] { TEST_HANDLE_ONE, TEST_SMS_TYPE_ALL, TEST_THREAD_ID, TEST_READ_FLAG_ONE, cal.getTimeInMillis(), "", null }); doReturn(cursor) .when(mMapMethodProxy) .contentResolverQuery(any(), any(), any(), any(), any(), any()); Map<Long, BluetoothMapContentObserver.Msg> map = new HashMap<>(); // Giving a different handle for msg below and cursor above makes handleMsgListChangesMms() // function for a non-existing message BluetoothMapContentObserver.Msg msg = new BluetoothMapContentObserver.Msg( TEST_HANDLE_TWO, TEST_SMS_TYPE_INBOX, TEST_READ_FLAG_ONE); map.put(TEST_HANDLE_TWO, msg); mObserver.setMsgListSms(map, true); mObserver.mMapEventReportVersion = BluetoothMapUtils.MAP_EVENT_REPORT_V12; mObserver.handleMsgListChangesSms(); Assert.assertEquals(null, mObserver.getMsgListSms().get(TEST_HANDLE_ONE)); } @Test public void handleMsgListChangesSms_withNonExistingOldMessage_andVersion12_andOneWeekLimit() { mSetFlagsRule.enableFlags(Flags.FLAG_MAP_LIMIT_NOTIFICATION); Instant oldInstant = Instant.now() .minus(BluetoothMapContentObserver.NEW_MESSAGE_DURATION_FOR_NOTIFICATION); MatrixCursor cursor = new MatrixCursor( new String[] { Sms._ID, Sms.TYPE, Sms.THREAD_ID, Sms.READ, Sms.DATE, Sms.BODY, Sms.ADDRESS }); cursor.addRow( new Object[] { TEST_HANDLE_ONE, TEST_SMS_TYPE_ALL, TEST_THREAD_ID, TEST_READ_FLAG_ONE, oldInstant.toEpochMilli(), "", null }); doReturn(cursor).when(mMapMethodProxy).contentResolverQuery(any(), any(), any(), any(), any(), any()); Loading @@ -1487,7 +1609,7 @@ public class BluetoothMapContentObserverTest { mObserver.handleMsgListChangesSms(); Assert.assertEquals(mObserver.getMsgListSms().get(TEST_HANDLE_ONE), null); Assert.assertEquals(null, mObserver.getMsgListSms().get(TEST_HANDLE_ONE)); } @Test Loading