Fix unncessary IMS re-registration with network
Omkar Kolangade [Fri, 24 Oct 2014 18:10:52 +0000 (11:10 -0700)]
When entire IMS stack turn off is going to follow the IMS
re-registration request for a specific service, there is an
unncessary overhead with extra signalling during the process of
re-registration. Also this delays the IMS turn off process.
Fixed by not performing a setFeatureValue operation for a service
turn off when the configuration allows for entire IMS stack to
be turned off.

Add Exception Handling To setAdvanced4GMode API

Bug: 22717994
Bug: 21800429
Change-Id: Ic5d7c54802818de5c8e241cacce62feb02629743

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

index eb78fd0..47d1405 100644 (file)
@@ -915,27 +915,36 @@ public class ImsManager {
         }
     }
 
+    private boolean isImsTurnOffAllowed() {
+        return getBooleanCarrierConfig(mContext,
+                CarrierConfigManager.KEY_CARRIER_ALLOW_TURNOFF_IMS_BOOL)
+                && (!isWfcEnabledByPlatform(mContext)
+                || !isWfcEnabledByUser(mContext));
+    }
+
     private 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);
-            if (isVtEnabledByPlatform(mContext)) {
-                // TODO: once VT is available on platform replace the '1' with the current
-                // user configuration of VT.
-                config.setFeatureValue(ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_LTE,
+        try {
+            ImsConfig config = getConfigInterface();
+            if (config != null && (turnOn || !isImsTurnOffAllowed())) {
+                config.setFeatureValue(ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_LTE,
                         TelephonyManager.NETWORK_TYPE_LTE, turnOn ? 1 : 0, null);
+                if (isVtEnabledByPlatform(mContext)) {
+                    // TODO: once VT is available on platform:
+                    // - replace the '1' with the current user configuration of VT.
+                    // - separate exception checks for setFeatureValue() failures for VoLTE and VT.
+                    //   I.e. if VoLTE fails still try to configure VT.
+                    config.setFeatureValue(ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_LTE,
+                            TelephonyManager.NETWORK_TYPE_LTE, turnOn ? 1 : 0, null);
+                }
             }
+        } catch (ImsException e) {
+            log("setAdvanced4GMode() : " + e);
         }
-
         if (turnOn) {
             turnOnIms();
-        } else if (getBooleanCarrierConfig(mContext,
-                CarrierConfigManager.KEY_CARRIER_ALLOW_TURNOFF_IMS_BOOL)
-                && (!isWfcEnabledByPlatform(mContext)
-                || !isWfcEnabledByUser(mContext))) {
+        } else if (isImsTurnOffAllowed()) {
             log("setAdvanced4GMode() : imsServiceAllowTurnOff -> turnOffIms");
             turnOffIms();
         }