Merge "[KDDI] Hide CFB, CFNR and CFNRC in Call Forwarding" into rvc-dev
diff --git a/src/com/android/phone/GsmUmtsCallForwardOptions.java b/src/com/android/phone/GsmUmtsCallForwardOptions.java
index 10bd8d7..fda0ea5 100644
--- a/src/com/android/phone/GsmUmtsCallForwardOptions.java
+++ b/src/com/android/phone/GsmUmtsCallForwardOptions.java
@@ -63,7 +63,9 @@
         mPhone = mSubscriptionInfoHelper.getPhone();
 
         PersistableBundle b = null;
+        boolean supportCFB = true;
         boolean supportCFNRc = true;
+        boolean supportCFNRy = true;
         if (mSubscriptionInfoHelper.hasSubId()) {
             b = PhoneGlobals.getInstance().getCarrierConfigForSubId(
                     mSubscriptionInfoHelper.getSubId());
@@ -75,8 +77,12 @@
                     CarrierConfigManager.KEY_CALL_FORWARDING_MAP_NON_NUMBER_TO_VOICEMAIL_BOOL);
             mCallForwardByUssd = b.getBoolean(
                     CarrierConfigManager.KEY_USE_CALL_FORWARDING_USSD_BOOL);
+            supportCFB = b.getBoolean(
+                    CarrierConfigManager.KEY_CALL_FORWARDING_WHEN_BUSY_SUPPORTED_BOOL);
             supportCFNRc = b.getBoolean(
                     CarrierConfigManager.KEY_CALL_FORWARDING_WHEN_UNREACHABLE_SUPPORTED_BOOL);
+            supportCFNRy = b.getBoolean(
+                    CarrierConfigManager.KEY_CALL_FORWARDING_WHEN_UNANSWERED_SUPPORTED_BOOL);
         }
 
         PreferenceScreen prefSet = getPreferenceScreen();
@@ -91,18 +97,9 @@
         mButtonCFNRc.setParentActivity(this, mButtonCFNRc.reason);
 
         mPreferences.add(mButtonCFU);
-        mPreferences.add(mButtonCFB);
-        mPreferences.add(mButtonCFNRy);
-
-        if (supportCFNRc) {
-            mPreferences.add(mButtonCFNRc);
-        } else {
-            // When CFNRc is not supported, mButtonCFNRc is grayed out from the menu.
-            // Default state for the preferences in this PreferenceScreen is disabled.
-            // Only preferences listed in the ArrayList mPreferences will be enabled.
-            // By not adding mButtonCFNRc to mPreferences it will be kept disabled.
-            if (DBG) Log.d(LOG_TAG, "onCreate: CFNRc is not supported, grey out the item.");
-        }
+        layoutCallForwardItem(supportCFB, mButtonCFB, prefSet);
+        layoutCallForwardItem(supportCFNRy, mButtonCFNRy, prefSet);
+        layoutCallForwardItem(supportCFNRc, mButtonCFNRc, prefSet);
 
         if (mCallForwardByUssd) {
             //the call forwarding ussd command's behavior is similar to the call forwarding when
@@ -130,6 +127,15 @@
         }
     }
 
+    private void layoutCallForwardItem(boolean support, CallForwardEditPreference preference,
+            PreferenceScreen prefSet) {
+        if (support) {
+            mPreferences.add(preference);
+        } else {
+            prefSet.removePreference(preference);
+        }
+    }
+
     @Override
     public void onResume() {
         super.onResume();