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

Commit 708e4251 authored by Chung-yih Wang's avatar Chung-yih Wang Committed by Android (Google) Code Review
Browse files

Merge "Revert the ANSWERING state." into gingerbread

parents 313af5a3 9779b714
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -238,9 +238,7 @@ public final class CallManager {
        Phone.State s = Phone.State.IDLE;

        for (Phone phone : mPhones) {
            if (phone.getState() == Phone.State.ANSWERING) {
                return Phone.State.ANSWERING;
            } else if (phone.getState() == Phone.State.RINGING) {
            if (phone.getState() == Phone.State.RINGING) {
                s = Phone.State.RINGING;
            } else if (phone.getState() == Phone.State.OFFHOOK) {
                if (s == Phone.State.IDLE) s = Phone.State.OFFHOOK;
@@ -358,18 +356,25 @@ public final class CallManager {
    }

    /**
     * @return the first answering call
     * unregister phone from CallManager
     * @param phone
     */
    public Call getFirstAnsweringCall() {
        for (Phone phone : mPhones) {
            if (phone.getState() == Phone.State.ANSWERING) {
                return phone.getForegroundCall();
    public void unregisterPhone(Phone phone) {
        if (phone != null && mPhones.contains(phone)) {
            mPhones.remove(phone);
            mRingingCalls.remove(phone.getRingingCall());
            mBackgroundCalls.remove(phone.getBackgroundCall());
            mForegroundCalls.remove(phone.getForegroundCall());
            unregisterForPhoneStates(phone);
            if (phone == mDefaultPhone) {
                if (mPhones.isEmpty()) {
                    mDefaultPhone = null;
                } else {
                    mDefaultPhone = mPhones.get(0);
                }
            }
        }
        return null;
    }



    public void setAudioMode() {
        Context context = getContext();
@@ -1359,7 +1364,7 @@ public final class CallManager {
     */
    public Call getFirstActiveBgCall() {
        for (Call call : mBackgroundCalls) {
            if (!call.isIdle()) {
            if (call.getState() != Call.State.IDLE) {
                return call;
            }
        }
+1 −3
Original line number Diff line number Diff line
@@ -55,12 +55,10 @@ public interface Phone {
     * <li>OFFHOOK = The phone is off hook. At least one call
     * exists that is dialing, active or holding and no calls are
     * ringing or waiting.</li>
     * <li>ANSWERING = The incoming call is picked up but the
     *  call is not established yet.</li>
     * </ul>
     */
    enum State {
        IDLE, RINGING, OFFHOOK, ANSWERING;
        IDLE, RINGING, OFFHOOK;
    };

    /**
+17 −13
Original line number Diff line number Diff line
@@ -143,23 +143,15 @@ public class SipPhone extends SipPhoneBase {
            // in case the active/holding call disappeared and this
            // is no longer call waiting

            if (ringingCall.getState() == Call.State.INCOMING) {
            if ((ringingCall.getState() == Call.State.INCOMING) ||
                    (ringingCall.getState() == Call.State.WAITING)) {
                Log.v(LOG_TAG, "acceptCall");
                // Always unmute when answering a new call
                setMute(false);
                // make ringingCall foreground
                foregroundCall.switchWith(ringingCall);
                foregroundCall.acceptCall();
            } else if (ringingCall.getState() == Call.State.WAITING) {
                setMute(false);
                switchHoldingAndActive();
                // make ringingCall foreground
                foregroundCall.switchWith(ringingCall);
                foregroundCall.acceptCall();
                ringingCall.acceptCall();
            } else {
                throw new CallStateException("phone not ringing");
            }
            updatePhoneState();
        }
    }

@@ -482,8 +474,8 @@ public class SipPhone extends SipPhoneBase {
        }

        void acceptCall() throws CallStateException {
            if (this != foregroundCall) {
                throw new CallStateException("acceptCall() in a non-fg call");
            if (this != ringingCall) {
                throw new CallStateException("acceptCall() in a non-ringing call");
            }
            if (connections.size() != 1) {
                throw new CallStateException("acceptCall() in a conf call");
@@ -646,6 +638,18 @@ public class SipPhone extends SipPhoneBase {
                    if (newState == Call.State.INCOMING) {
                        setState(mOwner.getState()); // INCOMING or WAITING
                    } else {
                        if (mOwner == ringingCall) {
                            if (ringingCall.getState() == Call.State.WAITING) {
                                try {
                                    switchHoldingAndActive();
                                } catch (CallStateException e) {
                                    // disconnect the call.
                                    onCallEnded(DisconnectCause.LOCAL);
                                    return;
                                }
                            }
                            foregroundCall.switchWith(ringingCall);
                        }
                        if (newState == Call.State.ACTIVE) call.startAudio();
                        setState(newState);
                    }
+0 −2
Original line number Diff line number Diff line
@@ -538,8 +538,6 @@ abstract class SipPhoneBase extends PhoneBase {

        if (getRingingCall().isRinging()) {
            state = State.RINGING;
        } else if (getForegroundCall().isRinging()) {
            state = State.ANSWERING;
        } else if (getForegroundCall().isIdle()
                && getBackgroundCall().isIdle()) {
            state = State.IDLE;