Allow updating TIMES_CONTACTED again.
Explicitly setting to TIMES_CONTACTED was allowed on pre-N builds.
We tried to disable it for O, but turned out some system apps are using it.
Let's re-open it.
Test: adb shell am instrument -w com.android.providers.contacts.tests
Test: adb shell am instrument -w -e package android.provider.cts.contacts android.provider.cts/android.support.test.runner.AndroidJUnitRunner
Bug: 35321783
Change-Id: I07af087256cc9908b031bd8dfbd9fad479d4681f
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index 69b87cf..7d626ae 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -4529,10 +4529,9 @@
ContactsDatabaseHelper.copyLongValue(
ret, Contacts.RAW_LAST_TIME_CONTACTED,
ret, Contacts.LR_LAST_TIME_CONTACTED);
- if (ret.containsKey(Contacts.LR_TIMES_CONTACTED)) {
- Log.w(TAG, "Column '" + Contacts.LR_TIMES_CONTACTED + "' can no longer be modified"
- + " directly, ignored. Caller=" + getCallingPackage());
- }
+ ContactsDatabaseHelper.copyLongValue(
+ ret, Contacts.RAW_TIMES_CONTACTED,
+ ret, Contacts.LR_TIMES_CONTACTED);
ret.remove(Contacts.LR_LAST_TIME_CONTACTED);
ret.remove(Contacts.LR_TIMES_CONTACTED);
diff --git a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
index e9cf2a1..8930338 100644
--- a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
+++ b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
@@ -979,7 +979,7 @@
long rawContactId = ContentUris.parseId(rowUri);
values.put(RawContacts.LAST_TIME_CONTACTED, 86400);
- values.put(RawContacts.TIMES_CONTACTED, 0); // This is not insertable.
+ values.put(RawContacts.TIMES_CONTACTED, 10);
assertStoredValues(rowUri, values);
assertSelection(RawContacts.CONTENT_URI, values, RawContacts._ID, rawContactId);