Added API to configure VT over IMS.
Etan Cohen [Tue, 5 May 2015 01:02:09 +0000 (18:02 -0700)]
Bug: 20750301
Change-Id: Iecad593e8f7aa5a76a37ff63e9ff9b9536827a5c

src/java/com/android/ims/ImsManager.java

index 0113f7b..ec08384 100644 (file)
@@ -302,6 +302,49 @@ public class ImsManager {
     }
 
     /**
+     * Returns the user configuration of VT setting
+     */
+    public static boolean isVtEnabledByUser(Context context) {
+        int enabled = android.provider.Settings.Global.getInt(context.getContentResolver(),
+                android.provider.Settings.Global.VT_IMS_ENABLED,
+                ImsConfig.FeatureValueConstants.ON);
+        return (enabled == 1) ? true : false;
+    }
+
+    /**
+     * Change persistent VT enabled setting
+     */
+    public static void setVtSetting(Context context, boolean enabled) {
+        int value = enabled ? 1 : 0;
+        android.provider.Settings.Global.putInt(context.getContentResolver(),
+                android.provider.Settings.Global.VT_IMS_ENABLED, value);
+
+        ImsManager imsManager = ImsManager.getInstance(context,
+                SubscriptionManager.getDefaultVoicePhoneId());
+        if (imsManager != null) {
+            try {
+                ImsConfig config = imsManager.getConfigInterface();
+                config.setFeatureValue(ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_LTE,
+                        TelephonyManager.NETWORK_TYPE_LTE,
+                        enabled ? ImsConfig.FeatureValueConstants.ON
+                                : ImsConfig.FeatureValueConstants.OFF, null);
+
+                if (enabled) {
+                    imsManager.turnOnIms();
+                } else if (context.getResources().getBoolean(
+                        com.android.internal.R.bool.imsServiceAllowTurnOff) && (
+                        !isVolteEnabledByPlatform(context)
+                        || !isEnhanced4gLteModeSettingEnabledByUser(context))) {
+                    log("setVtSetting() : imsServiceAllowTurnOff -> turnOffIms");
+                    imsManager.turnOffIms();
+                }
+            } catch (ImsException e) {
+                loge("setVtSetting(): " + e);
+            }
+        }
+    }
+
+    /**
      * Returns the user configuration of WFC setting
      */
     public static boolean isWfcEnabledByUser(Context context) {