diff options
author | Rika Brooks <rbrooks@codeaurora.org> | 2012-09-20 15:52:58 -0700 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2014-02-17 17:13:45 -0800 |
commit | 0d7ab2b8d4d3eedc1c32ad17c684b13381c7d4e3 (patch) | |
tree | aa9091038aa0d78e78113269f3dd119e51296348 | |
parent | 764f55efed6d388122ebebf9fc138f1f96ef2896 (diff) | |
download | android_packages_apps_CellBroadcastReceiver-0d7ab2b8d4d3eedc1c32ad17c684b13381c7d4e3.tar.gz android_packages_apps_CellBroadcastReceiver-0d7ab2b8d4d3eedc1c32ad17c684b13381c7d4e3.tar.bz2 android_packages_apps_CellBroadcastReceiver-0d7ab2b8d4d3eedc1c32ad17c684b13381c7d4e3.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
(cherry picked from commit d39c79169dac8773281b5b5f7e6bba073e269e94)
(cherry picked from commit ad167a8ffbaa1dd84fb5266f156b29a7cdea5298)
(cherry picked from commit 0f7cac5c8005eb4bb9d7d5d0ff23ae62f5c07944)
-rw-r--r-- | src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java index 75907c9f..af9da338 100644 --- a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java +++ b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java @@ -27,6 +27,7 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.os.IBinder; import android.os.UserHandle; +import android.os.SystemProperties; import android.preference.PreferenceManager; import android.provider.Telephony; import android.telephony.CellBroadcastMessage; @@ -56,6 +57,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 message ID and geographical scope, for duplicate message detection. */ private static final class MessageServiceCategoryAndScope { @@ -145,31 +151,33 @@ public class CellBroadcastAlertService extends Service { return; } - // 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()); - - // 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()); + + // 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); |