Add incoming-during-hold case to fullscreen Notification code.

We use fullScreen notifications to bring up the incoming call screen
when it is not already being shown.  Android framework ignores
fullScreen property if the same notification ID already exists. To fix
that we cancel the notification right before setting it to full screen.

We only used to do that for the CALL_WAITING state since that when it
mattered.  However, if the current call is on hold, a new call comes in
as INCOMING instead of CALL_WAITING so this change adds that condition
as well.

Also fixed two other minor pieces of code which only checked INCOMING
and not CALL_WAITING.  One for an icon, the other used to acquiring
location as part of the contact info (we only do so for incoming calls).

bug:11578080
Change-Id: Id010a6848cd1ca06d68e8405041565bc008a781e
diff --git a/src/com/android/incallui/InCallPresenter.java b/src/com/android/incallui/InCallPresenter.java
index bfb4a50..80c4739 100644
--- a/src/com/android/incallui/InCallPresenter.java
+++ b/src/com/android/incallui/InCallPresenter.java
@@ -94,7 +94,7 @@
 
         mContactInfoCache = ContactInfoCache.getInstance(context);
 
-        mStatusBarNotifier = new StatusBarNotifier(context, mContactInfoCache, mCallList);
+        mStatusBarNotifier = new StatusBarNotifier(context, mContactInfoCache);
         addListener(mStatusBarNotifier);
 
         mAudioModeProvider = audioModeProvider;
diff --git a/src/com/android/incallui/StatusBarNotifier.java b/src/com/android/incallui/StatusBarNotifier.java
index 89c9ff4..6d9fd60 100644
--- a/src/com/android/incallui/StatusBarNotifier.java
+++ b/src/com/android/incallui/StatusBarNotifier.java
@@ -96,8 +96,7 @@
     private Bitmap mSavedLargeIcon;
     private String mSavedContentTitle;
 
-    public StatusBarNotifier(Context context, ContactInfoCache contactInfoCache,
-            CallList callList) {
+    public StatusBarNotifier(Context context, ContactInfoCache contactInfoCache) {
         Preconditions.checkNotNull(context);
 
         mContext = context;
@@ -254,12 +253,15 @@
     }
 
     private void showNotification(final Call call, final boolean allowFullScreenIntent) {
+        final boolean isIncoming = (call.getState() == Call.State.INCOMING ||
+                call.getState() == Call.State.CALL_WAITING);
+
         // we make a call to the contact info cache to query for supplemental data to what the
         // call provides.  This includes the contact name and photo.
         // This callback will always get called immediately and synchronously with whatever data
         // it has available, and may make a subsequent call later (same thread) if it had to
         // call into the contacts provider for more data.
-        mContactInfoCache.findInfo(call.getIdentification(), call.getState() == Call.State.INCOMING,
+        mContactInfoCache.findInfo(call.getIdentification(), isIncoming,
                 new ContactInfoCacheCallback() {
                     private boolean mAllowFullScreenIntent = allowFullScreenIntent;
 
@@ -457,12 +459,12 @@
     }
 
     /**
-     * Returns the message to use with the notificaiton.
+     * Returns the message to use with the notification.
      */
     private int getContentString(Call call) {
         int resId = R.string.notification_ongoing_call;
 
-        if (call.getState() == Call.State.INCOMING) {
+        if (call.getState() == Call.State.INCOMING || call.getState() == Call.State.CALL_WAITING) {
             resId = R.string.notification_incoming_call;
 
         } else if (call.getState() == Call.State.ONHOLD) {
@@ -535,7 +537,14 @@
         // TODO: there should be a cleaner way of avoiding this
         // problem (see discussion in bug 3184149.)
 
-        if (call.getState() == Call.State.CALL_WAITING) {
+        // If a call is onhold during an incoming call, the call actually comes in as
+        // INCOMING.  For that case *and* traditional call-waiting, we want to
+        // cancel the notification.
+        boolean isCallWaiting = (call.getState() == Call.State.CALL_WAITING ||
+                (call.getState() == Call.State.INCOMING &&
+                        CallList.getInstance().getBackgroundCall() != null));
+
+        if (isCallWaiting) {
             Log.i(this, "updateInCallNotification: call-waiting! force relaunch...");
             // Cancel the IN_CALL_NOTIFICATION immediately before
             // (re)posting it; this seems to force the