Merge "Made message body duplicate detection customizable"
am: 07a1624c45

Change-Id: I9e1de65d74f55391cc6ae481bc204f5c2a6f1b18
diff --git a/res/values-mcc440/config.xml b/res/values-mcc440/config.xml
index 6a80539..31a8fcd 100644
--- a/res/values-mcc440/config.xml
+++ b/res/values-mcc440/config.xml
@@ -21,4 +21,6 @@
     <!-- Whether to always sound CBS alerts at full volume -->
     <!-- By default it's true for Japanese users -->
     <bool name="use_full_volume">true</bool>
+    <!-- Whether to compare message body when performing message duplicate dection -->
+    <bool name="duplicate_compare_body">true</bool>
 </resources>
diff --git a/res/values-mcc441/config.xml b/res/values-mcc441/config.xml
index ca58e7f..31a8fcd 100644
--- a/res/values-mcc441/config.xml
+++ b/res/values-mcc441/config.xml
@@ -18,4 +18,9 @@
     <!-- Whether to enable CMAS settings (United States) -->
     <!-- No need to show this for Japanese users -->
     <bool name="show_cmas_settings">false</bool>
+    <!-- Whether to always sound CBS alerts at full volume -->
+    <!-- By default it's true for Japanese users -->
+    <bool name="use_full_volume">true</bool>
+    <!-- Whether to compare message body when performing message duplicate dection -->
+    <bool name="duplicate_compare_body">true</bool>
 </resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index db592ae..0e4d2ac 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -27,4 +27,6 @@
     <string-array name="additional_cbs_channels_strings" translatable="false"></string-array>
     <!-- Emergecny alert tone duration in milliseconds. -1 indicates playing the tone with the tone's duration -->
     <integer name="alert_duration">-1</integer>
+    <!-- Whether to compare message body when performing message duplicate dection -->
+    <bool name="duplicate_compare_body">false</bool>
 </resources>
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
index ed909d1..2c610e6 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
@@ -244,12 +244,11 @@
             return;
         }
 
-        // If this is an ETWS message, then we want to include the body message to be a factor for
-        // duplication detection. We found that some Japanese carriers send ETWS messages
-        // with the same serial number, therefore the subsequent messages were all ignored.
-        // In the other hand, US carriers have the requirement that only serial number, location,
-        // and category should be used for duplicate detection.
-        int hashCode = message.isEtwsMessage() ? message.getMessageBody().hashCode() : 0;
+        // Check if message body should be used for duplicate detection.
+        boolean shouldCompareMessageBody =
+                getApplicationContext().getResources().getBoolean(R.bool.duplicate_compare_body);
+
+        int hashCode = shouldCompareMessageBody ? message.getMessageBody().hashCode() : 0;
 
         // If this is an ETWS message, we need to include primary/secondary message information to
         // be a factor for duplication detection as well. Per 3GPP TS 23.041 section 8.2,