Performance improvements to call log scrolling.

- Remove call to CallUtil to check if video is enabled. It seems
like it's fine to include the content description of what the
call was, if it was a video call, even if there is not a
video-enabled call account.

- Factor out PhoneNumberDisplayHelper so it doesn't need to be
an instance. This reduces some extra calls to getDisplayNameHelper.
Probably a marginal difference, performance-wise, but it probably
helps a smidgen and also simplifies the need for creating and
passing or recalculating various instances of things.

TODO: It'd be much better if PhoneCallDetails had a builder.
It's terribly painful to fix all the tests when adding fields...

Change-Id: I6da13dc8b6b047043aba871796a8ed13b112a227
diff --git a/src/com/android/dialer/PhoneCallDetails.java b/src/com/android/dialer/PhoneCallDetails.java
index ec9657e..843e193 100644
--- a/src/com/android/dialer/PhoneCallDetails.java
+++ b/src/com/android/dialer/PhoneCallDetails.java
@@ -17,15 +17,20 @@
 package com.android.dialer;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.android.dialer.calllog.PhoneNumberDisplayUtil;
 
+import android.content.Context;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.provider.CallLog.Calls;
 import android.provider.ContactsContract.CommonDataKinds.Phone;
 import android.telecom.PhoneAccountHandle;
+import android.text.TextUtils;
 
 /**
  * The details of a phone call to be shown in the UI.
+ *
+ * TODO: Create a builder, to make it easier to construct an instance.
  */
 public class PhoneCallDetails {
     /** The number of the other party involved in the call. */
@@ -85,35 +90,40 @@
      */
     public final String transcription;
 
+    public final String displayNumber;
+    public final boolean isVoicemail;
+
     /**
      * Create the details for a call, with empty defaults specified for extra fields that are
      * not necessary for testing.
      */
     @VisibleForTesting
-    public PhoneCallDetails(CharSequence number, int numberPresentation,
+    public PhoneCallDetails(Context context, CharSequence number, int numberPresentation,
             CharSequence formattedNumber, String countryIso, String geocode,
-            int[] callTypes, long date, long duration) {
-        this (number, numberPresentation, formattedNumber, countryIso, geocode,
-                callTypes, date, duration, "", 0, "", null, null, 0, null, 0, null, null);
+            int[] callTypes, long date, long duration, boolean isVoicemail) {
+        this(context, number, numberPresentation, formattedNumber, countryIso, geocode,
+                callTypes, date, duration, "", 0, "", null, null, 0, null, 0, null, null,
+                isVoicemail);
     }
 
     /** Create the details for a call with a number not associated with a contact. */
-    public PhoneCallDetails(CharSequence number, int numberPresentation,
+    public PhoneCallDetails(Context context, CharSequence number, int numberPresentation,
             CharSequence formattedNumber, String countryIso, String geocode,
             int[] callTypes, long date, long duration,
-            PhoneAccountHandle accountHandle, int features, Long dataUsage, String transcription) {
-        this(number, numberPresentation, formattedNumber, countryIso, geocode, callTypes, date,
-                duration, "", 0, "", null, null, 0, accountHandle, features, dataUsage,
-                transcription);
+            PhoneAccountHandle accountHandle, int features, Long dataUsage, String transcription,
+            boolean isVoicemail) {
+        this(context, number, numberPresentation, formattedNumber, countryIso, geocode,
+                callTypes, date, duration, "", 0, "", null, null, 0, accountHandle, features,
+                dataUsage, transcription, isVoicemail);
     }
 
     /** Create the details for a call with a number associated with a contact. */
-    public PhoneCallDetails(CharSequence number, int numberPresentation,
+    public PhoneCallDetails(Context context, CharSequence number, int numberPresentation,
             CharSequence formattedNumber, String countryIso, String geocode,
             int[] callTypes, long date, long duration, CharSequence name,
             int numberType, CharSequence numberLabel, Uri contactUri, Uri photoUri,
             int sourceType, PhoneAccountHandle accountHandle, int features, Long dataUsage,
-            String transcription) {
+            String transcription, boolean isVoicemail) {
         this.number = number;
         this.numberPresentation = numberPresentation;
         this.formattedNumber = formattedNumber;
@@ -132,5 +142,14 @@
         this.features = features;
         this.dataUsage = dataUsage;
         this.transcription = transcription;
+        this.isVoicemail = isVoicemail;
+
+        this.displayNumber = PhoneNumberDisplayUtil.getDisplayNumber(
+                context,
+                this.accountHandle,
+                this.number,
+                this.numberPresentation,
+                this.formattedNumber,
+                this.isVoicemail).toString();
     }
 }