    private void updateInCallNotification(boolean allowFullScreenIntent) {
        int resId;
        if (DBG) log("updateInCallNotification(allowFullScreenIntent = "
                     + allowFullScreenIntent + ")...");
        if (!PhoneApp.sVoiceCapable) {
            if (DBG) log("- non-voice-capable device; suppressing notification.");
            return;
        }
        if (mCM.getState() == Phone.State.IDLE) {
            cancelInCall();
            cancelMute();
            cancelSpeakerphone();
            return;
        }
        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);
        }
        if (mApp.isShowingCallScreen() && !hasRingingCall) {
            cancelInCall();
            return;
        }
        boolean enhancedVoicePrivacy = mApp.notifier.getVoicePrivacyState();
        if (DBG) log("updateInCallNotification: enhancedVoicePrivacy = " + enhancedVoicePrivacy);
        if (hasRingingCall) {
            resId = R.drawable.stat_sys_phone_call_ringing;
        } else if (!hasActiveCall && hasHoldingCall) {
            if (enhancedVoicePrivacy) {
                resId = R.drawable.stat_sys_vp_phone_call_on_hold;
            } else {
                resId = R.drawable.stat_sys_phone_call_on_hold;
            }
        } else if (mApp.showBluetoothIndication()) {
            if (enhancedVoicePrivacy) {
                resId = R.drawable.stat_sys_vp_phone_call_bluetooth;
            } else {
                resId = R.drawable.stat_sys_phone_call_bluetooth;
            }
        } else {
            if (enhancedVoicePrivacy) {
                resId = R.drawable.stat_sys_vp_phone_call;
            } else {
                resId = R.drawable.stat_sys_phone_call;
            }
        }
        if (DBG) log("- Updating status bar icon: resId = " + resId);
        mInCallResId = resId;
        int expandedViewIcon = mInCallResId;
        Call currentCall;
        if (hasRingingCall) {
            currentCall = mCM.getFirstActiveRingingCall();
        } else if (hasActiveCall) {
            currentCall = mCM.getActiveFgCall();
        } else {
            currentCall = mCM.getFirstActiveBgCall();
        }
        Connection currentConn = currentCall.getEarliestConnection();
        Notification notification = new Notification();
        notification.icon = mInCallResId;
        notification.flags |= Notification.FLAG_ONGOING_EVENT;
        PendingIntent inCallPendingIntent =
                PendingIntent.getActivity(mContext, 0,
                                          PhoneApp.createInCallIntent(), 0);
        notification.contentIntent = inCallPendingIntent;
        RemoteViews contentView = new RemoteViews(mContext.getPackageName(),
                                                   R.layout.ongoing_call_notification);
        contentView.setImageViewResource(R.id.icon, expandedViewIcon);
        if (currentConn != null) {
            long callDurationMsec = currentConn.getDurationMillis();
            long chronometerBaseTime = SystemClock.elapsedRealtime() - callDurationMsec;
            String expandedViewLine1;
            if (hasRingingCall) {
                expandedViewLine1 = mContext.getString(R.string.notification_incoming_call);
            } else if (hasHoldingCall && !hasActiveCall) {
                expandedViewLine1 = mContext.getString(R.string.notification_on_hold);
            } else {
                expandedViewLine1 = mContext.getString(R.string.notification_ongoing_call_format);
            }
            if (DBG) log("- Updating expanded view: line 1 '" +  "xxxxxxx" + "'");
            contentView.setChronometer(R.id.text1,
                                       chronometerBaseTime,
                                       expandedViewLine1,
                                       true);
        } else if (DBG) {
            Log.w(LOG_TAG, "updateInCallNotification: null connection, can't set exp view line 1.");
        }
        String expandedViewLine2 = "";
        if (PhoneUtils.isConferenceCall(currentCall)) {
            expandedViewLine2 = mContext.getString(R.string.card_title_conf_call);
        } else {
            PhoneUtils.CallerInfoToken cit =
                PhoneUtils.startGetCallerInfo(mContext, currentCall, this, this);
            expandedViewLine2 = PhoneUtils.getCompactNameFromCallerInfo(cit.currentInfo, mContext);
        }
        if (DBG) log("- Updating expanded view: line 2 '" +  "xxxxxxx" + "'");
        contentView.setTextViewText(R.id.text2, expandedViewLine2);
        notification.contentView = contentView;
        if (hasRingingCall) {
            if (DBG) log("- Using hi-pri notification for ringing call!");
            notification.flags |= Notification.FLAG_HIGH_PRIORITY;
            notification.tickerText = expandedViewLine2;
            if (allowFullScreenIntent) {
                if (DBG) log("- Setting fullScreenIntent: " + inCallPendingIntent);
                notification.fullScreenIntent = inCallPendingIntent;
                Call ringingCall = mCM.getFirstActiveRingingCall();
                if ((ringingCall.getState() == Call.State.WAITING) && !mApp.isShowingCallScreen()) {
                    Log.i(LOG_TAG, "updateInCallNotification: call-waiting! force relaunch...");
                    mNotificationManager.cancel(IN_CALL_NOTIFICATION);
                }
            }
        }
        if (DBG) log("Notifying IN_CALL_NOTIFICATION: " + notification);
        mNotificationManager.notify(IN_CALL_NOTIFICATION,
                                notification);
        updateSpeakerNotification();
        updateMuteNotification();
    }

    private void updateInCallNotification(boolean allowFullScreenIntent) {
        int resId;
        if (DBG) log("updateInCallNotification(allowFullScreenIntent = "
                     + allowFullScreenIntent + ")...");
        if (!PhoneApp.sVoiceCapable) {
            if (DBG) log("- non-voice-capable device; suppressing notification.");
            return;
        }
        if (mCM.getState() == Phone.State.IDLE) {
            cancelInCall();
            cancelMute();
            cancelSpeakerphone();
            return;
        }
        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);
        }
        if (mApp.isShowingCallScreen() && !hasRingingCall) {
            cancelInCall();
            return;
        }
        boolean enhancedVoicePrivacy = mApp.notifier.getVoicePrivacyState();
        if (DBG) log("updateInCallNotification: enhancedVoicePrivacy = " + enhancedVoicePrivacy);
        if (hasRingingCall) {
            resId = R.drawable.stat_sys_phone_call_ringing;
        } else if (!hasActiveCall && hasHoldingCall) {
            if (enhancedVoicePrivacy) {
                resId = R.drawable.stat_sys_vp_phone_call_on_hold;
            } else {
                resId = R.drawable.stat_sys_phone_call_on_hold;
            }
        } else if (mApp.showBluetoothIndication()) {
            if (enhancedVoicePrivacy) {
                resId = R.drawable.stat_sys_vp_phone_call_bluetooth;
            } else {
                resId = R.drawable.stat_sys_phone_call_bluetooth;
            }
        } else {
            if (enhancedVoicePrivacy) {
                resId = R.drawable.stat_sys_vp_phone_call;
            } else {
                resId = R.drawable.stat_sys_phone_call;
            }
        }
        if (DBG) log("- Updating status bar icon: resId = " + resId);
        mInCallResId = resId;
        int expandedViewIcon = mInCallResId;
        Call currentCall;
        if (hasRingingCall) {
            currentCall = mCM.getFirstActiveRingingCall();
        } else if (hasActiveCall) {
            currentCall = mCM.getActiveFgCall();
        } else {
            currentCall = mCM.getFirstActiveBgCall();
        }
        Connection currentConn = currentCall.getEarliestConnection();
        Notification notification = new Notification();
        notification.icon = mInCallResId;
        notification.flags |= Notification.FLAG_ONGOING_EVENT;
        PendingIntent inCallPendingIntent =
                PendingIntent.getActivity(mContext, 0,
                                          PhoneApp.createInCallIntent(), 0);
        notification.contentIntent = inCallPendingIntent;
        RemoteViews contentView = new RemoteViews(mContext.getPackageName(),
                                                   R.layout.ongoing_call_notification);
        contentView.setImageViewResource(R.id.icon, expandedViewIcon);
        if (currentConn != null) {
            long callDurationMsec = currentConn.getDurationMillis();
            long chronometerBaseTime = SystemClock.elapsedRealtime() - callDurationMsec;
            String expandedViewLine1;
            if (hasRingingCall) {
                expandedViewLine1 = mContext.getString(R.string.notification_incoming_call);
            } else if (hasHoldingCall && !hasActiveCall) {
                expandedViewLine1 = mContext.getString(R.string.notification_on_hold);
            } else {
                expandedViewLine1 = mContext.getString(R.string.notification_ongoing_call_format);
            }
            if (DBG) log("- Updating expanded view: line 1 '" +  "xxxxxxx" + "'");
            contentView.setChronometer(R.id.text1,
                                       chronometerBaseTime,
                                       expandedViewLine1,
                                       true);
        } else if (DBG) {
            Log.w(LOG_TAG, "updateInCallNotification: null connection, can't set exp view line 1.");
        }
        String expandedViewLine2 = "";
        if (PhoneUtils.isConferenceCall(currentCall)) {
            expandedViewLine2 = mContext.getString(R.string.card_title_conf_call);
        } else {
            PhoneUtils.CallerInfoToken cit =
                PhoneUtils.startGetCallerInfo(mContext, currentCall, this, this);
            expandedViewLine2 = PhoneUtils.getCompactNameFromCallerInfo(cit.currentInfo, mContext);
        }
        if (DBG) log("- Updating expanded view: line 2 '" +  "xxxxxxx" + "'");
        contentView.setTextViewText(R.id.title, expandedViewLine2);
        notification.contentView = contentView;
        if (hasRingingCall) {
            if (DBG) log("- Using hi-pri notification for ringing call!");
            notification.flags |= Notification.FLAG_HIGH_PRIORITY;
            notification.tickerText = expandedViewLine2;
            if (allowFullScreenIntent) {
                if (DBG) log("- Setting fullScreenIntent: " + inCallPendingIntent);
                notification.fullScreenIntent = inCallPendingIntent;
                Call ringingCall = mCM.getFirstActiveRingingCall();
                if ((ringingCall.getState() == Call.State.WAITING) && !mApp.isShowingCallScreen()) {
                    Log.i(LOG_TAG, "updateInCallNotification: call-waiting! force relaunch...");
                    mNotificationManager.cancel(IN_CALL_NOTIFICATION);
                }
            }
        }
        if (DBG) log("Notifying IN_CALL_NOTIFICATION: " + notification);
        mNotificationManager.notify(IN_CALL_NOTIFICATION,
                                notification);
        updateSpeakerNotification();
        updateMuteNotification();
    }
