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

Commit 2eed60bc authored by yaolu's avatar yaolu
Browse files

Wrap calllog query into try-catch to log exceptions

Bug: 31186013
Test: manual - start QuickContact w/o any call log interactions

Change-Id: I270f9405b6e4e5c8a4cca473792bad4fff9b1482
parent 6942b708
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.database.DatabaseUtils;
import android.net.Uri;
import android.provider.CallLog.Calls;
import android.text.TextUtils;
import android.util.Log;

import com.google.common.annotations.VisibleForTesting;

@@ -37,6 +38,8 @@ import java.util.List;

public class CallLogInteractionsLoader extends AsyncTaskLoader<List<ContactInteraction>> {

    private static final String TAG = "CallLogInteractions";

    private final String[] mPhoneNumbers;
    private final String[] mSipNumbers;
    private final int mMaxToRetrieve;
@@ -129,8 +132,13 @@ public class CallLogInteractionsLoader extends AsyncTaskLoader<List<ContactInter
        // as we don't also set the {@link android.provider.CallLog.Calls.LIMIT_PARAM_KEY} that
        // becomes available in KK.
        final String orderByAndLimit = Calls.DATE + " DESC LIMIT " + mMaxToRetrieve;
        final Cursor cursor = getContext().getContentResolver().query(uri, null, null, null,
        Cursor cursor = null;
        try {
            cursor = getContext().getContentResolver().query(uri, null, null, null,
                    orderByAndLimit);
        } catch (Exception e) {
            Log.e(TAG, "Can not query calllog", e);
        }
        try {
            if (cursor == null || cursor.getCount() < 1) {
                return Collections.emptyList();