Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6b3f45a authored by Santos Cordon's avatar Santos Cordon Committed by Android Git Automerger
Browse files

am 187e6ffe: Dont overwrite cnap name with a failed local lookup.

* commit '187e6ffef5fe2fdbc6954159a0e9fc79b55fbbda':
  Dont overwrite cnap name with a failed local lookup.
parents 59ae56ee 37295b9c
Loading
Loading
Loading
Loading
+14 −8
Original line number Original line Diff line number Diff line
@@ -156,16 +156,24 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete
            presentationMode = TelecomManager.PRESENTATION_ALLOWED;
            presentationMode = TelecomManager.PRESENTATION_ALLOWED;
        }
        }


        final ContactCacheEntry cacheEntry = buildEntry(mContext, callId,
        ContactCacheEntry cacheEntry = mInfoMap.get(callId);
                callerInfo, presentationMode, isIncoming);
        // Rebuild the entry from the new data if:

        // 1) This is NOT the asynchronous local lookup (IOW, this is the first pass)
        // Add the contact info to the cache.
        // 2) The local lookup was done and the contact exists
        // 3) The existing cached entry is empty (no name).
        if (!didLocalLookup || callerInfo.contactExists ||
                (cacheEntry != null && TextUtils.isEmpty(cacheEntry.name))) {
            cacheEntry = buildEntry(mContext, callId, callerInfo, presentationMode, isIncoming);
            mInfoMap.put(callId, cacheEntry);
            mInfoMap.put(callId, cacheEntry);
        }

        sendInfoNotifications(callId, cacheEntry);
        sendInfoNotifications(callId, cacheEntry);


        if (didLocalLookup) {
        if (didLocalLookup) {
            if (!callerInfo.contactExists && cacheEntry.name == null &&
            // Before issuing a request for more data from other services, We only check that the
                    mPhoneNumberService != null) {
            // contact wasn't found in the local DB.  We don't check the if the cache entry already
            // has a name because we allow overriding cnap data with data from other services.
            if (!callerInfo.contactExists && mPhoneNumberService != null) {
                Log.d(TAG, "Contact lookup. Local contacts miss, checking remote");
                Log.d(TAG, "Contact lookup. Local contacts miss, checking remote");
                final PhoneNumberServiceListener listener = new PhoneNumberServiceListener(callId);
                final PhoneNumberServiceListener listener = new PhoneNumberServiceListener(callId);
                mPhoneNumberService.getPhoneNumberInfo(cacheEntry.number, listener, listener,
                mPhoneNumberService.getPhoneNumberInfo(cacheEntry.number, listener, listener,
@@ -179,8 +187,6 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete
            } else {
            } else {
                if (callerInfo.contactExists) {
                if (callerInfo.contactExists) {
                    Log.d(TAG, "Contact lookup done. Local contact found, no image.");
                    Log.d(TAG, "Contact lookup done. Local contact found, no image.");
                } else if (cacheEntry.name != null) {
                    Log.d(TAG, "Contact lookup done. Special contact type.");
                } else {
                } else {
                    Log.d(TAG, "Contact lookup done. Local contact not found and"
                    Log.d(TAG, "Contact lookup done. Local contact not found and"
                            + " no remote lookup service available.");
                            + " no remote lookup service available.");