Fix the blurry contact photo.

A high res sync update request should be sent to trigger the photo sync.
Without this request, the contact photo will stay in low res until user action
to trigger it in other ways such as click on quick contacts or open it in
contacts app.

Bug: 62390496
Test: manual
PiperOrigin-RevId: 163905019
Change-Id: Iaf47934df02dc15f75e806505dfd425402fde07c
diff --git a/java/com/android/dialer/app/list/PhoneFavoriteTileView.java b/java/com/android/dialer/app/list/PhoneFavoriteTileView.java
index 455085d..29147e7 100644
--- a/java/com/android/dialer/app/list/PhoneFavoriteTileView.java
+++ b/java/com/android/dialer/app/list/PhoneFavoriteTileView.java
@@ -18,6 +18,7 @@
 
 import android.content.ClipData;
 import android.content.Context;
+import android.net.Uri;
 import android.provider.ContactsContract.PinnedPositions;
 import android.text.TextUtils;
 import android.util.AttributeSet;
@@ -26,10 +27,12 @@
 import com.android.contacts.common.MoreContactUtils;
 import com.android.contacts.common.list.ContactEntry;
 import com.android.contacts.common.list.ContactTileView;
+import com.android.contacts.common.model.ContactLoader;
 import com.android.dialer.app.R;
 import com.android.dialer.callintent.CallInitiationType;
 import com.android.dialer.callintent.CallSpecificAppData;
 import com.android.dialer.callintent.SpeedDialContactType;
+import com.android.dialer.common.LogUtil;
 import com.android.dialer.contactphoto.ContactPhotoManager.DefaultImageRequest;
 import com.android.dialer.lettertile.LetterTileDrawable;
 import com.android.dialer.logging.InteractionEvent;
@@ -94,6 +97,7 @@
     isPinned = (entry.pinned != PinnedPositions.UNPINNED);
     isStarred = entry.isFavorite;
     if (entry != null) {
+      sendViewNotification(getContext(), entry.lookupUri);
       // Grab the phone-number to call directly. See {@link onClick()}.
       mPhoneNumberString = entry.phoneNumber;
 
@@ -186,4 +190,22 @@
   public void setPosition(int position) {
     this.position = position;
   }
+
+  /**
+   * Send a notification using a {@link ContactLoader} to inform the sync adapter that we are
+   * viewing a particular contact, so that it can download the high-res photo.
+   */
+  private static void sendViewNotification(Context context, Uri contactUri) {
+    ContactLoader loader = new ContactLoader(context, contactUri, true /* postViewNotification */);
+    loader.registerListener(
+        0,
+        (loader1, contact) -> {
+          try {
+            loader1.reset();
+          } catch (RuntimeException e) {
+            LogUtil.e("PhoneFavoriteTileView.onLoadComplete", "error resetting loader", e);
+          }
+        });
+    loader.startLoading();
+  }
 }
diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java
index afd2342..222b5b8 100644
--- a/java/com/android/incallui/CallCardPresenter.java
+++ b/java/com/android/incallui/CallCardPresenter.java
@@ -587,8 +587,8 @@
     if (call != null) {
       call.getLogState().contactLookupResult = entry.contactLookupResult;
     }
-    if (entry.contactUri != null) {
-      CallerInfoUtils.sendViewNotification(mContext, entry.contactUri);
+    if (entry.lookupUri != null) {
+      CallerInfoUtils.sendViewNotification(mContext, entry.lookupUri);
     }
   }
 
diff --git a/java/com/android/incallui/ContactInfoCache.java b/java/com/android/incallui/ContactInfoCache.java
index d50a5c2..3530153 100644
--- a/java/com/android/incallui/ContactInfoCache.java
+++ b/java/com/android/incallui/ContactInfoCache.java
@@ -699,8 +699,6 @@
     // Note in cache entry whether this is a pending async loading action to know whether to
     // wait for its callback or not.
     boolean hasPendingQuery;
-    /** This will be used for the "view" notification. */
-    public Uri contactUri;
     /** Either a display photo or a thumbnail URI. */
     Uri displayPhotoUri;
 
@@ -741,8 +739,6 @@
           + photo
           + ", isSipCall="
           + isSipCall
-          + ", contactUri="
-          + contactUri
           + ", displayPhotoUri="
           + displayPhotoUri
           + ", contactLookupResult="