diff options
author | Wenyi Wang <wenyiw@google.com> | 2017-03-24 16:02:44 -0700 |
---|---|---|
committer | Wenyi Wang <wenyiw@google.com> | 2017-03-24 16:16:03 -0700 |
commit | 57a0e98eed836b72dd3dc3540b9cac029266ed7c (patch) | |
tree | 391c5ebb82bd0c1591efae45fe8ca0432112581b /src/com/android/contacts/model | |
parent | 1aa5775c6da7cf5d5b7ea521baf71f156c82f8af (diff) | |
download | Contacts-57a0e98eed836b72dd3dc3540b9cac029266ed7c.tar.gz |
Add isLoggable checks to all verbose and debug log outputs (1/2)
Bug: 6813854
Test: built apk and verified log is seen in logcat
Change-Id: Ib17cac0d2d9553276c4271221110305ab2d70a46
Diffstat (limited to 'src/com/android/contacts/model')
3 files changed, 12 insertions, 116 deletions
diff --git a/src/com/android/contacts/model/RawContactDelta.java b/src/com/android/contacts/model/RawContactDelta.java index b7d06657c..6ee31ba03 100644 --- a/src/com/android/contacts/model/RawContactDelta.java +++ b/src/com/android/contacts/model/RawContactDelta.java @@ -56,7 +56,7 @@ public class RawContactDelta implements Parcelable { // TODO: optimize by using contentvalues pool, since we allocate so many of them private static final String TAG = "EntityDelta"; - private static final boolean LOGV = false; + private static final boolean DEBUG = false; /** * Direct values from {@link Entity#getEntityValues()}. @@ -110,7 +110,7 @@ public class RawContactDelta implements Parcelable { // Create local version if none exists yet if (local == null) local = new RawContactDelta(); - if (LOGV) { + if (DEBUG) { final Long localVersion = (local.mValues == null) ? null : local.mValues .getAsLong(RawContacts.VERSION); final Long remoteVersion = remote.mValues.getAsLong(RawContacts.VERSION); diff --git a/src/com/android/contacts/model/RawContactDeltaList.java b/src/com/android/contacts/model/RawContactDeltaList.java index de007d2eb..2fe475a9e 100644 --- a/src/com/android/contacts/model/RawContactDeltaList.java +++ b/src/com/android/contacts/model/RawContactDeltaList.java @@ -120,99 +120,11 @@ public class RawContactDeltaList extends ArrayList<RawContactDelta> implements P } /** - * Build a list of {@link ContentProviderOperation} that will transform all + * Build a list of {@link CPOWrapper} that will transform all * the "before" {@link Entity} states into the modified state which all * {@link RawContactDelta} objects represent. This method specifically creates * any {@link AggregationExceptions} rules needed to groups edits together. */ - public ArrayList<ContentProviderOperation> buildDiff() { - if (VERBOSE_LOGGING) { - Log.v(TAG, "buildDiff: list=" + toString()); - } - final ArrayList<ContentProviderOperation> diff = Lists.newArrayList(); - - final long rawContactId = this.findRawContactId(); - int firstInsertRow = -1; - - // First pass enforces versions remain consistent - for (RawContactDelta delta : this) { - delta.buildAssert(diff); - } - - final int assertMark = diff.size(); - int backRefs[] = new int[size()]; - - int rawContactIndex = 0; - - // Second pass builds actual operations - for (RawContactDelta delta : this) { - final int firstBatch = diff.size(); - final boolean isInsert = delta.isContactInsert(); - backRefs[rawContactIndex++] = isInsert ? firstBatch : -1; - - delta.buildDiff(diff); - - // If the user chose to join with some other existing raw contact(s) at save time, - // add aggregation exceptions for all those raw contacts. - if (mJoinWithRawContactIds != null) { - for (Long joinedRawContactId : mJoinWithRawContactIds) { - final Builder builder = beginKeepTogether(); - builder.withValue(AggregationExceptions.RAW_CONTACT_ID1, joinedRawContactId); - if (rawContactId != -1) { - builder.withValue(AggregationExceptions.RAW_CONTACT_ID2, rawContactId); - } else { - builder.withValueBackReference( - AggregationExceptions.RAW_CONTACT_ID2, firstBatch); - } - diff.add(builder.build()); - } - } - - // Only create rules for inserts - if (!isInsert) continue; - - // If we are going to split all contacts, there is no point in first combining them - if (mSplitRawContacts) continue; - - if (rawContactId != -1) { - // Has existing contact, so bind to it strongly - final Builder builder = beginKeepTogether(); - builder.withValue(AggregationExceptions.RAW_CONTACT_ID1, rawContactId); - builder.withValueBackReference(AggregationExceptions.RAW_CONTACT_ID2, firstBatch); - diff.add(builder.build()); - - } else if (firstInsertRow == -1) { - // First insert case, so record row - firstInsertRow = firstBatch; - - } else { - // Additional insert case, so point at first insert - final Builder builder = beginKeepTogether(); - builder.withValueBackReference(AggregationExceptions.RAW_CONTACT_ID1, - firstInsertRow); - builder.withValueBackReference(AggregationExceptions.RAW_CONTACT_ID2, firstBatch); - diff.add(builder.build()); - } - } - - if (mSplitRawContacts) { - buildSplitContactDiff(diff, backRefs); - } - - // No real changes if only left with asserts - if (diff.size() == assertMark) { - diff.clear(); - } - if (VERBOSE_LOGGING) { - Log.v(TAG, "buildDiff: ops=" + diffToString(diff)); - } - return diff; - } - - /** - * For compatibility purpose, this method is copied from {@link #buildDiff} and returns an - * ArrayList of CPOWrapper. - */ public ArrayList<CPOWrapper> buildDiffWrapper() { if (VERBOSE_LOGGING) { Log.v(TAG, "buildDiffWrapper: list=" + toString()); @@ -334,26 +246,6 @@ public class RawContactDeltaList extends ArrayList<RawContactDelta> implements P * Builds {@link AggregationExceptions} to split all constituent raw contacts into * separate contacts. */ - private void buildSplitContactDiff(final ArrayList<ContentProviderOperation> diff, - int[] backRefs) { - final int count = size(); - for (int i = 0; i < count; i++) { - for (int j = 0; j < count; j++) { - if (i == j) { - continue; - } - final Builder builder = buildSplitContactDiffHelper(i, j, backRefs); - if (builder != null) { - diff.add(builder.build()); - } - } - } - } - - /** - * For compatibility purpose, this method is copied from {@link #buildSplitContactDiff} and - * takes an ArrayList of CPOWrapper as parameter. - */ private void buildSplitContactDiffWrapper(final ArrayList<CPOWrapper> diff, int[] backRefs) { final int count = size(); for (int i = 0; i < count; i++) { diff --git a/src/com/android/contacts/model/account/AccountTypeProvider.java b/src/com/android/contacts/model/account/AccountTypeProvider.java index ba2788a67..38d8ca63d 100644 --- a/src/com/android/contacts/model/account/AccountTypeProvider.java +++ b/src/com/android/contacts/model/account/AccountTypeProvider.java @@ -172,8 +172,10 @@ public class AccountTypeProvider { && isLocalAccountType(mLocalAccountTypeFactory, type)) { accountType = mLocalAccountTypeFactory.getAccountType(type); } else { - Log.d(TAG, "Registering external account type=" + type - + ", packageName=" + auth.packageName); + if (Log.isLoggable(TAG, Log.DEBUG)) { + Log.d(TAG, "Registering external account type=" + type + + ", packageName=" + auth.packageName); + } accountType = new ExternalAccountType(mContext, auth.packageName, false); } if (!accountType.isInitialized()) { @@ -215,9 +217,11 @@ public class AccountTypeProvider { " doesn't match expected type " + type); continue; } - Log.d(TAG, "Registering extension package account type=" - + accountType.accountType + ", dataSet=" + accountType.dataSet - + ", packageName=" + extensionPackage); + if (Log.isLoggable(TAG, Log.DEBUG)) { + Log.d(TAG, "Registering extension package account type=" + + accountType.accountType + ", dataSet=" + accountType.dataSet + + ", packageName=" + extensionPackage); + } result.add(extensionType); } |