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

Commit 9cc21097 authored by Brandon Maxwell's avatar Brandon Maxwell
Browse files

Updating uses of ContactDisplayUtils and FBE fix

+ ContactDisplayUtils's preferredName methods now accept the
ContactsPreferences object rather than just an int. This was done to
abstract out the null checks that were previously necessary when using
the utility.
+ Conference calls were crashing because the ContactsPreferences
object was attempting to access shared preferences while File based
encryption locked. This change makes use of the
ContactsPreferencesFactory to handle returning the proper instance
when in this locked case.

Bug=26822105

Change-Id: Ie382c0c615cf27f69682774fc9538828cc429e69
parent ed9be496
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -936,13 +936,10 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
     */
    @NeededForTesting
    String getNameForCall(ContactCacheEntry contactInfo) {
        String preferredName = contactInfo.namePrimary;
        if (mContactsPreferences != null) {
            preferredName = ContactDisplayUtils.getPreferredDisplayName(
        String preferredName = ContactDisplayUtils.getPreferredDisplayName(
                contactInfo.namePrimary,
                contactInfo.nameAlternative,
                    mContactsPreferences.getDisplayOrder());
        }
                mContactsPreferences);
        if (TextUtils.isEmpty(preferredName)) {
            return contactInfo.number;
        }
@@ -956,13 +953,10 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
    String getNumberForCall(ContactCacheEntry contactInfo) {
        // If the name is empty, we use the number for the name...so don't show a second
        // number in the number field
        String preferredName = contactInfo.namePrimary;
        if (mContactsPreferences != null) {
            preferredName = ContactDisplayUtils.getPreferredDisplayName(
        String preferredName = ContactDisplayUtils.getPreferredDisplayName(
                    contactInfo.namePrimary,
                    contactInfo.nameAlternative,
                    mContactsPreferences.getDisplayOrder());
        }
                    mContactsPreferences);
        if (TextUtils.isEmpty(preferredName)) {
            return contactInfo.location;
        }
+10 −7
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import com.google.common.base.MoreObjects;

import android.content.Context;
import android.net.Uri;
import android.support.annotation.Nullable;
import android.text.BidiFormatter;
import android.text.TextDirectionHeuristics;
import android.text.TextUtils;
@@ -206,7 +207,7 @@ public class ConferenceParticipantListAdapter extends BaseAdapter {
    /**
     * ContactsPreferences used to lookup displayName preferences
     */
    private final ContactsPreferences mContactsPreferences;
    @Nullable private final ContactsPreferences mContactsPreferences;

    /**
     * The layout inflater used to inflate new views.
@@ -236,7 +237,7 @@ public class ConferenceParticipantListAdapter extends BaseAdapter {

        mListView = listView;
        mContext = context;
        mContactsPreferences = new ContactsPreferences(mContext);
        mContactsPreferences = ContactsPreferencesFactory.newContactsPreferences(mContext);
        mLayoutInflater = layoutInflater;
        mContactPhotoManager = contactPhotoManager;
    }
@@ -249,8 +250,10 @@ public class ConferenceParticipantListAdapter extends BaseAdapter {
     *                                      conference.
     */
    public void updateParticipants(List<Call> conferenceParticipants, boolean parentCanSeparate) {
        if (mContactsPreferences != null) {
            mContactsPreferences.refreshValue(ContactsPreferences.DISPLAY_ORDER_KEY);
            mContactsPreferences.refreshValue(ContactsPreferences.SORT_ORDER_KEY);
        }
        mParentCanSeparate = parentCanSeparate;
        updateParticipantInfo(conferenceParticipants);
    }
@@ -361,7 +364,7 @@ public class ConferenceParticipantListAdapter extends BaseAdapter {

        setCallerInfoForRow(result, contactCache.namePrimary,
                ContactDisplayUtils.getPreferredDisplayName(contactCache.namePrimary,
                        contactCache.nameAlternative, mContactsPreferences.getDisplayOrder()),
                        contactCache.nameAlternative, mContactsPreferences),
                contactCache.number, contactCache.label,
                contactCache.lookupKey, contactCache.displayPhotoUri, thisRowCanSeparate,
                thisRowCanDisconnect);
@@ -513,7 +516,7 @@ public class ConferenceParticipantListAdapter extends BaseAdapter {
                        ContactDisplayUtils.getPreferredSortName(
                                c1.namePrimary,
                                c1.nameAlternative,
                                mContactsPreferences.getSortOrder()),
                                mContactsPreferences),
                        "");

                ContactCacheEntry c2 = p2.getContactCacheEntry();
@@ -521,7 +524,7 @@ public class ConferenceParticipantListAdapter extends BaseAdapter {
                        ContactDisplayUtils.getPreferredSortName(
                                c2.namePrimary,
                                c2.nameAlternative,
                                mContactsPreferences.getSortOrder()),
                                mContactsPreferences),
                        "");

                return p1Name.compareToIgnoreCase(p2Name);
+2 −5
Original line number Diff line number Diff line
@@ -397,11 +397,8 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener,
            return mContext.getResources().getString(R.string.card_title_conf_call);
        }

        String preferredName = contactInfo.namePrimary;
        if (mContactsPreferences != null) {
            preferredName = ContactDisplayUtils.getPreferredDisplayName(contactInfo.namePrimary,
                    contactInfo.nameAlternative, mContactsPreferences.getDisplayOrder());
        }
        String preferredName = ContactDisplayUtils.getPreferredDisplayName(contactInfo.namePrimary,
                    contactInfo.nameAlternative, mContactsPreferences);
        if (TextUtils.isEmpty(preferredName)) {
            return TextUtils.isEmpty(contactInfo.number) ? null : BidiFormatter.getInstance()
                    .unicodeWrap(contactInfo.number, TextDirectionHeuristics.LTR);