Search in sources :

Example 11 with DialerCall

use of com.android.incallui.call.DialerCall in project android_packages_apps_Dialer by LineageOS.

the class ConferenceManagerPresenter method onStateChange.

@Override
public void onStateChange(InCallState oldState, InCallState newState, CallList callList) {
    if (getUi().isFragmentVisible()) {
        Log.v(this, "onStateChange" + newState);
        if (newState == InCallState.INCALL) {
            final DialerCall call = callList.getActiveOrBackgroundCall();
            if (call != null && call.isConferenceCall()) {
                Log.v(this, "Number of existing calls is " + String.valueOf(call.getChildCallIds().size()));
                update(callList);
            } else {
                InCallPresenter.getInstance().showConferenceCallManager(false);
            }
        } else {
            InCallPresenter.getInstance().showConferenceCallManager(false);
        }
    }
}
Also used : DialerCall(com.android.incallui.call.DialerCall)

Example 12 with DialerCall

use of com.android.incallui.call.DialerCall in project android_packages_apps_Dialer by LineageOS.

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<DialerCall> conferenceParticipants) {
    final ContactInfoCache cache = ContactInfoCache.getInstance(getContext());
    boolean newParticipantAdded = false;
    Set<String> newCallIds = new ArraySet<>(conferenceParticipants.size());
    // Update or add conference participant info.
    for (DialerCall call : conferenceParticipants) {
        String callId = call.getId();
        newCallIds.add(callId);
        ContactCacheEntry contactCache = cache.getInfo(callId);
        if (contactCache == null) {
            contactCache = ContactInfoCache.buildCacheEntryFromCall(getContext(), call, call.getState() == DialerCall.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();
}
Also used : ContactCacheEntry(com.android.incallui.ContactInfoCache.ContactCacheEntry) ContactCacheEntry(com.android.incallui.ContactInfoCache.ContactCacheEntry) ArraySet(android.util.ArraySet) DialerCall(com.android.incallui.call.DialerCall) ArrayMap(android.support.v4.util.ArrayMap) Map(java.util.Map)

Example 13 with DialerCall

use of com.android.incallui.call.DialerCall in project android_packages_apps_Dialer by LineageOS.

the class ConferenceParticipantListAdapter method getView.

/**
 * Creates or populates an existing conference participant row.
 *
 * @param position The position of the item within the adapter's data set of the item whose view
 *     we want.
 * @param convertView The old view to reuse, if possible.
 * @param parent The parent that this view will eventually be attached to
 * @return The populated view.
 */
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Make sure we have a valid convertView to start with
    final View result = convertView == null ? LayoutInflater.from(parent.getContext()).inflate(R.layout.caller_in_conference, parent, false) : convertView;
    ParticipantInfo participantInfo = mConferenceParticipants.get(position);
    DialerCall call = participantInfo.getCall();
    ContactCacheEntry contactCache = participantInfo.getContactCacheEntry();
    final ContactInfoCache cache = ContactInfoCache.getInstance(getContext());
    // photo, do it now.
    if (!participantInfo.isCacheLookupComplete()) {
        cache.findInfo(participantInfo.getCall(), participantInfo.getCall().getState() == DialerCall.State.INCOMING, new ContactLookupCallback(this));
    }
    boolean thisRowCanSeparate = mParentCanSeparate && call.can(android.telecom.Call.Details.CAPABILITY_SEPARATE_FROM_CONFERENCE);
    boolean thisRowCanDisconnect = call.can(android.telecom.Call.Details.CAPABILITY_DISCONNECT_FROM_CONFERENCE);
    String name = ContactDisplayUtils.getPreferredDisplayName(contactCache.namePrimary, contactCache.nameAlternative, mContactsPreferences);
    setCallerInfoForRow(result, contactCache.namePrimary, call.updateNameIfRestricted(name), contactCache.number, contactCache.label, contactCache.lookupKey, contactCache.displayPhotoUri, thisRowCanSeparate, thisRowCanDisconnect);
    // Tag the row in the conference participant list with the call id to make it easier to
    // find calls when contact cache information is loaded.
    result.setTag(call.getId());
    return result;
}
Also used : ContactCacheEntry(com.android.incallui.ContactInfoCache.ContactCacheEntry) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) DialerCall(com.android.incallui.call.DialerCall)

Example 14 with DialerCall

use of com.android.incallui.call.DialerCall in project android_packages_apps_Dialer by LineageOS.

the class AnswerScreenPresenter method onAnswerAndReleaseCall.

@Override
public void onAnswerAndReleaseCall() {
    LogUtil.enterBlock("AnswerScreenPresenter.onAnswerAndReleaseCall");
    DialerCall activeCall = CallList.getInstance().getActiveCall();
    if (activeCall == null) {
        LogUtil.i("AnswerScreenPresenter.onAnswerAndReleaseCall", "activeCall == null");
        onAnswer(false);
    } else {
        activeCall.setReleasedByAnsweringSecondCall(true);
        activeCall.addListener(new AnswerOnDisconnected(activeCall));
        activeCall.disconnect();
    }
    addTimeoutCheck();
}
Also used : DialerCall(com.android.incallui.call.DialerCall)

Example 15 with DialerCall

use of com.android.incallui.call.DialerCall in project android_packages_apps_Dialer by LineageOS.

the class CallCardPresenter method onInCallScreenDelegateInit.

@Override
public void onInCallScreenDelegateInit(InCallScreen inCallScreen) {
    Assert.isNotNull(inCallScreen);
    mInCallScreen = inCallScreen;
    mContactsPreferences = ContactsPreferencesFactory.newContactsPreferences(mContext);
    // Call may be null if disconnect happened already.
    DialerCall call = CallList.getInstance().getFirstCall();
    if (call != null) {
        mPrimary = call;
        if (shouldShowNoteSentToast(mPrimary)) {
            mInCallScreen.showNoteSentToast();
        }
        call.addListener(this);
        // start processing lookups right away.
        if (!call.isConferenceCall()) {
            startContactInfoSearch(call, true, call.getState() == DialerCall.State.INCOMING);
        } else {
            updateContactEntry(null, true);
        }
    }
    onStateChange(null, InCallPresenter.getInstance().getInCallState(), CallList.getInstance());
}
Also used : DialerCall(com.android.incallui.call.DialerCall)

Aggregations

DialerCall (com.android.incallui.call.DialerCall)35 CallList (com.android.incallui.call.CallList)6 RequiresPermission (android.support.annotation.RequiresPermission)3 ContactCacheEntry (com.android.incallui.ContactInfoCache.ContactCacheEntry)3 PhoneAccountHandle (android.telecom.PhoneAccountHandle)2 SpannableString (android.text.SpannableString)2 ActivityManager (android.app.ActivityManager)1 AlertDialog (android.app.AlertDialog)1 Dialog (android.app.Dialog)1 Notification (android.app.Notification)1 Context (android.content.Context)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 Point (android.graphics.Point)1 AudioAttributes (android.media.AudioAttributes)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 ArrayMap (android.support.v4.util.ArrayMap)1 CallAudioState (android.telecom.CallAudioState)1