summaryrefslogtreecommitdiff
path: root/InCallUI
diff options
context:
space:
mode:
authorBrandon Maxwell <maxwelb@google.com>2016-02-04 20:09:46 -0800
committerBrandon Maxwell <maxwelb@google.com>2016-02-04 20:09:46 -0800
commit9cc21097e06859c8e3b36b9f18e5bad7c739c5f8 (patch)
tree2aff41f8b5b5832945424389ff85e4e699eb35ac /InCallUI
parented9be4967dde7f7d4585d4018385396b79aed461 (diff)
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
Diffstat (limited to 'InCallUI')
-rw-r--r--InCallUI/src/com/android/incallui/CallCardPresenter.java18
-rw-r--r--InCallUI/src/com/android/incallui/ConferenceParticipantListAdapter.java17
-rw-r--r--InCallUI/src/com/android/incallui/StatusBarNotifier.java7
3 files changed, 18 insertions, 24 deletions
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java
index 8156cc52f..ea39aa646 100644
--- a/InCallUI/src/com/android/incallui/CallCardPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java
@@ -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(
- contactInfo.namePrimary,
- contactInfo.nameAlternative,
- mContactsPreferences.getDisplayOrder());
- }
+ String preferredName = ContactDisplayUtils.getPreferredDisplayName(
+ contactInfo.namePrimary,
+ contactInfo.nameAlternative,
+ 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;
}
diff --git a/InCallUI/src/com/android/incallui/ConferenceParticipantListAdapter.java b/InCallUI/src/com/android/incallui/ConferenceParticipantListAdapter.java
index 79c5faef8..86002b0d7 100644
--- a/InCallUI/src/com/android/incallui/ConferenceParticipantListAdapter.java
+++ b/InCallUI/src/com/android/incallui/ConferenceParticipantListAdapter.java
@@ -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) {
- mContactsPreferences.refreshValue(ContactsPreferences.DISPLAY_ORDER_KEY);
- mContactsPreferences.refreshValue(ContactsPreferences.SORT_ORDER_KEY);
+ 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);
diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java
index 66091bd55..623cbb667 100644
--- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java
+++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java
@@ -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);