summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/speeddial
diff options
context:
space:
mode:
authorcalderwoodra <calderwoodra@google.com>2018-05-15 17:03:56 -0700
committerCopybara-Service <copybara-piper@google.com>2018-05-15 17:04:50 -0700
commit60e0b7c0eaef5734eb173b67ea28cd3fa99ba680 (patch)
tree22209426598dcaac0c3b4f64af43f284883cb3b2 /java/com/android/dialer/speeddial
parent5b9d0c58eeaf9d41b99d77a85cc8d26810f909fc (diff)
Don't add identical numbers in the cursor to the SpeedDialUiItem.
Bug: 78492722,79213974 Test: SpeedDialUiItemTest PiperOrigin-RevId: 196754044 Change-Id: I7aec281ea7904087de0363245974cb08aec54c73
Diffstat (limited to 'java/com/android/dialer/speeddial')
-rw-r--r--java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java b/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java
index 365b88f8c..2b056bbfc 100644
--- a/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java
+++ b/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java
@@ -23,6 +23,7 @@ import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
import android.support.annotation.Nullable;
import android.text.TextUtils;
+import android.util.ArraySet;
import com.android.dialer.common.Assert;
import com.android.dialer.glidephotomanager.PhotoInfo;
import com.android.dialer.speeddial.database.SpeedDialEntry;
@@ -33,6 +34,7 @@ import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
+import java.util.Set;
/**
* POJO representation of each speed dial list element.
@@ -121,10 +123,18 @@ public abstract class SpeedDialUiItem {
// While there are more rows and the lookup keys are the same, add a channel for each of the
// contact's phone numbers.
List<Channel> channels = new ArrayList<>();
+ Set<String> numbers = new ArraySet<>();
do {
+ String number = cursor.getString(NUMBER);
+ // TODO(78492722): consider using lib phone number to compare numbers
+ if (!numbers.add(number)) {
+ // Number is identical to an existing number, skip this number
+ continue;
+ }
+
Channel channel =
Channel.builder()
- .setNumber(cursor.getString(NUMBER))
+ .setNumber(number)
.setPhoneType(cursor.getInt(TYPE))
.setLabel(getLabel(resources, cursor))
.setTechnology(Channel.VOICE)