summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/speeddial/loader
diff options
context:
space:
mode:
authorcalderwoodra <calderwoodra@google.com>2018-05-17 16:15:40 -0700
committerCopybara-Service <copybara-piper@google.com>2018-05-17 17:31:53 -0700
commit29b95403e0997f58e0030e638dcdaf209319f282 (patch)
treef62cec766780b6c943f49e3ffc56315e359a046c /java/com/android/dialer/speeddial/loader
parent147e86270e70bf090cfc8ebb4bc5903a17a9ef10 (diff)
Fixed various speed dial issues.
X. Pinned contacts are now saved onPause 4. Large display size no longer crops images 14. If ViLTE is disabled, IMS_VIDEO channels won't be added. Bug: 78491298,79876391,79876661 Test: manual PiperOrigin-RevId: 197068627 Change-Id: I642a11d684c648b7f6579792313b09eabb09a9fa
Diffstat (limited to 'java/com/android/dialer/speeddial/loader')
-rw-r--r--java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java9
-rw-r--r--java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java33
2 files changed, 37 insertions, 5 deletions
diff --git a/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java b/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java
index 2b056bbfc..9e227553b 100644
--- a/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java
+++ b/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java
@@ -18,6 +18,7 @@ package com.android.dialer.speeddial.loader;
import android.content.res.Resources;
import android.database.Cursor;
+import android.os.Trace;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
@@ -105,7 +106,9 @@ public abstract class SpeedDialUiItem {
* <p>If the cursor started at row X, this method will advance to row Y s.t. rows X, X + 1, ... Y
* - 1 all belong to the same contact (that is, share the same contact id and lookup key).
*/
- public static SpeedDialUiItem fromCursor(Resources resources, Cursor cursor) {
+ public static SpeedDialUiItem fromCursor(
+ Resources resources, Cursor cursor, boolean isImsEnabled) {
+ Trace.beginSection("fromCursor");
Assert.checkArgument(cursor != null);
Assert.checkArgument(cursor.getCount() != 0);
String lookupKey = cursor.getString(LOOKUP_KEY);
@@ -141,7 +144,8 @@ public abstract class SpeedDialUiItem {
.build();
channels.add(channel);
- if ((cursor.getInt(CARRIER_PRESENCE) & Data.CARRIER_PRESENCE_VT_CAPABLE) == 1) {
+ if (isImsEnabled
+ && (cursor.getInt(CARRIER_PRESENCE) & Data.CARRIER_PRESENCE_VT_CAPABLE) == 1) {
// Add another channel if the number is ViLTE reachable
channels.add(channel.toBuilder().setTechnology(Channel.IMS_VIDEO).build());
}
@@ -149,6 +153,7 @@ public abstract class SpeedDialUiItem {
} while (cursor.moveToNext() && Objects.equals(lookupKey, cursor.getString(LOOKUP_KEY)));
builder.setChannels(ImmutableList.copyOf(channels));
+ Trace.endSection();
return builder.build();
}
diff --git a/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java b/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java
index 1ad37dc2a..998793e6e 100644
--- a/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java
+++ b/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java
@@ -25,6 +25,7 @@ import android.database.Cursor;
import android.net.Uri;
import android.os.Build.VERSION_CODES;
import android.os.RemoteException;
+import android.os.Trace;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
@@ -46,6 +47,7 @@ import com.android.dialer.speeddial.database.SpeedDialEntry;
import com.android.dialer.speeddial.database.SpeedDialEntry.Channel;
import com.android.dialer.speeddial.database.SpeedDialEntryDao;
import com.android.dialer.speeddial.database.SpeedDialEntryDatabaseHelper;
+import com.android.dialer.util.CallUtil;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -205,7 +207,9 @@ public final class SpeedDialUiItemMutator {
return loadSpeedDialUiItemsInternal();
}
Assert.checkArgument(cursor.moveToFirst(), "Cursor should never be empty");
- SpeedDialUiItem item = SpeedDialUiItem.fromCursor(appContext.getResources(), cursor);
+ SpeedDialUiItem item =
+ SpeedDialUiItem.fromCursor(
+ appContext.getResources(), cursor, CallUtil.isVideoEnabled(appContext));
// Star the contact if it isn't starred already, then return.
if (!item.isStarred()) {
@@ -228,9 +232,12 @@ public final class SpeedDialUiItemMutator {
@WorkerThread
private ImmutableList<SpeedDialUiItem> loadSpeedDialUiItemsInternal() {
+ Trace.beginSection("loadSpeedDialUiItemsInternal");
Assert.isWorkerThread();
contactsPreferences.refreshValue(ContactsPreferences.DISPLAY_ORDER_KEY);
+ Trace.beginSection("getAllEntries");
SpeedDialEntryDao db = getSpeedDialEntryDao();
+ Trace.endSection(); // getAllEntries
// This is the list of contacts that we will display to the user
List<SpeedDialUiItem> speedDialUiItems = new ArrayList<>();
@@ -251,6 +258,7 @@ public final class SpeedDialUiItemMutator {
"Updated entries are incomplete: " + entries.size() + " != " + entriesToUiItems.size());
// Mark the SpeedDialEntries to be updated or deleted
+ Trace.beginSection("updateOrDeleteEntries");
for (SpeedDialEntry entry : entries) {
SpeedDialUiItem contact = entriesToUiItems.get(entry);
// Remove contacts that no longer exist or are no longer starred
@@ -271,12 +279,14 @@ public final class SpeedDialUiItemMutator {
// These are our existing starred entries
speedDialUiItems.add(contact);
}
+ Trace.endSection(); // updateOrDeleteEntries
// Get all Strequent Contacts
List<SpeedDialUiItem> strequentContacts = getStrequentContacts();
// For each contact, if it isn't starred, add it as a suggestion.
// If it is starred and not already accounted for above, then insert into the SpeedDialEntry DB.
+ Trace.beginSection("addSuggestions");
for (SpeedDialUiItem contact : strequentContacts) {
if (!contact.isStarred()) {
// Add this contact as a suggestion
@@ -291,12 +301,16 @@ public final class SpeedDialUiItemMutator {
speedDialUiItems.add(contact);
}
}
+ Trace.endSection(); // addSuggestions
+ Trace.beginSection("insertUpdateAndDelete");
ImmutableMap<SpeedDialEntry, Long> insertedEntriesToIdsMap =
db.insertUpdateAndDelete(
ImmutableList.copyOf(entriesToInsert),
ImmutableList.copyOf(entriesToUpdate),
ImmutableList.copyOf(entriesToDelete));
+ Trace.endSection(); // insertUpdateAndDelete
+ Trace.endSection(); // loadSpeedDialUiItemsInternal
return speedDialUiItemsWithUpdatedIds(speedDialUiItems, insertedEntriesToIdsMap);
}
@@ -388,11 +402,13 @@ public final class SpeedDialUiItemMutator {
@WorkerThread
private Map<SpeedDialEntry, SpeedDialUiItem> getSpeedDialUiItemsFromEntries(
List<SpeedDialEntry> entries) {
+ Trace.beginSection("getSpeedDialUiItemsFromEntries");
Assert.isWorkerThread();
// Fetch the contact ids from the SpeedDialEntries
Set<String> contactIds = new ArraySet<>();
entries.forEach(entry -> contactIds.add(Long.toString(entry.contactId())));
if (contactIds.isEmpty()) {
+ Trace.endSection();
return new ArrayMap<>();
}
@@ -410,7 +426,9 @@ public final class SpeedDialUiItemMutator {
null)) {
Map<SpeedDialEntry, SpeedDialUiItem> map = new ArrayMap<>();
for (cursor.moveToFirst(); !cursor.isAfterLast(); /* Iterate in the loop */ ) {
- SpeedDialUiItem item = SpeedDialUiItem.fromCursor(appContext.getResources(), cursor);
+ SpeedDialUiItem item =
+ SpeedDialUiItem.fromCursor(
+ appContext.getResources(), cursor, CallUtil.isVideoEnabled(appContext));
for (SpeedDialEntry entry : entries) {
if (entry.contactId() == item.contactId()) {
// Update the id and pinned position to match it's corresponding SpeedDialEntry.
@@ -442,6 +460,7 @@ public final class SpeedDialUiItemMutator {
for (SpeedDialEntry entry : entries) {
map.putIfAbsent(entry, null);
}
+ Trace.endSection();
return map;
}
}
@@ -467,6 +486,7 @@ public final class SpeedDialUiItemMutator {
@WorkerThread
private List<SpeedDialUiItem> getStrequentContacts() {
+ Trace.beginSection("getStrequentContacts");
Assert.isWorkerThread();
Set<String> contactIds = new ArraySet<>();
@@ -482,9 +502,11 @@ public final class SpeedDialUiItemMutator {
.query(strequentUri, new String[] {Phone.CONTACT_ID}, null, null, null)) {
if (cursor == null) {
LogUtil.e("SpeedDialUiItemMutator.getStrequentContacts", "null cursor");
+ Trace.endSection();
return new ArrayList<>();
}
if (cursor.getCount() == 0) {
+ Trace.endSection();
return new ArrayList<>();
}
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
@@ -507,14 +529,19 @@ public final class SpeedDialUiItemMutator {
List<SpeedDialUiItem> contacts = new ArrayList<>();
if (cursor == null) {
LogUtil.e("SpeedDialUiItemMutator.getStrequentContacts", "null cursor");
+ Trace.endSection();
return new ArrayList<>();
}
if (cursor.getCount() == 0) {
+ Trace.endSection();
return contacts;
}
for (cursor.moveToFirst(); !cursor.isAfterLast(); /* Iterate in the loop */ ) {
- contacts.add(SpeedDialUiItem.fromCursor(appContext.getResources(), cursor));
+ contacts.add(
+ SpeedDialUiItem.fromCursor(
+ appContext.getResources(), cursor, CallUtil.isVideoEnabled(appContext)));
}
+ Trace.endSection();
return contacts;
}
}