This change reflects the Dialer V10 RC00 branch.

RC00 is based on:
branch: dialer-android_release_branch/153304843.1
synced to: 153304843

following the instructions at go/dialer-aosp-release.

In this release:

* Removes final apache sources.
* Uses native lite compilation.

More drops will follow with subsequent release candidates
until we reach our final v10 release, in cadence with our
prebuilt drops.

Test: TreeHugger, on device
Change-Id: Ic9684057230f9b579c777820c746cd21bf45ec0f
diff --git a/java/com/android/incallui/ContactInfoCache.java b/java/com/android/incallui/ContactInfoCache.java
index 9e696b5..3014de3 100644
--- a/java/com/android/incallui/ContactInfoCache.java
+++ b/java/com/android/incallui/ContactInfoCache.java
@@ -45,7 +45,8 @@
 import com.android.dialer.common.concurrent.DialerExecutor;
 import com.android.dialer.common.concurrent.DialerExecutor.Worker;
 import com.android.dialer.common.concurrent.DialerExecutors;
-import com.android.dialer.logging.nano.ContactLookupResult;
+import com.android.dialer.logging.ContactLookupResult;
+import com.android.dialer.logging.ContactSource;
 import com.android.dialer.oem.CequintCallerIdManager;
 import com.android.dialer.oem.CequintCallerIdManager.CequintCallerIdContact;
 import com.android.dialer.phonenumbercache.CachedNumberLookupService;
@@ -98,7 +99,7 @@
       }
       ContactInfo contactInfo = new ContactInfo();
       CachedContactInfo cacheInfo = input.service.buildCachedContactInfo(contactInfo);
-      cacheInfo.setSource(CachedContactInfo.SOURCE_TYPE_CNAP, "CNAP", 0);
+      cacheInfo.setSource(ContactSource.Type.SOURCE_TYPE_CNAP, "CNAP", 0);
       contactInfo.name = input.cnapName;
       contactInfo.number = input.number;
       contactInfo.type = ContactsContract.CommonDataKinds.Phone.TYPE_MAIN;
@@ -143,8 +144,7 @@
 
     // TODO: get rid of caller info.
     final CallerInfo info = CallerInfoUtils.buildCallerInfo(context, call);
-    ContactInfoCache.populateCacheEntry(
-        context, info, entry, call.getNumberPresentation(), isIncoming);
+    ContactInfoCache.populateCacheEntry(context, info, entry, call.getNumberPresentation());
     return entry;
   }
 
@@ -153,8 +153,7 @@
       @NonNull Context context,
       @NonNull CallerInfo info,
       @NonNull ContactCacheEntry cce,
-      int presentation,
-      boolean isIncoming) {
+      int presentation) {
     Objects.requireNonNull(info);
     String displayName = null;
     String displayNumber = null;
@@ -442,7 +441,7 @@
     }
 
     // We always replace the entry. The only exception is the same photo case.
-    ContactCacheEntry cacheEntry = buildEntry(mContext, callerInfo, presentationMode, isIncoming);
+    ContactCacheEntry cacheEntry = buildEntry(mContext, callerInfo, presentationMode);
     cacheEntry.queryId = queryToken.mQueryId;
 
     ContactCacheEntry existingCacheEntry = mInfoMap.get(callId);
@@ -509,20 +508,26 @@
     if (cequintCallerIdContact == null) {
       return;
     }
+    boolean hasUpdate = false;
 
     if (TextUtils.isEmpty(callerInfo.name) && !TextUtils.isEmpty(cequintCallerIdContact.name)) {
       callerInfo.name = cequintCallerIdContact.name;
-      callerInfo.contactExists = true;
+      hasUpdate = true;
     }
     if (!TextUtils.isEmpty(cequintCallerIdContact.geoDescription)) {
       callerInfo.geoDescription = cequintCallerIdContact.geoDescription;
       callerInfo.shouldShowGeoDescription = true;
-      callerInfo.contactExists = true;
+      hasUpdate = true;
     }
-    if (callerInfo.contactDisplayPhotoUri == null && cequintCallerIdContact.imageUrl != null) {
+    // Don't overwrite photo in local contacts.
+    if (!callerInfo.contactExists
+        && callerInfo.contactDisplayPhotoUri == null
+        && cequintCallerIdContact.imageUrl != null) {
       callerInfo.contactDisplayPhotoUri = Uri.parse(cequintCallerIdContact.imageUrl);
-      callerInfo.contactExists = true;
+      hasUpdate = true;
     }
+    // Set contact to exist to avoid phone number service lookup.
+    callerInfo.contactExists = hasUpdate;
   }
 
   /**
@@ -600,10 +605,9 @@
     mQueryId = 0;
   }
 
-  private ContactCacheEntry buildEntry(
-      Context context, CallerInfo info, int presentation, boolean isIncoming) {
+  private ContactCacheEntry buildEntry(Context context, CallerInfo info, int presentation) {
     final ContactCacheEntry cce = new ContactCacheEntry();
-    populateCacheEntry(context, info, cce, presentation, isIncoming);
+    populateCacheEntry(context, info, cce, presentation);
 
     // This will only be true for emergency numbers
     if (info.photoResource != 0) {
@@ -712,7 +716,7 @@
 
     public Uri lookupUri; // Sent to NotificationMananger
     public String lookupKey;
-    public int contactLookupResult = ContactLookupResult.Type.NOT_FOUND;
+    public ContactLookupResult.Type contactLookupResult = ContactLookupResult.Type.NOT_FOUND;
     public long userType = ContactsUtils.USER_TYPE_CURRENT;
     Uri contactRingtoneUri;
     /** Query id to identify the query session. */