Moved channels settings from carrier config to resources

Since CBS channels are more countries specific instead
of carrier specific, moving it to resources makes
more sense.

Test: Manual
bug: 31223529

Change-Id: Id76c7eb7515ff924e84a54c77b98bf8973c60c1b
diff --git a/res/values-mcc425/config.xml b/res/values-mcc425/config.xml
new file mode 100644
index 0000000..c672bf8
--- /dev/null
+++ b/res/values-mcc425/config.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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>
+    <string-array name="additional_cbs_channels_strings">
+        <!-- Channel 919 ~ 928 are required by Israel government -->
+        <item>0x0397-0x03A0:type=other, emergency=false</item>
+    </string-array>
+</resources>
diff --git a/res/values-mcc440-mnc10/config.xml b/res/values-mcc440-mnc10/config.xml
new file mode 100644
index 0000000..7c6e033
--- /dev/null
+++ b/res/values-mcc440-mnc10/config.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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>
+    <string-array name="additional_cbs_channels_strings">
+        <item>0xA001-0xA002:type=other, emergency=true</item>
+        <item>0xA004-0xA3FF:type=other, emergency=true</item>
+    </string-array>
+</resources>
diff --git a/res/values-mcc440-mnc20/config.xml b/res/values-mcc440-mnc20/config.xml
new file mode 100644
index 0000000..fe1cfb5
--- /dev/null
+++ b/res/values-mcc440-mnc20/config.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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>
+    <string-array name="additional_cbs_channels_strings">
+        <item>0xA800:type=earthquake, emergency=true</item>
+        <item>0xAFEE:type=tsunami, emergency=true</item>
+        <item>0xAC00-0xAFED:type=other, emergency=true</item>
+        <item>0xA802:type=etws_default, emergency=true</item>
+        <item>0xA804:type=etws_default, emergency=true</item>
+    </string-array>
+</resources>
diff --git a/res/values-mcc440-mnc50/config.xml b/res/values-mcc440-mnc50/config.xml
new file mode 100644
index 0000000..df41bab
--- /dev/null
+++ b/res/values-mcc440-mnc50/config.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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>
+    <string-array name="additional_cbs_channels_strings">
+        <item>0xA003:type=other, emergency=true</item>
+    </string-array>
+</resources>
diff --git a/res/values-mcc440-mnc51/config.xml b/res/values-mcc440-mnc51/config.xml
new file mode 100644
index 0000000..df41bab
--- /dev/null
+++ b/res/values-mcc440-mnc51/config.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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>
+    <string-array name="additional_cbs_channels_strings">
+        <item>0xA003:type=other, emergency=true</item>
+    </string-array>
+</resources>
diff --git a/res/values-mcc440-mnc52/config.xml b/res/values-mcc440-mnc52/config.xml
new file mode 100644
index 0000000..df41bab
--- /dev/null
+++ b/res/values-mcc440-mnc52/config.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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>
+    <string-array name="additional_cbs_channels_strings">
+        <item>0xA003:type=other, emergency=true</item>
+    </string-array>
+</resources>
diff --git a/res/values-mcc466/config.xml b/res/values-mcc466/config.xml
index da85a38..a3ddf52 100644
--- a/res/values-mcc466/config.xml
+++ b/res/values-mcc466/config.xml
@@ -18,4 +18,10 @@
     <!-- Whether to enable CMAS settings (United States) -->
     <!-- No need to show this for Taiwanese users -->
     <bool name="show_cmas_settings">false</bool>
+
+    <string-array name="additional_cbs_channels_strings">
+        <!-- Channel 911 and 919 are required by Taiwan NCC -->
+        <item>0x038F:type=other, emergency=false</item>
+        <item>0x0397:type=other, emergency=false</item>
+    </string-array>
 </resources>
diff --git a/res/values-mcc724/config.xml b/res/values-mcc724/config.xml
new file mode 100644
index 0000000..0243da2
--- /dev/null
+++ b/res/values-mcc724/config.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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>
+    <string-array name="additional_cbs_channels_strings">
+        <!-- Channel 50 is required by Brazilian government -->
+        <item>0x032:type=other, emergency=false</item>
+    </string-array>
+</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index 7fe018a..b2f3684 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -23,4 +23,6 @@
     <bool name="show_cmas_settings">true</bool>
     <!-- Whether to enable channel 50 settings (Brazil) -->
     <bool name="show_brazil_settings">false</bool>
+
+    <string-array name="additional_cbs_channels_strings"></string-array>
 </resources>
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
index b126d1f..9dfbc18 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
@@ -50,6 +50,7 @@
 import com.android.cellbroadcastreceiver.CellBroadcastChannelManager.CellBroadcastChannelRange;
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.telephony.PhoneConstants;
+import com.android.internal.telephony.gsm.SmsCbConstants;
 
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
@@ -397,7 +398,7 @@
             }
         }
 
-        if (message.getServiceCategory() == 50) {
+        if (message.getServiceCategory() == SmsCbConstants.MESSAGE_ID_GSMA_ALLOCATED_CHANNEL_50) {
             // save latest area info broadcast for Settings display and send as broadcast
             CellBroadcastReceiverApp.setLatestAreaInfo(message);
             Intent intent = new Intent(CB_AREA_INFO_RECEIVED_ACTION);
@@ -460,8 +461,7 @@
                     prefs.getBoolean(CellBroadcastSettings.KEY_ENABLE_ALERT_VIBRATE, true));
             int channel = message.getServiceCategory();
             ArrayList<CellBroadcastChannelRange> ranges = CellBroadcastChannelManager
-                    .getInstance().getCellBroadcastChannelRanges(getApplicationContext(),
-                    message.getSubId());
+                    .getInstance().getCellBroadcastChannelRanges(getApplicationContext());
             if (ranges != null) {
                 for (CellBroadcastChannelRange range : ranges) {
                     if (channel >= range.mStartId && channel <= range.mEndId) {
@@ -655,13 +655,12 @@
         }
 
         int id = cbm.getServiceCategory();
-        int subId = cbm.getSubId();
 
         if (cbm.isEmergencyAlertMessage()) {
             isEmergency = true;
         } else {
             ArrayList<CellBroadcastChannelRange> ranges = CellBroadcastChannelManager
-                    .getInstance().getCellBroadcastChannelRanges(context, subId);
+                    .getInstance().getCellBroadcastChannelRanges(context);
 
             if (ranges != null) {
                 for (CellBroadcastChannelRange range : ranges) {
@@ -673,8 +672,7 @@
             }
         }
 
-        Log.d(TAG, "isEmergencyMessage: " + isEmergency + ", subId = " + subId + ", " +
-                "message id = " + id);
+        Log.d(TAG, "isEmergencyMessage: " + isEmergency + "message id = " + id);
         return isEmergency;
     }
 }
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastChannelManager.java b/src/com/android/cellbroadcastreceiver/CellBroadcastChannelManager.java
index 4963814..3c17f9f 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastChannelManager.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastChannelManager.java
@@ -17,10 +17,7 @@
 package com.android.cellbroadcastreceiver;
 
 import android.content.Context;
-import android.os.PersistableBundle;
-import android.telephony.CarrierConfigManager;
 import android.util.Log;
-import android.util.SparseArray;
 
 import com.android.cellbroadcastreceiver.CellBroadcastAlertAudio.ToneType;
 
@@ -46,12 +43,6 @@
     private static CellBroadcastChannelManager sInstance = null;
 
     /**
-     * Channel range caches with sub id as the key.
-     */
-    private static SparseArray<ArrayList<CellBroadcastChannelRange>> sChannelRanges =
-            new SparseArray<>();
-
-    /**
      * Cell broadcast channel range
      * A range is consisted by starting channel id, ending channel id, and the tone type
      */
@@ -120,62 +111,25 @@
     /**
      * Get cell broadcast channels enabled by the carriers.
      * @param context Application context
-     * @param subId Subscription id
      * @return The list of channel ranges enabled by the carriers.
      */
-    public ArrayList<CellBroadcastChannelRange> getCellBroadcastChannelRanges(
-            Context context, int subId) {
+    public ArrayList<CellBroadcastChannelRange> getCellBroadcastChannelRanges(Context context) {
 
-        // Check if the cache already had it.
-        if (sChannelRanges.get(subId) == null) {
+        ArrayList<CellBroadcastChannelRange> result = new ArrayList<>();
+        String[] ranges = context.getResources().getStringArray(
+                R.array.additional_cbs_channels_strings);
 
-            if (context == null) {
-                loge("context is null");
-                return null;
-            }
-
-            ArrayList<CellBroadcastChannelRange> result = new ArrayList<>();
-            String[] ranges;
-            CarrierConfigManager configManager =
-                    (CarrierConfigManager) context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
-
-            if (configManager != null) {
-                PersistableBundle carrierConfig = configManager.getConfigForSubId(subId);
-
-                if (carrierConfig != null) {
-                    ranges = carrierConfig.getStringArray(
-                            CarrierConfigManager.KEY_CARRIER_ADDITIONAL_CBS_CHANNELS_STRINGS);
-
-                    if (ranges == null || ranges.length == 0) {
-                        log("No additional channels configured. subId = " + subId);
-
-                        // If there is nothing configured, store an empty list in the cache
-                        // so we won't look up again next time.
-                        sChannelRanges.put(subId, result);
-                        return result;
-                    }
-
-                    for (String range : ranges) {
-                        try {
-                            result.add(new CellBroadcastChannelRange(range));
-                        } catch (Exception e) {
-                            loge("Failed to parse \"" + range + "\". e=" + e);
-                        }
-                    }
-
-                    sChannelRanges.put(subId, result);
-
-                } else {
-                    loge("Can't get carrier config. subId=" + subId);
-                    return null;
+        if (ranges != null) {
+            for (String range : ranges) {
+                try {
+                    result.add(new CellBroadcastChannelRange(range));
+                } catch (Exception e) {
+                    loge("Failed to parse \"" + range + "\". e=" + e);
                 }
-            } else {
-                loge("Carrier config manager is not available");
-                return null;
             }
         }
 
-        return sChannelRanges.get(subId);
+        return result;
     }
 
     private static void log(String msg) {
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastConfigService.java b/src/com/android/cellbroadcastreceiver/CellBroadcastConfigService.java
index ed4d537..6b97b0d 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastConfigService.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastConfigService.java
@@ -19,15 +19,12 @@
 import static com.android.cellbroadcastreceiver.CellBroadcastReceiver.VDBG;
 
 import android.app.IntentService;
-import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
-import android.content.res.Resources;
 import android.preference.PreferenceManager;
 import android.telephony.CarrierConfigManager;
 import android.telephony.SmsManager;
 import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
 import android.util.Log;
 
 import com.android.cellbroadcastreceiver.CellBroadcastChannelManager.CellBroadcastChannelRange;
@@ -52,10 +49,6 @@
 
     static final String ACTION_ENABLE_CHANNELS = "ACTION_ENABLE_CHANNELS";
 
-    private static final String COUNTRY_TAIWAN = "tw";
-    private static final String COUNTRY_ISRAEL = "ir";
-    private static final String COUNTRY_BRAZIL = "br";
-
     public CellBroadcastConfigService() {
         super(TAG);          // use class name for worker thread name
     }
@@ -92,14 +85,14 @@
                                 if (id == subId) {
                                     // Enable cell broadcast messages on this sub.
                                     log("Enable CellBroadcast on sub " + id);
-                                    setCellBroadcastOnSub(manager, id, true);
+                                    setCellBroadcastOnSub(manager, true);
                                 }
                                 else {
                                     // Disable all cell broadcast message on this sub.
                                     // This is only for multi-sim scenario. For single SIM device
                                     // we should not reach here.
                                     log("Disable CellBroadcast on sub " + id);
-                                    setCellBroadcastOnSub(manager, id, false);
+                                    setCellBroadcastOnSub(manager, false);
                                 }
                             }
                         }
@@ -108,8 +101,7 @@
                         // For no sim scenario.
                         SmsManager manager = SmsManager.getDefault();
                         if (manager != null) {
-                            setCellBroadcastOnSub(manager,
-                                    SubscriptionManager.INVALID_SUBSCRIPTION_ID, true);
+                            setCellBroadcastOnSub(manager, true);
                         }
                     }
                 }
@@ -123,14 +115,12 @@
      * Enable/disable cell broadcast messages id on one subscription
      * This includes all ETWS and CMAS alerts.
      * @param manager SMS manager
-     * @param subId Subscription id
      * @param enableForSub True if want to enable messages on this sub (e.g default SMS). False
      *                     will disable all messages
      */
-    private void setCellBroadcastOnSub(SmsManager manager, int subId, boolean enableForSub) {
+    private void setCellBroadcastOnSub(SmsManager manager, boolean enableForSub) {
 
         SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
-        Resources res = getResources();
 
         // boolean for each user preference checkbox, true for checked, false for unchecked
         // Note: If enableEmergencyAlerts is false, it disables ALL emergency broadcasts
@@ -167,22 +157,6 @@
                 enableEmergencyAlerts &&
                 prefs.getBoolean(CellBroadcastSettings.KEY_ENABLE_CMAS_TEST_ALERTS, false);
 
-        TelephonyManager tm = (TelephonyManager) getSystemService(
-                Context.TELEPHONY_SERVICE);
-
-        boolean enableChannel50Support = res.getBoolean(R.bool.show_brazil_settings) ||
-                COUNTRY_BRAZIL.equals(tm.getSimCountryIso(subId));
-
-        boolean enableChannel50Alerts = enableChannel50Support &&
-                prefs.getBoolean(CellBroadcastSettings.KEY_ENABLE_CHANNEL_50_ALERTS, true);
-
-        // Current Israel requires enable certain CMAS messages ids.
-        boolean supportIsraelPwsAlerts = (COUNTRY_ISRAEL.equals(tm.getSimCountryIso(subId))
-                || COUNTRY_ISRAEL.equals(tm.getNetworkCountryIso(subId)));
-
-        boolean supportTaiwanPwsAlerts = (COUNTRY_TAIWAN.equals(tm.getSimCountryIso(subId))
-                || COUNTRY_TAIWAN.equals(tm.getNetworkCountryIso(subId)));
-
         if (VDBG) {
             log("enableEmergencyAlerts = " + enableEmergencyAlerts);
             log("enableEtwsAlerts = " + enableEtwsAlerts);
@@ -193,9 +167,6 @@
             log("forceDisableEtwsCmasTest = " + forceDisableEtwsCmasTest);
             log("enableEtwsTestAlerts = " + enableEtwsTestAlerts);
             log("enableCmasTestAlerts = " + enableCmasTestAlerts);
-            log("enableChannel50Alerts = " + enableChannel50Alerts);
-            log("supportIsraelPwsAlerts = " + supportIsraelPwsAlerts);
-            log("supportTaiwanPwsAlerts = " + supportTaiwanPwsAlerts);
         }
 
         /** Enable CDMA CMAS series messages. */
@@ -230,7 +201,7 @@
                 SmsEnvelope.SERVICE_CATEGORY_CMAS_TEST_MESSAGE,
                 SmsEnvelope.SERVICE_CATEGORY_CMAS_TEST_MESSAGE);
 
-        /** Enable GSM ETWS series messages. */
+        // Enable GSM ETWS series messages.
 
         // Enable/Disable GSM ETWS messages (4352~4354).
         setCellBroadcastRange(manager, enableEtwsAlerts,
@@ -250,7 +221,7 @@
                 SmsCbConstants.MESSAGE_ID_ETWS_TEST_MESSAGE,
                 SmsCbConstants.MESSAGE_ID_ETWS_TEST_MESSAGE);
 
-        /** Enable GSM CMAS series messages. */
+        // Enable GSM CMAS series messages.
 
         // Enable/Disable GSM CMAS presidential message (4370).
         setCellBroadcastRange(manager, enablePresidential,
@@ -283,7 +254,7 @@
                 SmsCbConstants.MESSAGE_ID_CMAS_ALERT_OPERATOR_DEFINED_USE);
 
 
-        /** Enable GSM CMAS series messages for additional languages. */
+        // Enable GSM CMAS series messages for additional languages.
 
         // Enable/Disable GSM CMAS presidential messages for additional languages (4383).
         setCellBroadcastRange(manager, enablePresidential,
@@ -315,15 +286,9 @@
                 SmsCbConstants.MESSAGE_ID_CMAS_ALERT_REQUIRED_MONTHLY_TEST_LANGUAGE,
                 SmsCbConstants.MESSAGE_ID_CMAS_ALERT_OPERATOR_DEFINED_USE_LANGUAGE);
 
-        // Enable/Disable channel 50 messages for Brazil (50).
-        setCellBroadcastRange(manager, enableChannel50Alerts,
-                SmsManager.CELL_BROADCAST_RAN_TYPE_GSM,
-                SmsCbConstants.MESSAGE_ID_GSMA_ALLOCATED_CHANNEL_50,
-                SmsCbConstants.MESSAGE_ID_GSMA_ALLOCATED_CHANNEL_50);
-
         // Enable/Disable additional channels based on carrier specific requirement.
         ArrayList<CellBroadcastChannelRange> ranges = CellBroadcastChannelManager
-                .getInstance().getCellBroadcastChannelRanges(getApplicationContext(), subId);
+                .getInstance().getCellBroadcastChannelRanges(getApplicationContext());
 
         if (ranges != null) {
             for (CellBroadcastChannelRange range: ranges) {
@@ -332,27 +297,6 @@
                         range.mStartId, range.mEndId);
             }
         }
-
-        // Enable/Disable additional channels based on country specific requirement.
-        if (supportIsraelPwsAlerts) {
-            // Enable/Disable Israel PWS channels (919~928).
-            setCellBroadcastRange(manager, enableEmergencyAlerts,
-                    SmsManager.CELL_BROADCAST_RAN_TYPE_GSM,
-                    SmsCbConstants.MESSAGE_ID_GSMA_ALLOCATED_CHANNEL_919,
-                    SmsCbConstants.MESSAGE_ID_GSMA_ALLOCATED_CHANNEL_928);
-        } else if (supportTaiwanPwsAlerts) {
-            // Enable/Disable Taiwan PWS Chinese channel (911).
-            setCellBroadcastRange(manager, enableEmergencyAlerts,
-                    SmsManager.CELL_BROADCAST_RAN_TYPE_GSM,
-                    SmsCbConstants.MESSAGE_ID_GSMA_ALLOCATED_CHANNEL_911,
-                    SmsCbConstants.MESSAGE_ID_GSMA_ALLOCATED_CHANNEL_911);
-
-            // Enable/Disable Taiwan PWS English channel (919).
-            setCellBroadcastRange(manager, enableEmergencyAlerts,
-                    SmsManager.CELL_BROADCAST_RAN_TYPE_GSM,
-                    SmsCbConstants.MESSAGE_ID_GSMA_ALLOCATED_CHANNEL_919,
-                    SmsCbConstants.MESSAGE_ID_GSMA_ALLOCATED_CHANNEL_919);
-        }
     }
     /**
      * Enable/disable cell broadcast with messages id range
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastResources.java b/src/com/android/cellbroadcastreceiver/CellBroadcastResources.java
index 2355890..7348135 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastResources.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastResources.java
@@ -295,7 +295,7 @@
 
         if (CellBroadcastAlertService.isEmergencyMessage(context, cbm)) {
             ArrayList<CellBroadcastChannelRange> ranges = CellBroadcastChannelManager
-                    .getInstance().getCellBroadcastChannelRanges(context, cbm.getSubId());
+                    .getInstance().getCellBroadcastChannelRanges(context);
             if (ranges != null) {
                 for (CellBroadcastChannelRange range : ranges) {
                     if (cbm.getServiceCategory() >= range.mStartId &&
diff --git a/tests/unit/src/com/android/cellbroadcastreceiver/CellBroadcastChannelManagerTest.java b/tests/unit/src/com/android/cellbroadcastreceiver/CellBroadcastChannelManagerTest.java
index 752cbc3..1a47b38 100644
--- a/tests/unit/src/com/android/cellbroadcastreceiver/CellBroadcastChannelManagerTest.java
+++ b/tests/unit/src/com/android/cellbroadcastreceiver/CellBroadcastChannelManagerTest.java
@@ -20,7 +20,6 @@
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-import android.telephony.CarrierConfigManager;
 import android.test.suitebuilder.annotation.SmallTest;
 
 import com.android.cellbroadcastreceiver.CellBroadcastAlertAudio.ToneType;
@@ -53,18 +52,16 @@
     @Test
     @SmallTest
     public void testGetCellBroadcastChannelRanges() throws Exception {
-        int subId = 1234;
-        carrierConfigSetStringArray(subId,
-                CarrierConfigManager.KEY_CARRIER_ADDITIONAL_CBS_CHANNELS_STRINGS,
-                new String[]{
-                        "12:type=earthquake, emergency=true",
-                        "456:type=tsunami, emergency=true",
-                        "0xAC00-0xAFED:type=other, emergency=false",
-                        "54-60:emergency=true",
-                        "100-200"
-                });
+        putResources(R.array.additional_cbs_channels_strings, new String[]{
+                "12:type=earthquake, emergency=true",
+                "456:type=tsunami, emergency=true",
+                "0xAC00-0xAFED:type=other, emergency=false",
+                "54-60:emergency=true",
+                "100-200"
+        });
+
         ArrayList<CellBroadcastChannelRange> list = CellBroadcastChannelManager.getInstance()
-                .getCellBroadcastChannelRanges(mContext, subId);
+                .getCellBroadcastChannelRanges(mContext);
 
         assertEquals(12, list.get(0).mStartId);
         assertEquals(12, list.get(0).mEndId);
diff --git a/tests/unit/src/com/android/cellbroadcastreceiver/CellBroadcastTest.java b/tests/unit/src/com/android/cellbroadcastreceiver/CellBroadcastTest.java
index 9e3e93c..bda8cb2 100644
--- a/tests/unit/src/com/android/cellbroadcastreceiver/CellBroadcastTest.java
+++ b/tests/unit/src/com/android/cellbroadcastreceiver/CellBroadcastTest.java
@@ -16,32 +16,19 @@
 
 package com.android.cellbroadcastreceiver;
 
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.eq;
+
 import android.content.Context;
-import android.os.IBinder;
+import android.content.res.Resources;
 import android.os.PersistableBundle;
-import android.os.ServiceManager;
-import android.telephony.SmsManager;
-import android.util.Log;
 import android.telephony.CarrierConfigManager;
+import android.util.Log;
 import android.util.SparseArray;
 
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyInt;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
 public abstract class CellBroadcastTest {
 
     protected static String TAG;
@@ -54,6 +41,8 @@
     Context mContext;
     @Mock
     CarrierConfigManager mCarrierConfigManager;
+    @Mock
+    Resources mResources;
 
     protected void setUp(String tag) throws Exception {
         TAG = tag;
@@ -63,8 +52,9 @@
     }
 
     private void initContext() {
-        doReturn(mCarrierConfigManager).when(mContext).
-                getSystemService(eq(Context.CARRIER_CONFIG_SERVICE));
+        doReturn(mCarrierConfigManager).when(mContext)
+                .getSystemService(eq(Context.CARRIER_CONFIG_SERVICE));
+        doReturn(mResources).when(mContext).getResources();
     }
 
     void carrierConfigSetStringArray(int subId, String key, String[] values) {
@@ -75,6 +65,10 @@
         doReturn(mBundles.get(subId)).when(mCarrierConfigManager).getConfigForSubId(eq(subId));
     }
 
+    void putResources(int id, String[] values) {
+        doReturn(values).when(mResources).getStringArray(eq(id));
+    }
+
     protected void tearDown() throws Exception {
         mMockedServiceManager.restoreAllServices();
     }