summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java')
-rw-r--r--java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java29
1 files changed, 18 insertions, 11 deletions
diff --git a/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java b/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java
index ed64f7a52..a20185989 100644
--- a/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java
+++ b/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java
@@ -46,6 +46,7 @@ import com.android.dialer.duo.DuoComponent;
import com.android.dialer.logging.InteractionEvent;
import com.android.dialer.logging.Logger;
import com.android.dialer.shortcuts.ShortcutRefresher;
+import com.android.dialer.strictmode.StrictModeUtils;
import com.google.common.collect.ComparisonChain;
import java.util.ArrayList;
import java.util.Comparator;
@@ -519,22 +520,27 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop
}
if (changed && dropEntryIndex < PIN_LIMIT) {
- final ArrayList<ContentProviderOperation> operations =
+ ArrayList<ContentProviderOperation> operations =
getReflowedPinningOperations(contactEntries, draggedEntryIndex, dropEntryIndex);
- if (!operations.isEmpty()) {
- // update the database here with the new pinned positions
- try {
- context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, operations);
- Logger.get(context).logInteraction(InteractionEvent.Type.SPEED_DIAL_PIN_CONTACT);
- } catch (RemoteException | OperationApplicationException e) {
- LogUtil.e(TAG, "Exception thrown when pinning contacts", e);
- }
- }
+ StrictModeUtils.bypass(() -> updateDatabaseWithPinnedPositions(operations));
}
draggedEntry = null;
}
}
+ private void updateDatabaseWithPinnedPositions(ArrayList<ContentProviderOperation> operations) {
+ if (operations.isEmpty()) {
+ // Nothing to update
+ return;
+ }
+ try {
+ context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, operations);
+ Logger.get(context).logInteraction(InteractionEvent.Type.SPEED_DIAL_PIN_CONTACT);
+ } catch (RemoteException | OperationApplicationException e) {
+ LogUtil.e(TAG, "Exception thrown when pinning contacts", e);
+ }
+ }
+
/**
* Used when a contact is removed from speeddial. This will both unstar and set pinned position of
* the contact to PinnedPosition.DEMOTED so that it doesn't show up anymore in the favorites list.
@@ -543,7 +549,8 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop
final ContentValues values = new ContentValues(2);
values.put(Contacts.STARRED, false);
values.put(Contacts.PINNED, PinnedPositions.DEMOTED);
- context.getContentResolver().update(contactUri, values, null, null);
+ StrictModeUtils.bypass(
+ () -> context.getContentResolver().update(contactUri, values, null, null));
}
/**