Showing badge icon in incall ui if it is a work call

Work call means the call is placed through work phone account
or it is an outgoing call initiated from work dialer.
Please notice that both personal and work call is handled by personal
in-call UI, that's why we need to add a badge to indicate it.

There is another scenario we need to add badge, ie. having a work
contact caller, and it will be handled in ag/836110.


BUG=26022174

Change-Id: I96e72068f70674dbeabfbbf7bfffc6c15c3203bf
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java
index 93d499e..efd4818 100644
--- a/InCallUI/src/com/android/incallui/CallCardFragment.java
+++ b/InCallUI/src/com/android/incallui/CallCardFragment.java
@@ -559,10 +559,12 @@
      * @param isSipCall {@code true} if this is a SIP call.
      * @param isContactPhotoShown {@code true} if the contact photo should be shown (it will be
      *      updated even if it is not shown).
+     * @param isWorkCall Whether the call is placed through a work phone account or caller is a work
+              contact.
      */
     @Override
     public void setPrimary(String number, String name, boolean nameIsNumber, String label,
-            Drawable photo, boolean isSipCall, boolean isContactPhotoShown, boolean isWorkContact) {
+            Drawable photo, boolean isSipCall, boolean isContactPhotoShown, boolean isWorkCall) {
         Log.d(this, "Setting primary call");
         // set the name field.
         setPrimaryName(name, nameIsNumber);
@@ -584,7 +586,7 @@
 
         setDrawableToImageViews(photo);
         showImageView(mPhotoLarge, isContactPhotoShown);
-        showImageView(mWorkProfileIcon, isWorkContact);
+        showImageView(mWorkProfileIcon, isWorkCall);
     }
 
     @Override
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java
index a52a36d..fed229d 100644
--- a/InCallUI/src/com/android/incallui/CallCardPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java
@@ -56,6 +56,7 @@
 
 import java.lang.ref.WeakReference;
 
+import static com.android.contacts.common.compat.CallSdkCompat.Details.PROPERTY_WORK_CALL;
 /**
  * Presenter for the Call Card Fragment.
  * <p>
@@ -722,6 +723,9 @@
         boolean showContactPhoto = !VideoCallPresenter
                 .showIncomingVideo(mPrimary.getVideoState(), mPrimary.getState());
 
+        // Call placed through a work phone account.
+        boolean hasWorkCallProperty = mPrimary.hasProperty(PROPERTY_WORK_CALL);
+
         if (mPrimary.isConferenceCall()) {
             Log.d(TAG, "Update primary display info for conference call.");
 
@@ -733,7 +737,7 @@
                     getConferencePhoto(mPrimary),
                     false /* isSipCall */,
                     showContactPhoto,
-                    false /* isWorkContact */);
+                    hasWorkCallProperty);
         } else if (mPrimaryContactInfo != null) {
             Log.d(TAG, "Update primary display info for " + mPrimaryContactInfo);
 
@@ -765,6 +769,7 @@
             maybeShowHdAudioIcon();
 
             boolean nameIsNumber = name != null && name.equals(mPrimaryContactInfo.number);
+            // Call with caller that is a work contact.
             boolean isWorkContact = (mPrimaryContactInfo.userType == ContactsUtils.USER_TYPE_WORK);
             ui.setPrimary(
                     number,
@@ -774,7 +779,7 @@
                     mPrimaryContactInfo.photo,
                     mPrimaryContactInfo.isSipCall,
                     showContactPhoto,
-                    isWorkContact);
+                    hasWorkCallProperty || isWorkContact);
 
             updateContactInteractions();
         } else {
@@ -1095,8 +1100,7 @@
         void showContactContext(boolean show);
         void setCallCardVisible(boolean visible);
         void setPrimary(String number, String name, boolean nameIsNumber, String label,
-                Drawable photo, boolean isSipCall, boolean isContactPhotoShown,
-                boolean isWorkContact);
+                Drawable photo, boolean isSipCall, boolean isContactPhotoShown, boolean isWorkCall);
         void setSecondary(boolean show, String name, boolean nameIsNumber, String label,
                 String providerLabel, boolean isConference, boolean isVideoCall,
                 boolean isFullscreen);