Enable TDSCDMA mode when connecting CMCC roaming network

If user connects CMCC roaming network with CMHK SIM,
user should be able to select TDSCDMA mode.

Bug: 24382870
Change-Id: I5d3628b4c6afea277720b31d00c6ed9d02f676bc
diff --git a/res/values-mcc454-mnc12/config.xml b/res/values-mcc454-mnc12/config.xml
new file mode 100644
index 0000000..4329402
--- /dev/null
+++ b/res/values-mcc454-mnc12/config.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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>
+    <!-- Show enabled tdscdma option for device when connect roaming network -->
+    <string-array name="config_support_tdscdma_roaming_on_networks" translatable="false">
+        <item>46000</item>
+        <item>46002</item>
+        <item>46007</item>
+        <item>46008</item>
+    </string-array>
+</resources>
diff --git a/res/values-mcc454-mnc13/config.xml b/res/values-mcc454-mnc13/config.xml
new file mode 100644
index 0000000..4329402
--- /dev/null
+++ b/res/values-mcc454-mnc13/config.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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>
+    <!-- Show enabled tdscdma option for device when connect roaming network -->
+    <string-array name="config_support_tdscdma_roaming_on_networks" translatable="false">
+        <item>46000</item>
+        <item>46002</item>
+        <item>46007</item>
+        <item>46008</item>
+    </string-array>
+</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index e0ea198..0425070 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -140,6 +140,9 @@
     <bool name="config_enabled_lte" translatable="false">false</bool>
     <!-- Show enabled tdscdma option for device -->
     <bool name="config_support_tdscdma" translatable="false">false</bool>
+    <!-- Show enabled tdscdma option for device when connect roaming network -->
+    <string-array name="config_support_tdscdma_roaming_on_networks" translatable="false">
+    </string-array>
     <!-- Show cdma auto network mode in (glabal) roaming -->
     <!-- DEPRECATED: Use CarrierConfigManager#KEY_SHOW_CDMA_CHOICES_BOOL -->
     <bool name="config_show_cdma" translatable="false">false</bool>
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index 1d8ceb0..aa78204 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -627,7 +627,7 @@
                     mGsmUmtsOptions = null;
                 }
             } else if (phoneType == PhoneConstants.PHONE_TYPE_GSM) {
-                if (getResources().getBoolean(R.bool.config_support_tdscdma)) {
+                if (isSupportTdscdma()) {
                     mButtonEnabledNetworks.setEntries(
                             R.array.enabled_networks_tdscdma_choices);
                     mButtonEnabledNetworks.setEntryValues(
@@ -1167,7 +1167,7 @@
             case Phone.NT_MODE_LTE_TDSCDMA_WCDMA:
             case Phone.NT_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA:
             case Phone.NT_MODE_LTE_CDMA_EVDO_GSM_WCDMA:
-                if (getResources().getBoolean(R.bool.config_support_tdscdma)) {
+                if (isSupportTdscdma()) {
                     mButtonEnabledNetworks.setValue(
                             Integer.toString(Phone.NT_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA));
                     mButtonEnabledNetworks.setSummary(R.string.network_lte);
@@ -1313,4 +1313,22 @@
         }
     }
 
+    private boolean isSupportTdscdma() {
+        if (getResources().getBoolean(R.bool.config_support_tdscdma)) {
+            return true;
+        }
+
+        String operatorNumeric = mPhone.getServiceState().getOperatorNumeric();
+        String[] numericArray = getResources().getStringArray(
+                R.array.config_support_tdscdma_roaming_on_networks);
+        if (numericArray.length == 0 || operatorNumeric == null) {
+            return false;
+        }
+        for (String numeric : numericArray) {
+            if (operatorNumeric.equals(numeric)) {
+                return true;
+            }
+        }
+        return false;
+    }
 }