Stop checking usage related contacts provider behavior
The relevant APIs should still exist and "work", but we skip checking
their effects on usage stats.
Bug: 112190021
Test: Run the modified tests with tradefed on:
cts-tradefed run cts-dev --skip-device-info --skip-preconditions --skip-system-status-check com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker -a armeabi-v7a -l INFO -m CtsProviderTestCases
(with unrelated tests in the module removed.)
- oreo-cts-dev (on oc-release marlin)
- oreo-mr1-cts-dev (on oc-mr1-release marlin)
- pie-cts-dev (on pi-release walleye)
Change-Id: I1f4dcac959bee2be1a345bc63434ab7a535b3eca
Merged-in: I10e66441a9766947c7c14ae25022deadac5a9c7c
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_ContactsTest.java b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_ContactsTest.java
index 3c56aba..c5fdc1a 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_ContactsTest.java
+++ b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_ContactsTest.java
@@ -206,8 +206,6 @@
final TestContact contact = rawContact.getContact().load();
contact.load();
- assertEquals(0L, contact.getLong(Contacts.TIMES_CONTACTED));
- assertEquals(0L, contact.getLong(Contacts.LAST_TIME_CONTACTED));
final long now = System.currentTimeMillis();
@@ -218,8 +216,6 @@
ContactUtil.update(mResolver, contact.getId(), values);
contact.load();
- assertEquals(3L, contact.getLong(Contacts.TIMES_CONTACTED));
- assertEquals(now / 86400 * 86400, contact.getLong(Contacts.LAST_TIME_CONTACTED));
// This is also the same as markAsContacted().
values.clear();
@@ -227,8 +223,6 @@
ContactUtil.update(mResolver, contact.getId(), values);
contact.load();
- assertEquals(4L, contact.getLong(Contacts.TIMES_CONTACTED));
- assertEquals(now / 86400 * 86400, contact.getLong(Contacts.LAST_TIME_CONTACTED));
values.clear();
values.put(Contacts.TIMES_CONTACTED, 10);
@@ -236,27 +230,17 @@
ContactUtil.update(mResolver, contact.getId(), values);
contact.load();
- assertEquals(10L, contact.getLong(Contacts.TIMES_CONTACTED));
- assertEquals(now / 86400 * 86400, contact.getLong(Contacts.LAST_TIME_CONTACTED));
}
- /**
- * Make sure the rounded usage stats values are also what the callers would see in where
- * clauses.
- *
- * This tests both contacts and raw_contacts.
- */
public void testContactUpdateDelete_usageStats_visibilityInWhere() throws Exception {
final TestRawContact rawContact = mBuilder.newRawContact().insert().load();
final TestContact contact = rawContact.getContact().load();
- // To make things more predictable, inline markAsContacted here with a known timestamp.
final long now = (System.currentTimeMillis() / 86400 * 86400) + 86400 * 5 + 123;
ContentValues values = new ContentValues();
values.put(Contacts.LAST_TIME_CONTACTED, now);
- // This makes the internal TIMES_CONTACTED 35. But the visible value is still 30.
for (int i = 0; i < 35; i++) {
ContactUtil.update(mResolver, contact.getId(), values);
}
@@ -264,12 +248,6 @@
contact.load();
rawContact.load();
- assertEquals(now / 86400 * 86400, contact.getLong(Contacts.LAST_TIME_CONTACTED));
- assertEquals(30, contact.getLong(Contacts.TIMES_CONTACTED));
-
- assertEquals(now / 86400 * 86400, rawContact.getLong(Contacts.LAST_TIME_CONTACTED));
- assertEquals(30, rawContact.getLong(Contacts.TIMES_CONTACTED));
-
final ContentValues cv = new ContentValues();
cv.put(Contacts.STARRED, 1);
@@ -277,12 +255,7 @@
(Contacts.LAST_TIME_CONTACTED + "=P1 AND " + Contacts.TIMES_CONTACTED + "=P2")
.replaceAll("P1", String.valueOf(now / 86400 * 86400))
.replaceAll("P2", "30");
- assertEquals(1, mResolver.update(Contacts.CONTENT_URI, cv, where, null));
- assertEquals(1, mResolver.update(RawContacts.CONTENT_URI, cv, where, null));
- // Also delete. This will actually delete the row, so we can test it only for one of the
- // contact or the raw contact.
- assertEquals(1, mResolver.delete(RawContacts.CONTENT_URI, where, null));
rawContact.setAlreadyDeleted();
contact.setAlreadyDeleted();
}
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DataUsageTest.java b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DataUsageTest.java
index d5ab172..befbeb8 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DataUsageTest.java
+++ b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DataUsageTest.java
@@ -93,28 +93,20 @@
long[] dataIds = setupRawContactDataItems(ids.mRawContactId);
- assertDataUsageEquals(dataIds, 0, 0, 0, 0);
-
updateMultipleAndAssertUpdateSuccess(new long[] {dataIds[1], dataIds[2]});
- assertDataUsageEquals(dataIds, 0, 1, 1, 0);
updateMultipleAndAssertUpdateSuccess(new long[]{dataIds[1], dataIds[2]});
- assertDataUsageEquals(dataIds, 0, 2, 2, 0);
for (int i = 3; i <= 10; i++) {
updateMultipleAndAssertUpdateSuccess(new long[]{dataIds[1]});
}
- assertDataUsageEquals(dataIds, 0, 10, 2, 0);
updateMultipleAndAssertUpdateSuccess(new long[]{dataIds[0], dataIds[1]});
- assertDataUsageEquals(dataIds, 1, 10, 2, 0);
for (int i = 12; i <= 19; i++) {
updateMultipleAndAssertUpdateSuccess(new long[]{dataIds[1]});
- assertDataUsageEquals(dataIds, 1, 10, 2, 0);
}
updateMultipleAndAssertUpdateSuccess(new long[]{dataIds[1]});
- assertDataUsageEquals(dataIds, 1, 20, 2, 0);
deleteDataUsage();
RawContactUtil.delete(mResolver, ids.mRawContactId, true);
@@ -142,7 +134,6 @@
.appendQueryParameter(DataUsageFeedback.USAGE_TYPE,
DataUsageFeedback.USAGE_TYPE_CALL).build();
int result = mResolver.update(uri, new ContentValues(), null, null);
- assertTrue(result > 0);
}
/**
@@ -154,42 +145,6 @@
.appendQueryParameter(DataUsageFeedback.USAGE_TYPE,
DataUsageFeedback.USAGE_TYPE_CALL).build();
int result = mResolver.update(uri, new ContentValues(), null, null);
- assertTrue(result > 0);
-
- assertDataUsageEquals(dataId, assertValue);
- }
-
- /**
- * Assert that the given data ids have usage values in the respective order.
- */
- private void assertDataUsageEquals(long[] dataIds, int... expectedValues) {
- if (dataIds.length != expectedValues.length) {
- throw new IllegalArgumentException("dataIds and expectedValues must be the same size");
- }
-
- for (int i = 0; i < dataIds.length; i++) {
- assertDataUsageEquals(dataIds[i], expectedValues[i]);
- }
- }
-
- /**
- * Assert a single data item has a specific usage value.
- */
- private void assertDataUsageEquals(long dataId, int expectedValue) {
- // Query and assert value is expected.
- String[] projection = new String[]{ContactsContract.Data.TIMES_USED};
- String[] record = DataUtil.queryById(mResolver, dataId, projection);
- assertNotNull(record);
- long actual = 0;
- // Tread null as 0
- if (record[0] != null) {
- actual = Long.parseLong(record[0]);
- }
- assertEquals(expectedValue, actual);
-
- // Also make sure the rounded value is used in 'where' too.
- assertEquals("Query should match", 1, DataUtil.queryById(mResolver, dataId, projection,
- "ifnull(" + Data.TIMES_USED + ",0)=" + expectedValue, null).length);
}
private void deleteDataUsage() {
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_FrequentsStrequentsTest.java b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_FrequentsStrequentsTest.java
index 2231bd2f..f06c859 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_FrequentsStrequentsTest.java
+++ b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_FrequentsStrequentsTest.java
@@ -196,11 +196,6 @@
// Contact the third contact twice.
markDataAsUsed(mDataIds[2], 2);
-
- // The strequents uri should now return contact 2, 3, 1 in order due to ranking by
- // data usage.
- assertCursorStoredValuesWithContactsFilter(Contacts.CONTENT_STREQUENT_URI, ids,
- false, sContentValues[1], sContentValues[2], sContentValues[0]);
}
/**
@@ -220,13 +215,6 @@
// Contact the third contact twice, and mark it as used
markDataAsUsed(mDataIds[2], 2);
starContact(ids[2]);
-
- // The strequents uri should now return contact 3, 2, 1 in order. Contact 3 is ranked first
- // because it is starred, followed by contacts 2 and 1 due to their data usage ranking.
- // Note that contact 3 is only returned once (as a starred contact) even though it is also
- // a frequently contacted contact.
- assertCursorStoredValuesWithContactsFilter(Contacts.CONTENT_STREQUENT_URI, ids,
- false, sContentValues[2], sContentValues[1], sContentValues[0]);
}
/**
@@ -243,10 +231,6 @@
// Construct a uri that filters for the query string "ta".
Uri uri = Contacts.CONTENT_STREQUENT_FILTER_URI.buildUpon().appendEncodedPath("ta").build();
-
- // Only contact 1 and 2 should be returned (sorted in alphabetical order) due to the
- // filtered query.
- assertCursorStoredValuesWithContactsFilter(uri, ids, false, sContentValues[1], sContentValues[0]);
}
public void testStrequents_projection() throws Exception {
@@ -303,10 +287,6 @@
// Construct a uri for phone only favorites.
Uri uri = Contacts.CONTENT_STREQUENT_URI.buildUpon().
appendQueryParameter(ContactsContract.STREQUENT_PHONE_ONLY, "true").build();
-
- // Only the contacts with phone numbers are returned, in frequency ranking order.
- assertCursorStoredValuesWithContactsFilter(uri, mDataIds, false,
- sContentValues[2], sContentValues[0]);
}
public void testStrequents_phoneOnly_projection() throws Exception {
@@ -342,11 +322,6 @@
// Contact the third contact twice.
markDataAsUsed(mDataIds[2], 2);
-
- // The frequents uri should now return contact 2, 3, 1 in order due to ranking by
- // data usage.
- assertCursorStoredValuesWithContactsFilter(Contacts.CONTENT_FREQUENT_URI, ids,
- true /* inOrder */, sContentValues[1], sContentValues[2], sContentValues[0]);
}
public void testFrequent_projection() throws Exception {
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_RawContactsTest.java b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_RawContactsTest.java
index 7c971b3..d937005 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_RawContactsTest.java
+++ b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_RawContactsTest.java
@@ -243,8 +243,6 @@
.insert();
rawContact.load();
- assertEquals(12340, rawContact.getLong(RawContacts.TIMES_CONTACTED));
- assertEquals(now / 86400 * 86400, rawContact.getLong(RawContacts.LAST_TIME_CONTACTED));
}
{
@@ -255,8 +253,6 @@
.insert();
rawContact.load();
- assertEquals(5L, rawContact.getLong(RawContacts.TIMES_CONTACTED));
- assertEquals(0, rawContact.getLong(RawContacts.LAST_TIME_CONTACTED));
}
{
TestRawContact rawContact = mBuilder.newRawContact()
@@ -266,8 +262,6 @@
.insert();
rawContact.load();
- assertEquals(0L, rawContact.getLong(RawContacts.TIMES_CONTACTED));
- assertEquals(now / 86400 * 86400, rawContact.getLong(RawContacts.LAST_TIME_CONTACTED));
}
}
@@ -283,24 +277,17 @@
.insert();
rawContact.load();
- assertEquals(12340L, rawContact.getLong(RawContacts.TIMES_CONTACTED));
- assertEquals(now / 86400 * 86400, rawContact.getLong(RawContacts.LAST_TIME_CONTACTED));
values.clear();
values.put(RawContacts.TIMES_CONTACTED, 99999);
RawContactUtil.update(mResolver, rawContact.getId(), values);
rawContact.load();
- assertEquals(99990L, rawContact.getLong(RawContacts.TIMES_CONTACTED));
- assertEquals(now / 86400 * 86400, rawContact.getLong(RawContacts.LAST_TIME_CONTACTED));
values.clear();
values.put(RawContacts.LAST_TIME_CONTACTED, now + 86400);
RawContactUtil.update(mResolver, rawContact.getId(), values);
rawContact.load();
- assertEquals(99990L, rawContact.getLong(RawContacts.TIMES_CONTACTED));
- assertEquals((now / 86400 * 86400) + 86400,
- rawContact.getLong(RawContacts.LAST_TIME_CONTACTED));
}
}