Starting in Android 10, contacts-affinity-related data, managed by the Contacts Provider component (the source of data seen in a device’s contacts app), is accessed differently than in Android 9 and lower.
Prior to Android 10, apps used the Contacts Provider to access data and transfer it between a device and online services. Android 10 features changes regarding data accessibility to ensure increased user privacy in all Android 10 devices that use the Contacts Provider. For one, the underlying database doesn’t contain contact affinities data. Therefore apps can’t write to or read from it. Changes include the following:
- The Contacts Provider doesn’t record contacts-affinity-related data, such as the number of times a user was contacted, the last time of contact, the app used, the person contacted, or any related historical data.
MultiAutoCompleteTextViewclass in the Contacts Provider autocomplete API doesn’t sort query results by interaction counter.
- The Android framework doesn’t provide implicit contacts ranking. (However, user-controlled, explicit contacts ranking (such as starred contacts) remains).
To implement these changes, do one of the following:
- Use the latest Contacts Provider.
- Update your version (if you’re using a forked version).
In addition, update any apps that rely on the deprecated Contacts Provider features. API versions designed to be workarounds to the deprecated functions aren’t allowed.
For Android 9 and lower, contact-interaction data from the Contacts Provider hasn’t been removed. Instead, contact-interaction data is cleared periodically (approximately once per day) to simulate the equivalent in Android 10. The Contacts Provider stores this information, but only temporarily.
These changes are expected to have a large impact on APIs. For example, autocomplete ranking won’t perform as well. Potential impacts on API behavior include the following:
- The Contacts Provider won’t store a user's preferences for, or interactions
with, the contact in the
- The autocomplete API won’t sort results by interaction counter.
LAST_TIME_USEDcolumns won’t be updated.
- These clear (to either
nullor set to 0, depending on the affected columns) upon upgrade to Android 10.
- Ranking in the autocomplete query APIs returns results sorted alphabetically, never by affinity information.
- API calls for frequent contacts (for example, using the filter string
CONTENT_FREQUENT_URI) return no results.
Generally, if any of the deprecated Contacts Provider API elements use counters,
those counters (when used in Android 10) contain 0, and
return 0 when queried. Update requests from affected APIs are ignored. For
ContactsContract.DataUsageFeedback class was
deprecated, so update and delete calls to this class are ignored.
Fields that impact APIs
These fields have changed in Android 10:
The affected fields in Android 10 may be present in different APIs, as indicated in the table below. Deprecated API fields return behaviors as listed. Because one of these deprecated fields may be used in several of your APIs, verify your use cases.
|Class||API fields||10 returns|
||These columns always contain 0, regardless of how they’re used. Attempts to modify them are ignored.|
||Strequent (starred + frequent)
||Returns starred contacts only. No frequent contacts returned.|
||Filter (also called autocomplete) APIs
||Results not sorted by affinity. These are sorted by starred and name.|
There are no alternatives to the deprecated API fields. Workarounds designed to circumvent these restrictions, whether in the form of new APIs or new fields, aren’t allowed.
You don’t need to do anything to implement these changes. They’re part of the initiative to increase user privacy on the Android OS platform. However, if your apps rely on deprecated features, you may want to update your apps to compensate for any changes. Additionally, if you use a forked version of the Contacts Provider, you must update your Contacts Provider.
Don’t customize or work around the contacts affinity information changes. They’re built into the framework, and making any changes takes you out of compliance. Never alter the default settings or provide backdoor alternatives.