Add function to enable/disable "advanced 4G features"

Perform needed configuration settings and IMS turn on/off.

Some carriers may allow disabling of specific IMS features (e.g. VoLTE)
but require that the IMS service itself is never "turned off". Add code
to use configuration bool (which can be overlayed) to control actual
turnOffIms() function execution.

Change-Id: I3cc0fef1426a31924ff5d5cd4516972bcfae040d
diff --git a/src/java/com/android/ims/ImsManager.java b/src/java/com/android/ims/ImsManager.java
index 494e8dc..b33517f 100644
--- a/src/java/com/android/ims/ImsManager.java
+++ b/src/java/com/android/ims/ImsManager.java
@@ -19,7 +19,6 @@
 import android.app.PendingIntent;
 import android.content.Context;
 import android.content.Intent;
-import android.content.IntentFilter;
 import android.os.IBinder;
 import android.os.IBinder.DeathRecipient;
 import android.os.Message;
@@ -27,6 +26,7 @@
 import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.telephony.Rlog;
+import android.telephony.TelephonyManager;
 
 import com.android.ims.internal.IImsCallSession;
 import com.android.ims.internal.IImsEcbm;
@@ -37,7 +37,6 @@
 import com.android.ims.internal.ImsCallSession;
 import com.android.ims.internal.IImsConfig;
 
-
 import java.util.HashMap;
 
 /**
@@ -187,8 +186,6 @@
      */
     public int open(int serviceClass, PendingIntent incomingCallPendingIntent,
             ImsConnectionStateListener listener) throws ImsException {
-        // TODO: check global IMS-enabled property and do not open if disabled
-
         checkAndThrowExceptionIfServiceUnavailable();
 
         if (incomingCallPendingIntent == null) {
@@ -590,6 +587,26 @@
         }
     }
 
+    public void setAdvanced4GMode(boolean turnOn) throws ImsException {
+        checkAndThrowExceptionIfServiceUnavailable();
+
+        ImsConfig config = getConfigInterface();
+        if (config != null) {
+            config.setFeatureValue(ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_LTE,
+                    TelephonyManager.NETWORK_TYPE_LTE, turnOn ? 1 : 0, null);
+            config.setFeatureValue(ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_LTE,
+                    TelephonyManager.NETWORK_TYPE_LTE, turnOn ? 1 : 0, null);
+        }
+
+        if (turnOn) {
+            turnOnIms();
+        } else if (mContext.getResources().getBoolean(
+                com.android.internal.R.bool.imsServiceAllowTurnOff)) {
+            log("setAdvanced4GMode() : imsServiceAllowTurnOff -> turnOffIms");
+            turnOffIms();
+        }
+    }
+
     /**
      * Used for turning off IMS completely in order to make the device CSFB'ed.
      * Once turned off, all calls will be over CS.