summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-01-10 19:01:28 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-01-10 19:01:28 +0000
commitf4a9b289c31e479fd7690605b7f56e67876c1c80 (patch)
tree3d32d8391cf8c4d7e3f7daec9f1c90a7130b5c61
parent9317fef435c070285a6f1c586361846483817c7d (diff)
parent6f38bbc1582b50ae5a9f58268c28ba39125ee097 (diff)
downloadCellBroadcastService-aml_tz5_341510010.tar.gz
Snap for 11296156 from 6f38bbc1582b50ae5a9f58268c28ba39125ee097 to mainline-tzdata5-releaseaml_tz5_341510070aml_tz5_341510050aml_tz5_341510010aml_tz5_341510010
Change-Id: Ibb543bc258f3145c67085f72e6738d110ee7d737
-rw-r--r--res/values-pa/strings.xml2
-rw-r--r--src/com/android/cellbroadcastservice/CellBroadcastHandler.java2
-rw-r--r--tests/src/com/android/cellbroadcastservice/tests/CellBroadcastHandlerTest.java38
3 files changed, 40 insertions, 2 deletions
diff --git a/res/values-pa/strings.xml b/res/values-pa/strings.xml
index 636ec6c..461b50f 100644
--- a/res/values-pa/strings.xml
+++ b/res/values-pa/strings.xml
@@ -20,5 +20,5 @@
<string name="etws_primary_default_message_tsunami" msgid="2521384573822842618">"ਤੁਰੰਤ ਤੱਟੀ ਖੇਤਰਾਂ ਅਤੇ ਨਦੀ ਦੇ ਕਿਨਾਰੇ ਵਾਲੇ ਖੇਤਰਾਂ ਨੂੰ ਖਾਲੀ ਕਰ ਕੇ ਕਿਸੇ ਸੁਰੱਖਿਅਤ ਸਥਾਨ \'ਤੇ ਚਲੇ ਜਾਓ ਜਿਵੇਂ ਕਿ ਉੱਚੀ ਜ਼ਮੀਨ।"</string>
<string name="etws_primary_default_message_earthquake_and_tsunami" msgid="7826176257527823396">"ਸ਼ਾਂਤ ਰਹੋ ਅਤੇ ਆਸ-ਪਾਸ ਪਨਾਹ ਮੰਗੋ।"</string>
<string name="etws_primary_default_message_test" msgid="2739829278266087553">"ਸੰਕਟਕਾਲੀਨ ਸੰਦੇਸ਼ ਟੈਸਟ"</string>
- <string name="etws_primary_default_message_others" msgid="3271611843755121534">"ਸਥਾਨਕ ਸਰਕਾਰ ਵੱਲੋਂ ਸੁਚੇਤਨਾ ਜਾਰੀ ਕੀਤੀ ਗਈ। ਹੋਰ ਜਾਣਕਾਰੀ ਜਲਦ ਹੀ ਆ ਰਹੀ ਹੈ।"</string>
+ <string name="etws_primary_default_message_others" msgid="3271611843755121534">"ਸਥਾਨਕ ਸਰਕਾਰ ਵੱਲੋਂ ਅਲਰਟ ਜਾਰੀ ਕੀਤਾ ਗਿਆ। ਹੋਰ ਜਾਣਕਾਰੀ ਜਲਦ ਹੀ ਆ ਰਹੀ ਹੈ।"</string>
</resources>
diff --git a/src/com/android/cellbroadcastservice/CellBroadcastHandler.java b/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
index 550bd73..3113e87 100644
--- a/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
+++ b/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
@@ -564,7 +564,7 @@ public class CellBroadcastHandler extends WakeLockStateMachine {
// If messages are from different slots, then we only compare the message body.
if (VDBG) log("Checking the message " + messageToCheck);
if (crossSimDuplicateDetection
- && message.getSlotIndex() != messageToCheck.getSlotIndex()) {
+ && message.getSubscriptionId() != messageToCheck.getSubscriptionId()) {
if (TextUtils.equals(message.getMessageBody(), messageToCheck.getMessageBody())) {
log("Duplicate message detected from different slot. " + message);
return true;
diff --git a/tests/src/com/android/cellbroadcastservice/tests/CellBroadcastHandlerTest.java b/tests/src/com/android/cellbroadcastservice/tests/CellBroadcastHandlerTest.java
index bf8b661..2764504 100644
--- a/tests/src/com/android/cellbroadcastservice/tests/CellBroadcastHandlerTest.java
+++ b/tests/src/com/android/cellbroadcastservice/tests/CellBroadcastHandlerTest.java
@@ -349,6 +349,44 @@ public class CellBroadcastHandlerTest extends CellBroadcastServiceTestBase {
@Test
@SmallTest
+ public void testCrossSimDuplicateDetection() throws Exception {
+ int differentSlotID = 1;
+ int differentSubID = 2;
+
+ // enable cross_sim_duplicate_detection
+ putResources(com.android.cellbroadcastservice.R.bool.cross_sim_duplicate_detection, true);
+
+ // The message with different subId will be detected as duplication.
+ SmsCbMessage msg1 = new SmsCbMessage(SmsCbMessage.MESSAGE_FORMAT_3GPP,
+ 0, 1234, new SmsCbLocation("311480", 0, 0),
+ 4370, "en", "Test Message", 3,
+ null, null, 0, differentSubID);
+ assertTrue(mCellBroadcastHandler.isDuplicate(msg1));
+
+ // The message with different body won't be detected as a duplication.
+ SmsCbMessage msg2 = new SmsCbMessage(SmsCbMessage.MESSAGE_FORMAT_3GPP,
+ 0, 1234, new SmsCbLocation("311480", 0, 0),
+ 4370, "en", "Different Message", 3,
+ null, null, 0, differentSubID);
+ assertFalse(mCellBroadcastHandler.isDuplicate(msg2));
+
+ // The message with different slotId will be detected as a duplication.
+ SmsCbMessage msg3 = new SmsCbMessage(SmsCbMessage.MESSAGE_FORMAT_3GPP,
+ 0, 1234, new SmsCbLocation("311480", 0, 0),
+ 4370, "en", "Test Message", 3,
+ null, null, differentSlotID, 1);
+ assertTrue(mCellBroadcastHandler.isDuplicate(msg3));
+
+ // The message with different slotId and body will be detected as a duplication.
+ SmsCbMessage msg4 = new SmsCbMessage(SmsCbMessage.MESSAGE_FORMAT_3GPP,
+ 0, 1234, new SmsCbLocation("311480", 0, 0),
+ 4370, "en", "Different Message", 3,
+ null, null, differentSlotID, 1);
+ assertTrue(mCellBroadcastHandler.isDuplicate(msg4));
+ }
+
+ @Test
+ @SmallTest
public void testGetResources() throws Exception {
// verify not to call SubscriptionManager#getResourcesForSubId for DEFAULT ID
mCellBroadcastHandler.getResources(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID);