Fix secondary call card in rtl

Bug: 10541171
Change-Id: Ia63b6c5f1ce12ffe0a253d10a92470bbd1e7539e
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java
index bf3c42c..486b083 100644
--- a/InCallUI/src/com/android/incallui/CallCardFragment.java
+++ b/InCallUI/src/com/android/incallui/CallCardFragment.java
@@ -202,12 +202,19 @@
     }
 
     @Override
-    public void setSecondary(boolean show, String name, String label, Drawable photo) {
+    public void setSecondary(boolean show, String name, boolean nameIsNumber, String label,
+            Drawable photo) {
 
         if (show) {
             showAndInitializeSecondaryCallInfo();
-
             mSecondaryCallName.setText(name);
+
+            int nameDirection = View.TEXT_DIRECTION_INHERIT;
+            if (nameIsNumber) {
+                nameDirection = View.TEXT_DIRECTION_LTR;
+            }
+            mSecondaryCallName.setTextDirection(nameDirection);
+
             setDrawableToImageView(mSecondaryPhoto, photo);
         } else {
             mSecondaryCallInfo.setVisibility(View.GONE);
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java
index 5b6520d..42dfb8e 100644
--- a/InCallUI/src/com/android/incallui/CallCardPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java
@@ -21,6 +21,7 @@
 import android.content.pm.PackageManager;
 import android.graphics.drawable.Drawable;
 import android.graphics.Bitmap;
+import android.telephony.PhoneNumberUtils;
 import android.text.TextUtils;
 import android.text.format.DateUtils;
 
@@ -368,11 +369,15 @@
 
         if (mSecondaryContactInfo != null) {
             Log.d(TAG, "updateSecondaryDisplayInfo() " + mSecondaryContactInfo);
-            ui.setSecondary(true, getNameForCall(mSecondaryContactInfo),
-                    mSecondaryContactInfo.label, mSecondaryContactInfo.photo);
+            final String nameForCall = getNameForCall(mSecondaryContactInfo);
+
+            final boolean nameIsNumber = nameForCall != null && nameForCall.equals(
+                    mSecondaryContactInfo.number);
+            ui.setSecondary(true, nameForCall, nameIsNumber, mSecondaryContactInfo.label,
+                    mSecondaryContactInfo.photo);
         } else {
             // reset to nothing so that it starts off blank next time we use it.
-            ui.setSecondary(false, null, null, null);
+            ui.setSecondary(false, null, false, null, null);
         }
     }
 
@@ -490,10 +495,10 @@
         void setVisible(boolean on);
         void setPrimary(String number, String name, boolean nameIsNumber, String label,
                 Drawable photo, boolean isConference, String gatewayLabel, String gatewayNumber);
-        void setSecondary(boolean show, String name, String label, Drawable photo);
+        void setSecondary(boolean show, String name, boolean nameIsNumber, String label,
+                Drawable photo);
         void setSecondaryImage(Bitmap bitmap);
         void setCallState(int state, Call.DisconnectCause cause, boolean bluetoothOn);
-
         void setPrimaryCallElapsedTime(boolean show, String duration);
         void setPrimaryName(String name, boolean nameIsNumber);
         void setPrimaryImage(Bitmap bitmap);