summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Lehmann <lehmannd@google.com>2011-08-14 15:53:42 -0700
committerDaniel Lehmann <lehmannd@google.com>2011-08-14 15:53:42 -0700
commit0bf6b318e3c994294d4a885f57906debd4a0e64e (patch)
treedc730be21876e5179d97c98f3ecf292d2ba61a93
parent0e272967c6c6662d8a6eed80650dad0369aac085 (diff)
downloadpackages_providers_ContactsProvider-0bf6b318e3c994294d4a885f57906debd4a0e64e.zip
packages_providers_ContactsProvider-0bf6b318e3c994294d4a885f57906debd4a0e64e.tar.gz
packages_providers_ContactsProvider-0bf6b318e3c994294d4a885f57906debd4a0e64e.tar.bz2
Several DB changes as requested by ES
- Switch from resource ids to names to prevent breakage on package upgrade Bug:5135277 - Add SYNC1...SYNC4 columns to StreamItems and StreamItemPhotos Bug:5119385 - Remove ACTION, ACTION_URI from Groups, StreamItems and StreamItemPhotos (this reduces db size and prevents click intercepting) Bug:5135808 - Add some raw-contact fields to the StreamItem and StreamItemPhotos query Bug:5134081 Doing those changes in one block to prevent too many db upgrade steps Bug:5135277 Change-Id: I1d1661c9a507d9efd4ef334fe21481097e820b7c
-rw-r--r--src/com/android/providers/contacts/ContactsDatabaseHelper.java157
-rw-r--r--src/com/android/providers/contacts/ContactsProvider2.java76
-rw-r--r--tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java10
-rw-r--r--tests/src/com/android/providers/contacts/ContactsMockPackageManager.java8
-rw-r--r--tests/src/com/android/providers/contacts/ContactsMockResources.java68
-rw-r--r--tests/src/com/android/providers/contacts/ContactsProvider2Test.java4
6 files changed, 221 insertions, 102 deletions
diff --git a/src/com/android/providers/contacts/ContactsDatabaseHelper.java b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
index 962617c..08ec24f 100644
--- a/src/com/android/providers/contacts/ContactsDatabaseHelper.java
+++ b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
@@ -102,7 +102,7 @@ import java.util.Locale;
* 600-699 Ice Cream Sandwich
* </pre>
*/
- static final int DATABASE_VERSION = 612;
+ static final int DATABASE_VERSION = 613;
private static final String DATABASE_NAME = "contacts2.db";
private static final String DATABASE_PRESENCE = "presence_db";
@@ -402,8 +402,6 @@ import java.util.Locale;
public static final String CONCRETE_DATA_SET = Tables.GROUPS + "." + Groups.DATA_SET;
public static final String CONCRETE_ACCOUNT_TYPE_AND_DATA_SET = Tables.GROUPS + "." +
Groups.ACCOUNT_TYPE_AND_DATA_SET;
- public static final String CONCRETE_ACTION = Tables.GROUPS + "." + Groups.ACTION;
- public static final String CONCRETE_ACTION_URI = Tables.GROUPS + "." + Groups.ACTION_URI;
}
public interface ActivitiesColumns {
@@ -514,27 +512,33 @@ import java.util.Locale;
}
public interface StreamItemsColumns {
- String CONCRETE_ID = Tables.STREAM_ITEMS + "." + BaseColumns._ID;
- String CONCRETE_RAW_CONTACT_ID = Tables.STREAM_ITEMS + "." + StreamItems.RAW_CONTACT_ID;
- String CONCRETE_PACKAGE = Tables.STREAM_ITEMS + "." + StreamItems.RES_PACKAGE;
- String CONCRETE_ICON = Tables.STREAM_ITEMS + "." + StreamItems.RES_ICON;
- String CONCRETE_LABEL = Tables.STREAM_ITEMS + "." + StreamItems.RES_LABEL;
- String CONCRETE_TEXT = Tables.STREAM_ITEMS + "." + StreamItems.TEXT;
- String CONCRETE_TIMESTAMP = Tables.STREAM_ITEMS + "." + StreamItems.TIMESTAMP;
- String CONCRETE_COMMENTS = Tables.STREAM_ITEMS + "." + StreamItems.COMMENTS;
- String CONCRETE_ACTION = Tables.STREAM_ITEMS + "." + StreamItems.ACTION;
- String CONCRETE_ACTION_URI = Tables.STREAM_ITEMS + "." + StreamItems.ACTION_URI;
+ final String CONCRETE_ID = Tables.STREAM_ITEMS + "." + BaseColumns._ID;
+ final String CONCRETE_RAW_CONTACT_ID =
+ Tables.STREAM_ITEMS + "." + StreamItems.RAW_CONTACT_ID;
+ final String CONCRETE_PACKAGE = Tables.STREAM_ITEMS + "." + StreamItems.RES_PACKAGE;
+ final String CONCRETE_ICON = Tables.STREAM_ITEMS + "." + StreamItems.RES_ICON;
+ final String CONCRETE_LABEL = Tables.STREAM_ITEMS + "." + StreamItems.RES_LABEL;
+ final String CONCRETE_TEXT = Tables.STREAM_ITEMS + "." + StreamItems.TEXT;
+ final String CONCRETE_TIMESTAMP = Tables.STREAM_ITEMS + "." + StreamItems.TIMESTAMP;
+ final String CONCRETE_COMMENTS = Tables.STREAM_ITEMS + "." + StreamItems.COMMENTS;
+ final String CONCRETE_SYNC1 = Tables.STREAM_ITEMS + "." + StreamItems.SYNC1;
+ final String CONCRETE_SYNC2 = Tables.STREAM_ITEMS + "." + StreamItems.SYNC2;
+ final String CONCRETE_SYNC3 = Tables.STREAM_ITEMS + "." + StreamItems.SYNC3;
+ final String CONCRETE_SYNC4 = Tables.STREAM_ITEMS + "." + StreamItems.SYNC4;
}
public interface StreamItemPhotosColumns {
- String CONCRETE_ID = Tables.STREAM_ITEM_PHOTOS + "." + BaseColumns._ID;
- String CONCRETE_STREAM_ITEM_ID = Tables.STREAM_ITEM_PHOTOS + "."
+ final String CONCRETE_ID = Tables.STREAM_ITEM_PHOTOS + "." + BaseColumns._ID;
+ final String CONCRETE_STREAM_ITEM_ID = Tables.STREAM_ITEM_PHOTOS + "."
+ StreamItemPhotos.STREAM_ITEM_ID;
- String CONCRETE_SORT_INDEX = Tables.STREAM_ITEM_PHOTOS + "." + StreamItemPhotos.SORT_INDEX;
- String CONCRETE_PHOTO_FILE_ID = Tables.STREAM_ITEM_PHOTOS + "."
+ final String CONCRETE_SORT_INDEX =
+ Tables.STREAM_ITEM_PHOTOS + "." + StreamItemPhotos.SORT_INDEX;
+ final String CONCRETE_PHOTO_FILE_ID = Tables.STREAM_ITEM_PHOTOS + "."
+ StreamItemPhotos.PHOTO_FILE_ID;
- String CONCRETE_ACTION = Tables.STREAM_ITEM_PHOTOS + "." + StreamItemPhotos.ACTION;
- String CONCRETE_ACTION_URI = Tables.STREAM_ITEM_PHOTOS + "." + StreamItemPhotos.ACTION_URI;
+ final String CONCRETE_SYNC1 = Tables.STREAM_ITEM_PHOTOS + "." + StreamItemPhotos.SYNC1;
+ final String CONCRETE_SYNC2 = Tables.STREAM_ITEM_PHOTOS + "." + StreamItemPhotos.SYNC2;
+ final String CONCRETE_SYNC3 = Tables.STREAM_ITEM_PHOTOS + "." + StreamItemPhotos.SYNC3;
+ final String CONCRETE_SYNC4 = Tables.STREAM_ITEM_PHOTOS + "." + StreamItemPhotos.SYNC4;
}
public interface PhotoFilesColumns {
@@ -916,13 +920,15 @@ import java.util.Locale;
StreamItems._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
StreamItems.RAW_CONTACT_ID + " INTEGER NOT NULL, " +
StreamItems.RES_PACKAGE + " TEXT, " +
- StreamItems.RES_ICON + " INTEGER, " +
- StreamItems.RES_LABEL + " INTEGER, " +
- StreamItems.TEXT + " TEXT NOT NULL, " +
+ StreamItems.RES_ICON + " TEXT, " +
+ StreamItems.RES_LABEL + " TEXT, " +
+ StreamItems.TEXT + " TEXT, " +
StreamItems.TIMESTAMP + " INTEGER NOT NULL, " +
- StreamItems.COMMENTS + " TEXT NOT NULL, " +
- StreamItems.ACTION + " TEXT, " +
- StreamItems.ACTION_URI + " TEXT, " +
+ StreamItems.COMMENTS + " TEXT, " +
+ StreamItems.SYNC1 + " TEXT, " +
+ StreamItems.SYNC2 + " TEXT, " +
+ StreamItems.SYNC3 + " TEXT, " +
+ StreamItems.SYNC4 + " TEXT, " +
"FOREIGN KEY(" + StreamItems.RAW_CONTACT_ID + ") REFERENCES " +
Tables.RAW_CONTACTS + "(" + RawContacts._ID + "));");
@@ -931,8 +937,10 @@ import java.util.Locale;
StreamItemPhotos.STREAM_ITEM_ID + " INTEGER NOT NULL, " +
StreamItemPhotos.SORT_INDEX + " INTEGER, " +
StreamItemPhotos.PHOTO_FILE_ID + " INTEGER NOT NULL, " +
- StreamItemPhotos.ACTION + " TEXT, " +
- StreamItemPhotos.ACTION_URI + " TEXT, " +
+ StreamItemPhotos.SYNC1 + " TEXT, " +
+ StreamItemPhotos.SYNC2 + " TEXT, " +
+ StreamItemPhotos.SYNC3 + " TEXT, " +
+ StreamItemPhotos.SYNC4 + " TEXT, " +
"FOREIGN KEY(" + StreamItemPhotos.STREAM_ITEM_ID + ") REFERENCES " +
Tables.STREAM_ITEMS + "(" + StreamItems._ID + "));");
@@ -1073,8 +1081,6 @@ import java.util.Locale;
Groups.TITLE + " TEXT," +
Groups.TITLE_RES + " INTEGER," +
Groups.NOTES + " TEXT," +
- Groups.ACTION + " TEXT," +
- Groups.ACTION_URI + " TEXT," +
Groups.SYSTEM_ID + " TEXT," +
Groups.DELETED + " INTEGER NOT NULL DEFAULT 0," +
Groups.GROUP_VISIBLE + " INTEGER NOT NULL DEFAULT 0," +
@@ -1731,8 +1737,6 @@ import java.util.Locale;
+ Groups.TITLE + ","
+ Groups.TITLE_RES + ","
+ Groups.NOTES + ","
- + Groups.ACTION + ", "
- + Groups.ACTION_URI + ", "
+ Groups.SYSTEM_ID + ","
+ Groups.DELETED + ","
+ Groups.GROUP_VISIBLE + ","
@@ -2118,6 +2122,11 @@ import java.util.Locale;
oldVersion = 612;
}
+ if (oldVersion < 613) {
+ upgradeToVersion613(db);
+ oldVersion = 613;
+ }
+
if (upgradeViewsAndTriggers) {
createContactsViews(db);
createGroupsView(db);
@@ -3224,8 +3233,10 @@ import java.util.Locale;
}
private void upgradeToVersion607(SQLiteDatabase db) {
- db.execSQL("ALTER TABLE groups ADD COLUMN action TEXT");
- db.execSQL("ALTER TABLE groups ADD COLUMN action_uri TEXT");
+ // We added "action" and "action_uri" to groups here, but realized this was not a smart
+ // move. This upgrade step has been removed (all dogfood phones that executed this step
+ // will have those columns, but that shouldn't hurt. Unfortunately, SQLite makes it hard
+ // to remove columns)
}
private void upgradeToVersion608(SQLiteDatabase db) {
@@ -3239,36 +3250,9 @@ import java.util.Locale;
}
private void upgradeToVersion609(SQLiteDatabase db) {
- // The stream item and stream item photos APIs were not in-use by anyone in the time
- // between their initial creation (in v605) and this update. So we're just dropping
- // and re-creating them to get appropriate columns. The delta is as follows:
- // - In stream_items, package_id was replaced by res_package.
- // - In stream_item_photos, picture was replaced by photo_file_id.
-
- db.execSQL("DROP TABLE IF EXISTS stream_items");
- db.execSQL("DROP TABLE IF EXISTS stream_item_photos");
-
- db.execSQL("CREATE TABLE stream_items(" +
- "_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
- "raw_contact_id INTEGER NOT NULL, " +
- "res_package TEXT, " +
- "icon INTEGER, " +
- "label INTEGER, " +
- "text TEXT NOT NULL, " +
- "timestamp INTEGER NOT NULL, " +
- "comments TEXT NOT NULL, " +
- "action TEXT, " +
- "action_uri TEXT, " +
- "FOREIGN KEY(raw_contact_id) REFERENCES raw_contacts(_id));");
-
- db.execSQL("CREATE TABLE stream_item_photos(" +
- "_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
- "stream_item_id INTEGER NOT NULL, " +
- "sort_index INTEGER, " +
- "photo_file_id INTEGER NOT NULL, " +
- "action TEXT, " +
- "action_uri TEXT, " +
- "FOREIGN KEY(stream_item_id) REFERENCES stream_items(_id));");
+ // This version used to create the stream item and stream item photos tables, but a newer
+ // version of those tables is created in version 613 below. So omitting the creation in
+ // this upgrade step to avoid a create->drop->create.
}
private void upgradeToVersion610(SQLiteDatabase db) {
@@ -3292,6 +3276,47 @@ import java.util.Locale;
// Old calls will not have a geocoded location; new calls will get it when inserted.
}
+ private void upgradeToVersion613(SQLiteDatabase db) {
+ // The stream item and stream item photos APIs were not in-use by anyone in the time
+ // between their initial creation (in v609) and this update. So we're just dropping
+ // and re-creating them to get appropriate columns. The delta is as follows:
+ // - In stream_items, package_id was replaced by res_package.
+ // - In stream_item_photos, picture was replaced by photo_file_id.
+ // - Instead of resource ids for icon and label, we use resource name strings now
+ // - Added sync columns
+ // - Removed action and action_uri
+ // - Text and comments are now nullable
+
+ db.execSQL("DROP TABLE IF EXISTS stream_items");
+ db.execSQL("DROP TABLE IF EXISTS stream_item_photos");
+
+ db.execSQL("CREATE TABLE stream_items(" +
+ "_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
+ "raw_contact_id INTEGER NOT NULL, " +
+ "res_package TEXT, " +
+ "icon TEXT, " +
+ "label TEXT, " +
+ "text TEXT, " +
+ "timestamp INTEGER NOT NULL, " +
+ "comments TEXT, " +
+ "stream_item_sync1 TEXT, " +
+ "stream_item_sync2 TEXT, " +
+ "stream_item_sync3 TEXT, " +
+ "stream_item_sync4 TEXT, " +
+ "FOREIGN KEY(raw_contact_id) REFERENCES raw_contacts(_id));");
+
+ db.execSQL("CREATE TABLE stream_item_photos(" +
+ "_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
+ "stream_item_id INTEGER NOT NULL, " +
+ "sort_index INTEGER, " +
+ "photo_file_id INTEGER NOT NULL, " +
+ "stream_item_photo_sync1 TEXT, " +
+ "stream_item_photo_sync2 TEXT, " +
+ "stream_item_photo_sync3 TEXT, " +
+ "stream_item_photo_sync4 TEXT, " +
+ "FOREIGN KEY(stream_item_id) REFERENCES stream_items(_id));");
+ }
+
public String extractHandleFromEmailAddress(String email) {
Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(email);
if (tokens.length == 0) {
@@ -4064,7 +4089,7 @@ import java.util.Locale;
}
public void replaceStatusUpdate(Long dataId, long timestamp, String status, String resPackage,
- Long iconResource, Integer labelResource) {
+ Integer iconResource, Integer labelResource) {
if (mStatusUpdateReplace == null) {
mStatusUpdateReplace = getWritableDatabase().compileStatement(
"INSERT OR REPLACE INTO " + Tables.STATUS_UPDATES + "("
@@ -4085,8 +4110,8 @@ import java.util.Locale;
mStatusUpdateReplace.execute();
}
- public void insertStatusUpdate(Long dataId, String status, String resPackage, Long iconResource,
- Integer labelResource) {
+ public void insertStatusUpdate(Long dataId, String status, String resPackage,
+ Integer iconResource, Integer labelResource) {
if (mStatusUpdateInsert == null) {
mStatusUpdateInsert = getWritableDatabase().compileStatement(
"INSERT INTO " + Tables.STATUS_UPDATES + "("
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index fae513c..edcd201 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -71,8 +71,11 @@ import android.content.OperationApplicationException;
import android.content.SharedPreferences;
import android.content.SyncAdapterType;
import android.content.UriMatcher;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.AssetFileDescriptor;
import android.content.res.Resources;
+import android.content.res.Resources.NotFoundException;
import android.database.CrossProcessCursor;
import android.database.Cursor;
import android.database.CursorWindow;
@@ -839,8 +842,6 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun
.add(Groups.SYSTEM_ID)
.add(Groups.DELETED)
.add(Groups.NOTES)
- .add(Groups.ACTION)
- .add(Groups.ACTION_URI)
.add(Groups.SHOULD_SYNC)
.add(Groups.FAVORITES)
.add(Groups.AUTO_ADD)
@@ -957,30 +958,39 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun
private static final ProjectionMap sStreamItemsProjectionMap = ProjectionMap.builder()
.add(StreamItems._ID, StreamItemsColumns.CONCRETE_ID)
.add(RawContacts.CONTACT_ID)
+ .add(StreamItems.ACCOUNT_NAME, RawContactsColumns.CONCRETE_ACCOUNT_NAME)
+ .add(StreamItems.ACCOUNT_TYPE, RawContactsColumns.CONCRETE_ACCOUNT_TYPE)
+ .add(StreamItems.DATA_SET, RawContactsColumns.CONCRETE_DATA_SET)
.add(StreamItems.RAW_CONTACT_ID)
+ .add(StreamItems.RAW_CONTACT_SOURCE_ID, RawContactsColumns.CONCRETE_SOURCE_ID)
.add(StreamItems.RES_PACKAGE)
.add(StreamItems.RES_ICON)
.add(StreamItems.RES_LABEL)
.add(StreamItems.TEXT)
.add(StreamItems.TIMESTAMP)
.add(StreamItems.COMMENTS)
- .add(StreamItems.ACTION)
- .add(StreamItems.ACTION_URI)
+ .add(StreamItems.SYNC1)
+ .add(StreamItems.SYNC2)
+ .add(StreamItems.SYNC3)
+ .add(StreamItems.SYNC4)
.build();
private static final ProjectionMap sStreamItemPhotosProjectionMap = ProjectionMap.builder()
.add(StreamItemPhotos._ID, StreamItemPhotosColumns.CONCRETE_ID)
.add(StreamItems.RAW_CONTACT_ID)
+ .add(StreamItems.RAW_CONTACT_SOURCE_ID, RawContactsColumns.CONCRETE_SOURCE_ID)
.add(StreamItemPhotos.STREAM_ITEM_ID)
.add(StreamItemPhotos.SORT_INDEX)
.add(StreamItemPhotos.PHOTO_FILE_ID)
.add(StreamItemPhotos.PHOTO_URI,
"'" + DisplayPhoto.CONTENT_URI + "'||'/'||" + StreamItemPhotos.PHOTO_FILE_ID)
- .add(StreamItemPhotos.ACTION, StreamItemPhotosColumns.CONCRETE_ACTION)
- .add(StreamItemPhotos.ACTION_URI, StreamItemPhotosColumns.CONCRETE_ACTION_URI)
.add(PhotoFiles.HEIGHT)
.add(PhotoFiles.WIDTH)
.add(PhotoFiles.FILESIZE)
+ .add(StreamItemPhotos.SYNC1)
+ .add(StreamItemPhotos.SYNC2)
+ .add(StreamItemPhotos.SYNC3)
+ .add(StreamItemPhotos.SYNC4)
.build();
/** Contains Live Folders columns */
@@ -3011,27 +3021,38 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun
if (values.containsKey(StatusUpdates.STATUS)) {
String status = values.getAsString(StatusUpdates.STATUS);
String resPackage = values.getAsString(StatusUpdates.STATUS_RES_PACKAGE);
- Integer labelResource = values.getAsInteger(StatusUpdates.STATUS_LABEL);
+ Resources resources = getContext().getResources();
+ if (!TextUtils.isEmpty(resPackage)) {
+ PackageManager pm = getContext().getPackageManager();
+ try {
+ resources = pm.getResourcesForApplication(resPackage);
+ } catch (NameNotFoundException e) {
+ Log.w(TAG, "Contact status update resource package not found: "
+ + resPackage);
+ }
+ }
+ Integer labelResourceId = values.getAsInteger(StatusUpdates.STATUS_LABEL);
- if (TextUtils.isEmpty(resPackage)
- && (labelResource == null || labelResource == 0)
- && protocol != null) {
- labelResource = Im.getProtocolLabelResource(protocol);
+ if ((labelResourceId == null || labelResourceId == 0) && protocol != null) {
+ labelResourceId = Im.getProtocolLabelResource(protocol);
}
+ String labelResource = getResourceName(resources, "string", labelResourceId);
- Long iconResource = values.getAsLong(StatusUpdates.STATUS_ICON);
+ Integer iconResourceId = values.getAsInteger(StatusUpdates.STATUS_ICON);
// TODO compute the default icon based on the protocol
+ String iconResource = getResourceName(resources, "drawable", iconResourceId);
+
if (TextUtils.isEmpty(status)) {
mDbHelper.deleteStatusUpdate(dataId);
} else {
Long timestamp = values.getAsLong(StatusUpdates.STATUS_TIMESTAMP);
if (timestamp != null) {
mDbHelper.replaceStatusUpdate(dataId, timestamp, status, resPackage,
- iconResource, labelResource);
+ iconResourceId, labelResourceId);
} else {
- mDbHelper.insertStatusUpdate(dataId, status, resPackage, iconResource,
- labelResource);
+ mDbHelper.insertStatusUpdate(dataId, status, resPackage, iconResourceId,
+ labelResourceId);
}
// For forward compatibility with the new stream item API, insert this status update
@@ -3078,7 +3099,6 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun
} finally {
c.close();
}
-
}
}
}
@@ -3090,6 +3110,25 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun
return dataId;
}
+ private String getResourceName(Resources resources, String expectedType, Integer resourceId) {
+ try {
+ if (resourceId == null || resourceId == 0) return null;
+
+ // Resource has an invalid type (e.g. a string as icon)? ignore
+ final String resourceEntryName = resources.getResourceEntryName(resourceId);
+ final String resourceTypeName = resources.getResourceTypeName(resourceId);
+ if (!expectedType.equals(resourceTypeName)) {
+ Log.w(TAG, "Resource " + resourceId + " (" + resourceEntryName + ") is of type " +
+ resourceTypeName + " but " + expectedType + " is required.");
+ return null;
+ }
+
+ return resourceEntryName;
+ } catch (NotFoundException e) {
+ return null;
+ }
+ }
+
@Override
protected int deleteInTransaction(Uri uri, String selection, String[] selectionArgs) {
if (VERBOSE_LOGGING) {
@@ -6184,7 +6223,10 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun
+ PhotoFilesColumns.CONCRETE_ID
+ ") JOIN " + Tables.STREAM_ITEMS + " ON ("
+ StreamItemPhotosColumns.CONCRETE_STREAM_ITEM_ID + "="
- + StreamItemsColumns.CONCRETE_ID + ")");
+ + StreamItemsColumns.CONCRETE_ID + ")"
+ + " JOIN " + Tables.RAW_CONTACTS + " ON ("
+ + StreamItemsColumns.CONCRETE_RAW_CONTACT_ID + "=" + RawContactsColumns.CONCRETE_ID
+ + ")");
qb.setProjectionMap(sStreamItemPhotosProjectionMap);
}
diff --git a/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java b/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java
index 51d806d..9a881a8 100644
--- a/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java
+++ b/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java
@@ -16,7 +16,8 @@
package com.android.providers.contacts;
-import com.google.android.collect.Maps;
+import static com.android.providers.contacts.ContactsActor.PACKAGE_GREY;
+
import com.google.android.collect.Sets;
import android.accounts.Account;
@@ -26,7 +27,6 @@ import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.Entity;
-import android.content.res.Resources;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
@@ -49,14 +49,10 @@ import android.provider.ContactsContract.RawContacts;
import android.provider.ContactsContract.Settings;
import android.provider.ContactsContract.StatusUpdates;
import android.provider.ContactsContract.StreamItems;
-import android.test.AndroidTestCase;
import android.test.MoreAsserts;
import android.test.mock.MockContentResolver;
import android.util.Log;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
@@ -65,8 +61,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import static com.android.providers.contacts.ContactsActor.PACKAGE_GREY;
-
/**
* A common superclass for {@link ContactsProvider2}-related tests.
*/
diff --git a/tests/src/com/android/providers/contacts/ContactsMockPackageManager.java b/tests/src/com/android/providers/contacts/ContactsMockPackageManager.java
index 03a86c2..7aadca8 100644
--- a/tests/src/com/android/providers/contacts/ContactsMockPackageManager.java
+++ b/tests/src/com/android/providers/contacts/ContactsMockPackageManager.java
@@ -22,7 +22,6 @@ import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Binder;
import android.test.mock.MockPackageManager;
-import android.test.mock.MockResources;
import java.util.HashMap;
import java.util.List;
@@ -92,11 +91,6 @@ public class ContactsMockPackageManager extends MockPackageManager {
@Override
public Resources getResourcesForApplication(String appPackageName) {
- return new MockResources() {
- @Override
- public String getResourceName(int resid) throws NotFoundException {
- return String.valueOf(resid);
- }
- };
+ return new ContactsMockResources();
}
}
diff --git a/tests/src/com/android/providers/contacts/ContactsMockResources.java b/tests/src/com/android/providers/contacts/ContactsMockResources.java
new file mode 100644
index 0000000..d1ec817
--- /dev/null
+++ b/tests/src/com/android/providers/contacts/ContactsMockResources.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.providers.contacts;
+
+import com.google.common.collect.Maps;
+
+import android.content.res.Resources.NotFoundException;
+import android.test.mock.MockResources;
+
+import java.util.Map;
+
+final class ContactsMockResources extends MockResources {
+ private Map<Integer, String> mPackages = Maps.newHashMap();
+ private Map<Integer, String> mTypes = Maps.newHashMap();
+ private Map<Integer, String> mEntries = Maps.newHashMap();
+
+ public void addResource(int resId, String packageName, String typeName, String entryName) {
+ mPackages.put(resId, packageName);
+ mTypes.put(resId, typeName);
+ mEntries.put(resId, entryName);
+ }
+
+ @Override
+ public String getResourceName(int resId) throws NotFoundException {
+ if (!mPackages.containsKey(resId)) {
+ throw new NotFoundException("Resource " + resId + " not found");
+ }
+ return mPackages.get(resId) + ":" + mTypes.get(resId) + "/" + mEntries.get(resId);
+ }
+
+ @Override
+ public String getResourcePackageName(int resId) throws NotFoundException {
+ if (!mPackages.containsKey(resId)) {
+ throw new NotFoundException("Resource " + resId + " not found");
+ }
+ return mPackages.get(resId);
+ }
+
+ @Override
+ public String getResourceTypeName(int resId) throws NotFoundException {
+ if (!mPackages.containsKey(resId)) {
+ throw new NotFoundException("Resource " + resId + " not found");
+ }
+ return mTypes.get(resId);
+ }
+
+ @Override
+ public String getResourceEntryName(int resId) throws NotFoundException {
+ if (!mPackages.containsKey(resId)) {
+ throw new NotFoundException("Resource " + resId + " not found");
+ }
+ return mEntries.get(resId);
+ }
+} \ No newline at end of file
diff --git a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
index bf59ffd..973eb80 100644
--- a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
+++ b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
@@ -520,8 +520,6 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
Groups.SYSTEM_ID,
Groups.DELETED,
Groups.NOTES,
- Groups.ACTION,
- Groups.ACTION_URI,
Groups.SHOULD_SYNC,
Groups.FAVORITES,
Groups.AUTO_ADD,
@@ -550,8 +548,6 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
Groups.SYSTEM_ID,
Groups.DELETED,
Groups.NOTES,
- Groups.ACTION,
- Groups.ACTION_URI,
Groups.SHOULD_SYNC,
Groups.FAVORITES,
Groups.AUTO_ADD,