Update CMAS duplicate message detection for carrier requirement.

There is a carrier requirement for CMAS to use only an in-memory
table for duplicate message ID detection. When the max number of
65535 messages is received, the oldest message ID is removed from
the list. After a reboot, a previously received message ID will be
considered a new message. This is required for CMAS lab testing.

The app does not care if there are multiple rows in the SQLite DB
with the same message ID, because the primary key is a unique ID.
Remove the duplicate message detection from the CBContentProvider
and use only the in-memory duplicate detection in CBAlertService.
This is safe for other types of alerts such as ETWS, and has the
benefit that a new alert will not be suppressed due to a very old
alert with the same message ID that was never deleted from the DB.

Message IDs are now stored in an ArrayList as well as a HashSet
in CellBroadcastAlertService. When the 65535 message limit is
reached, an index is used into the ArrayList to remove the oldest
message ID from the HashSet. The new message ID replaces the old
one in the ArrayList, so the size stays fixed at 65535 entries and
no array copies are needed to replace the oldest message ID.

Bug: 7045601
Change-Id: I2d08bf8131aa473648c5810913b62baa09a97756
2 files changed