Merge IMS changes from klp-wireless-dev to master

Change-Id: I247fa2b0e3aa159a27d96951edb0b04afd4d5ec6
diff --git a/Android.mk b/Android.mk
index 17c748a..75c81ac 100644
--- a/Android.mk
+++ b/Android.mk
@@ -9,7 +9,7 @@
 src_dirs := src $(phone_common_dir)/src
 res_dirs := res $(phone_common_dir)/res
 
-LOCAL_JAVA_LIBRARIES := telephony-common voip-common
+LOCAL_JAVA_LIBRARIES := telephony-common voip-common ims-common
 LOCAL_STATIC_JAVA_LIBRARIES := \
         com.android.services.telephony.common \
         guava \
diff --git a/res/values/config.xml b/res/values/config.xml
index 2664bc7..5dea4dd 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -143,4 +143,7 @@
          TODO: This is GSM specific. Need to define a generic "use the builtin SIMs" Connection
          Service and use it as the default. -->
     <string name="connection_service_default" translatable="false">com.android.phone/com.android.services.telephony.PstnConnectionService</string>
+
+    <!-- Does not display additional call seting for IMS phone based on GSM Phone -->
+    <bool name="config_additional_call_setting">true</bool>
 </resources>
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index cec266d..289767d 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -1624,7 +1624,10 @@
                     addPreferencesFromResource(R.xml.cdma_call_privacy);
                 }
             } else if (phoneType == PhoneConstants.PHONE_TYPE_GSM) {
-                addPreferencesFromResource(R.xml.gsm_umts_call_options);
+                if (getResources().getBoolean(
+                            R.bool.config_additional_call_setting)) {
+                    addPreferencesFromResource(R.xml.gsm_umts_call_options);
+                }
             } else {
                 throw new IllegalStateException("Unexpected phone type: " + phoneType);
             }
diff --git a/src/com/android/phone/CallNotifier.java b/src/com/android/phone/CallNotifier.java
index bc19568..9ab2b5e 100644
--- a/src/com/android/phone/CallNotifier.java
+++ b/src/com/android/phone/CallNotifier.java
@@ -759,6 +759,7 @@
 
         if (fgPhone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM
                 || fgPhone.getPhoneType() == PhoneConstants.PHONE_TYPE_SIP
+                || fgPhone.getPhoneType() == PhoneConstants.PHONE_TYPE_IMS
                 || fgPhone.getPhoneType() == PhoneConstants.PHONE_TYPE_THIRD_PARTY) {
             Call.State callState = mCM.getActiveFgCallState();
             if (!callState.isDialing()) {
@@ -1249,6 +1250,7 @@
                         toneLengthMillis = 1000;
                     } else if (phoneType == PhoneConstants.PHONE_TYPE_GSM
                             || phoneType == PhoneConstants.PHONE_TYPE_SIP
+                            || phoneType == PhoneConstants.PHONE_TYPE_IMS
                             || phoneType == PhoneConstants.PHONE_TYPE_THIRD_PARTY) {
                         toneType = ToneGenerator.TONE_SUP_BUSY;
                         toneVolume = TONE_RELATIVE_VOLUME_HIPRI;
diff --git a/src/com/android/phone/ImsUtil.java b/src/com/android/phone/ImsUtil.java
new file mode 100644
index 0000000..23ddf7d
--- /dev/null
+++ b/src/com/android/phone/ImsUtil.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.phone;
+
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+
+import com.android.phone.PhoneGlobals;
+
+public class ImsUtil {
+    private ImsUtil() {
+    }
+
+    private static boolean sImsPhoneSupported = false;
+    static {
+        PhoneGlobals app = PhoneGlobals.getInstance();
+        sImsPhoneSupported = true;
+    }
+
+    /**
+     * @return true if this device supports voice calls using the built-in SIP stack.
+     */
+    static boolean isImsPhoneSupported() {
+        return sImsPhoneSupported;
+    }
+}
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index f446d36..2b76c91 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -914,6 +914,7 @@
                         phone.getForegroundCall().getLatestConnection());
             } else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
                     || (phoneType == PhoneConstants.PHONE_TYPE_SIP)
+                    || (phoneType == PhoneConstants.PHONE_TYPE_IMS)
                     || (phoneType == PhoneConstants.PHONE_TYPE_THIRD_PARTY)) {
                 shouldMute = sConnectionMuteTable.get(c);
             }
@@ -1481,6 +1482,7 @@
             conn = call.getLatestConnection();
         } else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
                 || (phoneType == PhoneConstants.PHONE_TYPE_SIP)
+                || (phoneType == PhoneConstants.PHONE_TYPE_IMS)
                 || (phoneType == PhoneConstants.PHONE_TYPE_THIRD_PARTY)) {
             conn = call.getEarliestConnection();
         } else {
@@ -1583,6 +1585,7 @@
                 switch (phoneType) {
                     case PhoneConstants.PHONE_TYPE_NONE: log("  ==> PHONE_TYPE_NONE"); break;
                     case PhoneConstants.PHONE_TYPE_GSM: log("  ==> PHONE_TYPE_GSM"); break;
+                    case PhoneConstants.PHONE_TYPE_IMS: log("  ==> PHONE_TYPE_IMS"); break;
                     case PhoneConstants.PHONE_TYPE_CDMA: log("  ==> PHONE_TYPE_CDMA"); break;
                     case PhoneConstants.PHONE_TYPE_SIP: log("  ==> PHONE_TYPE_SIP"); break;
                     case PhoneConstants.PHONE_TYPE_THIRD_PARTY:
@@ -2205,6 +2208,7 @@
                 answerCall(phone.getRingingCall());
             } else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
                     || (phoneType == PhoneConstants.PHONE_TYPE_SIP)
+                    || (phoneType == PhoneConstants.PHONE_TYPE_IMS)
                     || (phoneType == PhoneConstants.PHONE_TYPE_THIRD_PARTY)) {
                 if (hasActiveCall && hasHoldingCall) {
                     if (DBG) log("handleHeadsetHook: ringing (both lines in use) ==> answer!");
@@ -2350,6 +2354,7 @@
                     == CdmaPhoneCallState.PhoneCallState.CONF_CALL);
         } else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
                 || (phoneType == PhoneConstants.PHONE_TYPE_SIP)
+                || (phoneType == PhoneConstants.PHONE_TYPE_IMS)
                 || (phoneType == PhoneConstants.PHONE_TYPE_THIRD_PARTY)) {
             // GSM: "Swap" is available if both lines are in use and there's no
             // incoming call.  (Actually we need to verify that the active
@@ -2410,6 +2415,7 @@
                     && (app.cdmaPhoneCallState.getAddCallMenuStateAfterCallWaiting()));
         } else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
                 || (phoneType == PhoneConstants.PHONE_TYPE_SIP)
+                || (phoneType == PhoneConstants.PHONE_TYPE_IMS)
                 || (phoneType == PhoneConstants.PHONE_TYPE_THIRD_PARTY)) {
             // GSM: "Add call" is available only if ALL of the following are true:
             // - There's no incoming ringing call