App changes for handling profile DB split.
- Added a custom loader to load in the profile and contact list.
- Made the CursorLoader for ContactEntryListFragment and its
subclasses pluggable, so the default one could substitute in
the combined profile-and-contact list loader.
- The photo manager needs some awareness of the profile ID-space,
since it's doing bulk photo queries using a custom selection.
- Adapted Isaac's change to the section indexer to handle the
profile being out of consideration when doing the address book
index query.
- Removed uses of the ALLOW_PROFILE param, since it no longer exists.
Bug 5204577
Bug 5136432
Bug 5140891
Change-Id: I676b4cdeabe87b1b585c6c8df2cde51605777106
diff --git a/src/com/android/contacts/ContactPhotoManager.java b/src/com/android/contacts/ContactPhotoManager.java
index 0f7065d..fd2e6a2 100644
--- a/src/com/android/contacts/ContactPhotoManager.java
+++ b/src/com/android/contacts/ContactPhotoManager.java
@@ -21,6 +21,7 @@
import com.google.android.collect.Sets;
import android.content.ContentResolver;
+import android.content.ContentUris;
import android.content.Context;
import android.content.res.Resources;
import android.database.Cursor;
@@ -642,7 +643,6 @@
ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(Directory.DEFAULT))
.appendQueryParameter(ContactsContract.LIMIT_PARAM_KEY,
String.valueOf(MAX_PHOTOS_TO_PRELOAD))
- .appendQueryParameter(ContactsContract.ALLOW_PROFILE, "1")
.build();
cursor = mResolver.query(uri, new String[] { Contacts.PHOTO_ID },
Contacts.PHOTO_ID + " NOT NULL AND " + Contacts.PHOTO_ID + "!=0",
@@ -698,8 +698,7 @@
Cursor cursor = null;
try {
- cursor = mResolver.query(Data.CONTENT_URI.buildUpon()
- .appendQueryParameter(ContactsContract.ALLOW_PROFILE, "1").build(),
+ cursor = mResolver.query(Data.CONTENT_URI,
COLUMNS,
mStringBuilder.toString(),
mPhotoIdsAsStrings.toArray(EMPTY_STRING_ARRAY),
@@ -719,9 +718,30 @@
}
}
- // Remaining photos were not found in the database - mark the cache accordingly.
+ // Remaining photos were not found in the contacts database (but might be in profile).
for (Long id : mPhotoIds) {
- cacheBitmap(id, null, preloading);
+ if (ContactsContract.isProfileId(id)) {
+ Cursor profileCursor = null;
+ try {
+ profileCursor = mResolver.query(
+ ContentUris.withAppendedId(Data.CONTENT_URI, id),
+ COLUMNS, null, null, null);
+ if (profileCursor != null && profileCursor.moveToFirst()) {
+ cacheBitmap(profileCursor.getLong(0), profileCursor.getBlob(1),
+ preloading);
+ } else {
+ // Couldn't load a photo this way either.
+ cacheBitmap(id, null, preloading);
+ }
+ } finally {
+ if (profileCursor != null) {
+ profileCursor.close();
+ }
+ }
+ } else {
+ // Not a profile photo and not found - mark the cache accordingly
+ cacheBitmap(id, null, preloading);
+ }
}
mMainThreadHandler.sendEmptyMessage(MESSAGE_PHOTOS_LOADED);