Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e37be5d authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Finalize multiendpoint functionality.

1) Handle the PULLING state throughout telecom.
2) When parcelling calls to send to InCallServices, remap PULLING state
to DIALING if an InCallService doesn't support external calls.  This
ensures compatibility for things like Android Wear/Auto.
3) Ensure add call isn't disabled because of external calls.
4) Modify InCallController to handle changes to whether a call is external
or not.  For IncallServices that do not support external calls, we will
add the call when an external call becomes a regular call, and we will
remove it when a regular call becomes external.

Change-Id: I1bf6c1f7e182834c3ab1ed34cd119467a4698993
parent 11cbb8ac
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -344,7 +344,8 @@ public class BluetoothPhoneServiceImpl {
            // state. We can assume that the active call will be automatically held which will
            // send another update at which point we will be in the right state.
            if (mCallsManager.getActiveCall() != null
                    && oldState == CallState.CONNECTING && newState == CallState.DIALING) {
                    && oldState == CallState.CONNECTING &&
                    (newState == CallState.DIALING || newState == CallState.PULLING)) {
                return;
            }
            updateHeadsetWithCallState(false /* force */);
@@ -821,6 +822,7 @@ public class BluetoothPhoneServiceImpl {
            case CallState.CONNECTING:
            case CallState.SELECT_PHONE_ACCOUNT:
            case CallState.DIALING:
            case CallState.PULLING:
                // Yes, this is correctly returning ALERTING.
                // "Dialing" for BT means that we have sent information to the service provider
                // to place the call but there is no confirmation that the call is going through.
+5 −0
Original line number Diff line number Diff line
@@ -655,6 +655,9 @@ public class Call implements CreateConnectionResponse {
                case CallState.DIALING:
                    event = Log.Events.SET_DIALING;
                    break;
                case CallState.PULLING:
                    event = Log.Events.SET_PULLING;
                    break;
                case CallState.DISCONNECTED:
                    event = Log.Events.SET_DISCONNECTED;
                    data = getDisconnectCause();
@@ -1978,6 +1981,8 @@ public class Call implements CreateConnectionResponse {
                return CallState.ACTIVE;
            case Connection.STATE_DIALING:
                return CallState.DIALING;
            case Connection.STATE_PULLING_CALL:
                return CallState.PULLING;
            case Connection.STATE_DISCONNECTED:
                return CallState.DISCONNECTED;
            case Connection.STATE_HOLDING:
+8 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ public class CallAudioManager extends CallsManagerListenerBase {
            put(CallState.CONNECTING, mActiveDialingOrConnectingCalls);
            put(CallState.ACTIVE, mActiveDialingOrConnectingCalls);
            put(CallState.DIALING, mActiveDialingOrConnectingCalls);
            put(CallState.PULLING, mActiveDialingOrConnectingCalls);
            put(CallState.RINGING, mRingingCalls);
            put(CallState.ON_HOLD, mHoldingCalls);
        }};
@@ -489,9 +490,13 @@ public class CallAudioManager extends CallsManagerListenerBase {
            case CallState.ON_HOLD:
                onCallLeavingHold();
                break;
            case CallState.PULLING:
                onCallLeavingActiveDialingOrConnecting();
                break;
            case CallState.DIALING:
                stopRingbackForCall(call);
                onCallLeavingActiveDialingOrConnecting();
                break;
        }
    }

@@ -507,6 +512,9 @@ public class CallAudioManager extends CallsManagerListenerBase {
            case CallState.ON_HOLD:
                onCallEnteringHold();
                break;
            case CallState.PULLING:
                onCallEnteringActiveDialingOrConnecting();
                break;
            case CallState.DIALING:
                onCallEnteringActiveDialingOrConnecting();
                playRingbackForCall(call);
+11 −0
Original line number Diff line number Diff line
@@ -103,6 +103,15 @@ public final class CallState {
     */
    public static final int DISCONNECTING = 9;

    /**
     * Indicates that the call is in the process of being pulled to the local device.
     * <p>
     * This state should only be set on a call with
     * {@link android.telecom.Connection#PROPERTY_IS_EXTERNAL_CALL} and
     * {@link android.telecom.Connection#CAPABILITY_CAN_PULL_CALL}.
     */
    public static final int PULLING = 10;

    public static String toString(int callState) {
        switch (callState) {
            case NEW:
@@ -125,6 +134,8 @@ public final class CallState {
                return "ABORTED";
            case DISCONNECTING:
                return "DISCONNECTING";
            case PULLING:
                return "PULLING";
            default:
                return "UNKNOWN";
        }
+17 −5
Original line number Diff line number Diff line
@@ -119,11 +119,13 @@ public class CallsManager extends Call.ListenerBase
    private static final int MAXIMUM_TOP_LEVEL_CALLS = 2;

    private static final int[] OUTGOING_CALL_STATES =
            {CallState.CONNECTING, CallState.SELECT_PHONE_ACCOUNT, CallState.DIALING};
            {CallState.CONNECTING, CallState.SELECT_PHONE_ACCOUNT, CallState.DIALING,
                    CallState.PULLING};

    private static final int[] LIVE_CALL_STATES =
            {CallState.CONNECTING, CallState.SELECT_PHONE_ACCOUNT, CallState.DIALING,
                CallState.ACTIVE};
                    CallState.PULLING, CallState.ACTIVE};

    public static final String TELECOM_CALL_ID_PREFIX = "TC@";

    // Maps call technologies in PhoneConstants to those in Analytics.
@@ -990,7 +992,8 @@ public class CallsManager extends Call.ListenerBase
            // STATE_DIALING, put it on hold before answering the call.
            if (foregroundCall != null && foregroundCall != call &&
                    (foregroundCall.isActive() ||
                     foregroundCall.getState() == CallState.DIALING)) {
                     foregroundCall.getState() == CallState.DIALING ||
                     foregroundCall.getState() == CallState.PULLING)) {
                if (0 == (foregroundCall.getConnectionCapabilities()
                        & Connection.CAPABILITY_HOLD)) {
                    // This call does not support hold.  If it is from a different connection
@@ -1351,6 +1354,11 @@ public class CallsManager extends Call.ListenerBase
        maybeMoveToSpeakerPhone(call);
    }

    void markCallAsPulling(Call call) {
        setCallState(call, CallState.PULLING, "pulling set explicitly");
        maybeMoveToSpeakerPhone(call);
    }

    void markCallAsActive(Call call) {
        setCallState(call, CallState.ACTIVE, "active set explicitly");
        maybeMoveToSpeakerPhone(call);
@@ -1444,7 +1452,8 @@ public class CallsManager extends Call.ListenerBase
            } else if (HeadsetMediaButton.LONG_PRESS == type) {
                Log.d(this, "handleHeadsetHook: longpress -> hangup");
                Call callToHangup = getFirstCallWithState(
                        CallState.RINGING, CallState.DIALING, CallState.ACTIVE, CallState.ON_HOLD);
                        CallState.RINGING, CallState.DIALING, CallState.PULLING, CallState.ACTIVE,
                        CallState.ON_HOLD);
                if (callToHangup != null) {
                    callToHangup.disconnect();
                    return true;
@@ -1474,6 +1483,9 @@ public class CallsManager extends Call.ListenerBase
            if (call.isEmergencyCall()) {
                // We never support add call if one of the calls is an emergency call.
                return false;
            } else if (call.isExternalCall()) {
                // External calls don't count.
                continue;
            } else if (call.getParentCall() == null) {
                count++;
            }
@@ -1838,7 +1850,7 @@ public class CallsManager extends Call.ListenerBase
    }

    private boolean hasMaximumDialingCalls() {
        return MAXIMUM_DIALING_CALLS <= getNumCallsWithState(CallState.DIALING);
        return MAXIMUM_DIALING_CALLS <= getNumCallsWithState(CallState.DIALING, CallState.PULLING);
    }

    private boolean makeRoomForOutgoingCall(Call call, boolean isEmergency) {
Loading