Merge "Don't show "device" on SIM import after account added" into ub-contactsdialer-h-dev
diff --git a/src/com/android/contacts/common/list/FavoritesAndContactsLoader.java b/src/com/android/contacts/common/list/FavoritesAndContactsLoader.java
index 2dcbc18..e112846 100644
--- a/src/com/android/contacts/common/list/FavoritesAndContactsLoader.java
+++ b/src/com/android/contacts/common/list/FavoritesAndContactsLoader.java
@@ -47,9 +47,6 @@
private CountDownLatch mAutocompleteLatch = new CountDownLatch(1);
private Cursor mAutocompleteCursor;
private int mAutocompleteTimeout;
- // If we didn't get anything back from autocomplete and we've fallen back to CP2,
- // we can't wait for the Experiments.SEARCH_YENTA_TIMEOUT_MILLIS everytime the query changes.
- private boolean mAutocompleteFallback;
public FavoritesAndContactsLoader(Context context) {
super(context);
@@ -74,27 +71,14 @@
@Override
public Cursor loadInBackground() {
List<Cursor> cursors = Lists.newArrayList();
-
- // Load favorites
if (mLoadFavorites) {
cursors.add(loadFavoritesContacts());
}
- // Load contacts
- final Cursor contactsCursor;
- if (mAutocompleteQuery == null || mAutocompleteFallback) {
- // Query CP2 normally
- contactsCursor = loadContacts();
- cursors.add(contactsCursor);
- } else {
+ if (mAutocompleteQuery != null) {
final AutocompleteHelper autocompleteHelper =
ObjectFactory.getAutocompleteHelper(getContext());
- if (autocompleteHelper == null) {
- // Fallback to CP2, the flag is on but we couldn't instantiate autocomplete
- contactsCursor = loadContacts();
- cursors.add(contactsCursor);
- mAutocompleteFallback = true;
- } else {
+ if (autocompleteHelper != null) {
autocompleteHelper.setListener(this);
autocompleteHelper.setProjection(mProjection);
autocompleteHelper.setQuery(mAutocompleteQuery);
@@ -105,18 +89,21 @@
} catch (InterruptedException e) {
logw("Interrupted while waiting for autocompletions");
}
- if (mAutocompleteCursor != null && mAutocompleteCursor.getCount() > 0) {
- contactsCursor = null;
+ if (mAutocompleteCursor != null) {
cursors.add(mAutocompleteCursor);
- } else {
- // Fallback to CP2, we didn't get anything back from autocomplete
- contactsCursor = loadContacts();
- cursors.add(loadContacts());
- mAutocompleteFallback = true;
+ // TODO: exclude these results from the main loader results, see b/30742359
}
}
}
+ // TODO: if the autocomplete experiment in on, only show those results even if they're empty
+ final Cursor contactsCursor = mAutocompleteQuery == null ? loadContacts() : null;
+ if (mAutocompleteQuery == null) {
+ cursors.add(contactsCursor);
+ }
+ // Guard against passing an empty array to the MergeCursor constructor
+ if (cursors.isEmpty()) cursors.add(null);
+
return new MergeCursor(cursors.toArray(new Cursor[cursors.size()])) {
@Override
public Bundle getExtras() {