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

Commit 8662f9f1 authored by John Huang's avatar John Huang Committed by Android (Google) Code Review
Browse files

Merge "Handle SIP authentication response for BYE."

parents 0ba9546b dc5bbe96
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -63,6 +63,9 @@ public final class SipSession {
        /** When an OPTIONS request is sent. */
        public static final int PINGING = 9;

        /** When ending a call. @hide */
        public static final int ENDING_CALL = 10;

        /** Not defined. */
        public static final int NOT_DEFINED = 101;

+29 −1
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ class SipSessionGroup implements SipListener {
    private static final String THREAD_POOL_SIZE = "1";
    private static final int EXPIRY_TIME = 3600; // in seconds
    private static final int CANCEL_CALL_TIMER = 3; // in seconds
    private static final int END_CALL_TIMER = 3; // in seconds
    private static final int KEEPALIVE_TIMEOUT = 3; // in seconds
    private static final int INCALL_KEEPALIVE_INTERVAL = 10; // in seconds
    private static final long WAKE_LOCK_HOLDING_TIME = 500; // in milliseconds
@@ -756,6 +757,9 @@ class SipSessionGroup implements SipListener {
                case SipSession.State.IN_CALL:
                    processed = inCall(evt);
                    break;
                case SipSession.State.ENDING_CALL:
                    processed = endingCall(evt);
                    break;
                default:
                    processed = false;
                }
@@ -1230,8 +1234,10 @@ class SipSessionGroup implements SipListener {
            // OK retransmission is handled in SipStack
            if (END_CALL == evt) {
                // rfc3261#section-15.1.1
                mState = SipSession.State.ENDING_CALL;
                mSipHelper.sendBye(mDialog);
                endCallNormally();
                mProxy.onCallEnded(this);
                startSessionTimer(END_CALL_TIMER);
                return true;
            } else if (isRequestEvent(Request.INVITE, evt)) {
                // got Re-INVITE
@@ -1260,6 +1266,28 @@ class SipSessionGroup implements SipListener {
            return false;
        }

        private boolean endingCall(EventObject evt) throws SipException {
            if (expectResponse(Request.BYE, evt)) {
                ResponseEvent event = (ResponseEvent) evt;
                Response response = event.getResponse();

                int statusCode = response.getStatusCode();
                switch (statusCode) {
                    case Response.UNAUTHORIZED:
                    case Response.PROXY_AUTHENTICATION_REQUIRED:
                        if (handleAuthentication(event)) {
                            return true;
                        } else {
                            // can't authenticate; pass through to end session
                        }
                }
                cancelSessionTimer();
                reset();
                return true;
            }
            return false;
        }

        // timeout in seconds
        private void startSessionTimer(int timeout) {
            if (timeout > 0) {