Merge "Cdma Outgoing 3way call support." into klp-dev
diff --git a/common/src/com/android/services/telephony/common/ICallHandlerService.aidl b/common/src/com/android/services/telephony/common/ICallHandlerService.aidl
index 0cbd9b9..c4f0961 100644
--- a/common/src/com/android/services/telephony/common/ICallHandlerService.aidl
+++ b/common/src/com/android/services/telephony/common/ICallHandlerService.aidl
@@ -67,7 +67,7 @@
     /**
      * Called when the system wants to bring the in-call UI into the foreground.
      */
-    void bringToForeground();
+    void bringToForeground(boolean showDialpad);
 
     void onPostDialWait(int callId, String remainingChars);
 }
diff --git a/res/values-ka-rGE/strings.xml b/res/values-ka-rGE/strings.xml
index ca78932..fb7c26b 100644
--- a/res/values-ka-rGE/strings.xml
+++ b/res/values-ka-rGE/strings.xml
@@ -451,7 +451,7 @@
     <string name="ota_title_activate" msgid="8616918561356194398">"თქვენი ტელეფონის აქტივაცია"</string>
     <string name="ota_touch_activate" msgid="6553212803262586244">"თქვენი ტელეფონის სერვისის გასააქტიურებლად აუცილებელია საგანგებო ზარის განხორციელება. \n\nტექსტზე „აქტივაცია“ დაჭერის შემდეგ, მოუსმინეთ ინსტრუქციებს თქვენი ტელეფონის აქტივაციისათვის."</string>
     <string name="ota_hfa_activation_title" msgid="2234246934160473981">"მიმდინარეობს გააქტიურება..."</string>
-    <string name="ota_hfa_activation_dialog_message" msgid="8092479227918463415">"ტელეფონი თქვენს მობილური ინტერნეტის სერვისს ააქტიურებს.\n\nამას შესაძლოა 6 წუთამდე დაჭირდეს."</string>
+    <string name="ota_hfa_activation_dialog_message" msgid="8092479227918463415">"ტელეფონი თქვენს მობილური ინტერნეტის სერვისს ააქტიურებს.\n\nამას შესაძლოა 5 წუთამდე დაჭირდეს."</string>
     <string name="ota_skip_activation_dialog_title" msgid="2943366608272261306">"გსურთ აქტივაციის გამოტოვება?"</string>
     <string name="ota_skip_activation_dialog_message" msgid="2440770373498870550">"თუ აქტივაციას გამოტოვებთ, ზარების განხორციელებას ან მობილური ინტერნეტის გამოყენებას ვერ შეძლებთ (თუმცა, შესაძლებელია Wi-Fi ქსელებთან დაკავშირება). სანამ ტელეფონს გაააქტიურებდეთ, მოგეთხოვებათ გაააქტიუროთ ის, სანამ ჩართავდეთ."</string>
     <string name="ota_skip_activation_dialog_skip_label" msgid="3458532775091563208">"გამოტოვება"</string>
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index 396b705..40625ec 100644
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -80,21 +80,21 @@
     <string name="sum_cfu_enabled_indicator" msgid="4014187342724130197">"转接所有来电"</string>
     <string name="sum_cfu_enabled" msgid="2450052502198827927">"将所有来电转接到 <xliff:g id="PHONENUMBER">{0}</xliff:g>"</string>
     <string name="sum_cfu_enabled_no_number" msgid="6591985777096823616">"未提供电话号码"</string>
-    <string name="sum_cfu_disabled" msgid="3698472522160364904">"已停用"</string>
+    <string name="sum_cfu_disabled" msgid="3698472522160364904">"未启用"</string>
     <string name="labelCFB" msgid="218938523102207587">"占线时转接"</string>
     <string name="messageCFB" msgid="3711089705936187129">"占线时的转接号码"</string>
     <string name="sum_cfb_enabled" msgid="5984198104833116690">"转接到 <xliff:g id="PHONENUMBER">{0}</xliff:g>"</string>
-    <string name="sum_cfb_disabled" msgid="227440009979537651">"已停用"</string>
+    <string name="sum_cfb_disabled" msgid="227440009979537651">"未启用"</string>
     <string name="disable_cfb_forbidden" msgid="3506984333877998061">"您的运营商不支持在手机占线时停用来电转接功能。"</string>
     <string name="labelCFNRy" msgid="3646316323834351390">"无人接听时转接"</string>
     <string name="messageCFNRy" msgid="672317899884380374">"无人接听时的转接号码"</string>
     <string name="sum_cfnry_enabled" msgid="6955775691317662910">"转接到 <xliff:g id="PHONENUMBER">{0}</xliff:g>"</string>
-    <string name="sum_cfnry_disabled" msgid="8422350929957344729">"已停用"</string>
+    <string name="sum_cfnry_disabled" msgid="8422350929957344729">"未启用"</string>
     <string name="disable_cfnry_forbidden" msgid="4308233959150658058">"您的运营商不支持在手机无人接听时停用来电转接功能。"</string>
     <string name="labelCFNRc" msgid="47183615370850000">"无法接通时转接"</string>
     <string name="messageCFNRc" msgid="6380695421020295119">"无法接通时的转接号码"</string>
     <string name="sum_cfnrc_enabled" msgid="7010898346095497421">"转接到 <xliff:g id="PHONENUMBER">{0}</xliff:g>"</string>
-    <string name="sum_cfnrc_disabled" msgid="7222141261321276464">"已停用"</string>
+    <string name="sum_cfnrc_disabled" msgid="7222141261321276464">"未启用"</string>
     <string name="disable_cfnrc_forbidden" msgid="5646361343094064333">"您的运营商不支持在手机无法接通时停用来电转接功能。"</string>
     <string name="updating_title" msgid="6146755386174019046">"通话设置"</string>
     <string name="error_updating_title" msgid="7970259216988931777">"通话设置出错"</string>
@@ -301,14 +301,14 @@
     <string name="manage_fdn_list" msgid="8777755791892122369">"固定拨号列表"</string>
     <string name="fdn_activation" msgid="2156479741307463576">"激活固定拨号"</string>
     <string name="fdn_enabled" msgid="5238109009915521240">"已启用固定拨号"</string>
-    <string name="fdn_disabled" msgid="4700049736675368279">"已停用固定拨号"</string>
+    <string name="fdn_disabled" msgid="4700049736675368279">"未启用固定拨号"</string>
     <string name="enable_fdn" msgid="3740191529180493851">"启用固定拨号"</string>
-    <string name="disable_fdn" msgid="7944020890722540616">"禁用固定拨号"</string>
+    <string name="disable_fdn" msgid="7944020890722540616">"停用固定拨号"</string>
     <string name="change_pin2" msgid="2153563695382176676">"更改 PIN2"</string>
-    <string name="enable_fdn_ok" msgid="7215588870329688132">"禁用固定拨号"</string>
+    <string name="enable_fdn_ok" msgid="7215588870329688132">"停用固定拨号"</string>
     <string name="disable_fdn_ok" msgid="5727046928930740173">"启用固定拨号"</string>
     <string name="sum_fdn" msgid="1959399454900272878">"管理固定拨号"</string>
-    <string name="sum_fdn_change_pin" msgid="6666549734792827932">"更改为访问固定拨号设置的 PIN"</string>
+    <string name="sum_fdn_change_pin" msgid="6666549734792827932">"更改使用固定拨号所需的 PIN 码"</string>
     <string name="sum_fdn_manage_list" msgid="8431088265332628316">"管理手机号码列表"</string>
     <string name="voice_privacy" msgid="3776841382844614716">"语音隐私权"</string>
     <string name="voice_privacy_summary" msgid="3159383389833516214">"启用增强型隐秘模式"</string>
@@ -352,7 +352,7 @@
     <string name="enable_sim_pin" msgid="5803702443844458831">"启用 SIM 卡 PIN"</string>
     <string name="enable_in_progress" msgid="3695303775100109650">"请稍候..."</string>
     <string name="enable_pin_ok" msgid="9166061915030865848">"SIM 卡 PIN 已启用。"</string>
-    <string name="disable_pin_ok" msgid="5596999379593924850">"SIM 卡 PIN 已停用。"</string>
+    <string name="disable_pin_ok" msgid="5596999379593924850">"未启用 SIM 卡 PIN 码。"</string>
     <string name="pin_failed" msgid="2298841192582192277">"键入的 PIN 有误。"</string>
     <string name="pin_changed" msgid="4365538014588501049">"已成功更改 SIM 卡 PIN。"</string>
     <string name="puk_requested" msgid="3898394204193202803">"密码不正确,SIM 已锁定!需要 PUK2。"</string>
@@ -436,8 +436,8 @@
     <string name="hac_mode_title" msgid="8740268574688743289">"助听器"</string>
     <string name="hac_mode_summary" msgid="6833851160514929341">"启用助听器兼容模式"</string>
   <string-array name="tty_mode_entries">
-    <item msgid="512950011423868021">"TTY 已停用"</item>
-    <item msgid="3971695875449640648">"TTY 已满"</item>
+    <item msgid="512950011423868021">"未启用 TTY"</item>
+    <item msgid="3971695875449640648">"TTY 完整"</item>
     <item msgid="1937509904407445684">"TTY HCO"</item>
     <item msgid="5644925873488772224">"TTY VCO"</item>
   </string-array>
@@ -497,15 +497,15 @@
     <string name="contactPhoto" msgid="4713193418046639466">"联系人照片"</string>
     <string name="goPrivate" msgid="865837794424530980">"私聊"</string>
     <string name="selectContact" msgid="781975788478987237">"选择联系人"</string>
-    <string name="sip_settings" msgid="6699045718560859691">"互联网通话设置"</string>
+    <string name="sip_settings" msgid="6699045718560859691">"互联网电话设置"</string>
     <string name="sip_accounts" msgid="2097054001288457163">"互联网电话 (SIP) 帐户"</string>
     <string name="sip_accounts_title" msgid="1212889069281054570">"帐户"</string>
     <string name="sip_receive_calls" msgid="5635685570889971559">"接听来电"</string>
     <string name="sip_receive_calls_summary" msgid="8403613238633679184">"会缩短电池待机时间"</string>
     <string name="sip_call_options_title" msgid="27433718808839672">"使用互联网电话"</string>
-    <string name="sip_call_options_wifi_only_title" msgid="145572394529090811">"使用互联网通话(仅限 WLAN)"</string>
+    <string name="sip_call_options_wifi_only_title" msgid="145572394529090811">"使用互联网电话(仅限 WLAN)"</string>
     <string name="sip_call_options_entry_1" msgid="6556668894178520760">"数据网络接通时适用于所有通话"</string>
-    <string name="sip_call_options_entry_2" msgid="6789764029719494361">"仅适用于互联网通话"</string>
+    <string name="sip_call_options_entry_2" msgid="6789764029719494361">"仅适用于互联网电话"</string>
     <string name="sip_call_options_entry_3" msgid="7474809001402649185">"每次呼叫时询问"</string>
     <string name="sip_call_options_wifi_only_entry_1" msgid="7423523864471650069">"适用于所有通话"</string>
     <string name="pick_outgoing_call_phone_type" msgid="5622916534828338675">"拨打电话"</string>
diff --git a/src/com/android/phone/CallHandlerServiceProxy.java b/src/com/android/phone/CallHandlerServiceProxy.java
index 4426fed..1d43fe8 100644
--- a/src/com/android/phone/CallHandlerServiceProxy.java
+++ b/src/com/android/phone/CallHandlerServiceProxy.java
@@ -294,13 +294,13 @@
         }
     }
 
-    public void bringToForeground() {
+    public void bringToForeground(boolean showDialpad) {
         // only support this call if the service is already connected.
         synchronized (mServiceAndQueueLock) {
             if (mCallHandlerServiceGuarded != null && mCallModeler.hasLiveCall()) {
                 try {
-                    if (DBG) Log.d(TAG, "bringToForeground");
-                    mCallHandlerServiceGuarded.bringToForeground();
+                    if (DBG) Log.d(TAG, "bringToForeground: " + showDialpad);
+                    mCallHandlerServiceGuarded.bringToForeground(showDialpad);
                 } catch (RemoteException e) {
                     Log.e(TAG, "Exception handling bringToForeground", e);
                 }
diff --git a/src/com/android/phone/CallNotifier.java b/src/com/android/phone/CallNotifier.java
index 64a77f3..c7db763 100644
--- a/src/com/android/phone/CallNotifier.java
+++ b/src/com/android/phone/CallNotifier.java
@@ -137,7 +137,6 @@
 
     private PhoneGlobals mApplication;
     private CallManager mCM;
-    private CallStateMonitor mCallStateMonitor;
     private Ringer mRinger;
     private BluetoothHeadset mBluetoothHeadset;
     private CallLogger mCallLogger;
@@ -195,7 +194,6 @@
         mApplication = app;
         mCM = app.mCM;
         mCallLogger = callLogger;
-        mCallStateMonitor = callStateMonitor;
         mBluetoothManager = bluetoothManager;
         mCallModeler = callModeler;
 
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index 4c0c8ed..5c33ab4 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -103,7 +103,6 @@
     private Context mContext;
     private NotificationManager mNotificationManager;
     private StatusBarManager mStatusBarManager;
-    private PowerManager mPowerManager;
     private Toast mToast;
     private boolean mShowingSpeakerphoneIcon;
     private boolean mShowingMuteIcon;
@@ -113,9 +112,7 @@
     // used to track the missed call counter, default to 0.
     private int mNumberMissedCalls = 0;
 
-    // Currently-displayed resource IDs for some status bar icons (or zero
-    // if no notification is active):
-    private int mInCallResId;
+    private boolean mHasInCallNotification = false;
 
     // used to track the notification of selected network unavailable
     private boolean mSelectedUnavailableNotify = false;
@@ -141,8 +138,6 @@
                 (NotificationManager) app.getSystemService(Context.NOTIFICATION_SERVICE);
         mStatusBarManager =
                 (StatusBarManager) app.getSystemService(Context.STATUS_BAR_SERVICE);
-        mPowerManager =
-                (PowerManager) app.getSystemService(Context.POWER_SERVICE);
         mPhone = app.phone;  // TODO: better style to use mCM.getDefaultPhone() everywhere instead
         mCM = app.mCM;
         statusBarHelper = new StatusBarHelper();
@@ -775,7 +770,6 @@
      *   layer (see updateNotificationAndLaunchIncomingCallUi().)
      */
     private void updateInCallNotification(boolean allowFullScreenIntent) {
-        int resId;
         if (DBG) log("updateInCallNotification(allowFullScreenIntent = "
                      + allowFullScreenIntent + ")...");
 
@@ -797,12 +791,8 @@
         }
 
         final boolean hasRingingCall = mCM.hasActiveRingingCall();
-        final boolean hasActiveCall = mCM.hasActiveFgCall();
-        final boolean hasHoldingCall = mCM.hasActiveBgCall();
         if (DBG) {
             log("  - hasRingingCall = " + hasRingingCall);
-            log("  - hasActiveCall = " + hasActiveCall);
-            log("  - hasHoldingCall = " + hasHoldingCall);
         }
 
         // Suppress the in-call notification if the InCallScreen is the
@@ -839,235 +829,14 @@
             return;
         }
 
-        // Display the appropriate icon in the status bar,
-        // based on the current phone and/or bluetooth state.
-
-        if (hasRingingCall) {
-            // There's an incoming ringing call.
-            resId = R.drawable.stat_sys_phone_call;
-        } else if (!hasActiveCall && hasHoldingCall) {
-            // There's only one call, and it's on hold.
-            if (enhancedVoicePrivacy) {
-                resId = R.drawable.stat_sys_vp_phone_call_on_hold;
-            } else {
-                resId = R.drawable.stat_sys_phone_call_on_hold;
-            }
-        } else {
-            if (enhancedVoicePrivacy) {
-                resId = R.drawable.stat_sys_vp_phone_call;
-            } else {
-                resId = R.drawable.stat_sys_phone_call;
-            }
-        }
-
-        // Note we can't just bail out now if (resId == mInCallResId),
-        // since even if the status icon hasn't changed, some *other*
-        // notification-related info may be different from the last time
-        // we were here (like the caller-id info of the foreground call,
-        // if the user swapped calls...)
-
-        if (DBG) log("- Updating status bar icon: resId = " + resId);
-        mInCallResId = resId;
-
-        // Even if both lines are in use, we only show a single item in
-        // the expanded Notifications UI.  It's labeled "Ongoing call"
-        // (or "On hold" if there's only one call, and it's on hold.)
-        // Also, we don't have room to display caller-id info from two
-        // different calls.  So if both lines are in use, display info
-        // from the foreground call.  And if there's a ringing call,
-        // display that regardless of the state of the other calls.
-
-        Call currentCall;
-        if (hasRingingCall) {
-            currentCall = mCM.getFirstActiveRingingCall();
-        } else if (hasActiveCall) {
-            currentCall = mCM.getActiveFgCall();
-        } else {
-            currentCall = mCM.getFirstActiveBgCall();
-        }
-        Connection currentConn = currentCall.getEarliestConnection();
-
-        final Notification.Builder builder = new Notification.Builder(mContext);
-        builder.setSmallIcon(mInCallResId).setOngoing(true);
-
-        // PendingIntent that can be used to launch the InCallScreen.  The
-        // system fires off this intent if the user pulls down the windowshade
-        // and clicks the notification's expanded view.  It's also used to
-        // launch the InCallScreen immediately when when there's an incoming
-        // call (see the "fullScreenIntent" field below).
-        PendingIntent inCallPendingIntent =
-                PendingIntent.getActivity(mContext, 0,
-                                          PhoneGlobals.createInCallIntent(), 0);
-        builder.setContentIntent(inCallPendingIntent);
-
-        // Update icon on the left of the notification.
-        // - If it is directly available from CallerInfo, we'll just use that.
-        // - If it is not, use the same icon as in the status bar.
-        CallerInfo callerInfo = null;
-        if (currentConn != null) {
-            Object o = currentConn.getUserData();
-            if (o instanceof CallerInfo) {
-                callerInfo = (CallerInfo) o;
-            } else if (o instanceof PhoneUtils.CallerInfoToken) {
-                callerInfo = ((PhoneUtils.CallerInfoToken) o).currentInfo;
-            } else {
-                Log.w(LOG_TAG, "CallerInfo isn't available while Call object is available.");
-            }
-        }
-        boolean largeIconWasSet = false;
-        if (callerInfo != null) {
-            // In most cases, the user will see the notification after CallerInfo is already
-            // available, so photo will be available from this block.
-            if (callerInfo.isCachedPhotoCurrent) {
-                // .. and in that case CallerInfo's cachedPhotoIcon should also be available.
-                // If it happens not, then try using cachedPhoto, assuming Drawable coming from
-                // ContactProvider will be BitmapDrawable.
-                if (callerInfo.cachedPhotoIcon != null) {
-                    builder.setLargeIcon(callerInfo.cachedPhotoIcon);
-                    largeIconWasSet = true;
-                } else if (callerInfo.cachedPhoto instanceof BitmapDrawable) {
-                    if (DBG) log("- BitmapDrawable found for large icon");
-                    Bitmap bitmap = ((BitmapDrawable) callerInfo.cachedPhoto).getBitmap();
-                    builder.setLargeIcon(bitmap);
-                    largeIconWasSet = true;
-                } else {
-                    if (DBG) {
-                        log("- Failed to fetch icon from CallerInfo's cached photo."
-                                + " (cachedPhotoIcon: " + callerInfo.cachedPhotoIcon
-                                + ", cachedPhoto: " + callerInfo.cachedPhoto + ")."
-                                + " Ignore it.");
-                    }
-                }
-            }
-
-            if (!largeIconWasSet && callerInfo.photoResource > 0) {
-                if (DBG) {
-                    log("- BitmapDrawable nor person Id not found for large icon."
-                            + " Use photoResource: " + callerInfo.photoResource);
-                }
-                Drawable drawable =
-                        mContext.getResources().getDrawable(callerInfo.photoResource);
-                if (drawable instanceof BitmapDrawable) {
-                    Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
-                    builder.setLargeIcon(bitmap);
-                    largeIconWasSet = true;
-                } else {
-                    if (DBG) {
-                        log("- PhotoResource was found but it didn't return BitmapDrawable."
-                                + " Ignore it");
-                    }
-                }
-            }
-        } else {
-            if (DBG) log("- CallerInfo not found. Use the same icon as in the status bar.");
-        }
-
-        // Failed to fetch Bitmap.
-        if (!largeIconWasSet && DBG) {
-            log("- No useful Bitmap was found for the photo."
-                    + " Use the same icon as in the status bar.");
-        }
-
-        // If the connection is valid, then build what we need for the
-        // content text of notification, and start the chronometer.
-        // Otherwise, don't bother and just stick with content title.
-        if (currentConn != null) {
-            if (DBG) log("- Updating context text and chronometer.");
-            if (hasRingingCall) {
-                // Incoming call is ringing.
-                builder.setContentText(mContext.getString(R.string.notification_incoming_call));
-                builder.setUsesChronometer(false);
-            } else if (hasHoldingCall && !hasActiveCall) {
-                // Only one call, and it's on hold.
-                builder.setContentText(mContext.getString(R.string.notification_on_hold));
-                builder.setUsesChronometer(false);
-            } else {
-                // We show the elapsed time of the current call using Chronometer.
-                builder.setUsesChronometer(true);
-
-                // Determine the "start time" of the current connection.
-                //   We can't use currentConn.getConnectTime(), because (1) that's
-                // in the currentTimeMillis() time base, and (2) it's zero when
-                // the phone first goes off hook, since the getConnectTime counter
-                // doesn't start until the DIALING -> ACTIVE transition.
-                //   Instead we start with the current connection's duration,
-                // and translate that into the elapsedRealtime() timebase.
-                long callDurationMsec = currentConn.getDurationMillis();
-                builder.setWhen(System.currentTimeMillis() - callDurationMsec);
-
-                int contextTextId = R.string.notification_ongoing_call;
-
-                Call call = mCM.getActiveFgCall();
-                if (TelephonyCapabilities.canDistinguishDialingAndConnected(
-                        call.getPhone().getPhoneType()) && call.isDialingOrAlerting()) {
-                  contextTextId = R.string.notification_dialing;
-                }
-
-                builder.setContentText(mContext.getString(contextTextId));
-            }
-        } else if (DBG) {
-            Log.w(LOG_TAG, "updateInCallNotification: null connection, can't set exp view line 1.");
-        }
-
-        // display conference call string if this call is a conference
-        // call, otherwise display the connection information.
-
-        // Line 2 of the expanded view (smaller text).  This is usually a
-        // contact name or phone number.
-        String expandedViewLine2 = "";
-        // TODO: it may not make sense for every point to make separate
-        // checks for isConferenceCall, so we need to think about
-        // possibly including this in startGetCallerInfo or some other
-        // common point.
-        if (PhoneUtils.isConferenceCall(currentCall)) {
-            // if this is a conference call, just use that as the caller name.
-            expandedViewLine2 = mContext.getString(R.string.card_title_conf_call);
-        } else {
-            // If necessary, start asynchronous query to do the caller-id lookup.
-            PhoneUtils.CallerInfoToken cit =
-                PhoneUtils.startGetCallerInfo(mContext, currentCall, this, this);
-            expandedViewLine2 = PhoneUtils.getCompactNameFromCallerInfo(cit.currentInfo, mContext);
-            // Note: For an incoming call, the very first time we get here we
-            // won't have a contact name yet, since we only just started the
-            // caller-id query.  So expandedViewLine2 will start off as a raw
-            // phone number, but we'll update it very quickly when the query
-            // completes (see onQueryComplete() below.)
-        }
-
-        if (DBG) log("- Updating expanded view: line 2 '" + /*expandedViewLine2*/ "xxxxxxx" + "'");
-        builder.setContentTitle(expandedViewLine2);
-
-        // TODO: We also need to *update* this notification in some cases,
-        // like when a call ends on one line but the other is still in use
-        // (ie. make sure the caller info here corresponds to the active
-        // line), and maybe even when the user swaps calls (ie. if we only
-        // show info here for the "current active call".)
+        mHasInCallNotification = true;
 
         // Activate a couple of special Notification features if an
         // incoming call is ringing:
         if (hasRingingCall) {
             if (DBG) log("- Using hi-pri notification for ringing call!");
 
-            // This is a high-priority event that should be shown even if the
-            // status bar is hidden or if an immersive activity is running.
-            builder.setPriority(Notification.PRIORITY_HIGH);
-
-            // If an immersive activity is running, we have room for a single
-            // line of text in the small notification popup window.
-            // We use expandedViewLine2 for this (i.e. the name or number of
-            // the incoming caller), since that's more relevant than
-            // expandedViewLine1 (which is something generic like "Incoming
-            // call".)
-            builder.setTicker(expandedViewLine2);
-
             if (allowFullScreenIntent) {
-                // Ok, we actually want to launch the incoming call
-                // UI at this point (in addition to simply posting a notification
-                // to the status bar).  Setting fullScreenIntent will cause
-                // the InCallScreen to be launched immediately *unless* the
-                // current foreground activity is marked as "immersive".
-                if (DBG) log("- Setting fullScreenIntent: " + inCallPendingIntent);
-                builder.setFullScreenIntent(inCallPendingIntent, true);
 
                 // Ugly hack alert:
                 //
@@ -1098,23 +867,8 @@
                     mNotificationManager.cancel(IN_CALL_NOTIFICATION);
                 }
             }
-        } else { // not ringing call
-            // Make the notification prioritized over the other normal notifications.
-            builder.setPriority(Notification.PRIORITY_HIGH);
-
-            // TODO: use "if (DBG)" for this comment.
-            log("Will show \"hang-up\" action in the ongoing active call Notification");
-            // TODO: use better asset.
-            builder.addAction(R.drawable.stat_sys_phone_call_end,
-                    mContext.getText(R.string.notification_action_end_call),
-                    PhoneGlobals.createHangUpOngoingCallPendingIntent(mContext));
         }
 
-        Notification notification = builder.getNotification();
-        if (DBG) log("Notifying IN_CALL_NOTIFICATION: " + notification);
-        // TODO(klp): not needed anymore.  Possibly delete this and move notification to incallui.
-        //mNotificationManager.notify(IN_CALL_NOTIFICATION, notification);
-
         // Finally, refresh the mute and speakerphone notifications (since
         // some phone state changes can indirectly affect the mute and/or
         // speaker state).
@@ -1159,7 +913,7 @@
     private void cancelInCall() {
         if (DBG) log("cancelInCall()...");
         mNotificationManager.cancel(IN_CALL_NOTIFICATION);
-        mInCallResId = 0;
+        mHasInCallNotification = false;
     }
 
     /**
@@ -1168,11 +922,11 @@
      */
     /* package */ void cancelCallInProgressNotifications() {
         if (DBG) log("cancelCallInProgressNotifications()...");
-        if (mInCallResId == 0) {
+        if (!mHasInCallNotification) {
             return;
         }
 
-        if (DBG) log("cancelCallInProgressNotifications: " + mInCallResId);
+        if (DBG) log("cancelCallInProgressNotifications");
         cancelInCall();
         cancelMute();
         cancelSpeakerphone();
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index c37fe07..1ce46b2 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -297,7 +297,7 @@
     }
 
     private boolean showCallScreenInternal(boolean specifyInitialDialpadState,
-                                           boolean initialDialpadState) {
+                                           boolean showDialpad) {
         if (!PhoneGlobals.sVoiceCapable) {
             // Never allow the InCallScreen to appear on data-only devices.
             return false;
@@ -308,7 +308,7 @@
         // If the phone isn't idle then go to the in-call screen
         long callingId = Binder.clearCallingIdentity();
 
-        mCallHandlerService.bringToForeground();
+        mCallHandlerService.bringToForeground(showDialpad);
 
         Binder.restoreCallingIdentity(callingId);
         return true;
diff --git a/src/com/android/phone/SipCallOptionHandler.java b/src/com/android/phone/SipCallOptionHandler.java
index 295e886..5a7e91f 100644
--- a/src/com/android/phone/SipCallOptionHandler.java
+++ b/src/com/android/phone/SipCallOptionHandler.java
@@ -36,6 +36,8 @@
 import android.net.sip.SipManager;
 import android.net.sip.SipProfile;
 import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
 import android.os.SystemProperties;
 import android.provider.Settings;
 import android.telephony.PhoneNumberUtils;
@@ -85,6 +87,21 @@
     private boolean mUseSipPhone = false;
     private boolean mMakePrimary = false;
 
+    private static final int EVENT_DELAYED_FINISH = 1;
+
+    private static final int DELAYED_FINISH_TIME = 2000; // msec
+
+    private final Handler mHandler = new Handler() {
+        @Override
+        public void handleMessage(Message msg) {
+            if (msg.what == EVENT_DELAYED_FINISH) {
+                finish();
+            } else {
+                Log.wtf(TAG, "Unknown message id: " + msg.what);
+            }
+        }
+    };
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -208,6 +225,14 @@
         setResultAndFinish();
     }
 
+    /**
+     * Starts a delayed finish() in order to give the UI
+     * some time to start up.
+     */
+    private void startDelayedFinish() {
+        mHandler.sendEmptyMessageDelayed(EVENT_DELAYED_FINISH, DELAYED_FINISH_TIME);
+    }
+
     @Override
     public void onPause() {
         super.onPause();
@@ -394,7 +419,7 @@
                     // Woo hoo -- it's finally OK to initiate the outgoing call!
                     PhoneGlobals.getInstance().callController.placeCall(mIntent);
                 }
-                finish();
+                startDelayedFinish();
             }
         });
     }