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

Commit 37aa2f3d authored by Nancy Chen's avatar Nancy Chen
Browse files

Adapt TelecomCallLogCache to pre-MSIM.

TelecomCallLogCache creates a mapping between PhoneAccount and per-SIM
information like voicemail number which is not relevant pre-LMr1. Create
a compatibility classes so that MSIM functionality is factored out
pre-LMr1.

Bug: 25776171

Change-Id: I67b012110829121dffa42d542aa0395d683fa78b
parent f6bf9e4c
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import com.android.contacts.common.preference.ContactsPreferences;
import com.android.contacts.common.util.PermissionsUtil;
import com.android.dialer.PhoneCallDetails;
import com.android.dialer.R;
import com.android.dialer.calllog.calllogcache.CallLogCache;
import com.android.dialer.contactinfo.ContactInfoCache;
import com.android.dialer.contactinfo.ContactInfoCache.OnContactInfoChangedListener;
import com.android.dialer.database.FilteredNumberAsyncQueryHandler;
@@ -131,8 +132,8 @@ public class CallLogAdapter extends GroupingListAdapter
    /** Instance of helper class for managing views. */
    private final CallLogListItemHelper mCallLogListItemHelper;

    /** Cache for repeated requests to TelecomManager. */
    protected final TelecomCallLogCache mTelecomCallLogCache;
    /** Cache for repeated requests to Telecom/Telephony. */
    protected final CallLogCache mCallLogCache;

    /** Helper to group call log entries. */
    private final CallLogGroupBuilder mCallLogGroupBuilder;
@@ -260,11 +261,12 @@ public class CallLogAdapter extends GroupingListAdapter
        Resources resources = mContext.getResources();
        CallTypeHelper callTypeHelper = new CallTypeHelper(resources);

        mTelecomCallLogCache = new TelecomCallLogCache(mContext);
        mCallLogCache = CallLogCache.getCallLogCache(mContext);

        PhoneCallDetailsHelper phoneCallDetailsHelper =
                new PhoneCallDetailsHelper(mContext, resources, mTelecomCallLogCache);
                new PhoneCallDetailsHelper(mContext, resources, mCallLogCache);
        mCallLogListItemHelper =
                new CallLogListItemHelper(phoneCallDetailsHelper, resources, mTelecomCallLogCache);
                new CallLogListItemHelper(phoneCallDetailsHelper, resources, mCallLogCache);
        mCallLogGroupBuilder = new CallLogGroupBuilder(this);
        mFilteredNumberAsyncQueryHandler =
                new FilteredNumberAsyncQueryHandler(mContext.getContentResolver());
@@ -331,7 +333,7 @@ public class CallLogAdapter extends GroupingListAdapter
    @VisibleForTesting
    /* package */ void pauseCache() {
        mContactInfoCache.stop();
        mTelecomCallLogCache.reset();
        mCallLogCache.reset();
    }

    @Override
@@ -360,7 +362,7 @@ public class CallLogAdapter extends GroupingListAdapter
                view,
                mContext,
                mExpandCollapseListener,
                mTelecomCallLogCache,
                mCallLogCache,
                mCallLogListItemHelper,
                mVoicemailPlaybackPresenter,
                mFilteredNumberAsyncQueryHandler,
@@ -451,7 +453,7 @@ public class CallLogAdapter extends GroupingListAdapter
        final String countryIso = c.getString(CallLogQuery.COUNTRY_ISO);
        final ContactInfo cachedContactInfo = ContactInfoHelper.getContactInfo(c);
        final boolean isVoicemailNumber =
                mTelecomCallLogCache.isVoicemailNumber(accountHandle, number);
                mCallLogCache.isVoicemailNumber(accountHandle, number);

        // Note: Binding of the action buttons is done as required in configureActionViews when the
        // user expands the actions ViewStub.
+7 −5
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.util.Log;
import com.android.dialer.PhoneCallDetails;
import com.android.dialer.util.AppCompatConstants;
import com.android.dialer.R;
import com.android.dialer.calllog.calllogcache.CallLogCache;

/**
 * Helper class to fill in the views of a call log entry.
@@ -36,21 +37,22 @@ import com.android.dialer.R;
    private final PhoneCallDetailsHelper mPhoneCallDetailsHelper;
    /** Resources to look up strings. */
    private final Resources mResources;
    private final TelecomCallLogCache mTelecomCallLogCache;
    private final CallLogCache mCallLogCache;

    /**
     * Creates a new helper instance.
     *
     * @param phoneCallDetailsHelper used to set the details of a phone call
     * @param phoneNumberHelper used to process phone number
     * @param resources The object from which resources can be retrieved
     * @param callLogCache A cache for values retrieved from telecom/telephony
     */
    public CallLogListItemHelper(
            PhoneCallDetailsHelper phoneCallDetailsHelper,
            Resources resources,
            TelecomCallLogCache telecomCallLogCache) {
            CallLogCache callLogCache) {
        mPhoneCallDetailsHelper = phoneCallDetailsHelper;
        mResources = resources;
        mTelecomCallLogCache = telecomCallLogCache;
        mCallLogCache = callLogCache;
    }

    /**
@@ -187,7 +189,7 @@ import com.android.dialer.R;
        }

        int stringID = getCallDescriptionStringID(details.callTypes, details.isRead);
        String accountLabel = mTelecomCallLogCache.getAccountLabel(details.accountHandle);
        String accountLabel = mCallLogCache.getAccountLabel(details.accountHandle);

        // Use chosen string resource to build up the message.
        CharSequence onAccountLabel = accountLabel == null
+17 −15
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import com.android.contacts.common.testing.NeededForTesting;
import com.android.contacts.common.util.UriUtils;
import com.android.dialer.DialtactsActivity;
import com.android.dialer.R;
import com.android.dialer.calllog.calllogcache.CallLogCache;
import com.android.dialer.database.FilteredNumberAsyncQueryHandler;
import com.android.dialer.filterednumber.BlockNumberDialogFragment;
import com.android.dialer.filterednumber.FilteredNumbersUtil;
@@ -189,7 +190,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
    public ContactInfo info;

    private final Context mContext;
    private final TelecomCallLogCache mTelecomCallLogCache;
    private final CallLogCache mCallLogCache;
    private final CallLogListItemHelper mCallLogListItemHelper;
    private final VoicemailPlaybackPresenter mVoicemailPlaybackPresenter;
    private final FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler;
@@ -203,7 +204,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
    private CallLogListItemViewHolder(
            Context context,
            View.OnClickListener expandCollapseListener,
            TelecomCallLogCache telecomCallLogCache,
            CallLogCache callLogCache,
            CallLogListItemHelper callLogListItemHelper,
            VoicemailPlaybackPresenter voicemailPlaybackPresenter,
            FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler,
@@ -219,7 +220,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder

        mContext = context;
        mExpandCollapseListener = expandCollapseListener;
        mTelecomCallLogCache = telecomCallLogCache;
        mCallLogCache = callLogCache;
        mCallLogListItemHelper = callLogListItemHelper;
        mVoicemailPlaybackPresenter = voicemailPlaybackPresenter;
        mFilteredNumberAsyncQueryHandler = filteredNumberAsyncQueryHandler;
@@ -253,7 +254,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
            View view,
            Context context,
            View.OnClickListener expandCollapseListener,
            TelecomCallLogCache telecomCallLogCache,
            CallLogCache callLogCache,
            CallLogListItemHelper callLogListItemHelper,
            VoicemailPlaybackPresenter voicemailPlaybackPresenter,
            FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler,
@@ -262,7 +263,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
        return new CallLogListItemViewHolder(
                context,
                expandCollapseListener,
                telecomCallLogCache,
                callLogCache,
                callLogListItemHelper,
                voicemailPlaybackPresenter,
                filteredNumberAsyncQueryHandler,
@@ -300,7 +301,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
        // 3) Number is a SIP address

        if (PhoneNumberUtil.canPlaceCallsTo(number, numberPresentation)
                && !mTelecomCallLogCache.isVoicemailNumber(accountHandle, number)
                && !mCallLogCache.isVoicemailNumber(accountHandle, number)
                && !PhoneNumberUtil.isSipNumber(number)) {
            menu.add(ContextMenu.NONE, R.id.context_menu_edit_before_call, ContextMenu.NONE,
                    R.string.action_edit_number_before_call)
@@ -421,7 +422,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
            // Treat as normal list item; show call button, if possible.
            if (PhoneNumberUtil.canPlaceCallsTo(number, numberPresentation)) {
                boolean isVoicemailNumber =
                        mTelecomCallLogCache.isVoicemailNumber(accountHandle, number);
                        mCallLogCache.isVoicemailNumber(accountHandle, number);
                if (isVoicemailNumber) {
                    // Call to generic voicemail number, in case there are multiple accounts.
                    primaryActionButtonView.setTag(
@@ -470,7 +471,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
        }

        // If one of the calls had video capabilities, show the video call button.
        if (mTelecomCallLogCache.isVideoEnabled() && canPlaceCallToNumber &&
        if (mCallLogCache.isVideoEnabled() && canPlaceCallToNumber &&
                phoneCallDetailsViews.callTypeIcons.isVideoShown()) {
            videoCallButtonView.setTag(IntentProvider.getReturnVideoCallIntentProvider(number));
            videoCallButtonView.setVisibility(View.VISIBLE);
@@ -524,9 +525,9 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
        mCallLogListItemHelper.setActionContentDescriptions(this);

        boolean supportsCallSubject =
                mTelecomCallLogCache.doesAccountSupportCallSubject(accountHandle);
                mCallLogCache.doesAccountSupportCallSubject(accountHandle);
        boolean isVoicemailNumber =
                mTelecomCallLogCache.isVoicemailNumber(accountHandle, number);
                mCallLogCache.isVoicemailNumber(accountHandle, number);
        callWithNoteButtonView.setVisibility(
                supportsCallSubject && !isVoicemailNumber ? View.VISIBLE : View.GONE);
    }
@@ -572,7 +573,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
    public void updatePhoto() {
        quickContactView.assignContactUri(info.lookupUri);

        final boolean isVoicemail = mTelecomCallLogCache.isVoicemailNumber(accountHandle, number);
        final boolean isVoicemail = mCallLogCache.isVoicemailNumber(accountHandle, number);
        int contactType = ContactPhotoManager.TYPE_DEFAULT;
        if (isVoicemail) {
            contactType = ContactPhotoManager.TYPE_VOICEMAIL;
@@ -628,15 +629,16 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
    @NeededForTesting
    public static CallLogListItemViewHolder createForTest(Context context) {
        Resources resources = context.getResources();
        TelecomCallLogCache telecomCallLogCache = new TelecomCallLogCache(context);
        CallLogCache callLogCache =
                CallLogCache.getCallLogCache(context);
        PhoneCallDetailsHelper phoneCallDetailsHelper = new PhoneCallDetailsHelper(
                context, resources, telecomCallLogCache);
                context, resources, callLogCache);

        CallLogListItemViewHolder viewHolder = new CallLogListItemViewHolder(
                context,
                null /* expandCollapseListener */,
                telecomCallLogCache,
                new CallLogListItemHelper(phoneCallDetailsHelper, resources, telecomCallLogCache),
                callLogCache,
                new CallLogListItemHelper(phoneCallDetailsHelper, resources, callLogCache),
                null /* voicemailPlaybackPresenter */,
                null /* filteredNumberAsyncQueryHandler */,
                null /* filteredNumberDialogCallback */,
+0 −1
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import android.util.Log;
import com.android.contacts.common.compat.SdkVersionOverride;
import com.android.contacts.common.database.NoNullCursorAsyncQueryHandler;
import com.android.contacts.common.util.PermissionsUtil;
import com.android.dialer.filterednumber.FilteredNumbersUtil;
import com.android.dialer.util.AppCompatConstants;
import com.android.dialer.util.TelecomUtil;
import com.android.dialer.voicemail.VoicemailStatusHelperImpl;
+0 −1
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.text.TextUtils;

import com.android.contacts.common.util.PermissionsUtil;
import com.android.dialer.util.TelecomUtil;

import java.util.ArrayList;
Loading