use of com.android.incallui.ContactInfoCache.ContactCacheEntry in project android_packages_apps_Dialer by MoKee.
the class ConferenceParticipantListAdapter method updateParticipantInfo.
/**
* Updates the participant info list which is bound to the ListView. Stores the call and
* contact info for all entries. The list is sorted alphabetically by participant name.
*
* @param conferenceParticipants The calls which make up the conference participants.
*/
private void updateParticipantInfo(List<Call> conferenceParticipants) {
Log.d(this, "updateParticipantInfo: " + conferenceParticipants);
final ContactInfoCache cache = ContactInfoCache.getInstance(mContext);
boolean newParticipantAdded = false;
HashSet<String> newCallIds = new HashSet<>(conferenceParticipants.size());
// Update or add conference participant info.
for (Call call : conferenceParticipants) {
String callId = call.getId();
newCallIds.add(callId);
ContactCacheEntry contactCache = cache.getInfo(callId);
if (contactCache == null) {
contactCache = ContactInfoCache.buildCacheEntryFromCall(mContext, call, call.getState() == Call.State.INCOMING);
}
if (mParticipantsByCallId.containsKey(callId)) {
ParticipantInfo participantInfo = mParticipantsByCallId.get(callId);
participantInfo.setCall(call);
participantInfo.setContactCacheEntry(contactCache);
} else {
newParticipantAdded = true;
ParticipantInfo participantInfo = new ParticipantInfo(call, contactCache);
mConferenceParticipants.add(participantInfo);
mParticipantsByCallId.put(call.getId(), participantInfo);
}
}
// Remove any participants that no longer exist.
Iterator<Map.Entry<String, ParticipantInfo>> it = mParticipantsByCallId.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, ParticipantInfo> entry = it.next();
String existingCallId = entry.getKey();
if (!newCallIds.contains(existingCallId)) {
ParticipantInfo existingInfo = entry.getValue();
mConferenceParticipants.remove(existingInfo);
it.remove();
}
}
if (newParticipantAdded) {
// Sort the list of participants by contact name.
sortParticipantList();
}
notifyDataSetChanged();
}
use of com.android.incallui.ContactInfoCache.ContactCacheEntry in project android_packages_apps_Dialer by LineageOS.
the class StatusBarNotifier method showNotification.
@RequiresPermission(Manifest.permission.READ_PHONE_STATE)
private void showNotification(final CallList callList, final DialerCall call) {
final boolean isIncoming = (call.getState() == DialerCall.State.INCOMING || call.getState() == DialerCall.State.CALL_WAITING);
setStatusBarCallListener(new StatusBarCallListener(call));
// we make a call to the contact info cache to query for supplemental data to what the
// call provides. This includes the contact name and photo.
// This callback will always get called immediately and synchronously with whatever data
// it has available, and may make a subsequent call later (same thread) if it had to
// call into the contacts provider for more data.
mContactInfoCache.findInfo(call, isIncoming, new ContactInfoCacheCallback() {
@Override
@RequiresPermission(Manifest.permission.READ_PHONE_STATE)
public void onContactInfoComplete(String callId, ContactCacheEntry entry) {
DialerCall call = callList.getCallById(callId);
if (call != null) {
call.getLogState().contactLookupResult = entry.contactLookupResult;
buildAndSendNotification(callList, call, entry);
}
}
@Override
@RequiresPermission(Manifest.permission.READ_PHONE_STATE)
public void onImageLoadComplete(String callId, ContactCacheEntry entry) {
DialerCall call = callList.getCallById(callId);
if (call != null) {
buildAndSendNotification(callList, call, entry);
}
}
});
}
use of com.android.incallui.ContactInfoCache.ContactCacheEntry in project android_packages_apps_Dialer by MoKee.
the class CallCardPresenterTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
MockitoAnnotations.initMocks(this);
Mockito.when(mContactsPreferences.getDisplayOrder()).thenReturn(ContactsPreferences.DISPLAY_ORDER_PRIMARY);
// Unlocked all contact info is available
mUnlockedContactInfo = new ContactCacheEntry();
mUnlockedContactInfo.namePrimary = NAME_PRIMARY;
mUnlockedContactInfo.nameAlternative = NAME_ALTERNATIVE;
mUnlockedContactInfo.location = LOCATION;
mUnlockedContactInfo.number = NUMBER;
// Locked only number and location are available
mLockedContactInfo = new ContactCacheEntry();
mLockedContactInfo.location = LOCATION;
mLockedContactInfo.number = NUMBER;
}
use of com.android.incallui.ContactInfoCache.ContactCacheEntry in project android_packages_apps_Dialer by MoKee.
the class CallCardPresenterTest method testGetNumberForCall_EmptyPreferredName.
public void testGetNumberForCall_EmptyPreferredName() {
ContactCacheEntry contactInfo = new ContactCacheEntry();
contactInfo.location = LOCATION;
ContactsPreferencesFactory.setTestInstance(null);
CallCardPresenter presenter = new CallCardPresenter();
presenter.init(getContext(), null);
assertEquals(LOCATION, presenter.getNumberForCall(contactInfo));
}
use of com.android.incallui.ContactInfoCache.ContactCacheEntry in project android_packages_apps_Dialer by MoKee.
the class StatusBarNotifierTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
MockitoAnnotations.initMocks(this);
Mockito.when(mContactsPreferences.getDisplayOrder()).thenReturn(ContactsPreferences.DISPLAY_ORDER_PRIMARY);
// Unlocked all contact info is available
mUnlockedContactInfo = new ContactCacheEntry();
mUnlockedContactInfo.namePrimary = NAME_PRIMARY;
mUnlockedContactInfo.nameAlternative = NAME_ALTERNATIVE;
mUnlockedContactInfo.location = LOCATION;
mUnlockedContactInfo.number = NUMBER;
// Locked only number and location are available
mLockedContactInfo = new ContactCacheEntry();
mLockedContactInfo.location = LOCATION;
mLockedContactInfo.number = NUMBER;
}
Aggregations