Merge "Fix flaky test"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 153ece2..d61e939 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -107,23 +107,16 @@
         <activity android:name="CellBroadcastOptOutActivity"
                   android:exported="false" />
 
-        <!-- Require sender permissions to prevent SMS spoofing -->
-        <receiver android:name="PrivilegedCellBroadcastReceiver"
-            android:permission="android.permission.BROADCAST_SMS">
+        <receiver android:name="CellBroadcastReceiver">
             <intent-filter>
+                <action android:name="android.telephony.action.DEFAULT_SMS_SUBSCRIPTION_CHANGED" />
+                <action android:name="android.telephony.action.CARRIER_CONFIG_CHANGED" />
                 <action android:name="android.provider.action.SMS_EMERGENCY_CB_RECEIVED" />
                 <action android:name="android.provider.Telephony.SMS_CB_RECEIVED" />
                 <action android:name="android.cellbroadcastreceiver.START_CONFIG" />
                 <action android:name="android.provider.Telephony.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED" />
                 <action android:name="android.intent.action.LOCALE_CHANGED" />
             </intent-filter>
-        </receiver>
-
-        <receiver android:name="CellBroadcastReceiver">
-            <intent-filter>
-                <action android:name="android.telephony.action.DEFAULT_SMS_SUBSCRIPTION_CHANGED" />
-                <action android:name="android.telephony.action.CARRIER_CONFIG_CHANGED" />
-            </intent-filter>
             <intent-filter>
                 <action android:name="android.telephony.action.SECRET_CODE" />
                 <!-- CMAS: To toggle test mode for cell broadcast testing on userdebug build -->
diff --git a/AndroidManifest_Platform.xml b/AndroidManifest_Platform.xml
index 0fabc80..c9a89b2 100644
--- a/AndroidManifest_Platform.xml
+++ b/AndroidManifest_Platform.xml
@@ -103,20 +103,13 @@
     <activity android:name="CellBroadcastOptOutActivity"
         android:exported="false" />
 
-    <!-- Require sender permissions to prevent SMS spoofing -->
-    <receiver android:name="PrivilegedCellBroadcastReceiver"
-        android:permission="android.permission.BROADCAST_SMS">
+    <receiver android:name="CellBroadcastReceiver">
       <intent-filter>
         <action android:name="android.provider.action.SMS_EMERGENCY_CB_RECEIVED" />
         <action android:name="android.provider.Telephony.SMS_CB_RECEIVED" />
         <action android:name="android.cellbroadcastreceiver.START_CONFIG" />
         <action android:name="android.provider.Telephony.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED" />
         <action android:name="android.intent.action.LOCALE_CHANGED" />
-      </intent-filter>
-    </receiver>
-
-    <receiver android:name="CellBroadcastReceiver">
-      <intent-filter>
         <action android:name="android.telephony.action.DEFAULT_SMS_SUBSCRIPTION_CHANGED" />
         <action android:name="android.telephony.action.CARRIER_CONFIG_CHANGED" />
       </intent-filter>
diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/res/values-mcc204/config.xml b/res/values-mcc204/config.xml
index 5a51d1a..426d0e0 100644
--- a/res/values-mcc204/config.xml
+++ b/res/values-mcc204/config.xml
@@ -15,8 +15,13 @@
 -->
 
 <resources>
-    <!-- Whether to enable CMAS settings -->
-    <bool name="show_cmas_settings">false</bool>
+    <!-- Whether to show extreme alert settings -->
+    <bool name="show_extreme_alert_settings">false</bool>
+    <!-- Whether to show severe alert settings -->
+    <bool name="show_severe_alert_settings">false</bool>
+    <!-- Whether to show amber alert settings -->
+    <bool name="show_amber_alert_settings">false</bool>
+
     <!-- 4372 -->
     <string-array name="cmas_alert_extreme_channels_range_strings" translatable="false">
         <item>0x1114:rat=gsm, emergency=true</item>
diff --git a/res/values-mcc226/config.xml b/res/values-mcc226/config.xml
index dd1c7d6..e29c287 100644
--- a/res/values-mcc226/config.xml
+++ b/res/values-mcc226/config.xml
@@ -16,7 +16,7 @@
 
 <resources>
     <!-- Whether to display presidential alert in the settings -->
-    <bool name="show_presidential_alerts_in_settings">true</bool>
+    <bool name="show_presidential_alerts_settings">true</bool>
     <!-- 4370 -->
     <string-array name="cmas_presidential_alerts_channels_range_strings" translatable="false">
         <item>0x1112:rat=gsm, emergency=true</item>
diff --git a/res/values-mcc310-mnc410/config.xml b/res/values-mcc310-mnc410/config.xml
index b52df5b..e988997 100644
--- a/res/values-mcc310-mnc410/config.xml
+++ b/res/values-mcc310-mnc410/config.xml
@@ -15,6 +15,8 @@
 -->
 
 <resources>
+    <!-- Whether to display presidential alert in the settings -->
+    <bool name="show_presidential_alerts_settings">true</bool>
     <!-- Show timestamp of the alert -->
     <bool name="show_date_time_title">true</bool>
     <!-- Whether to show CMAS messages by in a different order than received by prioritizing them -->
diff --git a/res/values-mcc310/config.xml b/res/values-mcc310/config.xml
index edcd0fb..2def4de 100644
--- a/res/values-mcc310/config.xml
+++ b/res/values-mcc310/config.xml
@@ -15,9 +15,6 @@
 -->
 
 <resources>
-    <!-- Preference title for other test alerts checkbox. [CHAR LIMIT=50] -->
-    <string name="enable_cmas_test_alerts_title">Other tests</string>
-
     <!-- Specify second language code to receive emergency alerts -->
     <string name="emergency_alert_second_language_code" translatable="false">es</string>
     <!-- 4370, 4383 -->
diff --git a/res/values-mcc310/strings.xml b/res/values-mcc310/strings.xml
index e883d78..5d5704e 100644
--- a/res/values-mcc310/strings.xml
+++ b/res/values-mcc310/strings.xml
@@ -16,6 +16,9 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- Preference title for other test alerts checkbox. [CHAR LIMIT=50] -->
+    <string name="enable_cmas_test_alerts_title">Other tests</string>
+
     <!-- Show additional language on/off switch in settings -->
     <!-- Preference title for enable CMAS second language checkbox. [CHAR LIMIT=50] -->
     <string name="receive_cmas_in_second_language_title">Spanish</string>
diff --git a/res/values-mcc420/config.xml b/res/values-mcc420/config.xml
index b64f791..7acbfba 100644
--- a/res/values-mcc420/config.xml
+++ b/res/values-mcc420/config.xml
@@ -15,9 +15,13 @@
 -->
 
 <resources>
-    <!-- Whether to enable CMAS settings (United States) -->
-    <!-- No need to show this for Saudi users -->
-    <bool name="show_cmas_settings">false</bool>
+    <!-- Whether to show extreme alert settings -->
+    <bool name="show_extreme_alert_settings">false</bool>
+    <!-- Whether to show severe alert settings -->
+    <bool name="show_severe_alert_settings">false</bool>
+    <!-- Whether to show amber alert settings -->
+    <bool name="show_amber_alert_settings">false</bool>
+
     <!-- Play alert sound in full volume regardless Do Not Disturb is on -->
     <bool name="override_dnd_default">true</bool>
     <!-- Channels to receive emergency alerts -->
diff --git a/res/values-mcc424/config.xml b/res/values-mcc424/config.xml
index a2f7b25..36b3f36 100644
--- a/res/values-mcc424/config.xml
+++ b/res/values-mcc424/config.xml
@@ -15,9 +15,13 @@
 -->
 
 <resources>
-    <!-- Whether to enable CMAS settings (United States) -->
-    <!-- No need to show this for United Arab Emirates users -->
-    <bool name="show_cmas_settings">false</bool>
+    <!-- Whether to show extreme alert settings -->
+    <bool name="show_extreme_alert_settings">false</bool>
+    <!-- Whether to show severe alert settings -->
+    <bool name="show_severe_alert_settings">false</bool>
+    <!-- Whether to show amber alert settings -->
+    <bool name="show_amber_alert_settings">false</bool>
+
     <!-- Hide state local test from menu, but still enable it -->
     <bool name="show_state_local_test_settings">false</bool>
     <bool name="state_local_test_alerts_enabled_default">true</bool>
diff --git a/res/values-mcc440-mnc10/config.xml b/res/values-mcc440-mnc10/config.xml
index 922b2f2..c428d8e 100644
--- a/res/values-mcc440-mnc10/config.xml
+++ b/res/values-mcc440-mnc10/config.xml
@@ -19,4 +19,8 @@
         <item>0xA001-0xA002:type=other, emergency=true, scope=carrier</item>
         <item>0xA004-0xA3FF:type=other, emergency=true, scope=carrier</item>
     </string-array>
+    <string-array name="etws_test_alerts_range_strings" translatable="false">
+        <item>0x1103:rat=gsm, emergency=true</item>
+        <item>0xA400-0xA4FF:rat=gsm, emergency=true</item>
+    </string-array>
 </resources>
diff --git a/res/values-mcc440/config.xml b/res/values-mcc440/config.xml
index 6661c62..ff4e217 100644
--- a/res/values-mcc440/config.xml
+++ b/res/values-mcc440/config.xml
@@ -15,9 +15,12 @@
 -->
 
 <resources>
-    <!-- Whether to enable CMAS settings (United States) -->
-    <!-- No need to show this for Japanese users -->
-    <bool name="show_cmas_settings">false</bool>
+    <!-- Whether to show extreme alert settings -->
+    <bool name="show_extreme_alert_settings">false</bool>
+    <!-- Whether to show severe alert settings -->
+    <bool name="show_severe_alert_settings">false</bool>
+    <!-- Whether to show amber alert settings -->
+    <bool name="show_amber_alert_settings">false</bool>
 
     <!-- Whether to show override dnd settings -->
     <bool name="show_override_dnd_settings">true</bool>
diff --git a/res/values-mcc450/config.xml b/res/values-mcc450/config.xml
index 621ce53..53ed91f 100644
--- a/res/values-mcc450/config.xml
+++ b/res/values-mcc450/config.xml
@@ -15,9 +15,12 @@
 -->
 
 <resources>
-    <!-- Whether to enable CMAS settings (United States) -->
-    <!-- No need to show this for Korean users -->
-    <bool name="show_cmas_settings">false</bool>
+    <!-- Whether to show extreme alert settings -->
+    <bool name="show_extreme_alert_settings">false</bool>
+    <!-- Whether to show severe alert settings -->
+    <bool name="show_severe_alert_settings">false</bool>
+    <!-- Whether to show amber alert settings -->
+    <bool name="show_amber_alert_settings">false</bool>
 
     <!-- 4370 -->
     <!-- Emergecny alert tone duration set to 1 minute for Korean users -->
@@ -32,9 +35,10 @@
     <string-array name="public_safety_messages_channels_range_strings" translatable="false">
         <item>0x1114:rat=gsm, emergency=false, alert_duration=60000</item>
     </string-array>
-    <!-- 4373~4379 -->
+    <!-- 4373~4379, 40960~45055-->
     <string-array name="additional_cbs_channels_strings" translatable="false">
         <item>0x1115-0x111B:rat=gsm, emergency=true, alert_duration=60000</item>
+        <item>0xA000-0xAFFF:rat=gsm, emergency=false</item>
     </string-array>
 
     <string-array name="cmas_alert_extreme_channels_range_strings" translatable="false"></string-array>
diff --git a/res/values-mcc454/config.xml b/res/values-mcc454/config.xml
new file mode 100644
index 0000000..a28d3ad
--- /dev/null
+++ b/res/values-mcc454/config.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 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 show extreme alert settings -->
+    <bool name="show_extreme_alert_settings">false</bool>
+    <!-- Whether to show severe alert settings -->
+    <bool name="show_severe_alert_settings">false</bool>
+
+    <!-- 4370, 4383 -->
+    <string-array name="cmas_presidential_alerts_channels_range_strings" translatable="false">
+        <item>0x1112:rat=gsm, emergency=true, override_dnd=true</item>
+        <!-- additional language -->
+        <item>0x111F:rat=gsm, emergency=true, override_dnd=true</item>
+    </string-array>
+
+    <string-array name="cmas_alert_extreme_channels_range_strings" translatable="false">
+    </string-array>
+    <string-array name="cmas_alerts_severe_range_strings" translatable="false">
+    </string-array>
+    <string-array name="cmas_amber_alerts_channels_range_strings" translatable="false">
+        <item>0x111B:rat=gsm, emergency=true</item>
+        <!-- additional language -->
+        <item>0x1128:rat=gsm, emergency=true</item>
+    </string-array>
+
+    <!-- 4371~4378, 4384~4391 -->
+    <string-array name="emergency_alerts_channels_range_strings" translatable="false">
+        <item>0x1113-0x111A:rat=gsm, emergency=true</item>
+        <!-- additional language -->
+        <item>0x1120-0x1127:rat=gsm, emergency=true</item>
+    </string-array>
+    <!-- 4380, 4393 -->
+    <string-array name="required_monthly_test_range_strings" translatable="false">
+        <item>0x111C:rat=gsm, type=info, emergency=true</item>
+        <!-- additional language -->
+        <item>0x1129:rat=gsm, type=info, emergency=true</item>
+    </string-array>
+    <string-array name="exercise_alert_range_strings" translatable="false"></string-array>
+    <string-array name="operator_defined_alert_range_strings" translatable="false"></string-array>
+</resources>
diff --git a/res/values-mcc454/strings.xml b/res/values-mcc454/strings.xml
new file mode 100644
index 0000000..899734b
--- /dev/null
+++ b/res/values-mcc454/strings.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 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 xmlns:android="http://schemas.android.com/apk/res/android"
+           xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="cmas_presidential_level_alert">Highest level alert</string>
+    <string name="cmas_extreme_alert">Emergency alert</string>
+    <string name="cmas_extreme_immediate_observed_alert" translatable="false">@string/cmas_extreme_alert</string>
+    <string name="cmas_extreme_immediate_likely_alert" translatable="false">@string/cmas_extreme_alert</string>
+    <string name="cmas_severe_alert" translatable="false">@string/cmas_extreme_alert</string>
+    <string name="cmas_amber_alert">Amber alert</string>
+    <string name="cmas_required_monthly_test">Test message</string>
+</resources>
diff --git a/res/values-mcc466/config.xml b/res/values-mcc466/config.xml
index ea93820..7243ca3 100644
--- a/res/values-mcc466/config.xml
+++ b/res/values-mcc466/config.xml
@@ -15,9 +15,12 @@
 -->
 
 <resources>
-    <!-- Whether to enable CMAS settings (United States) -->
-    <!-- No need to show this for Taiwanese users -->
-    <bool name="show_cmas_settings">false</bool>
+    <!-- Whether to show extreme alert settings -->
+    <bool name="show_extreme_alert_settings">false</bool>
+    <!-- Whether to show severe alert settings -->
+    <bool name="show_severe_alert_settings">false</bool>
+    <!-- Whether to show amber alert settings -->
+    <bool name="show_amber_alert_settings">false</bool>
 
     <string-array name="public_safety_messages_channels_range_strings" translatable="false">
         <!-- Channel 911 and 919 are required by Taiwan NCC -->
diff --git a/res/values-mcc505-mnc01/config.xml b/res/values-mcc505-mnc01/config.xml
index 50b87d8..ce00c37 100644
--- a/res/values-mcc505-mnc01/config.xml
+++ b/res/values-mcc505-mnc01/config.xml
@@ -15,7 +15,10 @@
 -->
 
 <resources>
-    <!-- Whether to enable CMAS settings (United States) -->
-    <!-- No need to show this for Telstra -->
-    <bool name="show_cmas_settings">false</bool>
+    <!-- Whether to show extreme alert settings -->
+    <bool name="show_extreme_alert_settings">false</bool>
+    <!-- Whether to show severe alert settings -->
+    <bool name="show_severe_alert_settings">false</bool>
+    <!-- Whether to show amber alert settings -->
+    <bool name="show_amber_alert_settings">false</bool>
 </resources>
diff --git a/res/values-mcc505-mnc11/config.xml b/res/values-mcc505-mnc11/config.xml
index 50b87d8..ce00c37 100644
--- a/res/values-mcc505-mnc11/config.xml
+++ b/res/values-mcc505-mnc11/config.xml
@@ -15,7 +15,10 @@
 -->
 
 <resources>
-    <!-- Whether to enable CMAS settings (United States) -->
-    <!-- No need to show this for Telstra -->
-    <bool name="show_cmas_settings">false</bool>
+    <!-- Whether to show extreme alert settings -->
+    <bool name="show_extreme_alert_settings">false</bool>
+    <!-- Whether to show severe alert settings -->
+    <bool name="show_severe_alert_settings">false</bool>
+    <!-- Whether to show amber alert settings -->
+    <bool name="show_amber_alert_settings">false</bool>
 </resources>
diff --git a/res/values-mcc505-mnc71/config.xml b/res/values-mcc505-mnc71/config.xml
index 50b87d8..ce00c37 100644
--- a/res/values-mcc505-mnc71/config.xml
+++ b/res/values-mcc505-mnc71/config.xml
@@ -15,7 +15,10 @@
 -->
 
 <resources>
-    <!-- Whether to enable CMAS settings (United States) -->
-    <!-- No need to show this for Telstra -->
-    <bool name="show_cmas_settings">false</bool>
+    <!-- Whether to show extreme alert settings -->
+    <bool name="show_extreme_alert_settings">false</bool>
+    <!-- Whether to show severe alert settings -->
+    <bool name="show_severe_alert_settings">false</bool>
+    <!-- Whether to show amber alert settings -->
+    <bool name="show_amber_alert_settings">false</bool>
 </resources>
diff --git a/res/values-mcc505-mnc72/config.xml b/res/values-mcc505-mnc72/config.xml
index 50b87d8..ce00c37 100644
--- a/res/values-mcc505-mnc72/config.xml
+++ b/res/values-mcc505-mnc72/config.xml
@@ -15,7 +15,10 @@
 -->
 
 <resources>
-    <!-- Whether to enable CMAS settings (United States) -->
-    <!-- No need to show this for Telstra -->
-    <bool name="show_cmas_settings">false</bool>
+    <!-- Whether to show extreme alert settings -->
+    <bool name="show_extreme_alert_settings">false</bool>
+    <!-- Whether to show severe alert settings -->
+    <bool name="show_severe_alert_settings">false</bool>
+    <!-- Whether to show amber alert settings -->
+    <bool name="show_amber_alert_settings">false</bool>
 </resources>
diff --git a/res/values-mcc716/config.xml b/res/values-mcc716/config.xml
index efdb979..9859379 100644
--- a/res/values-mcc716/config.xml
+++ b/res/values-mcc716/config.xml
@@ -15,9 +15,12 @@
 -->
 
 <resources>
-    <!-- Whether to enable CMAS settings (United States) -->
-    <!-- No need to show this for Peru users -->
-    <bool name="show_cmas_settings">false</bool>
+    <!-- Whether to show extreme alert settings -->
+    <bool name="show_extreme_alert_settings">false</bool>
+    <!-- Whether to show severe alert settings -->
+    <bool name="show_severe_alert_settings">false</bool>
+    <!-- Whether to show amber alert settings -->
+    <bool name="show_amber_alert_settings">false</bool>
 
     <!-- 4370, 4383, 50, 919 -->
     <!-- Emergecny alert tone duration set to 3 minute for Peru users -->
diff --git a/res/values-mcc730/config.xml b/res/values-mcc730/config.xml
index 7e76def..520db07 100644
--- a/res/values-mcc730/config.xml
+++ b/res/values-mcc730/config.xml
@@ -15,9 +15,12 @@
 -->
 
 <resources>
-    <!-- Whether to enable CMAS settings (United States) -->
-    <!-- No need to show this for Chilean users -->
-    <bool name="show_cmas_settings">false</bool>
+    <!-- Whether to show extreme alert settings -->
+    <bool name="show_extreme_alert_settings">false</bool>
+    <!-- Whether to show severe alert settings -->
+    <bool name="show_severe_alert_settings">false</bool>
+    <!-- Whether to show amber alert settings -->
+    <bool name="show_amber_alert_settings">false</bool>
 
     <string-array name="public_safety_messages_channels_range_strings" translatable="false">
         <!-- Channel 919 and 921 are required by Chile -->
diff --git a/res/values/config.xml b/res/values/config.xml
index 5838453..4a0cdf7 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -19,8 +19,14 @@
     <bool name="show_override_dnd_settings">false</bool>
     <!-- The default value for overriding dnd settings-->
     <bool name="override_dnd_default">false</bool>
-    <!-- Whether to enable CMAS settings (United States) -->
-    <bool name="show_cmas_settings">true</bool>
+    <!-- Whether to show presidential alert settings -->
+    <bool name="show_presidential_alerts_settings">false</bool>
+    <!-- Whether to show extreme alert settings -->
+    <bool name="show_extreme_alert_settings">true</bool>
+    <!-- Whether to show severe alert settings -->
+    <bool name="show_severe_alert_settings">true</bool>
+    <!-- Whether to show amber alert settings -->
+    <bool name="show_amber_alert_settings">true</bool>
     <!-- Whether to show test settings -->
     <bool name="show_test_settings">true</bool>
     <!-- Whether to append date-time to the alert title -->
@@ -33,8 +39,6 @@
     <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>
-    <!-- Show checkbox for Presidential alerts in settings -->
-    <bool name="show_presidential_alerts_in_settings">false</bool>
     <!-- Whether to display public safety alert settings, some countries/carriers want to enable it by default and not allow users to disable -->
     <bool name="show_public_safety_settings">true</bool>
     <!-- Whether to display state/local test settings, some countries/carriers want to enable it by default and not allow users to disable -->
diff --git a/res/values/overlayable.xml b/res/values/overlayable.xml
index 69431f8..16cce51 100644
--- a/res/values/overlayable.xml
+++ b/res/values/overlayable.xml
@@ -42,7 +42,7 @@
             <!-- Presidential alert is default on and cannot be turned off.
             AOSP CBR app does not show presidential alert in settings, however OEM can choose to
             display a greyout presidential alert settings by overriding below config -->
-            <item type="bool" name="show_presidential_alerts_in_settings" />
+            <item type="bool" name="show_presidential_alerts_settings" />
 
             <!-- Some JP carriers requires to enable 0xA807 in additional_cbs_channels_strings
             but only for certain products. OEMs can customize below config by including 0xA807
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java b/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java
index e34374c..3ac2971 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java
@@ -40,6 +40,8 @@
 
 import androidx.localbroadcastmanager.content.LocalBroadcastManager;
 
+import com.android.internal.annotations.VisibleForTesting;
+
 import java.util.ArrayList;
 
 public class CellBroadcastReceiver extends BroadcastReceiver {
@@ -66,12 +68,24 @@
 
     private Context mContext;
 
-    @Override
-    public void onReceive(Context context, Intent intent) {
-        onReceiveWithPrivilege(context, intent, false);
+    /**
+     * helper method for easier testing. To generate a new CellBroadcastTask
+     * @param deliveryTime message delivery time
+     */
+    @VisibleForTesting
+    public void getCellBroadcastTask(final long deliveryTime) {
+        new CellBroadcastContentProvider.AsyncCellBroadcastTask(mContext.getContentResolver())
+                .execute(new CellBroadcastContentProvider.CellBroadcastOperation() {
+                    @Override
+                    public boolean execute(CellBroadcastContentProvider provider) {
+                        return provider.markBroadcastRead(CellBroadcasts.DELIVERY_TIME,
+                                deliveryTime);
+                    }
+                });
     }
 
-    protected void onReceiveWithPrivilege(Context context, Intent intent, boolean privileged) {
+    @Override
+    public void onReceive(Context context, Intent intent) {
         if (DBG) log("onReceive " + intent);
 
         mContext = context.getApplicationContext();
@@ -79,14 +93,7 @@
 
         if (ACTION_MARK_AS_READ.equals(action)) {
             final long deliveryTime = intent.getLongExtra(EXTRA_DELIVERY_TIME, -1);
-            new CellBroadcastContentProvider.AsyncCellBroadcastTask(mContext.getContentResolver())
-                    .execute(new CellBroadcastContentProvider.CellBroadcastOperation() {
-                        @Override
-                        public boolean execute(CellBroadcastContentProvider provider) {
-                            return provider.markBroadcastRead(CellBroadcasts.DELIVERY_TIME,
-                                    deliveryTime);
-                        }
-                    });
+            getCellBroadcastTask(deliveryTime);
         } else if (CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED.equals(action)) {
             initializeSharedPreference();
             startConfigService(mContext);
@@ -95,28 +102,16 @@
             startConfigService(mContext);
         } else if (Telephony.Sms.Intents.ACTION_SMS_EMERGENCY_CB_RECEIVED.equals(action) ||
                 Telephony.Sms.Intents.SMS_CB_RECEIVED_ACTION.equals(action)) {
-            // If 'privileged' is false, it means that the intent was delivered to the base
-            // no-permissions receiver class.  If we get an SMS_CB_RECEIVED message that way, it
-            // means someone has tried to spoof the message by delivering it outside the normal
-            // permission-checked route, so we just ignore it.
-            if (privileged) {
-                intent.setClass(mContext, CellBroadcastAlertService.class);
-                mContext.startService(intent);
-            } else {
-                loge("ignoring unprivileged action received " + action);
-            }
+            intent.setClass(mContext, CellBroadcastAlertService.class);
+            mContext.startService(intent);
         } else if (Telephony.Sms.Intents.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION
                 .equals(action)) {
-            if (privileged) {
-                ArrayList<CdmaSmsCbProgramData> programDataList =
-                        intent.getParcelableArrayListExtra("program_data");
-                if (programDataList != null) {
-                    handleCdmaSmsCbProgramData(programDataList);
-                } else {
-                    loge("SCPD intent received with no program_data");
-                }
+            ArrayList<CdmaSmsCbProgramData> programDataList =
+                    intent.getParcelableArrayListExtra("program_data");
+            if (programDataList != null) {
+                handleCdmaSmsCbProgramData(programDataList);
             } else {
-                loge("ignoring unprivileged action received " + action);
+                loge("SCPD intent received with no program_data");
             }
         } else if (Intent.ACTION_LOCALE_CHANGED.equals(action)) {
             // rename registered notification channels on locale change
@@ -157,7 +152,11 @@
         return sp.getBoolean(TESTING_MODE, false);
     }
 
-    private void adjustReminderInterval() {
+    /**
+     * update reminder interval
+     */
+    @VisibleForTesting
+    public void adjustReminderInterval() {
         SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
         String currentIntervalDefault = sp.getString(CURRENT_INTERVAL_DEFAULT, "0");
 
@@ -181,7 +180,11 @@
         }
     }
 
-    private void initializeSharedPreference() {
+    /**
+     * initialize shared preferences before starting services
+     */
+    @VisibleForTesting
+    public void initializeSharedPreference() {
         if (isSystemUser(mContext)) {
             Log.d(TAG, "initializeSharedPreference");
             SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
@@ -334,7 +337,8 @@
      * @param context
      * @return whether the user is system user
      */
-    private static boolean isSystemUser(Context context) {
+    @VisibleForTesting
+    public static boolean isSystemUser(Context context) {
         return ((UserManager) context.getSystemService(Context.USER_SERVICE)).isSystemUser();
     }
 
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastSearchIndexableProvider.java b/src/com/android/cellbroadcastreceiver/CellBroadcastSearchIndexableProvider.java
index 6d51a2d..d9c0b02 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastSearchIndexableProvider.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastSearchIndexableProvider.java
@@ -132,18 +132,30 @@
                 SubscriptionManager.DEFAULT_SUBSCRIPTION_ID);
         Object[] ref;
 
-        if (!res.getBoolean(R.bool.show_cmas_settings)) {
+        if (!res.getBoolean(R.bool.show_presidential_alerts_settings)) {
+            ref = new Object[1];
+            ref[COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE] =
+                    CellBroadcastSettings.KEY_ENABLE_CMAS_PRESIDENTIAL_ALERTS;
+            cursor.addRow(ref);
+        }
+
+        if (!res.getBoolean(R.bool.show_extreme_alert_settings)) {
             // Remove CMAS preference items in emergency alert category.
             ref = new Object[1];
             ref[COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE] =
                     CellBroadcastSettings.KEY_ENABLE_CMAS_EXTREME_THREAT_ALERTS;
             cursor.addRow(ref);
+        }
+
+        if (!res.getBoolean(R.bool.show_severe_alert_settings)) {
 
             ref = new Object[1];
             ref[COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE] =
                     CellBroadcastSettings.KEY_ENABLE_CMAS_SEVERE_THREAT_ALERTS;
             cursor.addRow(ref);
+        }
 
+        if (!res.getBoolean(R.bool.show_amber_alert_settings)) {
             ref = new Object[1];
             ref[COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE] =
                     CellBroadcastSettings.KEY_ENABLE_CMAS_AMBER_ALERTS;
@@ -157,13 +169,6 @@
             cursor.addRow(ref);
         }
 
-        if (!res.getBoolean(R.bool.show_presidential_alerts_in_settings)) {
-            ref = new Object[1];
-            ref[COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE] =
-                    CellBroadcastSettings.KEY_ENABLE_CMAS_PRESIDENTIAL_ALERTS;
-            cursor.addRow(ref);
-        }
-
         CellBroadcastChannelManager channelManager = new CellBroadcastChannelManager(getContext(),
                 SubscriptionManager.DEFAULT_SUBSCRIPTION_ID);
         if (channelManager.getCellBroadcastChannelRanges(
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java b/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
index 056b2bc..1f424ba 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
@@ -402,23 +402,23 @@
 
             if (mPresidentialCheckBox != null) {
                 mPresidentialCheckBox.setVisible(
-                        res.getBoolean(R.bool.show_presidential_alerts_in_settings));
+                        res.getBoolean(R.bool.show_presidential_alerts_settings));
             }
 
             if (mExtremeCheckBox != null) {
-                mExtremeCheckBox.setVisible(res.getBoolean(R.bool.show_cmas_settings)
+                mExtremeCheckBox.setVisible(res.getBoolean(R.bool.show_extreme_alert_settings)
                         && !channelManager.getCellBroadcastChannelRanges(
                                 R.array.cmas_alert_extreme_channels_range_strings).isEmpty());
             }
 
             if (mSevereCheckBox != null) {
-                mSevereCheckBox.setVisible(res.getBoolean(R.bool.show_cmas_settings)
+                mSevereCheckBox.setVisible(res.getBoolean(R.bool.show_severe_alert_settings)
                         && !channelManager.getCellBroadcastChannelRanges(
                                 R.array.cmas_alerts_severe_range_strings).isEmpty());
             }
 
             if (mAmberCheckBox != null) {
-                mAmberCheckBox.setVisible(res.getBoolean(R.bool.show_cmas_settings)
+                mAmberCheckBox.setVisible(res.getBoolean(R.bool.show_amber_alert_settings)
                         && !channelManager.getCellBroadcastChannelRanges(
                                 R.array.cmas_amber_alerts_channels_range_strings).isEmpty());
             }
diff --git a/src/com/android/cellbroadcastreceiver/PrivilegedCellBroadcastReceiver.java b/src/com/android/cellbroadcastreceiver/PrivilegedCellBroadcastReceiver.java
deleted file mode 100644
index 2591c59..0000000
--- a/src/com/android/cellbroadcastreceiver/PrivilegedCellBroadcastReceiver.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package com.android.cellbroadcastreceiver;
-
-import android.content.Context;
-import android.content.Intent;
-
-/**
- * This class exists specifically to allow us to require permissions checks on SMS_RECEIVED
- * broadcasts that are not applicable to other kinds of broadcast messages handled by the
- * SmsReceiver base class.
- */
-public class PrivilegedCellBroadcastReceiver extends CellBroadcastReceiver {
-    @Override
-    public void onReceive(Context context, Intent intent) {
-        // Pass the message to the base class implementation, noting that it
-        // was permission-checked on the way in.
-        onReceiveWithPrivilege(context, intent, true);
-    }
-}
diff --git a/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastReceiverTest.java b/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastReceiverTest.java
new file mode 100644
index 0000000..184f7be
--- /dev/null
+++ b/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastReceiverTest.java
@@ -0,0 +1,199 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+package com.android.cellbroadcastreceiver.unit;
+
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.res.Configuration;
+import android.media.AudioDeviceInfo;
+import android.os.UserManager;
+import android.provider.Telephony;
+import android.telephony.CarrierConfigManager;
+import android.telephony.SubscriptionManager;
+
+import com.android.cellbroadcastreceiver.CellBroadcastAlertService;
+import com.android.cellbroadcastreceiver.CellBroadcastReceiver;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+public class CellBroadcastReceiverTest extends CellBroadcastTest {
+    private static final long MAX_INIT_WAIT_MS = 5000;
+
+    CellBroadcastReceiver mCellBroadcastReceiver;
+
+    @Mock
+    UserManager mUserManager;
+    @Mock
+    SharedPreferences mSharedPreferences;
+
+    @Mock
+    Intent mIntent;
+
+    private Configuration mConfiguration = new Configuration();
+    private AudioDeviceInfo[] mDevices = new AudioDeviceInfo[0];
+    private Object mLock = new Object();
+    private boolean mReady;
+
+    protected void waitUntilReady() {
+        synchronized (mLock) {
+            if (!mReady) {
+                try {
+                    mLock.wait(MAX_INIT_WAIT_MS);
+                } catch (InterruptedException ie) {
+                }
+
+                if (!mReady) {
+                    Assert.fail("Telephony tests failed to initialize");
+                }
+            }
+        }
+    }
+
+    protected void setReady(boolean ready) {
+        synchronized (mLock) {
+            mReady = ready;
+            mLock.notifyAll();
+        }
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp(this.getClass().getSimpleName());
+        MockitoAnnotations.initMocks(this);
+        doReturn(mConfiguration).when(mResources).getConfiguration();
+        mCellBroadcastReceiver = spy(new CellBroadcastReceiver());
+        doReturn(mContext).when(mContext).getApplicationContext();
+        //return false in isSystemUser, so that system services are not initiated
+
+    }
+
+    @Test
+    public void testOnReceive_actionMarkAsRead() {
+        doReturn(CellBroadcastReceiver.ACTION_MARK_AS_READ).when(mIntent).getAction();
+        doNothing().when(mCellBroadcastReceiver).getCellBroadcastTask(anyLong());
+        mCellBroadcastReceiver.onReceive(mContext, mIntent);
+        verify(mIntent).getLongExtra(CellBroadcastReceiver.EXTRA_DELIVERY_TIME, -1);
+    }
+
+    @Test
+    public void testOnReceive_actionCarrierConfigChanged() {
+        doReturn(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED).when(mIntent).getAction();
+        doReturn(mUserManager).when(mContext).getSystemService(anyString());
+        doReturn(false).when(mUserManager).isSystemUser();
+        mCellBroadcastReceiver.onReceive(mContext, mIntent);
+        verify(mCellBroadcastReceiver).initializeSharedPreference();
+        verify(mContext, times(2)).getSystemService(anyString());
+    }
+
+    @Test
+    public void testOnReceive_cellbroadcastStartConfigAction() {
+        doReturn(CellBroadcastReceiver.CELLBROADCAST_START_CONFIG_ACTION).when(mIntent).getAction();
+        doReturn(mUserManager).when(mContext).getSystemService(anyString());
+        doReturn(false).when(mUserManager).isSystemUser();
+        mCellBroadcastReceiver.onReceive(mContext, mIntent);
+        verify(mCellBroadcastReceiver, never()).initializeSharedPreference();
+        verify(mContext).getSystemService(anyString());
+    }
+
+    @Test
+    public void testOnReceive_actionDefaultSmsSubscriptionChanged() {
+        doReturn(SubscriptionManager.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED)
+                .when(mIntent).getAction();
+        doReturn(mUserManager).when(mContext).getSystemService(anyString());
+        doReturn(false).when(mUserManager).isSystemUser();
+        mCellBroadcastReceiver.onReceive(mContext, mIntent);
+        verify(mCellBroadcastReceiver, never()).initializeSharedPreference();
+        verify(mContext).getSystemService(anyString());
+    }
+
+    @Test
+    public void testOnReceive_actionSmsEmergencyCbReceived() {
+        doReturn(Telephony.Sms.Intents.ACTION_SMS_EMERGENCY_CB_RECEIVED).when(mIntent).getAction();
+        doReturn(mIntent).when(mIntent).setClass(mContext, CellBroadcastAlertService.class);
+
+        mCellBroadcastReceiver.onReceive(mContext, mIntent);
+        verify(mIntent).setClass(mContext, CellBroadcastAlertService.class);
+        verify(mContext).startService(mIntent);
+    }
+
+    @Test
+    public void testOnReceive_smsCbReceivedAction() {
+        doReturn(Telephony.Sms.Intents.SMS_CB_RECEIVED_ACTION).when(mIntent).getAction();
+        doReturn(mIntent).when(mIntent).setClass(mContext, CellBroadcastAlertService.class);
+
+        mCellBroadcastReceiver.onReceive(mContext, mIntent);
+        verify(mIntent).setClass(mContext, CellBroadcastAlertService.class);
+        verify(mContext).startService(mIntent);
+    }
+
+    @Test
+    public void testOnReceive_smsServiceCategoryProgramDataReceivedAction() {
+        doReturn(Telephony.Sms.Intents.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION)
+                .when(mIntent).getAction();
+        doReturn(null).when(mIntent).getParcelableArrayListExtra(anyString());
+
+        mCellBroadcastReceiver.onReceive(mContext, mIntent);
+        verify(mIntent).getParcelableArrayListExtra(anyString());
+    }
+
+    @Test
+    public void testInitializeSharedPreference_ifSystemUser() {
+        doReturn("An invalid action").when(mIntent).getAction();
+        mCellBroadcastReceiver.onReceive(mContext, mIntent);
+
+        doReturn(mUserManager).when(mContext).getSystemService(anyString());
+        doReturn(true).when(mUserManager).isSystemUser();
+        doReturn(mSharedPreferences).when(mContext).getSharedPreferences(anyString(), anyInt());
+        doReturn(true).when(mSharedPreferences).getBoolean(anyString(), anyBoolean());
+        doNothing().when(mCellBroadcastReceiver).adjustReminderInterval();
+        mCellBroadcastReceiver.initializeSharedPreference();
+        verify(mSharedPreferences).getBoolean(anyString(), anyBoolean());
+    }
+
+    @Test
+    public void testInitializeSharedPreference_ifNotSystemUser() {
+        doReturn("An invalid action").when(mIntent).getAction();
+        mCellBroadcastReceiver.onReceive(mContext, mIntent);
+
+        doReturn(mUserManager).when(mContext).getSystemService(anyString());
+        doReturn(false).when(mUserManager).isSystemUser();
+        doReturn(mSharedPreferences).when(mContext).getSharedPreferences(anyString(), anyInt());
+        mCellBroadcastReceiver.initializeSharedPreference();
+        verify(mSharedPreferences, never()).getBoolean(anyString(), anyBoolean());
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+}