Fixed crash when receiving ETWS message

Bug: 144139977
Test: CellBroadcastServiceTest
Merged-In: Icfbf6d0aacb0a1027d1f3cc2e3aafacde24d0698
Change-Id: Icfbf6d0aacb0a1027d1f3cc2e3aafacde24d0698
(cherry picked from commit 35a054022108156e5b641becaeee34b5b8157527)
diff --git a/src/com/android/cellbroadcastservice/CellBroadcastHandler.java b/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
index efbc4ea..8ca6d1b 100644
--- a/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
+++ b/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
@@ -67,6 +67,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -364,7 +365,7 @@
                         && message.getEtwsWarningInfo().isPrimary()
                         != messageToCheck.getEtwsWarningInfo().isPrimary()) {
                     // Not a dup. Check next one.
-                    log("Service category check. Not a dup. " + messageToCheck);
+                    log("ETWS primary check. Not a dup. " + messageToCheck);
                     continue;
                 }
 
@@ -372,12 +373,13 @@
                 // messages on different techs (i.e. GSM / CDMA), so we need to compare service
                 // category cross techs.
                 if (message.getServiceCategory() != messageToCheck.getServiceCategory()
-                        && mServiceCategoryCrossRATMap.get(message.getServiceCategory())
-                        != messageToCheck.getServiceCategory()
-                        && mServiceCategoryCrossRATMap.get(messageToCheck.getServiceCategory())
-                        != message.getServiceCategory()) {
+                        && !Objects.equals(mServiceCategoryCrossRATMap.get(
+                                message.getServiceCategory()), messageToCheck.getServiceCategory())
+                        && !Objects.equals(mServiceCategoryCrossRATMap.get(
+                                messageToCheck.getServiceCategory()),
+                        message.getServiceCategory())) {
                     // Not a dup. Check next one.
-                    log("ETWS primary check. Not a dup. " + messageToCheck);
+                    log("Service category check. Not a dup. " + messageToCheck);
                     continue;
                 }