Add Call Barring UI

Add Call Barring setting UI to CallSetting.
Since some operator requires, this feature is needed.

Bug: 30845125
Test: Manual
Change-Id: I5d80508afd8216f04f443c5a9e0dd83d5247788f
diff --git a/src/com/android/phone/GsmUmtsCallOptions.java b/src/com/android/phone/GsmUmtsCallOptions.java
index 419e72c..3b27d28 100644
--- a/src/com/android/phone/GsmUmtsCallOptions.java
+++ b/src/com/android/phone/GsmUmtsCallOptions.java
@@ -17,10 +17,12 @@
 package com.android.phone;
 
 import android.os.Bundle;
+import android.os.PersistableBundle;
 import android.preference.CheckBoxPreference;
 import android.preference.Preference;
 import android.preference.PreferenceActivity;
 import android.preference.PreferenceScreen;
+import android.telephony.CarrierConfigManager;
 import android.view.MenuItem;
 
 import com.android.internal.telephony.Phone;
@@ -31,6 +33,7 @@
     private final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
 
     private static final String CALL_FORWARDING_KEY = "call_forwarding_key";
+    private static final String CALL_BARRING_KEY = "call_barring_key";
     private static final String ADDITIONAL_GSM_SETTINGS_KEY = "additional_gsm_call_settings_key";
 
     @Override
@@ -68,5 +71,18 @@
                 prefScreen.findPreference(ADDITIONAL_GSM_SETTINGS_KEY);
         additionalGsmSettingsPref.setIntent(
                 subInfoHelper.getIntent(GsmUmtsAdditionalCallOptions.class));
+
+        Preference callBarringPref = prefScreen.findPreference(CALL_BARRING_KEY);
+        PersistableBundle b = null;
+        if (subInfoHelper.hasSubId()) {
+            b = PhoneGlobals.getInstance().getCarrierConfigForSubId(subInfoHelper.getSubId());
+        } else {
+            b = PhoneGlobals.getInstance().getCarrierConfig();
+        }
+        if (b != null && b.getBoolean(CarrierConfigManager.KEY_CALL_BARRING_VISIBILITY_BOOL)) {
+            callBarringPref.setIntent(subInfoHelper.getIntent(GsmUmtsCallBarringOptions.class));
+        } else {
+            prefScreen.removePreference(callBarringPref);
+        }
     }
 }