am 75f3ca3a: Fix unncessary IMS re-registration with network
Omkar Kolangade [Thu, 6 Aug 2015 01:42:57 +0000 (01:42 +0000)]
* commit '75f3ca3a51c8d16dbb83af1cfcc151ec596dc5f5':
  Fix unncessary IMS re-registration with network

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

@@@ -140,18 -140,6 +140,18 @@@ public class ImsManager 
       */
      public static final String EXTRA_USSD = "android:ussd";
  
 +    /**
 +     * Part of the ACTION_IMS_INCOMING_CALL intents.
 +     * A boolean value; Flag to indicate whether the call is an unknown
 +     * dialing call. Such calls are originated by sending commands (like
 +     * AT commands) directly to modem without Android involvement.
 +     * Even though they are not incoming calls, they are propagated
 +     * to Phone app using same ACTION_IMS_INCOMING_CALL intent.
 +     * Internal use only.
 +     * @hide
 +     */
 +    public static final String EXTRA_IS_UNKNOWN_CALL = "android:isUnknown";
 +
      private static final String TAG = "ImsManager";
      private static final boolean DBG = true;
  
          }
      }
  
+     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();
          }
                  mListener.onFeatureCapabilityChanged(serviceClass,
                          enabledFeatures, disabledFeatures);
              }
 +        }
 +
 +        @Override
 +        public void voiceMessageCountUpdate(int count) {
 +            log("voiceMessageCountUpdate :: count=" + count);
 +
 +            if (mListener != null) {
 +                mListener.onVoiceMessageCountChanged(count);
 +            }
          }
  
      }