Update Dialer source to latest internal Google revision.
Previously, Android's Dialer app was developed in an internal Google
source control system and only exported to public during AOSP drops.
The Dialer team is now switching to a public development model similar
to the telephony team.
This CL represents all internal Google changes that were committed to
Dialer between the public O release and today's tip of tree on internal
master. This CL squashes those changes into a single commit.
In subsequent changes, changes will be exported on a per-commit basis.
Test: make, flash install, run
Merged-In: I45270eaa8ce732d71a1bd84b08c7fa0e99af3160
Change-Id: I529aaeb88535b9533c0ae4ef4e6c1222d4e0f1c8
PiperOrigin-RevId: 167068436
diff --git a/java/com/android/incallui/ContactInfoCache.java b/java/com/android/incallui/ContactInfoCache.java
index e45eb97..9b92b48 100644
--- a/java/com/android/incallui/ContactInfoCache.java
+++ b/java/com/android/incallui/ContactInfoCache.java
@@ -33,6 +33,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.WorkerThread;
+import android.support.v4.content.ContextCompat;
import android.support.v4.os.UserManagerCompat;
import android.telecom.TelecomManager;
import android.telephony.PhoneNumberUtils;
@@ -265,6 +266,8 @@
cce.userType = info.userType;
cce.originalPhoneNumber = info.phoneNumber;
cce.shouldShowLocation = info.shouldShowGeoDescription;
+ cce.isEmergencyNumber = info.isEmergencyNumber();
+ cce.isVoicemailNumber = info.isVoiceMailNumber();
if (info.contactExists) {
cce.contactLookupResult = ContactLookupResult.Type.LOCAL_CONTACT;
@@ -406,7 +409,7 @@
} else {
ContactCacheEntry initialCacheEntry =
updateCallerInfoInCacheOnAnyThread(
- callId, call.getNumberPresentation(), callerInfo, isIncoming, false, queryToken);
+ callId, call.getNumberPresentation(), callerInfo, false, queryToken);
sendInfoNotifications(callId, initialCacheEntry);
}
}
@@ -416,7 +419,6 @@
String callId,
int numberPresentation,
CallerInfo callerInfo,
- boolean isIncoming,
boolean didLocalLookup,
CallerInfoQueryToken queryToken) {
Log.d(
@@ -428,6 +430,19 @@
+ "; didLocalLookup = "
+ didLocalLookup);
+ ContactCacheEntry existingCacheEntry = mInfoMap.get(callId);
+ Log.d(TAG, "Existing cacheEntry in hashMap " + existingCacheEntry);
+
+ // Mark it as emergency/voicemail if the cache exists and was emergency/voicemail before the
+ // number changed.
+ if (existingCacheEntry != null) {
+ if (existingCacheEntry.isEmergencyNumber) {
+ callerInfo.markAsEmergency(mContext);
+ } else if (existingCacheEntry.isVoicemailNumber) {
+ callerInfo.markAsVoiceMail(mContext);
+ }
+ }
+
int presentationMode = numberPresentation;
if (callerInfo.contactExists
|| callerInfo.isEmergencyNumber()
@@ -439,20 +454,8 @@
ContactCacheEntry cacheEntry = buildEntry(mContext, callerInfo, presentationMode);
cacheEntry.queryId = queryToken.mQueryId;
- ContactCacheEntry existingCacheEntry = mInfoMap.get(callId);
- Log.d(TAG, "Existing cacheEntry in hashMap " + existingCacheEntry);
-
if (didLocalLookup) {
- // Before issuing a request for more data from other services, we only check that the
- // 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");
- final PhoneNumberServiceListener listener =
- new PhoneNumberServiceListener(callId, queryToken.mQueryId);
- cacheEntry.hasPendingQuery = true;
- mPhoneNumberService.getPhoneNumberInfo(cacheEntry.number, listener, listener, isIncoming);
- } else if (cacheEntry.displayPhotoUri != null) {
+ if (cacheEntry.displayPhotoUri != null) {
// When the difference between 2 numbers is only the prefix (e.g. + or IDD),
// we will still trigger force query so that the number can be updated on
// the calling screen. We need not query the image again if the previous
@@ -606,13 +609,12 @@
// This will only be true for emergency numbers
if (info.photoResource != 0) {
- cce.photo = context.getResources().getDrawable(info.photoResource);
+ cce.photo = ContextCompat.getDrawable(context, info.photoResource);
} else if (info.isCachedPhotoCurrent) {
if (info.cachedPhoto != null) {
cce.photo = info.cachedPhoto;
cce.photoType = ContactPhotoType.CONTACT;
} else {
- cce.photo = getDefaultContactPhotoDrawable();
cce.photoType = ContactPhotoType.DEFAULT_PLACEHOLDER;
}
} else {
@@ -666,14 +668,6 @@
mCallBacks.remove(callId);
}
- public Drawable getDefaultContactPhotoDrawable() {
- if (mDefaultContactPhotoDrawable == null) {
- mDefaultContactPhotoDrawable =
- mContext.getResources().getDrawable(R.drawable.img_no_image_automirrored);
- }
- return mDefaultContactPhotoDrawable;
- }
-
/** Callback interface for the contact query. */
public interface ContactInfoCacheCallback {
@@ -696,8 +690,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;
@@ -713,6 +705,8 @@
boolean shouldShowLocation;
boolean isBusiness;
+ boolean isEmergencyNumber;
+ boolean isVoicemailNumber;
@Override
public String toString() {
@@ -736,8 +730,6 @@
+ photo
+ ", isSipCall="
+ isSipCall
- + ", contactUri="
- + contactUri
+ ", displayPhotoUri="
+ displayPhotoUri
+ ", contactLookupResult="
@@ -752,6 +744,10 @@
+ originalPhoneNumber
+ ", shouldShowLocation="
+ shouldShowLocation
+ + ", isEmergencyNumber="
+ + isEmergencyNumber
+ + ", isVoicemailNumber="
+ + isVoicemailNumber
+ '}';
}
}
@@ -789,7 +785,7 @@
maybeUpdateFromCequintCallerId(ci, cw.cnapName, mIsIncoming);
long time = SystemClock.uptimeMillis() - start;
Log.d(TAG, "Cequint Caller Id look up takes " + time + " ms.");
- updateCallerInfoInCacheOnAnyThread(cw.callId, cw.numberPresentation, ci, mIsIncoming, true, mQueryToken);
+ updateCallerInfoInCacheOnAnyThread(cw.callId, cw.numberPresentation, ci, true, mQueryToken);
}
@Override
@@ -807,6 +803,16 @@
clearCallbacks(callId);
return;
}
+ // Before issuing a request for more data from other services, we only check that the
+ // 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");
+ final PhoneNumberServiceListener listener =
+ new PhoneNumberServiceListener(callId, mQueryToken.mQueryId);
+ cacheEntry.hasPendingQuery = true;
+ mPhoneNumberService.getPhoneNumberInfo(cacheEntry.number, listener, listener, mIsIncoming);
+ }
sendInfoNotifications(callId, cacheEntry);
if (!cacheEntry.hasPendingQuery) {
if (callerInfo.contactExists) {
@@ -870,12 +876,12 @@
entry.shouldShowLocation = oldEntry.shouldShowLocation;
// Contact specific ringtone is obtained from local lookup.
entry.contactRingtoneUri = oldEntry.contactRingtoneUri;
+ entry.originalPhoneNumber = oldEntry.originalPhoneNumber;
}
// If no image and it's a business, switch to using the default business avatar.
if (info.getImageUrl() == null && info.isBusiness()) {
Log.d(TAG, "Business has no image. Using default.");
- entry.photo = mContext.getResources().getDrawable(R.drawable.img_business);
entry.photoType = ContactPhotoType.BUSINESS;
}