From bc8be0abe73f3626df5f36ff7232ac0b653a9878 Mon Sep 17 00:00:00 2001 From: Brandon Maxwell Date: Tue, 15 Mar 2016 17:14:09 -0700 Subject: Adding logging for migrate blocked numbers Bug: 26664600 Change-Id: I64e9d1fbd825f25e23124d95b2475fdd6e0830f9 --- src/com/android/dialer/compat/FilteredNumberCompat.java | 8 ++++++++ .../dialer/filterednumber/BlockedNumbersMigrator.java | 15 +++++++++++++++ .../MigrateBlockedNumbersDialogFragment.java | 1 - 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/com/android/dialer/compat/FilteredNumberCompat.java b/src/com/android/dialer/compat/FilteredNumberCompat.java index 08bf6c82a..c6c714b27 100644 --- a/src/com/android/dialer/compat/FilteredNumberCompat.java +++ b/src/com/android/dialer/compat/FilteredNumberCompat.java @@ -44,6 +44,7 @@ import com.android.dialer.filterednumber.BlockedNumbersMigrator; import com.android.dialer.filterednumber.BlockedNumbersSettingsActivity; import com.android.dialer.filterednumber.MigrateBlockedNumbersDialogFragment; import com.android.dialerbind.ObjectFactory; +import com.android.incallui.Log; import java.util.ArrayList; import java.util.List; @@ -57,6 +58,8 @@ import java.util.List; */ public class FilteredNumberCompat { + private static final String TAG = "FilteredNumberCompat"; + protected static final String HAS_MIGRATED_TO_NEW_BLOCKING_KEY = "migratedToNewBlocking"; private static Boolean isEnabledForTest; @@ -247,14 +250,18 @@ public class FilteredNumberCompat { final Integer blockId, final String number, final String countryIso, final String displayNumber, final Integer parentViewId, final FragmentManager fragmentManager, @Nullable final Callback callback) { + Log.i(TAG, "showBlockNumberDialogFlow - start"); // If the user is blocking a number and isn't using the framework solution when they // should be, show the migration dialog if (shouldShowMigrationDialog(blockId == null)) { + Log.i(TAG, "showBlockNumberDialogFlow - showing migration dialog"); MigrateBlockedNumbersDialogFragment .newInstance(new BlockedNumbersMigrator(contentResolver), new BlockedNumbersMigrator.Listener() { @Override public void onComplete() { + Log.i(TAG, "showBlockNumberDialogFlow - listener showing block " + + "number dialog"); BlockNumberDialogFragment .show(null, number, countryIso, displayNumber, parentViewId, @@ -263,6 +270,7 @@ public class FilteredNumberCompat { }).show(fragmentManager, "MigrateBlockedNumbers"); return; } + Log.i(TAG, "showBlockNumberDialogFlow - showing block number dialog"); BlockNumberDialogFragment .show(blockId, number, countryIso, displayNumber, parentViewId, fragmentManager, callback); diff --git a/src/com/android/dialer/filterednumber/BlockedNumbersMigrator.java b/src/com/android/dialer/filterednumber/BlockedNumbersMigrator.java index 555e647bc..373403046 100644 --- a/src/com/android/dialer/filterednumber/BlockedNumbersMigrator.java +++ b/src/com/android/dialer/filterednumber/BlockedNumbersMigrator.java @@ -28,6 +28,7 @@ import com.android.dialer.compat.FilteredNumberCompat; import com.android.dialer.database.FilteredNumberContract; import com.android.dialer.database.FilteredNumberContract.FilteredNumber; import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns; +import com.android.incallui.Log; /** * Class which should be used to migrate numbers from {@link FilteredNumberContract} blocking to @@ -35,6 +36,8 @@ import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns; */ public class BlockedNumbersMigrator { + private static final String TAG = "BlockedNumbersMigrator"; + /** * Listener for the operation to migrate from {@link FilteredNumberContract} blocking to * {@link android.provider.BlockedNumberContract} blocking. @@ -69,19 +72,24 @@ public class BlockedNumbersMigrator { * @throws NullPointerException if listener is null */ public boolean migrate(final Listener listener) { + Log.i(TAG, "migrate - start"); if (!FilteredNumberCompat.canUseNewFiltering()) { + Log.i(TAG, "migrate - can't use new filtering"); return false; } Preconditions.checkNotNull(listener); new AsyncTask() { @Override protected Boolean doInBackground(Void... params) { + Log.i(TAG, "migrate - start background migration"); return migrateToNewBlockingInBackground(mContentResolver); } @Override protected void onPostExecute(Boolean isSuccessful) { + Log.i(TAG, "migrate - marking migration complete"); FilteredNumberCompat.setHasMigratedToNewBlocking(isSuccessful); + Log.i(TAG, "migrate - calling listener"); listener.onComplete(); } }.execute(); @@ -92,19 +100,26 @@ public class BlockedNumbersMigrator { try (Cursor cursor = resolver.query(FilteredNumber.CONTENT_URI, new String[]{FilteredNumberColumns.NUMBER}, null, null, null)) { if (cursor == null) { + Log.i(TAG, "migrate - cursor was null"); return false; } + Log.i(TAG, "migrate - attempting to migrate " + cursor.getCount() + "numbers"); + + int numMigrated = 0; while (cursor.moveToNext()) { String originalNumber = cursor .getString(cursor.getColumnIndex(FilteredNumberColumns.NUMBER)); if (isNumberInNewBlocking(resolver, originalNumber)) { + Log.i(TAG, "migrate - number was already blocked in new blocking"); continue; } ContentValues values = new ContentValues(); values.put(BlockedNumbersSdkCompat.COLUMN_ORIGINAL_NUMBER, originalNumber); resolver.insert(BlockedNumbersSdkCompat.CONTENT_URI, values); + ++numMigrated; } + Log.i(TAG, "migrate - migration complete. " + numMigrated + " numbers migrated."); return true; } } diff --git a/src/com/android/dialer/filterednumber/MigrateBlockedNumbersDialogFragment.java b/src/com/android/dialer/filterednumber/MigrateBlockedNumbersDialogFragment.java index f29796125..209665292 100644 --- a/src/com/android/dialer/filterednumber/MigrateBlockedNumbersDialogFragment.java +++ b/src/com/android/dialer/filterednumber/MigrateBlockedNumbersDialogFragment.java @@ -25,7 +25,6 @@ import android.content.DialogInterface; import android.content.DialogInterface.OnShowListener; import android.os.Bundle; import android.view.View; - import com.android.dialer.R; import com.android.dialer.filterednumber.BlockedNumbersMigrator.Listener; -- cgit v1.2.3