Search in sources :

Example 6 with DisconnectCause

use of android.telecom.DisconnectCause in project android_packages_apps_Dialer by LineageOS.

the class InCallVibrationHandler method handleCallEnd.

private void handleCallEnd(DialerCall call) {
    long durationMillis = System.currentTimeMillis() - call.getConnectTimeMillis();
    DisconnectCause cause = call.getDisconnectCause();
    boolean localDisconnect = // Disconnection not yet processed
    call.getState() == DialerCall.State.DISCONNECTING || // Disconnection already processed
    (cause != null && cause.getCode() == DisconnectCause.LOCAL);
    Log.d(this, "Ending active call: duration = " + durationMillis + ", locally disconnected = " + localDisconnect);
    if (mPrefs.getBoolean(KEY_VIBRATE_HANGUP, false) && !localDisconnect && durationMillis > 500) {
        vibrate(50, 100, 50);
    }
    // Stop 45-second vibration
    removeMessages(MSG_VIBRATE_45_SEC);
}
Also used : DisconnectCause(android.telecom.DisconnectCause)

Example 7 with DisconnectCause

use of android.telecom.DisconnectCause in project android_packages_apps_Dialer by LineageOS.

the class DefaultErrorDialog method createDialog.

@Override
public Pair<Dialog, CharSequence> createDialog(@NonNull Context context, DialerCall call) {
    DisconnectCause disconnectCause = call.getDisconnectCause();
    CharSequence message = disconnectCause.getDescription();
    Dialog dialog = new AlertDialog.Builder(context).setMessage(message).setPositiveButton(android.R.string.cancel, null).create();
    return new Pair<>(dialog, message);
}
Also used : AlertDialog(android.app.AlertDialog) DisconnectCause(android.telecom.DisconnectCause) AlertDialog(android.app.AlertDialog) Dialog(android.app.Dialog) Pair(android.util.Pair)

Example 8 with DisconnectCause

use of android.telecom.DisconnectCause in project android_packages_apps_Dialer by LineageOS.

the class InCallPresenter method setDisconnectCauseForMissingAccounts.

/**
 * Sets the DisconnectCause for a call that was disconnected because it was missing a PhoneAccount
 * or PhoneAccounts to select from.
 */
private void setDisconnectCauseForMissingAccounts(DialerCall call) {
    Bundle extras = call.getIntentExtras();
    // Initialize the extras bundle to avoid NPE
    if (extras == null) {
        extras = new Bundle();
    }
    final List<PhoneAccountHandle> phoneAccountHandles = extras.getParcelableArrayList(android.telecom.Call.AVAILABLE_PHONE_ACCOUNTS);
    if (phoneAccountHandles == null || phoneAccountHandles.isEmpty()) {
        String scheme = call.getHandle().getScheme();
        final String errorMsg = PhoneAccount.SCHEME_TEL.equals(scheme) ? mContext.getString(R.string.callFailed_simError) : mContext.getString(R.string.incall_error_supp_service_unknown);
        DisconnectCause disconnectCause = new DisconnectCause(DisconnectCause.ERROR, null, errorMsg, errorMsg);
        call.setDisconnectCause(disconnectCause);
    }
}
Also used : DisconnectCause(android.telecom.DisconnectCause) PhoneAccountHandle(android.telecom.PhoneAccountHandle) Bundle(android.os.Bundle)

Example 9 with DisconnectCause

use of android.telecom.DisconnectCause in project android_packages_apps_Dialer by LineageOS.

the class CallList method clearOnDisconnect.

/**
 * This is called when the service disconnects, either expectedly or unexpectedly. For the
 * expected case, it's because we have no calls left. For the unexpected case, it is likely a
 * crash of phone and we need to clean up our calls manually. Without phone, there can be no
 * active calls, so this is relatively safe thing to do.
 */
public void clearOnDisconnect() {
    for (DialerCall call : mCallById.values()) {
        final int state = call.getState();
        if (state != DialerCall.State.IDLE && state != DialerCall.State.INVALID && state != DialerCall.State.DISCONNECTED) {
            call.setState(DialerCall.State.DISCONNECTED);
            call.setDisconnectCause(new DisconnectCause(DisconnectCause.UNKNOWN));
            updateCallInMap(call);
        }
    }
    notifyGenericListeners();
}
Also used : DisconnectCause(android.telecom.DisconnectCause)

Example 10 with DisconnectCause

use of android.telecom.DisconnectCause in project android_packages_apps_Dialer by MoKee.

the class CallCardPresenter method onStateChange.

@Override
public void onStateChange(InCallState oldState, InCallState newState, CallList callList) {
    Log.d(this, "onStateChange() " + newState);
    final CallCardUi ui = getUi();
    if (ui == null) {
        return;
    }
    Call primary = null;
    Call secondary = null;
    if (newState == InCallState.INCOMING) {
        primary = callList.getIncomingCall();
    } else if (newState == InCallState.PENDING_OUTGOING || newState == InCallState.OUTGOING) {
        primary = callList.getOutgoingCall();
        if (primary == null) {
            primary = callList.getPendingOutgoingCall();
        }
        // getCallToDisplay doesn't go through outgoing or incoming calls. It will return the
        // highest priority call to display as the secondary call.
        secondary = getCallToDisplay(callList, null, true);
    } else if (newState == InCallState.INCALL) {
        primary = getCallToDisplay(callList, null, false);
        secondary = getCallToDisplay(callList, primary, true);
    }
    if (mInCallContactInteractions != null && (oldState == InCallState.INCOMING || newState == InCallState.INCOMING)) {
        ui.showContactContext(newState != InCallState.INCOMING);
    }
    Log.d(this, "Primary call: " + primary);
    Log.d(this, "Secondary call: " + secondary);
    final boolean primaryChanged = !(Call.areSame(mPrimary, primary) && Call.areSameNumber(mPrimary, primary));
    final boolean secondaryChanged = !(Call.areSame(mSecondary, secondary) && Call.areSameNumber(mSecondary, secondary));
    final boolean primaryForwardedChanged = isForwarded(primary) != isForwarded(mPrimary);
    mSecondary = secondary;
    Call previousPrimary = mPrimary;
    mPrimary = primary;
    if (primaryChanged && shouldShowNoteSentToast(primary)) {
        ui.showNoteSentToast();
    }
    // 3. The call subject should be shown or hidden.
    if (shouldRefreshPrimaryInfo(primaryChanged, ui, shouldShowCallSubject(mPrimary))) {
        // primary call has changed
        if (previousPrimary != null) {
            // clear progess spinner (if any) related to previous primary call
            maybeShowProgressSpinner(previousPrimary.getState(), Call.SessionModificationState.NO_REQUEST);
            CallList.getInstance().removeCallUpdateListener(previousPrimary.getId(), this);
        }
        CallList.getInstance().addCallUpdateListener(mPrimary.getId(), this);
        mPrimaryContactInfo = ContactInfoCache.buildCacheEntryFromCall(mContext, mPrimary, isGeocoderLocationNeeded(mPrimary));
        updatePrimaryDisplayInfo();
        maybeStartSearch(mPrimary, true);
        maybeClearSessionModificationState(mPrimary);
    } else if (primaryForwardedChanged && mPrimary != null) {
        updatePrimaryDisplayInfo();
    }
    if (previousPrimary != null && mPrimary == null) {
        // clear progess spinner (if any) related to previous primary call
        maybeShowProgressSpinner(previousPrimary.getState(), Call.SessionModificationState.NO_REQUEST);
        CallList.getInstance().removeCallUpdateListener(previousPrimary.getId(), this);
    }
    if (mSecondary == null) {
        // Secondary call may have ended.  Update the ui.
        mSecondaryContactInfo = null;
        updateSecondaryDisplayInfo();
    } else if (secondaryChanged) {
        // secondary call has changed
        mSecondaryContactInfo = ContactInfoCache.buildCacheEntryFromCall(mContext, mSecondary, mSecondary.getState() == Call.State.INCOMING);
        updateSecondaryDisplayInfo();
        maybeStartSearch(mSecondary, false);
        maybeClearSessionModificationState(mSecondary);
    }
    CallRecorder recorder = CallRecorder.getInstance();
    boolean isVideo = VideoUtils.isVideoCall(mPrimary);
    boolean isEnabled = getPrefs(mContext).getBoolean(mContext.getString(R.string.call_recording_automatically_key), false);
    // Start/stop timers.
    if (isPrimaryCallActive()) {
        Log.d(this, "Starting the calltime timer");
        mPrimary.triggerCalcBaseChronometerTime();
        mCallTimer.start(CALL_TIME_UPDATE_INTERVAL_MS);
        if (ui.getMarkSnackBar() == null && mPrimaryContactInfo != null) {
            String name = getNameForCall(mPrimaryContactInfo);
            boolean nameIsNumber = name != null && name.equals(mPrimaryContactInfo.number);
            if (nameIsNumber) {
                ui.setMarkSnackBar(mPrimaryContactInfo.number);
            }
        }
        if (!mIsRecording && isEnabled && !isVideo && CallButtonFragment.getInstance() != null) {
            mIsRecording = true;
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    CallButtonFragment.getInstance().callRecordClicked(true);
                }
            }, 500);
        }
    } else {
        Log.d(this, "Canceling the calltime timer");
        mCallTimer.cancel();
        ui.setMarkSnackBar(null);
        ui.setPrimaryCallElapsedTime(false, 0);
        if (isEnabled && !isVideo) {
            if (recorder.isRecording()) {
                recorder.finishRecording();
            }
        }
    }
    // Set the call state
    int callState = Call.State.IDLE;
    if (mPrimary != null) {
        callState = mPrimary.getState();
        updatePrimaryCallState();
    } else {
        getUi().setCallState(callState, VideoProfile.STATE_AUDIO_ONLY, Call.SessionModificationState.NO_REQUEST, new DisconnectCause(DisconnectCause.UNKNOWN), null, null, null, false, /* isWifi */
        false, /* isConference */
        false, /* isWaitingForRemoteSide */
        false);
        getUi().showHdAudioIndicator(false);
    }
    if (!callList.hasAnyLiveCall() && isVolumeBoostEnabled()) {
        setVolumeBoost(false);
    }
    updateVBButton();
    maybeShowManageConferenceCallButton();
    // Hide the end call button instantly if we're receiving an incoming call.
    getUi().setEndCallButtonEnabled(shouldShowEndCallButton(mPrimary, callState), callState != Call.State.INCOMING);
    maybeSendAccessibilityEvent(oldState, newState, primaryChanged);
}
Also used : DisconnectCause(android.telecom.DisconnectCause) Handler(android.os.Handler)

Aggregations

DisconnectCause (android.telecom.DisconnectCause)12 AlertDialog (android.app.AlertDialog)2 Dialog (android.app.Dialog)2 Bundle (android.os.Bundle)2 PhoneAccountHandle (android.telecom.PhoneAccountHandle)2 Pair (android.util.Pair)2 Context (android.content.Context)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 Intent (android.content.Intent)1 Point (android.graphics.Point)1 Handler (android.os.Handler)1 NonNull (android.support.annotation.NonNull)1 Assert (com.android.dialer.common.Assert)1 LogUtil (com.android.dialer.common.LogUtil)1 DialerCall (com.android.incallui.call.DialerCall)1