diff options
author | twyen <twyen@google.com> | 2018-01-11 10:32:06 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-01-11 11:42:57 -0800 |
commit | 6f8abd3bdc3795f88c3e90bd4aedd0d0e2ce8df8 (patch) | |
tree | 09a1667ae03994352aea419437d3da11f0c57b79 /java | |
parent | cd705ba07e70bffba759d9cef37730ab70d58b20 (diff) |
Allow preferred SIM to be fully cleared
Bug: 70503524
Test: Unit tests.
PiperOrigin-RevId: 181627615
Change-Id: I9e48dd3acc339509ff3805ea38cc6399858ade1d
Diffstat (limited to 'java')
-rw-r--r-- | java/com/android/dialer/preferredsim/PreferredSimFallbackContract.java | 8 | ||||
-rw-r--r-- | java/com/android/dialer/preferredsim/impl/PreferredSimFallbackProvider.java | 10 |
2 files changed, 15 insertions, 3 deletions
diff --git a/java/com/android/dialer/preferredsim/PreferredSimFallbackContract.java b/java/com/android/dialer/preferredsim/PreferredSimFallbackContract.java index 79e097c47..6c2f860e6 100644 --- a/java/com/android/dialer/preferredsim/PreferredSimFallbackContract.java +++ b/java/com/android/dialer/preferredsim/PreferredSimFallbackContract.java @@ -24,9 +24,11 @@ import com.android.dialer.constants.Constants; /** * Extend fields for preferred SIM that is not available in {@link - * android.provider.ContactsContract.Data} before P. Only query and update is supported for this - * provider, and the update selection must be {@link PreferredSim#UPDATE_ID_SELECTION}. Caller must - * have {@link android.Manifest.permission#READ_CONTACTS} to read or {@link + * android.provider.ContactsContract.Data} before P. Insert is not supported for this provider. The + * update selection must be "data_id = ?". Delete is only supported directly on {@link #CONTENT_URI} + * with {@code null} selection, which clears all preferences. + * + * <p>Caller must have {@link android.Manifest.permission#READ_CONTACTS} to read or {@link * android.Manifest.permission#WRITE_CONTACTS} to write. */ public final class PreferredSimFallbackContract { diff --git a/java/com/android/dialer/preferredsim/impl/PreferredSimFallbackProvider.java b/java/com/android/dialer/preferredsim/impl/PreferredSimFallbackProvider.java index 1b10765a5..2263e9e38 100644 --- a/java/com/android/dialer/preferredsim/impl/PreferredSimFallbackProvider.java +++ b/java/com/android/dialer/preferredsim/impl/PreferredSimFallbackProvider.java @@ -91,6 +91,16 @@ public class PreferredSimFallbackProvider extends ContentProvider { @Override public int delete( @NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) { + checkWriteContactsPermission(); + + if (PreferredSimFallbackContract.CONTENT_URI.equals(uri) + && selection == null + && selectionArgs == null) { + return databaseHelper + .getWritableDatabase() + .delete(PreferredSimDatabaseHelper.TABLE, null, null); + } + if (!TextUtils.equals(getContext().getPackageName(), getCallingPackage())) { throw new IllegalArgumentException("Unsupported operation"); } |