aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasu Nori <vnori@google.com>2010-07-14 17:40:39 -0700
committerVasu Nori <vnori@google.com>2010-07-16 11:03:58 -0700
commitaabcd1d34a71ad06ee0a9395331540484f1ceb17 (patch)
treefc9f42c53d0e0f2685d6e10013ec8de95aac6855
parent487fa827e699a6b8d3d64fc90c3e18976808c5c0 (diff)
downloadContactsProvider-aabcd1d34a71ad06ee0a9395331540484f1ceb17.tar.gz
add chat_mode to presence_db tables: presence, aggregate_presence
Change-Id: I62fc49669217a6136e31164713dc25a5296721ef
-rw-r--r--src/com/android/providers/contacts/ContactAggregator.java26
-rw-r--r--src/com/android/providers/contacts/ContactsDatabaseHelper.java35
-rw-r--r--src/com/android/providers/contacts/ContactsProvider2.java15
-rw-r--r--tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java8
-rw-r--r--tests/src/com/android/providers/contacts/ContactsProvider2Test.java96
5 files changed, 127 insertions, 53 deletions
diff --git a/src/com/android/providers/contacts/ContactAggregator.java b/src/com/android/providers/contacts/ContactAggregator.java
index 5f80115a..7404dca6 100644
--- a/src/com/android/providers/contacts/ContactAggregator.java
+++ b/src/com/android/providers/contacts/ContactAggregator.java
@@ -209,13 +209,27 @@ public class ContactAggregator {
// Since we have no way of determining which custom status was set last,
// we'll just pick one randomly. We are using MAX as an approximation of randomness
- mAggregatedPresenceReplace = db.compileStatement(
+ final String replaceAggregatePresenceSql =
"INSERT OR REPLACE INTO " + Tables.AGGREGATED_PRESENCE + "("
- + AggregatedPresenceColumns.CONTACT_ID + ", "
- + StatusUpdates.PRESENCE_STATUS
- + ") SELECT ?, MAX(" + StatusUpdates.PRESENCE_STATUS + ") "
- + " FROM " + Tables.PRESENCE
- + " WHERE " + PresenceColumns.CONTACT_ID + "=?");
+ + AggregatedPresenceColumns.CONTACT_ID + ", "
+ + StatusUpdates.PRESENCE_STATUS + ", "
+ + StatusUpdates.CHAT_CAPABILITY + ")"
+ + " SELECT " + PresenceColumns.CONTACT_ID + ","
+ + StatusUpdates.PRESENCE_STATUS + ","
+ + StatusUpdates.CHAT_CAPABILITY
+ + " FROM " + Tables.PRESENCE
+ + " WHERE "
+ + " (" + StatusUpdates.PRESENCE_STATUS
+ + " * 10 + " + StatusUpdates.CHAT_CAPABILITY + ")"
+ + " = (SELECT "
+ + "MAX (" + StatusUpdates.PRESENCE_STATUS
+ + " * 10 + " + StatusUpdates.CHAT_CAPABILITY + ")"
+ + " FROM " + Tables.PRESENCE
+ + " WHERE " + PresenceColumns.CONTACT_ID
+ + "=?)"
+ + " AND " + PresenceColumns.CONTACT_ID
+ + "=?;";
+ mAggregatedPresenceReplace = db.compileStatement(replaceAggregatePresenceSql);
mRawContactCountQuery = db.compileStatement(
"SELECT COUNT(" + RawContacts._ID + ")" +
diff --git a/src/com/android/providers/contacts/ContactsDatabaseHelper.java b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
index edd73ff3..46519490 100644
--- a/src/com/android/providers/contacts/ContactsDatabaseHelper.java
+++ b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
@@ -579,6 +579,7 @@ import java.util.Locale;
PresenceColumns.CONTACT_ID + " INTEGER REFERENCES contacts(_id)," +
PresenceColumns.RAW_CONTACT_ID + " INTEGER REFERENCES raw_contacts(_id)," +
StatusUpdates.PRESENCE + " INTEGER," +
+ StatusUpdates.CHAT_CAPABILITY + " INTEGER NOT NULL DEFAULT 0," +
"UNIQUE(" + StatusUpdates.PROTOCOL + ", " + StatusUpdates.CUSTOM_PROTOCOL
+ ", " + StatusUpdates.IM_HANDLE + ", " + StatusUpdates.IM_ACCOUNT + ")" +
");");
@@ -587,10 +588,11 @@ import java.util.Locale;
+ Tables.PRESENCE + " (" + PresenceColumns.RAW_CONTACT_ID + ");");
db.execSQL("CREATE TABLE IF NOT EXISTS "
- + DATABASE_PRESENCE + "." + Tables.AGGREGATED_PRESENCE + " ("+
+ + DATABASE_PRESENCE + "." + Tables.AGGREGATED_PRESENCE + " ("+
AggregatedPresenceColumns.CONTACT_ID
+ " INTEGER PRIMARY KEY REFERENCES contacts(_id)," +
- StatusUpdates.PRESENCE_STATUS + " INTEGER" +
+ StatusUpdates.PRESENCE_STATUS + " INTEGER," +
+ StatusUpdates.CHAT_CAPABILITY + " INTEGER NOT NULL DEFAULT 0" +
");");
@@ -612,15 +614,26 @@ import java.util.Locale;
+ "!=OLD." + PresenceColumns.RAW_CONTACT_ID + "));"
+ " END");
- String replaceAggregatePresenceSql =
- "INSERT OR REPLACE INTO " + Tables.AGGREGATED_PRESENCE + "("
- + AggregatedPresenceColumns.CONTACT_ID + ", "
- + StatusUpdates.PRESENCE_STATUS + ")" +
- " SELECT " + PresenceColumns.CONTACT_ID + ","
- + "MAX(" + StatusUpdates.PRESENCE_STATUS + ")" +
- " FROM " + Tables.PRESENCE +
- " WHERE " + PresenceColumns.CONTACT_ID
- + "=NEW." + PresenceColumns.CONTACT_ID + ";";
+ final String replaceAggregatePresenceSql =
+ "INSERT OR REPLACE INTO " + Tables.AGGREGATED_PRESENCE + "("
+ + AggregatedPresenceColumns.CONTACT_ID + ", "
+ + StatusUpdates.PRESENCE_STATUS + ", "
+ + StatusUpdates.CHAT_CAPABILITY + ")"
+ + " SELECT " + PresenceColumns.CONTACT_ID + ","
+ + StatusUpdates.PRESENCE_STATUS + ","
+ + StatusUpdates.CHAT_CAPABILITY
+ + " FROM " + Tables.PRESENCE
+ + " WHERE "
+ + " (" + StatusUpdates.PRESENCE_STATUS
+ + " * 10 + " + StatusUpdates.CHAT_CAPABILITY + ")"
+ + " = (SELECT "
+ + "MAX (" + StatusUpdates.PRESENCE_STATUS
+ + " * 10 + " + StatusUpdates.CHAT_CAPABILITY + ")"
+ + " FROM " + Tables.PRESENCE
+ + " WHERE " + PresenceColumns.CONTACT_ID
+ + "=NEW." + PresenceColumns.CONTACT_ID + ")"
+ + " AND " + PresenceColumns.CONTACT_ID
+ + "=NEW." + PresenceColumns.CONTACT_ID + ";";
db.execSQL("CREATE TRIGGER " + DATABASE_PRESENCE + "." + Tables.PRESENCE + "_inserted"
+ " AFTER INSERT ON " + DATABASE_PRESENCE + "." + Tables.PRESENCE
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index f4a4c5a4..66a81ff9 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -532,6 +532,8 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun
// Handle projections for Contacts-level statuses
addProjection(sContactsProjectionMap, Contacts.CONTACT_PRESENCE,
Tables.AGGREGATED_PRESENCE + "." + StatusUpdates.PRESENCE);
+ addProjection(sContactsProjectionMap, Contacts.CONTACT_CHAT_CAPABILITY,
+ Tables.AGGREGATED_PRESENCE + "." + StatusUpdates.CHAT_CAPABILITY);
addProjection(sContactsProjectionMap, Contacts.CONTACT_STATUS,
ContactsStatusUpdatesColumns.CONCRETE_STATUS);
addProjection(sContactsProjectionMap, Contacts.CONTACT_STATUS_TIMESTAMP,
@@ -709,6 +711,8 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun
// Handle projections for Contacts-level statuses
addProjection(sDataProjectionMap, Contacts.CONTACT_PRESENCE,
Tables.AGGREGATED_PRESENCE + "." + StatusUpdates.PRESENCE);
+ addProjection(sContactsProjectionMap, Contacts.CONTACT_CHAT_CAPABILITY,
+ Tables.AGGREGATED_PRESENCE + "." + StatusUpdates.CHAT_CAPABILITY);
addProjection(sDataProjectionMap, Contacts.CONTACT_STATUS,
ContactsStatusUpdatesColumns.CONCRETE_STATUS);
addProjection(sDataProjectionMap, Contacts.CONTACT_STATUS_TIMESTAMP,
@@ -723,6 +727,8 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun
// Handle projections for Data-level statuses
addProjection(sDataProjectionMap, Data.PRESENCE,
Tables.PRESENCE + "." + StatusUpdates.PRESENCE);
+ addProjection(sDataProjectionMap, Data.CONTACT_CHAT_CAPABILITY,
+ Tables.AGGREGATED_PRESENCE + "." + StatusUpdates.CHAT_CAPABILITY);
addProjection(sDataProjectionMap, Data.STATUS,
StatusUpdatesColumns.CONCRETE_STATUS);
addProjection(sDataProjectionMap, Data.STATUS_TIMESTAMP,
@@ -786,6 +792,8 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun
// Handle projections for Contacts-level statuses
addProjection(sDistinctDataProjectionMap, Contacts.CONTACT_PRESENCE,
Tables.AGGREGATED_PRESENCE + "." + StatusUpdates.PRESENCE);
+ addProjection(sDistinctDataProjectionMap, Contacts.CONTACT_CHAT_CAPABILITY,
+ Tables.AGGREGATED_PRESENCE + "." + StatusUpdates.CHAT_CAPABILITY);
addProjection(sDistinctDataProjectionMap, Contacts.CONTACT_STATUS,
ContactsStatusUpdatesColumns.CONCRETE_STATUS);
addProjection(sDistinctDataProjectionMap, Contacts.CONTACT_STATUS_TIMESTAMP,
@@ -800,6 +808,8 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun
// Handle projections for Data-level statuses
addProjection(sDistinctDataProjectionMap, Data.PRESENCE,
Tables.PRESENCE + "." + StatusUpdates.PRESENCE);
+ addProjection(sDistinctDataProjectionMap, Data.CHAT_CAPABILITY,
+ Tables.PRESENCE + "." + StatusUpdates.CHAT_CAPABILITY);
addProjection(sDistinctDataProjectionMap, Data.STATUS,
StatusUpdatesColumns.CONCRETE_STATUS);
addProjection(sDistinctDataProjectionMap, Data.STATUS_TIMESTAMP,
@@ -933,6 +943,7 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun
+ "='' THEN NULL ELSE " + StatusUpdates.CUSTOM_PROTOCOL + " END) AS "
+ StatusUpdates.CUSTOM_PROTOCOL);
columns.put(StatusUpdates.PRESENCE, StatusUpdates.PRESENCE);
+ columns.put(StatusUpdates.CHAT_CAPABILITY, StatusUpdates.CHAT_CAPABILITY);
columns.put(StatusUpdates.STATUS, StatusUpdates.STATUS);
columns.put(StatusUpdates.STATUS_TIMESTAMP, StatusUpdates.STATUS_TIMESTAMP);
columns.put(StatusUpdates.STATUS_RES_PACKAGE, StatusUpdates.STATUS_RES_PACKAGE);
@@ -3137,6 +3148,8 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun
}
mValues.put(StatusUpdates.PRESENCE,
values.getAsString(StatusUpdates.PRESENCE));
+ mValues.put(StatusUpdates.CHAT_CAPABILITY,
+ values.getAsString(StatusUpdates.CHAT_CAPABILITY));
// Insert the presence update
mDb.replace(Tables.PRESENCE, null, mValues);
@@ -3646,6 +3659,8 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun
mValues.clear();
ContactsDatabaseHelper.copyStringValue(mValues, StatusUpdates.PRESENCE, values,
StatusUpdates.PRESENCE);
+ ContactsDatabaseHelper.copyStringValue(mValues, StatusUpdates.CHAT_CAPABILITY, values,
+ StatusUpdates.CHAT_CAPABILITY);
return mValues;
}
diff --git a/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java b/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java
index de410a9e..ebca24de 100644
--- a/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java
+++ b/tests/src/com/android/providers/contacts/BaseContactsProvider2Test.java
@@ -333,18 +333,19 @@ public abstract class BaseContactsProvider2Test extends AndroidTestCase {
}
protected Uri insertStatusUpdate(int protocol, String customProtocol, String handle,
- int presence, String status) {
- return insertStatusUpdate(protocol, customProtocol, handle, presence, status, 0);
+ int presence, String status, int chatMode) {
+ return insertStatusUpdate(protocol, customProtocol, handle, presence, status, 0, chatMode);
}
protected Uri insertStatusUpdate(int protocol, String customProtocol, String handle,
- int presence, String status, long timestamp) {
+ int presence, String status, long timestamp, int chatMode) {
ContentValues values = new ContentValues();
values.put(StatusUpdates.PROTOCOL, protocol);
values.put(StatusUpdates.CUSTOM_PROTOCOL, customProtocol);
values.put(StatusUpdates.IM_HANDLE, handle);
if (presence != 0) {
values.put(StatusUpdates.PRESENCE, presence);
+ values.put(StatusUpdates.CHAT_CAPABILITY, chatMode);
}
if (status != null) {
values.put(StatusUpdates.STATUS, status);
@@ -1171,6 +1172,7 @@ public abstract class BaseContactsProvider2Test extends AndroidTestCase {
values.put(StatusUpdates.IM_HANDLE, email);
values.put(StatusUpdates.IM_ACCOUNT, "foo");
values.put(StatusUpdates.PRESENCE_STATUS, StatusUpdates.OFFLINE);
+ values.put(StatusUpdates.CHAT_CAPABILITY, StatusUpdates.CAPABILITY_HAS_CAMERA);
values.put(StatusUpdates.PRESENCE_CUSTOM_STATUS, "Coding for Android");
mResolver.insert(StatusUpdates.CONTENT_URI, values);
}
diff --git a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
index a8beec0a..5114894f 100644
--- a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
+++ b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
@@ -389,7 +389,8 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
public void testQueryContactData() {
ContentValues values = new ContentValues();
long contactId = createContact(values, "John", "Doe",
- "18004664411", "goog411@acme.com", StatusUpdates.INVISIBLE, 4, 1, 0);
+ "18004664411", "goog411@acme.com", StatusUpdates.INVISIBLE, 4, 1, 0,
+ StatusUpdates.CAPABILITY_HAS_CAMERA | StatusUpdates.CAPABILITY_HAS_VIDEO_PLAYBACK_ONLY);
Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
assertStoredValues(contactUri, values);
@@ -399,8 +400,10 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
public void testQueryContactWithStatusUpdate() {
ContentValues values = new ContentValues();
long contactId = createContact(values, "John", "Doe",
- "18004664411", "goog411@acme.com", StatusUpdates.INVISIBLE, 4, 1, 0);
+ "18004664411", "goog411@acme.com", StatusUpdates.INVISIBLE, 4, 1, 0,
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
values.put(Contacts.CONTACT_PRESENCE, StatusUpdates.INVISIBLE);
+ values.put(Contacts.CONTACT_CHAT_CAPABILITY, StatusUpdates.CAPABILITY_HAS_CAMERA);
Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
assertStoredValuesWithProjection(contactUri, values);
assertSelectionWithProjection(Contacts.CONTENT_URI, values, Contacts._ID, contactId);
@@ -409,7 +412,9 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
public void testQueryContactFilter() {
ContentValues values = new ContentValues();
long rawContactId = createRawContact(values, "18004664411",
- "goog411@acme.com", StatusUpdates.INVISIBLE, 4, 1, 0);
+ "goog411@acme.com", StatusUpdates.INVISIBLE, 4, 1, 0,
+ StatusUpdates.CAPABILITY_HAS_CAMERA | StatusUpdates.CAPABILITY_HAS_VIDEO_PLAYBACK_ONLY |
+ StatusUpdates.CAPABILITY_HAS_VOICE);
ContentValues nameValues = new ContentValues();
nameValues.put(StructuredName.GIVEN_NAME, "Stu");
@@ -449,16 +454,20 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
public void testQueryContactStrequent() {
ContentValues values1 = new ContentValues();
createContact(values1, "Noah", "Tever", "18004664411",
- "a@acme.com", StatusUpdates.OFFLINE, 0, 0, 0);
+ "a@acme.com", StatusUpdates.OFFLINE, 0, 0, 0,
+ StatusUpdates.CAPABILITY_HAS_CAMERA | StatusUpdates.CAPABILITY_HAS_VIDEO_PLAYBACK_ONLY);
ContentValues values2 = new ContentValues();
createContact(values2, "Sam", "Times", "18004664412",
- "b@acme.com", StatusUpdates.INVISIBLE, 3, 0, 0);
+ "b@acme.com", StatusUpdates.INVISIBLE, 3, 0, 0,
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
ContentValues values3 = new ContentValues();
createContact(values3, "Lotta", "Calling", "18004664413",
- "c@acme.com", StatusUpdates.AWAY, 5, 0, 0);
+ "c@acme.com", StatusUpdates.AWAY, 5, 0, 0,
+ StatusUpdates.CAPABILITY_HAS_VIDEO_PLAYBACK_ONLY);
ContentValues values4 = new ContentValues();
createContact(values4, "Fay", "Veritt", "18004664414",
- "d@acme.com", StatusUpdates.AVAILABLE, 0, 1, 0);
+ "d@acme.com", StatusUpdates.AVAILABLE, 0, 1, 0,
+ StatusUpdates.CAPABILITY_HAS_VIDEO_PLAYBACK_ONLY | StatusUpdates.CAPABILITY_HAS_VOICE);
Cursor c = mResolver.query(Contacts.CONTENT_STREQUENT_URI, null, null, null,
Contacts._ID);
@@ -484,11 +493,13 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
ContentValues values1 = new ContentValues();
createContact(values1, "Best", "West", "18004664411",
- "west@acme.com", StatusUpdates.OFFLINE, 0, 0, groupId);
+ "west@acme.com", StatusUpdates.OFFLINE, 0, 0, groupId,
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
ContentValues values2 = new ContentValues();
createContact(values2, "Rest", "East", "18004664422",
- "east@acme.com", StatusUpdates.AVAILABLE, 0, 0, 0);
+ "east@acme.com", StatusUpdates.AVAILABLE, 0, 0, 0,
+ StatusUpdates.CAPABILITY_HAS_VOICE);
Uri filterUri1 = Uri.withAppendedPath(Contacts.CONTENT_GROUP_URI, "Test Group");
Cursor c = mResolver.query(filterUri1, null, null, null, Contacts._ID);
@@ -524,9 +535,11 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
insertEmail(rawContactId, "goog412@acme.com");
insertStatusUpdate(Im.PROTOCOL_GOOGLE_TALK, null, "goog411@acme.com",
- StatusUpdates.INVISIBLE, "Bad");
+ StatusUpdates.INVISIBLE, "Bad",
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
insertStatusUpdate(Im.PROTOCOL_GOOGLE_TALK, null, "goog412@acme.com",
- StatusUpdates.AVAILABLE, "Good");
+ StatusUpdates.AVAILABLE, "Good",
+ StatusUpdates.CAPABILITY_HAS_CAMERA | StatusUpdates.CAPABILITY_HAS_VOICE);
long contactId = queryContactId(rawContactId);
Uri uri = Data.CONTENT_URI;
@@ -1220,16 +1233,20 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
insertEmail(rawContactId, "m@acme.com");
// Match on IM (standard)
- insertStatusUpdate(Im.PROTOCOL_AIM, null, "aim", StatusUpdates.AVAILABLE, "Available");
+ insertStatusUpdate(Im.PROTOCOL_AIM, null, "aim", StatusUpdates.AVAILABLE, "Available",
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
// Match on IM (custom)
- insertStatusUpdate(Im.PROTOCOL_CUSTOM, "my_im_proto", "my_im", StatusUpdates.IDLE, "Idle");
+ insertStatusUpdate(Im.PROTOCOL_CUSTOM, "my_im_proto", "my_im", StatusUpdates.IDLE, "Idle",
+ StatusUpdates.CAPABILITY_HAS_CAMERA | StatusUpdates.CAPABILITY_HAS_VIDEO_PLAYBACK_ONLY);
// Match on Email
- insertStatusUpdate(Im.PROTOCOL_GOOGLE_TALK, null, "m@acme.com", StatusUpdates.AWAY, "Away");
+ insertStatusUpdate(Im.PROTOCOL_GOOGLE_TALK, null, "m@acme.com", StatusUpdates.AWAY, "Away",
+ StatusUpdates.CAPABILITY_HAS_VOICE);
// No match
- insertStatusUpdate(Im.PROTOCOL_ICQ, null, "12345", StatusUpdates.DO_NOT_DISTURB, "Go away");
+ insertStatusUpdate(Im.PROTOCOL_ICQ, null, "12345", StatusUpdates.DO_NOT_DISTURB, "Go away",
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
Cursor c = mResolver.query(StatusUpdates.CONTENT_URI, new String[] {
StatusUpdates.DATA_ID, StatusUpdates.PROTOCOL, StatusUpdates.CUSTOM_PROTOCOL,
@@ -1265,10 +1282,13 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
values.putNull(Contacts.CONTACT_STATUS);
assertStoredValuesWithProjection(contactUri, values);
- insertStatusUpdate(Im.PROTOCOL_AIM, null, "aim", StatusUpdates.AWAY, "BUSY");
- insertStatusUpdate(Im.PROTOCOL_AIM, null, "aim", StatusUpdates.DO_NOT_DISTURB, "GO AWAY");
+ insertStatusUpdate(Im.PROTOCOL_AIM, null, "aim", StatusUpdates.AWAY, "BUSY",
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
+ insertStatusUpdate(Im.PROTOCOL_AIM, null, "aim", StatusUpdates.DO_NOT_DISTURB, "GO AWAY",
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
Uri statusUri =
- insertStatusUpdate(Im.PROTOCOL_AIM, null, "aim", StatusUpdates.AVAILABLE, "Available");
+ insertStatusUpdate(Im.PROTOCOL_AIM, null, "aim", StatusUpdates.AVAILABLE, "Available",
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
long statusId = ContentUris.parseId(statusUri);
values.put(Contacts.CONTACT_PRESENCE, StatusUpdates.AVAILABLE);
@@ -1332,9 +1352,12 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
long contactId = queryContactId(rawContactId);
Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
- insertStatusUpdate(Im.PROTOCOL_AIM, null, "aim", 0, "Offline", 80);
- insertStatusUpdate(Im.PROTOCOL_AIM, null, "aim", 0, "Available", 100);
- insertStatusUpdate(Im.PROTOCOL_GOOGLE_TALK, null, "gtalk", 0, "Busy", 90);
+ insertStatusUpdate(Im.PROTOCOL_AIM, null, "aim", 0, "Offline", 80,
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
+ insertStatusUpdate(Im.PROTOCOL_AIM, null, "aim", 0, "Available", 100,
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
+ insertStatusUpdate(Im.PROTOCOL_GOOGLE_TALK, null, "gtalk", 0, "Busy", 90,
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
// Should return the latest status
ContentValues values = new ContentValues();
@@ -1360,9 +1383,12 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
long rawContactId1 = createRawContact();
insertImHandle(rawContactId1, protocol1, null, handle1);
- insertStatusUpdate(protocol1, null, handle1, StatusUpdates.AVAILABLE, "Green");
- insertStatusUpdate(protocol1, null, handle1, StatusUpdates.AWAY, "Yellow");
- insertStatusUpdate(protocol1, null, handle1, StatusUpdates.INVISIBLE, "Red");
+ insertStatusUpdate(protocol1, null, handle1, StatusUpdates.AVAILABLE, "Green",
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
+ insertStatusUpdate(protocol1, null, handle1, StatusUpdates.AWAY, "Yellow",
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
+ insertStatusUpdate(protocol1, null, handle1, StatusUpdates.INVISIBLE, "Red",
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
Cursor c = queryContact(queryContactId(rawContactId1),
new String[] {Contacts.CONTACT_PRESENCE, Contacts.CONTACT_STATUS});
@@ -1654,7 +1680,8 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
insertImHandle(rawContactId, Im.PROTOCOL_GOOGLE_TALK, null, "deleteme@android.com");
insertStatusUpdate(Im.PROTOCOL_GOOGLE_TALK, null, "deleteme@android.com",
- StatusUpdates.AVAILABLE, null);
+ StatusUpdates.AVAILABLE, null,
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
long contactId = queryContactId(rawContactId);
assertEquals(1, getCount(Uri.withAppendedPath(uri, RawContacts.Data.CONTENT_DIRECTORY),
@@ -1700,7 +1727,8 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
insertImHandle(rawContactId, Im.PROTOCOL_GOOGLE_TALK, null, "deleteme@android.com");
insertStatusUpdate(Im.PROTOCOL_GOOGLE_TALK, null, "deleteme@android.com",
- StatusUpdates.AVAILABLE, null);
+ StatusUpdates.AVAILABLE, null,
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
assertEquals(1, getCount(Uri.withAppendedPath(uri, RawContacts.Data.CONTENT_DIRECTORY),
null, null));
assertEquals(1, getCount(StatusUpdates.CONTENT_URI, PresenceColumns.RAW_CONTACT_ID + "="
@@ -1747,7 +1775,8 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
insertEmail(rawContactId2, "account2@email.com");
insertImHandle(rawContactId2, Im.PROTOCOL_GOOGLE_TALK, null, "deleteme@android.com");
insertStatusUpdate(Im.PROTOCOL_GOOGLE_TALK, null, "deleteme@android.com",
- StatusUpdates.AVAILABLE, null);
+ StatusUpdates.AVAILABLE, null,
+ StatusUpdates.CAPABILITY_HAS_CAMERA);
cp.onAccountsUpdated(new Account[]{mAccount});
assertEquals(2, getCount(RawContacts.CONTENT_URI, null, null));
@@ -2428,22 +2457,22 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
private long createContact(ContentValues values, String firstName, String givenName,
String phoneNumber, String email, int presenceStatus, int timesContacted, int starred,
- long groupId) {
+ long groupId, int chatMode) {
return queryContactId(createRawContact(values, firstName, givenName, phoneNumber, email,
- presenceStatus, timesContacted, starred, groupId));
+ presenceStatus, timesContacted, starred, groupId, chatMode));
}
private long createRawContact(ContentValues values, String firstName, String givenName,
String phoneNumber, String email, int presenceStatus, int timesContacted, int starred,
- long groupId) {
+ long groupId, int chatMode) {
long rawContactId = createRawContact(values, phoneNumber, email, presenceStatus,
- timesContacted, starred, groupId);
+ timesContacted, starred, groupId, chatMode);
insertStructuredName(rawContactId, firstName, givenName);
return rawContactId;
}
private long createRawContact(ContentValues values, String phoneNumber, String email,
- int presenceStatus, int timesContacted, int starred, long groupId) {
+ int presenceStatus, int timesContacted, int starred, long groupId, int chatMode) {
values.put(RawContacts.STARRED, starred);
values.put(RawContacts.SEND_TO_VOICEMAIL, 1);
values.put(RawContacts.CUSTOM_RINGTONE, "beethoven5");
@@ -2457,7 +2486,8 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
insertPhoneNumber(rawContactId, phoneNumber);
insertEmail(rawContactId, email);
- insertStatusUpdate(Im.PROTOCOL_GOOGLE_TALK, null, email, presenceStatus, "hacking");
+ insertStatusUpdate(Im.PROTOCOL_GOOGLE_TALK, null, email, presenceStatus, "hacking",
+ chatMode);
if (groupId != 0) {
insertGroupMembership(rawContactId, groupId);