Fix bug that phone number is shown for local contacts.

This is a regression caused by cl/169961072.
This change will make sure phone number is only shown on top row for non-local contacts if the name is not number and the call is active.

Bug: 67047386
Test: TopRowTest
PiperOrigin-RevId: 170424277
Change-Id: I9b3ab9432a938b2fb1c6632f2d9404bee413588f
diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java
index be9b3ef..d49d556 100644
--- a/java/com/android/incallui/CallCardPresenter.java
+++ b/java/com/android/incallui/CallCardPresenter.java
@@ -712,6 +712,7 @@
               showContactPhoto,
               hasWorkCallProperty,
               false /* isSpam */,
+              false /* isLocalContact */,
               false /* answeringDisconnectsOngoingCall */,
               shouldShowLocation(),
               null /* contactInfoLookupKey */,
@@ -760,6 +761,7 @@
               showContactPhoto,
               hasWorkCallProperty || isWorkContact,
               mPrimary.isSpam(),
+              mPrimaryContactInfo.isLocalContact(),
               mPrimary.answeringDisconnectsForegroundVideoCall(),
               shouldShowLocation(),
               mPrimaryContactInfo.lookupKey,
diff --git a/java/com/android/incallui/ContactInfoCache.java b/java/com/android/incallui/ContactInfoCache.java
index 39c4c2f..2a93945 100644
--- a/java/com/android/incallui/ContactInfoCache.java
+++ b/java/com/android/incallui/ContactInfoCache.java
@@ -721,6 +721,10 @@
     boolean isEmergencyNumber;
     boolean isVoicemailNumber;
 
+    public boolean isLocalContact() {
+      return contactLookupResult == ContactLookupResult.Type.LOCAL_CONTACT;
+    }
+
     @Override
     public String toString() {
       return "ContactCacheEntry{"
diff --git a/java/com/android/incallui/callpending/CallPendingActivity.java b/java/com/android/incallui/callpending/CallPendingActivity.java
index 26490d9..7fc4caf 100644
--- a/java/com/android/incallui/callpending/CallPendingActivity.java
+++ b/java/com/android/incallui/callpending/CallPendingActivity.java
@@ -189,6 +189,7 @@
         true /* isContactPhotoShown */,
         false /* isWorkCall */,
         false /* isSpam */,
+        true /* isLocalContact */,
         false /* answeringDisconnectsOngoingCall */,
         false /* shouldShowLocation */,
         getLookupKey(),
diff --git a/java/com/android/incallui/contactgrid/TopRow.java b/java/com/android/incallui/contactgrid/TopRow.java
index 8f54266..3593c99 100644
--- a/java/com/android/incallui/contactgrid/TopRow.java
+++ b/java/com/android/incallui/contactgrid/TopRow.java
@@ -122,6 +122,9 @@
     if (primaryInfo.location == null && isIncoming) {
       return false;
     }
+    if (primaryInfo.isLocalContact && !isIncoming) {
+      return false;
+    }
     if (TextUtils.isEmpty(primaryInfo.number)) {
       return false;
     }
diff --git a/java/com/android/incallui/incall/protocol/PrimaryInfo.java b/java/com/android/incallui/incall/protocol/PrimaryInfo.java
index 7fe0a0f..69eee20 100644
--- a/java/com/android/incallui/incall/protocol/PrimaryInfo.java
+++ b/java/com/android/incallui/incall/protocol/PrimaryInfo.java
@@ -36,6 +36,7 @@
   public final boolean isContactPhotoShown;
   public final boolean isWorkCall;
   public final boolean isSpam;
+  public final boolean isLocalContact;
   public final boolean answeringDisconnectsOngoingCall;
   public final boolean shouldShowLocation;
   // Used for consistent LetterTile coloring.
@@ -60,6 +61,7 @@
         false,
         false,
         false,
+        false,
         null,
         null,
         true,
@@ -78,6 +80,7 @@
       boolean isContactPhotoShown,
       boolean isWorkCall,
       boolean isSpam,
+      boolean isLocalContact,
       boolean answeringDisconnectsOngoingCall,
       boolean shouldShowLocation,
       @Nullable String contactInfoLookupKey,
@@ -95,6 +98,7 @@
     this.isContactPhotoShown = isContactPhotoShown;
     this.isWorkCall = isWorkCall;
     this.isSpam = isSpam;
+    this.isLocalContact = isLocalContact;
     this.answeringDisconnectsOngoingCall = answeringDisconnectsOngoingCall;
     this.shouldShowLocation = shouldShowLocation;
     this.contactInfoLookupKey = contactInfoLookupKey;