Merge "Adjust SIM icon tint and fix InCallUI glitches for call state icon." into lmp-dev
diff --git a/InCallUI/res/layout/select_account_list_item.xml b/InCallUI/res/layout/select_account_list_item.xml
index bb618ff..1999fce 100644
--- a/InCallUI/res/layout/select_account_list_item.xml
+++ b/InCallUI/res/layout/select_account_list_item.xml
@@ -15,7 +15,8 @@
 -->
 
 <!-- Layout of a single item in the InCallUI Account Chooser Dialog. -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<view class="com.android.contacts.common.widget.ActivityTouchLinearLayout"
+    xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="horizontal"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
@@ -34,4 +35,4 @@
               android:layout_width="0dp"
               android:layout_weight="1"
               android:layout_height="match_parent" />
-</LinearLayout>
+</view>
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java
index 6defe79..bd32684 100644
--- a/InCallUI/src/com/android/incallui/CallCardFragment.java
+++ b/InCallUI/src/com/android/incallui/CallCardFragment.java
@@ -369,7 +369,7 @@
     @Override
     public void setPrimaryName(String name, boolean nameIsNumber) {
         if (TextUtils.isEmpty(name)) {
-            mPrimaryName.setText("");
+            mPrimaryName.setText(null);
         } else {
             mPrimaryName.setText(name);
 
@@ -393,7 +393,7 @@
     public void setPrimaryPhoneNumber(String number) {
         // Set the number
         if (TextUtils.isEmpty(number)) {
-            mPhoneNumber.setText("");
+            mPhoneNumber.setText(null);
             mPhoneNumber.setVisibility(View.GONE);
         } else {
             mPhoneNumber.setText(number);
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java
index 9308189..2dc4274 100644
--- a/InCallUI/src/com/android/incallui/CallCardPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java
@@ -187,8 +187,6 @@
         Log.d(this, "Primary call: " + primary);
         Log.d(this, "Secondary call: " + secondary);
 
-        final boolean outgoingCallReady = newState == InCallState.OUTGOING &&
-                oldState == InCallState.PENDING_OUTGOING;
         final boolean primaryChanged = !Call.areSame(mPrimary, primary);
         final boolean secondaryChanged = !Call.areSame(mSecondary, secondary);
 
diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java
index cbb2af2..02635dc 100644
--- a/InCallUI/src/com/android/incallui/InCallActivity.java
+++ b/InCallUI/src/com/android/incallui/InCallActivity.java
@@ -454,14 +454,20 @@
                 intent.removeExtra(NEW_OUTGOING_CALL);
 
                 Point touchPoint = null;
-                Call call = CallList.getInstance().getOutgoingCall();
-                if (call == null) {
-                    call = CallList.getInstance().getPendingOutgoingCall();
-                }
-                if (call != null) {
-                    Bundle extras = call.getTelecommCall().getDetails().getExtras();
-                    touchPoint = (Point) (extras == null ?
-                            null : extras.getParcelable(TouchPointManager.TOUCH_POINT));
+                if (TouchPointManager.getInstance().hasValidPoint()) {
+                    // Use the most immediate touch point in the InCallUi if available
+                    touchPoint = TouchPointManager.getInstance().getPoint();
+                } else {
+                    // Otherwise retrieve the touch point from the call intent
+                    Call call = CallList.getInstance().getOutgoingCall();
+                    if (call == null) {
+                        call = CallList.getInstance().getPendingOutgoingCall();
+                    }
+                    if (call != null) {
+                        Bundle extras = call.getTelecommCall().getDetails().getExtras();
+                        touchPoint = (Point) (extras == null ?
+                                null : extras.getParcelable(TouchPointManager.TOUCH_POINT));
+                    }
                 }
                 mCallCardFragment.animateForNewOutgoingCall(touchPoint);
             }
diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java
index 38b5f54..77ef49d 100644
--- a/InCallUI/src/com/android/incallui/InCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/InCallPresenter.java
@@ -804,16 +804,18 @@
 
         // A new outgoing call indicates that the user just now dialed a number and when that
         // happens we need to display the screen immediately or show an account picker dialog if
-        // no default is set.
+        // no default is set. However, if the main InCallUI is already visible, we do not want to
+        // re-initiate the start-up animation, so we do not need to do anything here.
         //
         // It is also possible to go into an intermediate state where the call has been initiated
         // but Telecomm has not yet returned with the details of the call (handle, gateway, etc.).
-        // This pending outgoing state also launches the call screen.
+        // This pending outgoing state can also launch the call screen.
         //
         // This is different from the incoming call sequence because we do not need to shock the
         // user with a top-level notification.  Just show the call UI normally.
+        final boolean mainUiNotVisible = !isShowingInCallUi() || !getCallCardFragmentVisible();
         final boolean showCallUi = ((InCallState.PENDING_OUTGOING == newState ||
-                InCallState.OUTGOING == newState) || showAccountPicker);
+                InCallState.OUTGOING == newState) && mainUiNotVisible);
 
         // TODO: Can we be suddenly in a call without it having been in the outgoing or incoming
         // state?  I havent seen that but if it can happen, the code below should be enabled.
@@ -829,7 +831,7 @@
             return mInCallState;
         }
 
-        if (showCallUi) {
+        if (showCallUi || showAccountPicker) {
             Log.i(this, "Start in call UI");
             showInCall(false /* showDialpad */, !showAccountPicker /* newOutgoingCall */);
         } else if (startStartupSequence) {
@@ -1014,6 +1016,18 @@
     }
 
     /**
+     * Returns whether the call card fragment is currently visible.
+     *
+     * @return True if the call card fragment is visible.
+     */
+    public boolean getCallCardFragmentVisible() {
+        if (mInCallActivity != null) {
+            return mInCallActivity.getCallCardFragment().isVisible();
+        }
+        return false;
+    }
+
+    /**
      * @return True if the application is currently running in a right-to-left locale.
      */
     public static boolean isRtl() {
diff --git a/InCallUI/src/com/android/incallui/TelecommAdapter.java b/InCallUI/src/com/android/incallui/TelecommAdapter.java
index 22aff11..1f5c9c5 100644
--- a/InCallUI/src/com/android/incallui/TelecommAdapter.java
+++ b/InCallUI/src/com/android/incallui/TelecommAdapter.java
@@ -220,5 +220,9 @@
         }  else {
             Log.e(this, "error phoneAccountSelected, mAdapter is null");
         }
+
+        if (accountHandle == null) {
+            Log.e(this, "error phoneAccountSelected, accountHandle is null");
+        }
     }
 }