Loading java/com/android/dialer/app/calllog/CallLogGroupBuilder.java +2 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.text.format.Time; import com.android.contacts.common.util.DateUtils; Loading Loading @@ -193,7 +194,7 @@ public class CallLogGroupBuilder { if (PhoneNumberHelper.isUriNumber(number1) || PhoneNumberHelper.isUriNumber(number2)) { return compareSipAddresses(number1, number2); } else { return PhoneNumberHelper.compare(number1, number2); return PhoneNumberUtils.compare(number1, number2); } } Loading java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java +8 −8 Original line number Diff line number Diff line Loading @@ -42,10 +42,9 @@ public class AnnotatedCallLogContract { String TIMESTAMP = "timestamp"; /** * Copied from {@link android.provider.CallLog.Calls#CACHED_NAME}. * * <p>This is exactly how it should appear to the user. If the user's locale or name display * preferences change, this column should be rewritten. * The name (which may be a person's name or business name, but not a number) formatted exactly * as it should appear to the user. If the user's locale or name display preferences change, * this column should be rewritten. * * <p>Type: TEXT */ Loading @@ -61,28 +60,29 @@ public class AnnotatedCallLogContract { String NUMBER = "number"; /** * Copied from {@link android.provider.CallLog.Calls#CACHED_FORMATTED_NUMBER}. * The number formatted as it should be displayed to the user. Note that it may not always be * displayed, for example if the number has a corresponding person or business name. * * <p>Type: TEXT */ String FORMATTED_NUMBER = "formatted_number"; /** * Copied from {@link android.provider.CallLog.Calls#CACHED_PHOTO_URI}. * A photo URI for the contact to display in the call log list view. * * <p>TYPE: TEXT */ String PHOTO_URI = "photo_uri"; /** * Copied from {@link android.provider.CallLog.Calls#CACHED_PHOTO_ID}. * A photo ID (from the contacts provider) for the contact to display in the call log list view. * * <p>Type: INTEGER (long) */ String PHOTO_ID = "photo_id"; /** * Copied from {@link android.provider.CallLog.Calls#CACHED_LOOKUP_URI}. * The contacts provider lookup URI for the contact associated with the call. * * <p>TYPE: TEXT */ Loading java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java +23 −8 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import com.android.dialer.DialerPhoneNumber; import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.AnnotatedCallLog; import com.android.dialer.calllog.datasources.CallLogDataSource; import com.android.dialer.calllog.datasources.CallLogMutations; import com.android.dialer.calllog.datasources.util.RowCombiner; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor; import com.android.dialer.common.concurrent.Annotations.LightweightExecutor; Loading Loading @@ -260,8 +261,13 @@ public final class PhoneLookupDataSource implements CallLogDataSource { @WorkerThread @Override public ContentValues coalesce(List<ContentValues> individualRowsSortedByTimestampDesc) { // TODO(zachh): Implementation. return new ContentValues(); return new RowCombiner(individualRowsSortedByTimestampDesc) .useMostRecentString(AnnotatedCallLog.NAME) .useMostRecentString(AnnotatedCallLog.NUMBER_TYPE_LABEL) .useMostRecentString(AnnotatedCallLog.PHOTO_URI) .useMostRecentLong(AnnotatedCallLog.PHOTO_ID) .useMostRecentString(AnnotatedCallLog.LOOKUP_URI) .combine(); } @MainThread Loading Loading @@ -434,7 +440,7 @@ public final class PhoneLookupDataSource implements CallLogDataSource { PhoneLookupInfo phoneLookupInfo = existingInfo.get(id); // Existing info might be missing if data was cleared or for other reasons. if (phoneLookupInfo != null) { contentValues.put(AnnotatedCallLog.NAME, selectName(phoneLookupInfo)); updateContentValues(contentValues, phoneLookupInfo); } } } Loading Loading @@ -474,17 +480,17 @@ public final class PhoneLookupDataSource implements CallLogDataSource { * mutations from PhoneLookupHistory; in this case "John" would be copied during * populateInserts() and there wouldn't be further updates needed here. */ contentValuesToInsert.put(AnnotatedCallLog.NAME, selectName(phoneLookupInfo)); updateContentValues(contentValuesToInsert, phoneLookupInfo); continue; } ContentValues contentValuesToUpdate = mutations.getUpdates().get(id); if (contentValuesToUpdate != null) { contentValuesToUpdate.put(AnnotatedCallLog.NAME, selectName(phoneLookupInfo)); updateContentValues(contentValuesToUpdate, phoneLookupInfo); continue; } // Else this row is not already scheduled for insert or update and we need to schedule it. ContentValues contentValues = new ContentValues(); contentValues.put(AnnotatedCallLog.NAME, selectName(phoneLookupInfo)); updateContentValues(contentValues, phoneLookupInfo); mutations.getUpdates().put(id, contentValues); } } Loading Loading @@ -525,8 +531,17 @@ public final class PhoneLookupDataSource implements CallLogDataSource { return normalizedNumbersToDelete; } private static String selectName(PhoneLookupInfo phoneLookupInfo) { return PhoneLookupSelector.selectName(phoneLookupInfo); private static void updateContentValues( ContentValues contentValues, PhoneLookupInfo phoneLookupInfo) { contentValues.put(AnnotatedCallLog.NAME, PhoneLookupSelector.selectName(phoneLookupInfo)); contentValues.put( AnnotatedCallLog.PHOTO_URI, PhoneLookupSelector.selectPhotoUri(phoneLookupInfo)); contentValues.put( AnnotatedCallLog.PHOTO_ID, PhoneLookupSelector.selectPhotoId(phoneLookupInfo)); contentValues.put( AnnotatedCallLog.LOOKUP_URI, PhoneLookupSelector.selectLookupUri(phoneLookupInfo)); contentValues.put( AnnotatedCallLog.NUMBER_TYPE_LABEL, PhoneLookupSelector.selectNumberLabel(phoneLookupInfo)); } private static Uri numberUri(String number) { Loading java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java +8 −49 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ import android.os.Build; import android.os.Handler; import android.provider.CallLog; import android.provider.CallLog.Calls; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.support.annotation.ColorInt; import android.support.annotation.MainThread; import android.support.annotation.Nullable; Loading @@ -35,6 +34,7 @@ import android.support.annotation.VisibleForTesting; import android.support.annotation.WorkerThread; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.util.ArraySet; import com.android.dialer.DialerPhoneNumber; Loading Loading @@ -174,23 +174,16 @@ public class SystemCallLogDataSource implements CallLogDataSource { @Override public ContentValues coalesce(List<ContentValues> individualRowsSortedByTimestampDesc) { // TODO(zachh): Complete implementation. assertNoVoicemailsInRows(individualRowsSortedByTimestampDesc); return new RowCombiner(individualRowsSortedByTimestampDesc) .useMostRecentLong(AnnotatedCallLog.TIMESTAMP) .useMostRecentLong(AnnotatedCallLog.NEW) .useMostRecentString(AnnotatedCallLog.NUMBER_TYPE_LABEL) .useMostRecentString(AnnotatedCallLog.NAME) // Two different DialerPhoneNumbers could be combined if they are different but considered // to be an "exact match" by libphonenumber; in this case we arbitrarily select the most // recent one. .useMostRecentBlob(AnnotatedCallLog.NUMBER) .useMostRecentString(AnnotatedCallLog.FORMATTED_NUMBER) .useMostRecentString(AnnotatedCallLog.PHOTO_URI) .useMostRecentLong(AnnotatedCallLog.PHOTO_ID) .useMostRecentString(AnnotatedCallLog.LOOKUP_URI) .useMostRecentString(AnnotatedCallLog.GEOCODED_LOCATION) .useSingleValueString(AnnotatedCallLog.PHONE_ACCOUNT_COMPONENT_NAME) .useSingleValueString(AnnotatedCallLog.PHONE_ACCOUNT_ID) Loading Loading @@ -233,13 +226,6 @@ public class SystemCallLogDataSource implements CallLogDataSource { Calls.NUMBER, Calls.TYPE, Calls.COUNTRY_ISO, Calls.CACHED_NAME, Calls.CACHED_FORMATTED_NUMBER, Calls.CACHED_PHOTO_URI, Calls.CACHED_PHOTO_ID, Calls.CACHED_LOOKUP_URI, Calls.CACHED_NUMBER_TYPE, Calls.CACHED_NUMBER_LABEL, Calls.DURATION, Calls.DATA_USAGE, Calls.TRANSCRIPTION, Loading Loading @@ -272,14 +258,6 @@ public class SystemCallLogDataSource implements CallLogDataSource { int numberColumn = cursor.getColumnIndexOrThrow(Calls.NUMBER); int typeColumn = cursor.getColumnIndexOrThrow(Calls.TYPE); int countryIsoColumn = cursor.getColumnIndexOrThrow(Calls.COUNTRY_ISO); int cachedNameColumn = cursor.getColumnIndexOrThrow(Calls.CACHED_NAME); int cachedFormattedNumberColumn = cursor.getColumnIndexOrThrow(Calls.CACHED_FORMATTED_NUMBER); int cachedPhotoUriColumn = cursor.getColumnIndexOrThrow(Calls.CACHED_PHOTO_URI); int cachedPhotoIdColumn = cursor.getColumnIndexOrThrow(Calls.CACHED_PHOTO_ID); int cachedLookupUriColumn = cursor.getColumnIndexOrThrow(Calls.CACHED_LOOKUP_URI); int cachedNumberTypeColumn = cursor.getColumnIndexOrThrow(Calls.CACHED_NUMBER_TYPE); int cachedNumberLabelColumn = cursor.getColumnIndexOrThrow(Calls.CACHED_NUMBER_LABEL); int durationsColumn = cursor.getColumnIndexOrThrow(Calls.DURATION); int dataUsageColumn = cursor.getColumnIndexOrThrow(Calls.DATA_USAGE); int transcriptionColumn = cursor.getColumnIndexOrThrow(Calls.TRANSCRIPTION); Loading @@ -301,13 +279,6 @@ public class SystemCallLogDataSource implements CallLogDataSource { String numberAsStr = cursor.getString(numberColumn); long type = cursor.getInt(typeColumn); String countryIso = cursor.getString(countryIsoColumn); String cachedName = cursor.getString(cachedNameColumn); String formattedNumber = cursor.getString(cachedFormattedNumberColumn); String cachedPhotoUri = cursor.getString(cachedPhotoUriColumn); long cachedPhotoId = cursor.getLong(cachedPhotoIdColumn); String cachedLookupUri = cursor.getString(cachedLookupUriColumn); int cachedNumberType = cursor.getInt(cachedNumberTypeColumn); String cachedNumberLabel = cursor.getString(cachedNumberLabelColumn); int duration = cursor.getInt(durationsColumn); int dataUsage = cursor.getInt(dataUsageColumn); String transcription = cursor.getString(transcriptionColumn); Loading @@ -323,31 +294,19 @@ public class SystemCallLogDataSource implements CallLogDataSource { contentValues.put(AnnotatedCallLog.TIMESTAMP, date); if (!TextUtils.isEmpty(numberAsStr)) { byte[] numberAsProtoBytes = dialerPhoneNumberUtil.parse(numberAsStr, countryIso).toByteArray(); DialerPhoneNumber dialerPhoneNumber = dialerPhoneNumberUtil.parse(numberAsStr, countryIso); contentValues.put(AnnotatedCallLog.NUMBER, dialerPhoneNumber.toByteArray()); contentValues.put( AnnotatedCallLog.FORMATTED_NUMBER, PhoneNumberUtils.formatNumber(numberAsStr, countryIso)); // TODO(zachh): Need to handle post-dial digits; different on N and M. contentValues.put(AnnotatedCallLog.NUMBER, numberAsProtoBytes); } else { contentValues.put( AnnotatedCallLog.NUMBER, DialerPhoneNumber.getDefaultInstance().toByteArray()); } contentValues.put(AnnotatedCallLog.CALL_TYPE, type); contentValues.put(AnnotatedCallLog.NAME, cachedName); // TODO(zachh): Format the number using DialerPhoneNumberUtil here. contentValues.put(AnnotatedCallLog.FORMATTED_NUMBER, formattedNumber); contentValues.put(AnnotatedCallLog.PHOTO_URI, cachedPhotoUri); contentValues.put(AnnotatedCallLog.PHOTO_ID, cachedPhotoId); contentValues.put(AnnotatedCallLog.LOOKUP_URI, cachedLookupUri); // Phone.getTypeLabel returns "Custom" if given (0, null) which is not of any use. Just // omit setting the label if there's no information for it. if (cachedNumberType != 0 || cachedNumberLabel != null) { contentValues.put( AnnotatedCallLog.NUMBER_TYPE_LABEL, Phone.getTypeLabel(appContext.getResources(), cachedNumberType, cachedNumberLabel) .toString()); } contentValues.put(AnnotatedCallLog.IS_READ, isRead); contentValues.put(AnnotatedCallLog.NEW, isNew); contentValues.put(AnnotatedCallLog.GEOCODED_LOCATION, geocodedLocation); Loading java/com/android/dialer/phonelookup/PhoneLookupSelector.java +75 −4 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.dialer.phonelookup; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.android.dialer.phonelookup.PhoneLookupInfo.Cp2Info.Cp2ContactInfo; /** * Prioritizes information from a {@link PhoneLookupInfo}. Loading @@ -37,11 +39,80 @@ public final class PhoneLookupSelector { */ @NonNull public static String selectName(PhoneLookupInfo phoneLookupInfo) { if (phoneLookupInfo.getCp2Info().getCp2ContactInfoCount() > 0) { // Arbitrarily select the first contact's name. In the future, it may make sense to join the // names such as "Mom, Dad" in the case that multiple contacts share the same number. return phoneLookupInfo.getCp2Info().getCp2ContactInfo(0).getName(); Cp2ContactInfo firstLocalContact = firstLocalContact(phoneLookupInfo); if (firstLocalContact != null) { String name = firstLocalContact.getName(); if (!name.isEmpty()) { return firstLocalContact.getName(); } } return ""; } /** Select the photo URI associated with this number. */ @NonNull public static String selectPhotoUri(PhoneLookupInfo phoneLookupInfo) { Cp2ContactInfo firstLocalContact = firstLocalContact(phoneLookupInfo); if (firstLocalContact != null) { String photoUri = firstLocalContact.getPhotoUri(); if (!photoUri.isEmpty()) { return photoUri; } } return ""; } /** Select the photo ID associated with this number, or 0 if there is none. */ public static long selectPhotoId(PhoneLookupInfo phoneLookupInfo) { Cp2ContactInfo firstLocalContact = firstLocalContact(phoneLookupInfo); if (firstLocalContact != null) { long photoId = firstLocalContact.getPhotoId(); if (photoId > 0) { return photoId; } } return 0; } /** Select the lookup URI associated with this number. */ @NonNull public static String selectLookupUri(PhoneLookupInfo phoneLookupInfo) { Cp2ContactInfo firstLocalContact = firstLocalContact(phoneLookupInfo); if (firstLocalContact != null) { String lookupUri = firstLocalContact.getLookupUri(); if (!lookupUri.isEmpty()) { return lookupUri; } } return ""; } /** * A localized string representing the number type such as "Home" or "Mobile", or a custom value * set by the user. */ @NonNull public static String selectNumberLabel(PhoneLookupInfo phoneLookupInfo) { Cp2ContactInfo firstLocalContact = firstLocalContact(phoneLookupInfo); if (firstLocalContact != null) { String label = firstLocalContact.getLabel(); if (!label.isEmpty()) { return label; } } return ""; } /** * Arbitrarily select the first contact. In the future, it may make sense to display contact * information from all contacts with the same number (for example show the name as "Mom, Dad" or * show a synthesized photo containing photos of both "Mom" and "Dad"). */ @Nullable private static Cp2ContactInfo firstLocalContact(PhoneLookupInfo phoneLookupInfo) { if (phoneLookupInfo.getCp2Info().getCp2ContactInfoCount() > 0) { return phoneLookupInfo.getCp2Info().getCp2ContactInfo(0); } return null; } } Loading
java/com/android/dialer/app/calllog/CallLogGroupBuilder.java +2 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.text.format.Time; import com.android.contacts.common.util.DateUtils; Loading Loading @@ -193,7 +194,7 @@ public class CallLogGroupBuilder { if (PhoneNumberHelper.isUriNumber(number1) || PhoneNumberHelper.isUriNumber(number2)) { return compareSipAddresses(number1, number2); } else { return PhoneNumberHelper.compare(number1, number2); return PhoneNumberUtils.compare(number1, number2); } } Loading
java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java +8 −8 Original line number Diff line number Diff line Loading @@ -42,10 +42,9 @@ public class AnnotatedCallLogContract { String TIMESTAMP = "timestamp"; /** * Copied from {@link android.provider.CallLog.Calls#CACHED_NAME}. * * <p>This is exactly how it should appear to the user. If the user's locale or name display * preferences change, this column should be rewritten. * The name (which may be a person's name or business name, but not a number) formatted exactly * as it should appear to the user. If the user's locale or name display preferences change, * this column should be rewritten. * * <p>Type: TEXT */ Loading @@ -61,28 +60,29 @@ public class AnnotatedCallLogContract { String NUMBER = "number"; /** * Copied from {@link android.provider.CallLog.Calls#CACHED_FORMATTED_NUMBER}. * The number formatted as it should be displayed to the user. Note that it may not always be * displayed, for example if the number has a corresponding person or business name. * * <p>Type: TEXT */ String FORMATTED_NUMBER = "formatted_number"; /** * Copied from {@link android.provider.CallLog.Calls#CACHED_PHOTO_URI}. * A photo URI for the contact to display in the call log list view. * * <p>TYPE: TEXT */ String PHOTO_URI = "photo_uri"; /** * Copied from {@link android.provider.CallLog.Calls#CACHED_PHOTO_ID}. * A photo ID (from the contacts provider) for the contact to display in the call log list view. * * <p>Type: INTEGER (long) */ String PHOTO_ID = "photo_id"; /** * Copied from {@link android.provider.CallLog.Calls#CACHED_LOOKUP_URI}. * The contacts provider lookup URI for the contact associated with the call. * * <p>TYPE: TEXT */ Loading
java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java +23 −8 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import com.android.dialer.DialerPhoneNumber; import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.AnnotatedCallLog; import com.android.dialer.calllog.datasources.CallLogDataSource; import com.android.dialer.calllog.datasources.CallLogMutations; import com.android.dialer.calllog.datasources.util.RowCombiner; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor; import com.android.dialer.common.concurrent.Annotations.LightweightExecutor; Loading Loading @@ -260,8 +261,13 @@ public final class PhoneLookupDataSource implements CallLogDataSource { @WorkerThread @Override public ContentValues coalesce(List<ContentValues> individualRowsSortedByTimestampDesc) { // TODO(zachh): Implementation. return new ContentValues(); return new RowCombiner(individualRowsSortedByTimestampDesc) .useMostRecentString(AnnotatedCallLog.NAME) .useMostRecentString(AnnotatedCallLog.NUMBER_TYPE_LABEL) .useMostRecentString(AnnotatedCallLog.PHOTO_URI) .useMostRecentLong(AnnotatedCallLog.PHOTO_ID) .useMostRecentString(AnnotatedCallLog.LOOKUP_URI) .combine(); } @MainThread Loading Loading @@ -434,7 +440,7 @@ public final class PhoneLookupDataSource implements CallLogDataSource { PhoneLookupInfo phoneLookupInfo = existingInfo.get(id); // Existing info might be missing if data was cleared or for other reasons. if (phoneLookupInfo != null) { contentValues.put(AnnotatedCallLog.NAME, selectName(phoneLookupInfo)); updateContentValues(contentValues, phoneLookupInfo); } } } Loading Loading @@ -474,17 +480,17 @@ public final class PhoneLookupDataSource implements CallLogDataSource { * mutations from PhoneLookupHistory; in this case "John" would be copied during * populateInserts() and there wouldn't be further updates needed here. */ contentValuesToInsert.put(AnnotatedCallLog.NAME, selectName(phoneLookupInfo)); updateContentValues(contentValuesToInsert, phoneLookupInfo); continue; } ContentValues contentValuesToUpdate = mutations.getUpdates().get(id); if (contentValuesToUpdate != null) { contentValuesToUpdate.put(AnnotatedCallLog.NAME, selectName(phoneLookupInfo)); updateContentValues(contentValuesToUpdate, phoneLookupInfo); continue; } // Else this row is not already scheduled for insert or update and we need to schedule it. ContentValues contentValues = new ContentValues(); contentValues.put(AnnotatedCallLog.NAME, selectName(phoneLookupInfo)); updateContentValues(contentValues, phoneLookupInfo); mutations.getUpdates().put(id, contentValues); } } Loading Loading @@ -525,8 +531,17 @@ public final class PhoneLookupDataSource implements CallLogDataSource { return normalizedNumbersToDelete; } private static String selectName(PhoneLookupInfo phoneLookupInfo) { return PhoneLookupSelector.selectName(phoneLookupInfo); private static void updateContentValues( ContentValues contentValues, PhoneLookupInfo phoneLookupInfo) { contentValues.put(AnnotatedCallLog.NAME, PhoneLookupSelector.selectName(phoneLookupInfo)); contentValues.put( AnnotatedCallLog.PHOTO_URI, PhoneLookupSelector.selectPhotoUri(phoneLookupInfo)); contentValues.put( AnnotatedCallLog.PHOTO_ID, PhoneLookupSelector.selectPhotoId(phoneLookupInfo)); contentValues.put( AnnotatedCallLog.LOOKUP_URI, PhoneLookupSelector.selectLookupUri(phoneLookupInfo)); contentValues.put( AnnotatedCallLog.NUMBER_TYPE_LABEL, PhoneLookupSelector.selectNumberLabel(phoneLookupInfo)); } private static Uri numberUri(String number) { Loading
java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java +8 −49 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ import android.os.Build; import android.os.Handler; import android.provider.CallLog; import android.provider.CallLog.Calls; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.support.annotation.ColorInt; import android.support.annotation.MainThread; import android.support.annotation.Nullable; Loading @@ -35,6 +34,7 @@ import android.support.annotation.VisibleForTesting; import android.support.annotation.WorkerThread; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.util.ArraySet; import com.android.dialer.DialerPhoneNumber; Loading Loading @@ -174,23 +174,16 @@ public class SystemCallLogDataSource implements CallLogDataSource { @Override public ContentValues coalesce(List<ContentValues> individualRowsSortedByTimestampDesc) { // TODO(zachh): Complete implementation. assertNoVoicemailsInRows(individualRowsSortedByTimestampDesc); return new RowCombiner(individualRowsSortedByTimestampDesc) .useMostRecentLong(AnnotatedCallLog.TIMESTAMP) .useMostRecentLong(AnnotatedCallLog.NEW) .useMostRecentString(AnnotatedCallLog.NUMBER_TYPE_LABEL) .useMostRecentString(AnnotatedCallLog.NAME) // Two different DialerPhoneNumbers could be combined if they are different but considered // to be an "exact match" by libphonenumber; in this case we arbitrarily select the most // recent one. .useMostRecentBlob(AnnotatedCallLog.NUMBER) .useMostRecentString(AnnotatedCallLog.FORMATTED_NUMBER) .useMostRecentString(AnnotatedCallLog.PHOTO_URI) .useMostRecentLong(AnnotatedCallLog.PHOTO_ID) .useMostRecentString(AnnotatedCallLog.LOOKUP_URI) .useMostRecentString(AnnotatedCallLog.GEOCODED_LOCATION) .useSingleValueString(AnnotatedCallLog.PHONE_ACCOUNT_COMPONENT_NAME) .useSingleValueString(AnnotatedCallLog.PHONE_ACCOUNT_ID) Loading Loading @@ -233,13 +226,6 @@ public class SystemCallLogDataSource implements CallLogDataSource { Calls.NUMBER, Calls.TYPE, Calls.COUNTRY_ISO, Calls.CACHED_NAME, Calls.CACHED_FORMATTED_NUMBER, Calls.CACHED_PHOTO_URI, Calls.CACHED_PHOTO_ID, Calls.CACHED_LOOKUP_URI, Calls.CACHED_NUMBER_TYPE, Calls.CACHED_NUMBER_LABEL, Calls.DURATION, Calls.DATA_USAGE, Calls.TRANSCRIPTION, Loading Loading @@ -272,14 +258,6 @@ public class SystemCallLogDataSource implements CallLogDataSource { int numberColumn = cursor.getColumnIndexOrThrow(Calls.NUMBER); int typeColumn = cursor.getColumnIndexOrThrow(Calls.TYPE); int countryIsoColumn = cursor.getColumnIndexOrThrow(Calls.COUNTRY_ISO); int cachedNameColumn = cursor.getColumnIndexOrThrow(Calls.CACHED_NAME); int cachedFormattedNumberColumn = cursor.getColumnIndexOrThrow(Calls.CACHED_FORMATTED_NUMBER); int cachedPhotoUriColumn = cursor.getColumnIndexOrThrow(Calls.CACHED_PHOTO_URI); int cachedPhotoIdColumn = cursor.getColumnIndexOrThrow(Calls.CACHED_PHOTO_ID); int cachedLookupUriColumn = cursor.getColumnIndexOrThrow(Calls.CACHED_LOOKUP_URI); int cachedNumberTypeColumn = cursor.getColumnIndexOrThrow(Calls.CACHED_NUMBER_TYPE); int cachedNumberLabelColumn = cursor.getColumnIndexOrThrow(Calls.CACHED_NUMBER_LABEL); int durationsColumn = cursor.getColumnIndexOrThrow(Calls.DURATION); int dataUsageColumn = cursor.getColumnIndexOrThrow(Calls.DATA_USAGE); int transcriptionColumn = cursor.getColumnIndexOrThrow(Calls.TRANSCRIPTION); Loading @@ -301,13 +279,6 @@ public class SystemCallLogDataSource implements CallLogDataSource { String numberAsStr = cursor.getString(numberColumn); long type = cursor.getInt(typeColumn); String countryIso = cursor.getString(countryIsoColumn); String cachedName = cursor.getString(cachedNameColumn); String formattedNumber = cursor.getString(cachedFormattedNumberColumn); String cachedPhotoUri = cursor.getString(cachedPhotoUriColumn); long cachedPhotoId = cursor.getLong(cachedPhotoIdColumn); String cachedLookupUri = cursor.getString(cachedLookupUriColumn); int cachedNumberType = cursor.getInt(cachedNumberTypeColumn); String cachedNumberLabel = cursor.getString(cachedNumberLabelColumn); int duration = cursor.getInt(durationsColumn); int dataUsage = cursor.getInt(dataUsageColumn); String transcription = cursor.getString(transcriptionColumn); Loading @@ -323,31 +294,19 @@ public class SystemCallLogDataSource implements CallLogDataSource { contentValues.put(AnnotatedCallLog.TIMESTAMP, date); if (!TextUtils.isEmpty(numberAsStr)) { byte[] numberAsProtoBytes = dialerPhoneNumberUtil.parse(numberAsStr, countryIso).toByteArray(); DialerPhoneNumber dialerPhoneNumber = dialerPhoneNumberUtil.parse(numberAsStr, countryIso); contentValues.put(AnnotatedCallLog.NUMBER, dialerPhoneNumber.toByteArray()); contentValues.put( AnnotatedCallLog.FORMATTED_NUMBER, PhoneNumberUtils.formatNumber(numberAsStr, countryIso)); // TODO(zachh): Need to handle post-dial digits; different on N and M. contentValues.put(AnnotatedCallLog.NUMBER, numberAsProtoBytes); } else { contentValues.put( AnnotatedCallLog.NUMBER, DialerPhoneNumber.getDefaultInstance().toByteArray()); } contentValues.put(AnnotatedCallLog.CALL_TYPE, type); contentValues.put(AnnotatedCallLog.NAME, cachedName); // TODO(zachh): Format the number using DialerPhoneNumberUtil here. contentValues.put(AnnotatedCallLog.FORMATTED_NUMBER, formattedNumber); contentValues.put(AnnotatedCallLog.PHOTO_URI, cachedPhotoUri); contentValues.put(AnnotatedCallLog.PHOTO_ID, cachedPhotoId); contentValues.put(AnnotatedCallLog.LOOKUP_URI, cachedLookupUri); // Phone.getTypeLabel returns "Custom" if given (0, null) which is not of any use. Just // omit setting the label if there's no information for it. if (cachedNumberType != 0 || cachedNumberLabel != null) { contentValues.put( AnnotatedCallLog.NUMBER_TYPE_LABEL, Phone.getTypeLabel(appContext.getResources(), cachedNumberType, cachedNumberLabel) .toString()); } contentValues.put(AnnotatedCallLog.IS_READ, isRead); contentValues.put(AnnotatedCallLog.NEW, isNew); contentValues.put(AnnotatedCallLog.GEOCODED_LOCATION, geocodedLocation); Loading
java/com/android/dialer/phonelookup/PhoneLookupSelector.java +75 −4 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.dialer.phonelookup; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.android.dialer.phonelookup.PhoneLookupInfo.Cp2Info.Cp2ContactInfo; /** * Prioritizes information from a {@link PhoneLookupInfo}. Loading @@ -37,11 +39,80 @@ public final class PhoneLookupSelector { */ @NonNull public static String selectName(PhoneLookupInfo phoneLookupInfo) { if (phoneLookupInfo.getCp2Info().getCp2ContactInfoCount() > 0) { // Arbitrarily select the first contact's name. In the future, it may make sense to join the // names such as "Mom, Dad" in the case that multiple contacts share the same number. return phoneLookupInfo.getCp2Info().getCp2ContactInfo(0).getName(); Cp2ContactInfo firstLocalContact = firstLocalContact(phoneLookupInfo); if (firstLocalContact != null) { String name = firstLocalContact.getName(); if (!name.isEmpty()) { return firstLocalContact.getName(); } } return ""; } /** Select the photo URI associated with this number. */ @NonNull public static String selectPhotoUri(PhoneLookupInfo phoneLookupInfo) { Cp2ContactInfo firstLocalContact = firstLocalContact(phoneLookupInfo); if (firstLocalContact != null) { String photoUri = firstLocalContact.getPhotoUri(); if (!photoUri.isEmpty()) { return photoUri; } } return ""; } /** Select the photo ID associated with this number, or 0 if there is none. */ public static long selectPhotoId(PhoneLookupInfo phoneLookupInfo) { Cp2ContactInfo firstLocalContact = firstLocalContact(phoneLookupInfo); if (firstLocalContact != null) { long photoId = firstLocalContact.getPhotoId(); if (photoId > 0) { return photoId; } } return 0; } /** Select the lookup URI associated with this number. */ @NonNull public static String selectLookupUri(PhoneLookupInfo phoneLookupInfo) { Cp2ContactInfo firstLocalContact = firstLocalContact(phoneLookupInfo); if (firstLocalContact != null) { String lookupUri = firstLocalContact.getLookupUri(); if (!lookupUri.isEmpty()) { return lookupUri; } } return ""; } /** * A localized string representing the number type such as "Home" or "Mobile", or a custom value * set by the user. */ @NonNull public static String selectNumberLabel(PhoneLookupInfo phoneLookupInfo) { Cp2ContactInfo firstLocalContact = firstLocalContact(phoneLookupInfo); if (firstLocalContact != null) { String label = firstLocalContact.getLabel(); if (!label.isEmpty()) { return label; } } return ""; } /** * Arbitrarily select the first contact. In the future, it may make sense to display contact * information from all contacts with the same number (for example show the name as "Mom, Dad" or * show a synthesized photo containing photos of both "Mom" and "Dad"). */ @Nullable private static Cp2ContactInfo firstLocalContact(PhoneLookupInfo phoneLookupInfo) { if (phoneLookupInfo.getCp2Info().getCp2ContactInfoCount() > 0) { return phoneLookupInfo.getCp2Info().getCp2ContactInfo(0); } return null; } }