Loading android/app/src/com/android/bluetooth/map/BluetoothMapContentObserver.java +9 −25 Original line number Diff line number Diff line Loading @@ -57,7 +57,6 @@ 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 Loading @@ -1558,19 +1557,12 @@ public class BluetoothMapContentObserver { > 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 msgListSms.remove(id); continue; } } String subject = c.getString(c.getColumnIndex(Sms.BODY)); if (subject == null) { subject = ""; Loading Loading @@ -1813,19 +1805,11 @@ 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) { Loading android/app/src/com/android/bluetooth/map/BluetoothMapUtils.java +0 −17 Original line number Diff line number Diff line Loading @@ -755,23 +755,6 @@ 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.before(oneYearAgo)) { Log.v( TAG, "isDateTimeOlderThanOneYear " + cal.getTimeInMillis() + " oneYearAgo: " + oneYearAgo.getTimeInMillis()); return true; } return false; } static boolean isDateTimeOlderThanDuration(long timestamp, Duration duration) { Instant nowMinusDuration = Instant.now().minus(duration); Instant dateTime = Instant.ofEpochMilli(timestamp); Loading android/app/tests/unit/src/com/android/bluetooth/map/BluetoothMapContentObserverTest.java +0 −101 Original line number Diff line number Diff line Loading @@ -1458,61 +1458,8 @@ public class BluetoothMapContentObserverTest { mObserver.getMsgListMms().get(TEST_HANDLE_ONE).flagRead, TEST_READ_FLAG_ONE); } @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); long timestampSec = TimeUnit.MILLISECONDS.toSeconds(cal.getTimeInMillis()); 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() // function for a non-existing message 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 public void handleMsgListChangesMms_withNonExistingOldMessage_andVersion12_andOneWeekLimit() { mSetFlagsRule.enableFlags(Flags.FLAG_MAP_LIMIT_NOTIFICATION); Instant oldInstant = Instant.now() .minus(BluetoothMapContentObserver.NEW_MESSAGE_DURATION_FOR_NOTIFICATION); Loading Loading @@ -1860,56 +1807,8 @@ public class BluetoothMapContentObserverTest { mObserver.getMsgListSms().get(TEST_HANDLE_ONE).flagRead, TEST_READ_FLAG_ONE); } @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 }); 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); Loading flags/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ aconfig_declarations { "l2cap.aconfig", "le_advertising.aconfig", "leaudio.aconfig", "map.aconfig", "mapclient.aconfig", "mcp.aconfig", "metric.aconfig", Loading flags/BUILD.gn +0 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ aconfig("bluetooth_flags_c_lib") { "l2cap.aconfig", "le_advertising.aconfig", "leaudio.aconfig", "map.aconfig", "mapclient.aconfig", "mcp.aconfig", "metric.aconfig", Loading Loading
android/app/src/com/android/bluetooth/map/BluetoothMapContentObserver.java +9 −25 Original line number Diff line number Diff line Loading @@ -57,7 +57,6 @@ 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 Loading @@ -1558,19 +1557,12 @@ public class BluetoothMapContentObserver { > 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 msgListSms.remove(id); continue; } } String subject = c.getString(c.getColumnIndex(Sms.BODY)); if (subject == null) { subject = ""; Loading Loading @@ -1813,19 +1805,11 @@ 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) { Loading
android/app/src/com/android/bluetooth/map/BluetoothMapUtils.java +0 −17 Original line number Diff line number Diff line Loading @@ -755,23 +755,6 @@ 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.before(oneYearAgo)) { Log.v( TAG, "isDateTimeOlderThanOneYear " + cal.getTimeInMillis() + " oneYearAgo: " + oneYearAgo.getTimeInMillis()); return true; } return false; } static boolean isDateTimeOlderThanDuration(long timestamp, Duration duration) { Instant nowMinusDuration = Instant.now().minus(duration); Instant dateTime = Instant.ofEpochMilli(timestamp); Loading
android/app/tests/unit/src/com/android/bluetooth/map/BluetoothMapContentObserverTest.java +0 −101 Original line number Diff line number Diff line Loading @@ -1458,61 +1458,8 @@ public class BluetoothMapContentObserverTest { mObserver.getMsgListMms().get(TEST_HANDLE_ONE).flagRead, TEST_READ_FLAG_ONE); } @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); long timestampSec = TimeUnit.MILLISECONDS.toSeconds(cal.getTimeInMillis()); 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() // function for a non-existing message 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 public void handleMsgListChangesMms_withNonExistingOldMessage_andVersion12_andOneWeekLimit() { mSetFlagsRule.enableFlags(Flags.FLAG_MAP_LIMIT_NOTIFICATION); Instant oldInstant = Instant.now() .minus(BluetoothMapContentObserver.NEW_MESSAGE_DURATION_FOR_NOTIFICATION); Loading Loading @@ -1860,56 +1807,8 @@ public class BluetoothMapContentObserverTest { mObserver.getMsgListSms().get(TEST_HANDLE_ONE).flagRead, TEST_READ_FLAG_ONE); } @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 }); 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); Loading
flags/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ aconfig_declarations { "l2cap.aconfig", "le_advertising.aconfig", "leaudio.aconfig", "map.aconfig", "mapclient.aconfig", "mcp.aconfig", "metric.aconfig", Loading
flags/BUILD.gn +0 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ aconfig("bluetooth_flags_c_lib") { "l2cap.aconfig", "le_advertising.aconfig", "leaudio.aconfig", "map.aconfig", "mapclient.aconfig", "mcp.aconfig", "metric.aconfig", Loading