Read from CarrierConfigManager instead of config.xml

This updates GsmUmtsOptions and CdmaOptions to read from the new
CarrierConfigManager API. These variables have been migrated:

config_carrier_settings_enable
config_operator_selection_expand
config_show_apn_setting_cdma

We don't register for ACTION_CARRIER_CONFIG_CHANGED broadcasts because
this variable is read when the settings activity is created, and the
value of the variable should only change when the sim operator changes.
(i.e. swapping SIM while viewing this activity)

Bug: 20270007
Change-Id: I73c22af620942324be32b04209ea47fd14495675
diff --git a/src/com/android/phone/CdmaOptions.java b/src/com/android/phone/CdmaOptions.java
index a04427e..fa3db13 100644
--- a/src/com/android/phone/CdmaOptions.java
+++ b/src/com/android/phone/CdmaOptions.java
@@ -20,11 +20,13 @@
 import android.content.Intent;
 import android.content.res.Resources;
 import android.net.Uri;
+import android.os.Bundle;
 import android.os.SystemProperties;
 import android.preference.Preference;
 import android.preference.PreferenceActivity;
 import android.preference.PreferenceScreen;
 import android.provider.Settings;
+import android.telephony.CarrierConfigManager;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
 
@@ -64,9 +66,9 @@
 
         mButtonAPNExpand = (PreferenceScreen) mPrefScreen.findPreference(BUTTON_APN_EXPAND_KEY);
         boolean removedAPNExpand = false;
-        Resources res = mPrefActivity.getResources();
-        // Some CDMA carriers want the APN settings
-        if (!res.getBoolean(R.bool.config_show_apn_setting_cdma) && mButtonAPNExpand != null) {
+        Bundle carrierConfig = PhoneGlobals.getInstance().getCarrierConfigForSubId(mPhone.getSubId());
+        // Some CDMA carriers want the APN settings.
+        if (!carrierConfig.getBoolean(CarrierConfigManager.BOOL_SHOW_APN_SETTING_CDMA) && mButtonAPNExpand != null) {
             mPrefScreen.removePreference(mButtonAPNExpand);
             removedAPNExpand = true;
         }
@@ -115,8 +117,8 @@
         }
 
         // Read platform settings for carrier settings
-        final boolean isCarrierSettingsEnabled = mPrefActivity.getResources().getBoolean(
-                R.bool.config_carrier_settings_enable);
+        final boolean isCarrierSettingsEnabled = carrierConfig.getBoolean(
+                CarrierConfigManager.BOOL_CARRIER_SETTINGS_ENABLE);
         if (!isCarrierSettingsEnabled) {
             Preference pref = mPrefScreen.findPreference(BUTTON_CARRIER_SETTINGS_KEY);
             if (pref != null) {
diff --git a/src/com/android/phone/GsmUmtsOptions.java b/src/com/android/phone/GsmUmtsOptions.java
index ee6a738..b8597f7 100644
--- a/src/com/android/phone/GsmUmtsOptions.java
+++ b/src/com/android/phone/GsmUmtsOptions.java
@@ -16,13 +16,16 @@
 
 package com.android.phone;
 
+import android.content.Context;
 import android.content.Intent;
+import android.content.res.Resources;
+import android.os.Bundle;
 import android.preference.Preference;
 import android.preference.PreferenceActivity;
 import android.preference.PreferenceScreen;
-import android.content.res.Resources;
-
 import android.provider.Settings;
+import android.telephony.CarrierConfigManager;
+
 import com.android.internal.telephony.PhoneConstants;
 import com.android.internal.telephony.PhoneFactory;
 
@@ -63,16 +66,18 @@
         } else {
             log("Not a CDMA phone");
             Resources res = mPrefActivity.getResources();
+            Bundle carrierConfig = PhoneGlobals.getInstance().getCarrierConfigForSubId(mSubId);
 
-            // Determine which options to display, for GSM these are defaulted
-            // are defaulted to true in Phone/res/values/config.xml. But for
-            // some operators like verizon they maybe overriden in operator
-            // specific resources or device specific overlays.
-            if (!res.getBoolean(R.bool.config_apn_expand) && mButtonAPNExpand != null) {
+            // Determine which options to display. For GSM these are defaulted to true in
+            // CarrierConfigManager, but they maybe overriden by DefaultCarrierConfigService or a
+            // carrier app.
+            // Note: these settings used to be controlled with overlays in
+            // Telephony/res/values/config.xml
+            if (!carrierConfig.getBoolean(CarrierConfigManager.BOOL_APN_EXPAND) && mButtonAPNExpand != null) {
                 mPrefScreen.removePreference(mButtonAPNExpand);
                 removedAPNExpand = true;
             }
-            if (!res.getBoolean(R.bool.config_operator_selection_expand)) {
+            if (!carrierConfig.getBoolean(CarrierConfigManager.BOOL_OPERATOR_SELECTION_EXPAND)) {
                 mPrefScreen.removePreference(mPrefScreen
                         .findPreference(BUTTON_OPERATOR_SELECTION_EXPAND_KEY));
             }
@@ -89,8 +94,8 @@
             }
 
             // Read platform settings for carrier settings
-            final boolean isCarrierSettingsEnabled = mPrefActivity.getResources().getBoolean(
-                    R.bool.config_carrier_settings_enable);
+            final boolean isCarrierSettingsEnabled = carrierConfig.getBoolean(
+                CarrierConfigManager.BOOL_CARRIER_SETTINGS_ENABLE);
             if (!isCarrierSettingsEnabled) {
                 Preference pref = mPrefScreen.findPreference(BUTTON_CARRIER_SETTINGS_KEY);
                 if (pref != null) {