Search in sources :

Example 31 with DialerCall

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

the class InCallActivityCommon method maybeShowAccountSelectionDialog.

private boolean maybeShowAccountSelectionDialog() {
    DialerCall waitingForAccountCall = CallList.getInstance().getWaitingForAccountCall();
    if (waitingForAccountCall == null) {
        return false;
    }
    Bundle extras = waitingForAccountCall.getIntentExtras();
    List<PhoneAccountHandle> phoneAccountHandles;
    if (extras != null) {
        phoneAccountHandles = extras.getParcelableArrayList(android.telecom.Call.AVAILABLE_PHONE_ACCOUNTS);
    } else {
        phoneAccountHandles = new ArrayList<>();
    }
    selectPhoneAccountDialogFragment = SelectPhoneAccountDialogFragment.newInstance(R.string.select_phone_account_for_calls, true, phoneAccountHandles, selectAccountListener, waitingForAccountCall.getId());
    selectPhoneAccountDialogFragment.show(inCallActivity.getFragmentManager(), TAG_SELECT_ACCOUNT_FRAGMENT);
    return true;
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) Bundle(android.os.Bundle) DialerCall(com.android.incallui.call.DialerCall)

Example 32 with DialerCall

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

the class InCallPresenter method handleCallKey.

/**
 * Handles the green CALL key while in-call.
 *
 * @return true if we consumed the event.
 */
public boolean handleCallKey() {
    LogUtil.v("InCallPresenter.handleCallKey", null);
    // The green CALL button means either "Answer", "Unhold", or
    // "Swap calls", or can be a no-op, depending on the current state
    // of the Phone.
    /**
     * INCOMING CALL
     */
    final CallList calls = mCallList;
    final DialerCall incomingCall = calls.getIncomingCall();
    LogUtil.v("InCallPresenter.handleCallKey", "incomingCall: " + incomingCall);
    // (1) Attempt to answer a call
    if (incomingCall != null) {
        incomingCall.answer(VideoProfile.STATE_AUDIO_ONLY);
        return true;
    }
    /**
     * STATE_ACTIVE CALL
     */
    final DialerCall activeCall = calls.getActiveCall();
    if (activeCall != null) {
        // TODO: This logic is repeated from CallButtonPresenter.java. We should
        // consolidate this logic.
        final boolean canMerge = activeCall.can(android.telecom.Call.Details.CAPABILITY_MERGE_CONFERENCE);
        final boolean canSwap = activeCall.can(android.telecom.Call.Details.CAPABILITY_SWAP_CONFERENCE);
        LogUtil.v("InCallPresenter.handleCallKey", "activeCall: " + activeCall + ", canMerge: " + canMerge + ", canSwap: " + canSwap);
        // (2) Attempt actions on conference calls
        if (canMerge) {
            TelecomAdapter.getInstance().merge(activeCall.getId());
            return true;
        } else if (canSwap) {
            TelecomAdapter.getInstance().swap(activeCall.getId());
            return true;
        }
    }
    /**
     * BACKGROUND CALL
     */
    final DialerCall heldCall = calls.getBackgroundCall();
    if (heldCall != null) {
        // We have a hold call so presumeable it will always support HOLD...but
        // there is no harm in double checking.
        final boolean canHold = heldCall.can(android.telecom.Call.Details.CAPABILITY_HOLD);
        LogUtil.v("InCallPresenter.handleCallKey", "heldCall: " + heldCall + ", canHold: " + canHold);
        // (4) unhold call
        if (heldCall.getState() == DialerCall.State.ONHOLD && canHold) {
            heldCall.unhold();
            return true;
        }
    }
    // Always consume hard keys
    return true;
}
Also used : CallList(com.android.incallui.call.CallList) ExternalCallList(com.android.incallui.call.ExternalCallList) DialerCall(com.android.incallui.call.DialerCall)

Example 33 with DialerCall

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

the class InCallPresenter method onCallListChange.

/**
 * Called when there is a change to the call list. Sets the In-Call state for the entire in-call
 * app based on the information it gets from CallList. Dispatches the in-call state to all
 * listeners. Can trigger the creation or destruction of the UI based on the states that is
 * calculates.
 */
@Override
public void onCallListChange(CallList callList) {
    if (mInCallActivity != null && mInCallActivity.isInCallScreenAnimating()) {
        mAwaitingCallListUpdate = true;
        return;
    }
    if (callList == null) {
        return;
    }
    mAwaitingCallListUpdate = false;
    InCallState newState = getPotentialStateFromCallList(callList);
    InCallState oldState = mInCallState;
    LogUtil.d("InCallPresenter.onCallListChange", "onCallListChange oldState= " + oldState + " newState=" + newState);
    // If the user placed a call and was asked to choose the account, but then pressed "Home", the
    // incall activity for that call will still exist (even if it's not visible). In the case of
    // an incoming call in that situation, just disconnect that "waiting for account" call and
    // dismiss the dialog. The same activity will be reused to handle the new incoming call. See
    // b/33247755 for more details.
    DialerCall waitingForAccountCall;
    if (newState == InCallState.INCOMING && (waitingForAccountCall = callList.getWaitingForAccountCall()) != null) {
        waitingForAccountCall.disconnect();
        // The InCallActivity might be destroyed or not started yet at this point.
        if (isActivityStarted()) {
            mInCallActivity.dismissPendingDialogs();
        }
    }
    newState = startOrFinishUi(newState);
    LogUtil.d("InCallPresenter.onCallListChange", "onCallListChange newState changed to " + newState);
    // Set the new state before announcing it to the world
    LogUtil.i("InCallPresenter.onCallListChange", "Phone switching state: " + oldState + " -> " + newState);
    mInCallState = newState;
    // notify listeners of new state
    for (InCallStateListener listener : mListeners) {
        LogUtil.d("InCallPresenter.onCallListChange", "Notify " + listener + " of state " + mInCallState.toString());
        listener.onStateChange(oldState, mInCallState, callList);
    }
    if (isActivityStarted()) {
        final boolean hasCall = callList.getActiveOrBackgroundCall() != null || callList.getOutgoingCall() != null;
        mInCallActivity.dismissKeyguard(hasCall);
    }
}
Also used : DialerCall(com.android.incallui.call.DialerCall)

Example 34 with DialerCall

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

the class ReturnToCallActionReceiver method endCall.

private void endCall(Context context) {
    DialerCall call = getCall();
    Logger.get(context).logCallImpression(DialerImpression.Type.BUBBLE_END_CALL, call != null ? call.getUniqueCallId() : "", call != null ? call.getTimeAddedMs() : 0);
    if (call != null) {
        call.disconnect();
    }
}
Also used : DialerCall(com.android.incallui.call.DialerCall)

Example 35 with DialerCall

use of com.android.incallui.call.DialerCall 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);
            }
        }
    });
}
Also used : ContactCacheEntry(com.android.incallui.ContactInfoCache.ContactCacheEntry) ContactInfoCacheCallback(com.android.incallui.ContactInfoCache.ContactInfoCacheCallback) RequiresPermission(android.support.annotation.RequiresPermission) SpannableString(android.text.SpannableString) DialerCall(com.android.incallui.call.DialerCall) RequiresPermission(android.support.annotation.RequiresPermission)

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