Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit df7f4a90 authored by Brandon Maxwell's avatar Brandon Maxwell Committed by android-build-merger
Browse files

Adding logging for migrate blocked numbers

am: bc8be0ab

* commit 'bc8be0ab':
  Adding logging for migrate blocked numbers
parents e1473ca3 bc8be0ab
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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);
+15 −0
Original line number Diff line number Diff line
@@ -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<Void, Void, Boolean>() {
            @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;
        }
    }
+0 −1
Original line number Diff line number Diff line
@@ -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;