Merge "Ignore alerts in ECBM for VzW"
diff --git a/res/values-mcc310-mnc012/config.xml b/res/values-mcc310-mnc012/config.xml
new file mode 100644
index 0000000..2371467
--- /dev/null
+++ b/res/values-mcc310-mnc012/config.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources>
+    <!-- Whether to ignore any alert message in ECBM(Emergency Callback Mode) -->
+    <bool name="ignore_messages_in_ecbm">true</bool>
+</resources>
diff --git a/res/values-mcc311-mnc480 b/res/values-mcc311-mnc480
new file mode 120000
index 0000000..4313b51
--- /dev/null
+++ b/res/values-mcc311-mnc480
@@ -0,0 +1 @@
+values-mcc310-mnc012
\ No newline at end of file
diff --git a/res/values/config.xml b/res/values/config.xml
index 6ba6bb1..887c162 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -31,6 +31,8 @@
     <bool name="reset_duplicate_detection_on_airplane_mode">false</bool>
     <!-- Whether to show CMAS messages by in a different order than received by prioritizing them -->
     <bool name="show_cmas_messages_in_priority_order">false</bool>
+    <!-- Whether to ignore any alert message in ECBM(Emergency Callback Mode) -->
+    <bool name="ignore_messages_in_ecbm">false</bool>
 
     <!-- 4370, 4383 -->
     <string-array name="cmas_presidential_alerts_channels_range_strings" translatable="false">
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
index 9a43888..209fa96 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
@@ -46,6 +46,7 @@
 import android.telephony.SmsCbLocation;
 import android.telephony.SmsCbMessage;
 import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
 import android.text.TextUtils;
 import android.util.Log;
 
@@ -246,6 +247,19 @@
      * @return True if the message should be displayed to the user
      */
     private boolean shouldDisplayMessage(CellBroadcastMessage cbm) {
+        TelephonyManager tm =
+                ((TelephonyManager)
+                                getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE))
+                        .createForSubscriptionId(cbm.getSubId());
+        if (tm.getEmergencyCallbackMode()
+                && CellBroadcastSettings.getResourcesForDefaultSmsSubscriptionId(
+                                getApplicationContext())
+                        .getBoolean(R.bool.ignore_messages_in_ecbm)) {
+            // Ignore the message in ECBM.
+            // It is for LTE only mode. For 1xRTT, incoming pages should be ignored in the modem.
+            Log.d(TAG, "ignoring alert of type " + cbm.getServiceCategory() + " in ECBM");
+            return false;
+        }
         // Check if the channel is enabled by the user or configuration.
         if (!isChannelEnabled(cbm)) {
             Log.d(TAG, "ignoring alert of type " + cbm.getServiceCategory()