diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-01-12 02:48:25 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-01-12 02:48:25 +0000 |
commit | 6bd659e6e90346f58ed08f6c127835a320bbd2e4 (patch) | |
tree | b90e5f582dcab0d3ad6393f4ffbc7a4dd78e81dc /java/com/android/dialer/calllog/ui | |
parent | 58bade2ace277dff4db3bbbfa2e07015f0f7c6ad (diff) | |
parent | 01aac5de58903555a089d16a58b9346d34d54e7b (diff) |
Merge changes I2e091371,I4e0bc1c6,I24063ee4
* changes:
Implement PhoneLookup for CP2 remote contacts
Merge PhoneLookupDataSource results into a proto in annotated call log.
Attempt to place call even call permission is missing
Diffstat (limited to 'java/com/android/dialer/calllog/ui')
5 files changed, 64 insertions, 54 deletions
diff --git a/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java b/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java index 5c0ce2816..d72544b56 100644 --- a/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java +++ b/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java @@ -21,6 +21,7 @@ import android.database.Cursor; import android.support.v4.content.CursorLoader; import com.android.dialer.CoalescedIds; import com.android.dialer.DialerPhoneNumber; +import com.android.dialer.NumberAttributes; import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.CoalescedAnnotatedCallLog; import com.android.dialer.calllog.model.CoalescedRow; import com.google.protobuf.InvalidProtocolBufferException; @@ -31,27 +32,19 @@ final class CoalescedAnnotatedCallLogCursorLoader extends CursorLoader { // Indexes for CoalescedAnnotatedCallLog.ALL_COLUMNS private static final int ID = 0; private static final int TIMESTAMP = 1; - private static final int NAME = 2; - private static final int NUMBER = 3; - private static final int FORMATTED_NUMBER = 4; - private static final int PHOTO_URI = 5; - private static final int PHOTO_ID = 6; - private static final int LOOKUP_URI = 7; - private static final int NUMBER_TYPE_LABEL = 8; - private static final int IS_READ = 9; - private static final int NEW = 10; - private static final int GEOCODED_LOCATION = 11; - private static final int PHONE_ACCOUNT_COMPONENT_NAME = 12; - private static final int PHONE_ACCOUNT_ID = 13; - private static final int PHONE_ACCOUNT_LABEL = 14; - private static final int PHONE_ACCOUNT_COLOR = 15; - private static final int FEATURES = 16; - private static final int IS_BUSINESS = 17; - private static final int IS_VOICEMAIL = 18; - private static final int CALL_TYPE = 19; - private static final int CAN_REPORT_AS_INVALID_NUMBER = 20; - private static final int CP2_INFO_INCOMPLETE = 21; - private static final int COALESCED_IDS = 22; + private static final int NUMBER = 2; + private static final int FORMATTED_NUMBER = 3; + private static final int IS_READ = 4; + private static final int NEW = 5; + private static final int GEOCODED_LOCATION = 6; + private static final int PHONE_ACCOUNT_COMPONENT_NAME = 7; + private static final int PHONE_ACCOUNT_ID = 8; + private static final int PHONE_ACCOUNT_LABEL = 9; + private static final int PHONE_ACCOUNT_COLOR = 10; + private static final int FEATURES = 11; + private static final int NUMBER_ATTRIBUTES = 12; + private static final int CALL_TYPE = 13; + private static final int COALESCED_IDS = 14; CoalescedAnnotatedCallLogCursorLoader(Context context) { // CoalescedAnnotatedCallLog requires that PROJECTION be ALL_COLUMNS and the following params be @@ -81,16 +74,18 @@ final class CoalescedAnnotatedCallLogCursorLoader extends CursorLoader { throw new IllegalStateException("Couldn't parse CoalescedIds bytes"); } + NumberAttributes numberAttributes; + try { + numberAttributes = NumberAttributes.parseFrom(cursor.getBlob(NUMBER_ATTRIBUTES)); + } catch (InvalidProtocolBufferException e) { + throw new IllegalStateException("Couldn't parse NumberAttributes bytes"); + } + return CoalescedRow.builder() .setId(cursor.getInt(ID)) .setTimestamp(cursor.getLong(TIMESTAMP)) - .setName(cursor.getString(NAME)) .setNumber(number) .setFormattedNumber(cursor.getString(FORMATTED_NUMBER)) - .setPhotoUri(cursor.getString(PHOTO_URI)) - .setPhotoId(cursor.getLong(PHOTO_ID)) - .setLookupUri(cursor.getString(LOOKUP_URI)) - .setNumberTypeLabel(cursor.getString(NUMBER_TYPE_LABEL)) .setIsRead(cursor.getInt(IS_READ) == 1) .setIsNew(cursor.getInt(NEW) == 1) .setGeocodedLocation(cursor.getString(GEOCODED_LOCATION)) @@ -99,11 +94,8 @@ final class CoalescedAnnotatedCallLogCursorLoader extends CursorLoader { .setPhoneAccountLabel(cursor.getString(PHONE_ACCOUNT_LABEL)) .setPhoneAccountColor(cursor.getInt(PHONE_ACCOUNT_COLOR)) .setFeatures(cursor.getInt(FEATURES)) - .setIsBusiness(cursor.getInt(IS_BUSINESS) == 1) - .setIsVoicemail(cursor.getInt(IS_VOICEMAIL) == 1) .setCallType(cursor.getInt(CALL_TYPE)) - .setCanReportAsInvalidNumber(cursor.getInt(CAN_REPORT_AS_INVALID_NUMBER) == 1) - .setCp2InfoIncomplete(cursor.getInt(CP2_INFO_INCOMPLETE) == 1) + .setNumberAttributes(numberAttributes) .setCoalescedIds(coalescedIds) .build(); } diff --git a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java index 7482efdea..5b526b49d 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java @@ -20,6 +20,7 @@ import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.provider.CallLog.Calls; +import android.support.annotation.Nullable; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; import android.view.View; @@ -134,13 +135,18 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { ContactPhotoManager.getInstance(context) .loadDialerThumbnailOrPhoto( quickContactBadge, - TextUtils.isEmpty(row.lookupUri()) ? null : Uri.parse(row.lookupUri()), - row.photoId(), - TextUtils.isEmpty(row.photoUri()) ? null : Uri.parse(row.photoUri()), + parseUri(row.numberAttributes().getLookupUri()), + row.numberAttributes().getPhotoId(), + parseUri(row.numberAttributes().getPhotoUri()), CallLogEntryText.buildPrimaryText(context, row).toString(), CallLogContactTypes.getContactType(row)); } + @Nullable + private static Uri parseUri(@Nullable String uri) { + return TextUtils.isEmpty(uri) ? null : Uri.parse(uri); + } + private void setPrimaryCallTypes(CoalescedRow row) { primaryCallTypeIconsView.setShowHd( (row.features() & Calls.FEATURES_HD_CALL) == Calls.FEATURES_HD_CALL); diff --git a/java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java b/java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java index 74b7defb0..2cfe0b4ad 100644 --- a/java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java +++ b/java/com/android/dialer/calllog/ui/RealtimeRowProcessor.java @@ -19,6 +19,7 @@ package com.android.dialer.calllog.ui; import android.support.annotation.MainThread; import android.util.ArrayMap; import com.android.dialer.DialerPhoneNumber; +import com.android.dialer.NumberAttributes; import com.android.dialer.calllog.model.CoalescedRow; import com.android.dialer.common.concurrent.Annotations.Ui; import com.android.dialer.phonelookup.PhoneLookupInfo; @@ -68,7 +69,7 @@ public final class RealtimeRowProcessor { @MainThread ListenableFuture<Optional<CoalescedRow>> applyRealtimeProcessing(final CoalescedRow row) { // Cp2LocalPhoneLookup can not always efficiently process all rows. - if (!row.cp2InfoIncomplete()) { + if (!row.numberAttributes().getIsCp2InfoIncomplete()) { return Futures.immediateFuture(Optional.absent()); } @@ -97,11 +98,18 @@ public final class RealtimeRowProcessor { PhoneLookupInfo phoneLookupInfo = PhoneLookupInfo.newBuilder().setCp2LocalInfo(cp2Info).build(); // It is safe to overwrite any existing data because CP2 always has highest priority. return row.toBuilder() - .setName(phoneLookupSelector.selectName(phoneLookupInfo)) - .setPhotoUri(phoneLookupSelector.selectPhotoUri(phoneLookupInfo)) - .setPhotoId(phoneLookupSelector.selectPhotoId(phoneLookupInfo)) - .setLookupUri(phoneLookupSelector.selectLookupUri(phoneLookupInfo)) - .setNumberTypeLabel(phoneLookupSelector.selectNumberLabel(phoneLookupInfo)) + .setNumberAttributes( + NumberAttributes.newBuilder() + .setName(phoneLookupSelector.selectName(phoneLookupInfo)) + .setPhotoUri(phoneLookupSelector.selectPhotoUri(phoneLookupInfo)) + .setPhotoId(phoneLookupSelector.selectPhotoId(phoneLookupInfo)) + .setLookupUri(phoneLookupSelector.selectLookupUri(phoneLookupInfo)) + .setNumberTypeLabel(phoneLookupSelector.selectNumberLabel(phoneLookupInfo)) + .setIsBusiness(phoneLookupSelector.selectIsBusiness(phoneLookupInfo)) + .setIsVoicemail(phoneLookupSelector.selectIsVoicemail(phoneLookupInfo)) + .setCanReportAsInvalidNumber( + phoneLookupSelector.canReportAsInvalidNumber(phoneLookupInfo)) + .build()) .build(); } } diff --git a/java/com/android/dialer/calllog/ui/menu/Modules.java b/java/com/android/dialer/calllog/ui/menu/Modules.java index 3d667fc79..92dd41163 100644 --- a/java/com/android/dialer/calllog/ui/menu/Modules.java +++ b/java/com/android/dialer/calllog/ui/menu/Modules.java @@ -45,7 +45,11 @@ final class Modules { maybeAddModuleForVideoOrAudioCall(context, modules, row); SharedModules.maybeAddModuleForAddingToContacts( - context, modules, row.number(), row.name(), row.lookupUri()); + context, + modules, + row.number(), + row.numberAttributes().getName(), + row.numberAttributes().getLookupUri()); String originalNumber = row.number().getRawInput().getNumber(); SharedModules.maybeAddModuleForSendingTextMessage(context, modules, originalNumber); @@ -98,8 +102,8 @@ final class Modules { private static void addModuleForAccessingCallDetails( Context context, List<ContactActionModule> modules, CoalescedRow row) { - boolean canReportAsInvalidNumber = row.canReportAsInvalidNumber(); - boolean canSupportAssistedDialing = !TextUtils.isEmpty(row.lookupUri()); + boolean canReportAsInvalidNumber = row.numberAttributes().getCanReportAsInvalidNumber(); + boolean canSupportAssistedDialing = !TextUtils.isEmpty(row.numberAttributes().getLookupUri()); modules.add( new IntentModule( @@ -122,21 +126,21 @@ final class Modules { DialerContact.newBuilder() .setNumber(originalNumber) .setContactType(LetterTileDrawable.TYPE_DEFAULT) // TODO(zachh): Use proper type. - .setPhotoId(row.photoId()); + .setPhotoId(row.numberAttributes().getPhotoId()); - if (!TextUtils.isEmpty(row.name())) { - dialerContactBuilder.setNameOrNumber(row.name()); + if (!TextUtils.isEmpty(row.numberAttributes().getName())) { + dialerContactBuilder.setNameOrNumber(row.numberAttributes().getName()); } else if (!TextUtils.isEmpty(originalNumber)) { dialerContactBuilder.setNameOrNumber(originalNumber); } - if (row.numberTypeLabel() != null) { - dialerContactBuilder.setNumberLabel(row.numberTypeLabel()); + if (row.numberAttributes().hasNumberTypeLabel()) { + dialerContactBuilder.setNumberLabel(row.numberAttributes().getNumberTypeLabel()); } - if (row.photoUri() != null) { - dialerContactBuilder.setPhotoUri(row.photoUri()); + if (row.numberAttributes().hasPhotoUri()) { + dialerContactBuilder.setPhotoUri(row.numberAttributes().getPhotoUri()); } - if (row.lookupUri() != null) { - dialerContactBuilder.setContactUri(row.lookupUri()); + if (row.numberAttributes().hasLookupUri()) { + dialerContactBuilder.setContactUri(row.numberAttributes().getLookupUri()); } if (row.formattedNumber() != null) { dialerContactBuilder.setDisplayNumber(row.formattedNumber()); diff --git a/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java b/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java index faedc8f62..c7126e9dc 100644 --- a/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java +++ b/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java @@ -34,9 +34,9 @@ final class PrimaryAction { .setNumber(row.number()) .setPhotoInfo( PhotoInfo.builder() - .setPhotoId(row.photoId()) - .setPhotoUri(row.photoUri()) - .setLookupUri(row.lookupUri()) + .setPhotoId(row.numberAttributes().getPhotoId()) + .setPhotoUri(row.numberAttributes().getPhotoUri()) + .setLookupUri(row.numberAttributes().getLookupUri()) .setIsVideo((row.features() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO) .setContactType(CallLogContactTypes.getContactType(row)) .setDisplayName(primaryText.toString()) |