diff options
Diffstat (limited to 'java/com/android')
-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"); } |