Add ContentProvider operation logging for saving a contact
- To help with figuring out ContentProvider operations for group editor
- Taken from this CL in HCMR2 that was never merged:
https://android-git.corp.google.com/g/#change,111357,patchset=7
Change-Id: Iee2f6dff95d74a03c83f92f61cdb90f7fa5fcea6
diff --git a/src/com/android/contacts/ContactSaveService.java b/src/com/android/contacts/ContactSaveService.java
index d8dbdbc..5912225 100644
--- a/src/com/android/contacts/ContactSaveService.java
+++ b/src/com/android/contacts/ContactSaveService.java
@@ -61,6 +61,9 @@
public class ContactSaveService extends IntentService {
private static final String TAG = "ContactSaveService";
+ /** Set to true in order to view logs on content provider operations */
+ private static final boolean DEBUG = false;
+
public static final String ACTION_NEW_RAW_CONTACT = "newRawContact";
public static final String EXTRA_ACCOUNT_NAME = "accountName";
@@ -282,6 +285,13 @@
try {
// Build operations and try applying
final ArrayList<ContentProviderOperation> diff = state.buildDiff();
+ if (DEBUG) {
+ Log.v(TAG, "Content Provider Operations:");
+ for (ContentProviderOperation operation : diff) {
+ Log.v(TAG, operation.toString());
+ }
+ }
+
ContentProviderResult[] results = null;
if (!diff.isEmpty()) {
results = resolver.applyBatch(ContactsContract.AUTHORITY, diff);
diff --git a/src/com/android/contacts/model/EntityModifier.java b/src/com/android/contacts/model/EntityModifier.java
index 9d527df..fb05162 100644
--- a/src/com/android/contacts/model/EntityModifier.java
+++ b/src/com/android/contacts/model/EntityModifier.java
@@ -75,6 +75,9 @@
public class EntityModifier {
private static final String TAG = "EntityModifier";
+ /** Set to true in order to view logs on entity operations */
+ private static final boolean DEBUG = false;
+
/**
* For the given {@link EntityDelta}, determine if the given
* {@link DataKind} could be inserted under specific
@@ -426,8 +429,9 @@
final boolean isGooglePhoto = isPhoto && isGoogleAccount;
if (EntityModifier.isEmpty(entry, kind) && !isGooglePhoto) {
- // TODO: remove this verbose logging
- Log.w(TAG, "Trimming: " + entry.toString());
+ if (DEBUG) {
+ Log.v(TAG, "Trimming: " + entry.toString());
+ }
entry.markDeleted();
} else if (!entry.isFromTemplate()) {
hasValues = true;