diff options
author | Rika Brooks <rbrooks@codeaurora.org> | 2012-09-20 15:52:58 -0700 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:30:16 -0600 |
commit | 06c032e55efefe673fff9326cd4603c8c434d450 (patch) | |
tree | 1076791bc008d40fb821d897bb89dbba86d4573d | |
parent | f638759f83f2dabad707ad87a325ffe462a77ed7 (diff) | |
download | android_packages_apps_CellBroadcastReceiver-06c032e55efefe673fff9326cd4603c8c434d450.tar.gz android_packages_apps_CellBroadcastReceiver-06c032e55efefe673fff9326cd4603c8c434d450.tar.bz2 android_packages_apps_CellBroadcastReceiver-06c032e55efefe673fff9326cd4603c8c434d450.zip |
CB: Add system property to enable/disable dup detection
If system property persist.cb.dup_detection is set to false, duplicate
detection is disabled. If it is set to true, duplicate detection is
enabled. If the system property does not exist, using true/enabled
as a default value
Change-Id: If377675c46950b4a03253fa29c2d8ae1c5804544
-rw-r--r-- | src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java index 535a1836..3a669ff0 100644 --- a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java +++ b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java @@ -28,6 +28,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.os.UserHandle; +import android.os.SystemProperties; import android.provider.Telephony; import android.telephony.CellBroadcastMessage; import android.telephony.SmsCbCmasInfo; @@ -58,6 +59,11 @@ public class CellBroadcastAlertService extends Service { /** Sticky broadcast for latest area info broadcast received. */ static final String CB_AREA_INFO_RECEIVED_ACTION = "android.cellbroadcastreceiver.CB_AREA_INFO_RECEIVED"; + /** system property to enable/disable broadcast duplicate detecion. */ + private static final String CB_DUP_DETECTION = "persist.cb.dup_detection"; + + /** Check for system property to enable/disable duplicate detection. */ + static boolean mUseDupDetection = SystemProperties.getBoolean(CB_DUP_DETECTION, true); /** * Container for service category, serial number, location, and message body hash code for @@ -175,33 +181,35 @@ public class CellBroadcastAlertService extends Service { // and category should be used for duplicate detection. int hashCode = message.isEtwsMessage() ? message.getMessageBody().hashCode() : 0; - // Check for duplicate message IDs according to CMAS carrier requirements. Message IDs - // are stored in volatile memory. If the maximum of 65535 messages is reached, the - // message ID of the oldest message is deleted from the list. - MessageServiceCategoryAndScope newCmasId = new MessageServiceCategoryAndScope( - message.getServiceCategory(), message.getSerialNumber(), message.getLocation(), - hashCode); - - // Add the new message ID to the list. It's okay if this is a duplicate message ID, - // because the list is only used for removing old message IDs from the hash set. - if (sCmasIdList.size() < MAX_MESSAGE_ID_SIZE) { - sCmasIdList.add(newCmasId); - } else { - // Get oldest message ID from the list and replace with the new message ID. - MessageServiceCategoryAndScope oldestCmasId = sCmasIdList.get(sCmasIdListIndex); - sCmasIdList.set(sCmasIdListIndex, newCmasId); - Log.d(TAG, "message ID limit reached, removing oldest message ID " + oldestCmasId); - // Remove oldest message ID from the set. - sCmasIdSet.remove(oldestCmasId); - if (++sCmasIdListIndex >= MAX_MESSAGE_ID_SIZE) { - sCmasIdListIndex = 0; + if (mUseDupDetection) { + // Check for duplicate message IDs according to CMAS carrier requirements. Message IDs + // are stored in volatile memory. If the maximum of 65535 messages is reached, the + // message ID of the oldest message is deleted from the list. + MessageServiceCategoryAndScope newCmasId = new MessageServiceCategoryAndScope( + message.getServiceCategory(), message.getSerialNumber(), message.getLocation(), + hashCode); + + // Add the new message ID to the list. It's okay if this is a duplicate message ID, + // because the list is only used for removing old message IDs from the hash set. + if (sCmasIdList.size() < MAX_MESSAGE_ID_SIZE) { + sCmasIdList.add(newCmasId); + } else { + // Get oldest message ID from the list and replace with the new message ID. + MessageServiceCategoryAndScope oldestCmasId = sCmasIdList.get(sCmasIdListIndex); + sCmasIdList.set(sCmasIdListIndex, newCmasId); + Log.d(TAG, "message ID limit reached, removing oldest message ID " + oldestCmasId); + // Remove oldest message ID from the set. + sCmasIdSet.remove(oldestCmasId); + if (++sCmasIdListIndex >= MAX_MESSAGE_ID_SIZE) { + sCmasIdListIndex = 0; + } + } + // Set.add() returns false if message ID has already been added + if (!sCmasIdSet.add(newCmasId)) { + Log.d(TAG, "ignoring duplicate alert with " + newCmasId); + return; } } - // Set.add() returns false if message ID has already been added - if (!sCmasIdSet.add(newCmasId)) { - Log.d(TAG, "ignoring duplicate alert with " + newCmasId); - return; - } final Intent alertIntent = new Intent(SHOW_NEW_ALERT_ACTION); alertIntent.setClass(this, CellBroadcastAlertService.class); |