Hide/show Telephony video setting according to if IMS is enabled.
+ Add utility function get this value in ImsUtil.
+ Check this value to show/hide setting in Call Settings.
+ Include flag to override behavior and always hide VT, since it's
not shipping in MR1.
+ Take this account when reporting when the phone interface manager
reports whether we can make video calls.
Bug: 16014284
Change-Id: I31a13da61820988cdb53159126c6be9478b6a583
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index e59f4fb..7c828f9 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -98,6 +98,8 @@
EditPhoneNumberPreference.GetDefaultNumberListener {
private static final String LOG_TAG = "CallFeaturesSetting";
private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
+ // STOPSHIP if true. Flag to override behavior default behavior to hide VT setting.
+ private static final boolean ENABLE_VT_FLAG = false;
/**
* Intent action to bring up Voicemail Provider settings.
@@ -1677,10 +1679,13 @@
BUTTON_VOICEMAIL_NOTIFICATION_VIBRATE_KEY, false));
}
- mEnableVideoCalling.setChecked(PhoneGlobals.getInstance().phoneMgr.isVideoCallingEnabled());
- mEnableVideoCalling.setOnPreferenceChangeListener(this);
- // TODO: Perform checks to determine whether we should remove the preference.
- prefSet.removePreference(mEnableVideoCalling);
+ if (ImsUtil.isImsEnabled(mPhone.getContext()) && ENABLE_VT_FLAG) {
+ mEnableVideoCalling.setChecked(
+ PhoneGlobals.getInstance().phoneMgr.isVideoCallingEnabled());
+ mEnableVideoCalling.setOnPreferenceChangeListener(this);
+ } else {
+ prefSet.removePreference(mEnableVideoCalling);
+ }
// Look up the voicemail ringtone name asynchronously and update its preference.
new Thread(mVoicemailRingtoneLookupRunnable).start();
diff --git a/src/com/android/phone/ImsUtil.java b/src/com/android/phone/ImsUtil.java
index 23ddf7d..48276b7 100644
--- a/src/com/android/phone/ImsUtil.java
+++ b/src/com/android/phone/ImsUtil.java
@@ -19,14 +19,20 @@
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
+import android.provider.Settings.SettingNotFoundException;
+import android.util.Log;
+import com.android.internal.telephony.Phone;
import com.android.phone.PhoneGlobals;
public class ImsUtil {
+
+ private static final String TAG = ImsUtil.class.getSimpleName();
+ private static boolean sImsPhoneSupported = false;
+
private ImsUtil() {
}
- private static boolean sImsPhoneSupported = false;
static {
PhoneGlobals app = PhoneGlobals.getInstance();
sImsPhoneSupported = true;
@@ -37,5 +43,32 @@
*/
static boolean isImsPhoneSupported() {
return sImsPhoneSupported;
+
+ }
+
+ /**
+ * @see MobileNetworkSettings#setIMS
+ * @param context The context to get the content resolver from.
+ * @return Whether IMS is turned on by the user system setting.
+ */
+ static boolean isImsEnabled(Context context) {
+ int value = 0;
+ try {
+ value = android.provider.Settings.Global.getInt(
+ context.getContentResolver(),
+ android.provider.Settings.Global.VOLTE_VT_ENABLED);
+ } catch (SettingNotFoundException e) {
+ return false;
+ }
+
+ switch (value) {
+ case 0:
+ return false;
+ case 1:
+ return true;
+ default:
+ Log.wtf(TAG,"Unexpected value for VOLTE_VT_ENABLED: " + value);
+ return false;
+ }
}
}
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index ffbdebf..c9eeeaf 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -2080,6 +2080,11 @@
@Override
public boolean isVideoCallingEnabled() {
enforceReadPermission();
- return mTelephonySharedPreferences.getBoolean(PREF_ENABLE_VIDEO_CALLING, true);
+ // Check the user preference and the system-level IMS setting. Even if the user has
+ // enabled video calling, if IMS is disabled we aren't able to support video calling.
+ // In the long run, we may instead need to check if there exists a connection service
+ // which can support video calling.
+ return mTelephonySharedPreferences.getBoolean(PREF_ENABLE_VIDEO_CALLING, true)
+ && ImsUtil.isImsEnabled(mPhone.getContext());
}
}