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

Commit ae076d39 authored by Hung-ying Tyan's avatar Hung-ying Tyan
Browse files

SIP: add PEER_NOT_REACHABLE error feedback.

http://b/issue?id=3002033

Change-Id: Ib64b08919d214acbab89945ac19dc113a68e62ad
parent 88203cb1
Loading
Loading
Loading
Loading
+12 −2
Original line number Original line Diff line number Diff line
@@ -1036,8 +1036,7 @@ class SipSessionGroup implements SipListener {


        private void onError(Response response) {
        private void onError(Response response) {
            int statusCode = response.getStatusCode();
            int statusCode = response.getStatusCode();
            if (!mInCall && ((statusCode == Response.TEMPORARILY_UNAVAILABLE)
            if (!mInCall && (statusCode == Response.BUSY_HERE)) {
                    || (statusCode == Response.BUSY_HERE))) {
                endCallOnBusy();
                endCallOnBusy();
            } else {
            } else {
                onError(getErrorCode(statusCode), createErrorMessage(response));
                onError(getErrorCode(statusCode), createErrorMessage(response));
@@ -1046,11 +1045,22 @@ class SipSessionGroup implements SipListener {


        private SipErrorCode getErrorCode(int responseStatusCode) {
        private SipErrorCode getErrorCode(int responseStatusCode) {
            switch (responseStatusCode) {
            switch (responseStatusCode) {
                case Response.TEMPORARILY_UNAVAILABLE:
                case Response.FORBIDDEN:
                case Response.GONE:
                case Response.NOT_FOUND:
                case Response.NOT_FOUND:
                case Response.NOT_ACCEPTABLE:
                case Response.NOT_ACCEPTABLE_HERE:
                    return SipErrorCode.PEER_NOT_REACHABLE;

                case Response.REQUEST_URI_TOO_LONG:
                case Response.ADDRESS_INCOMPLETE:
                case Response.ADDRESS_INCOMPLETE:
                case Response.AMBIGUOUS:
                    return SipErrorCode.INVALID_REMOTE_URI;
                    return SipErrorCode.INVALID_REMOTE_URI;

                case Response.REQUEST_TIMEOUT:
                case Response.REQUEST_TIMEOUT:
                    return SipErrorCode.TIME_OUT;
                    return SipErrorCode.TIME_OUT;

                default:
                default:
                    if (responseStatusCode < 500) {
                    if (responseStatusCode < 500) {
                        return SipErrorCode.CLIENT_ERROR;
                        return SipErrorCode.CLIENT_ERROR;
+1 −0
Original line number Original line Diff line number Diff line
@@ -39,6 +39,7 @@ public abstract class Connection {
        CONGESTION,                     /* outgoing call to congested network */
        CONGESTION,                     /* outgoing call to congested network */
        MMI,                            /* not presently used; dial() returns null */
        MMI,                            /* not presently used; dial() returns null */
        INVALID_NUMBER,                 /* invalid dial string */
        INVALID_NUMBER,                 /* invalid dial string */
        NUMBER_UNREACHABLE,             /* cannot reach the peer */
        INVALID_CREDENTIALS,            /* invalid credentials */
        INVALID_CREDENTIALS,            /* invalid credentials */
        TIMED_OUT,                      /* client timed out */
        TIMED_OUT,                      /* client timed out */
        LOST_SIGNAL,
        LOST_SIGNAL,
+5 −0
Original line number Original line Diff line number Diff line
@@ -606,6 +606,7 @@ public class SipPhone extends SipPhoneBase {
                }
                }
                synchronized (SipPhone.class) {
                synchronized (SipPhone.class) {
                    setState(Call.State.DISCONNECTED);
                    setState(Call.State.DISCONNECTED);
                    mSipAudioCall.close();
                    mOwner.onConnectionEnded(SipConnection.this);
                    mOwner.onConnectionEnded(SipConnection.this);
                    Log.v(LOG_TAG, "-------- connection ended: "
                    Log.v(LOG_TAG, "-------- connection ended: "
                            + mPeer.getUriString() + ": "
                            + mPeer.getUriString() + ": "
@@ -822,6 +823,9 @@ public class SipPhone extends SipPhoneBase {
        public void onError(SipAudioCall call, SipErrorCode errorCode,
        public void onError(SipAudioCall call, SipErrorCode errorCode,
                String errorMessage) {
                String errorMessage) {
            switch (errorCode) {
            switch (errorCode) {
                case PEER_NOT_REACHABLE:
                    onError(Connection.DisconnectCause.NUMBER_UNREACHABLE);
                    break;
                case INVALID_REMOTE_URI:
                case INVALID_REMOTE_URI:
                    onError(Connection.DisconnectCause.INVALID_NUMBER);
                    onError(Connection.DisconnectCause.INVALID_NUMBER);
                    break;
                    break;
@@ -839,6 +843,7 @@ public class SipPhone extends SipPhoneBase {
                case SERVER_ERROR:
                case SERVER_ERROR:
                case CLIENT_ERROR:
                case CLIENT_ERROR:
                default:
                default:
                    Log.w(LOG_TAG, "error: " + errorCode + ": " + errorMessage);
                    onError(Connection.DisconnectCause.ERROR_UNSPECIFIED);
                    onError(Connection.DisconnectCause.ERROR_UNSPECIFIED);
            }
            }
        }
        }
+3 −0
Original line number Original line Diff line number Diff line
@@ -43,6 +43,9 @@ public enum SipErrorCode {
    /** When the remote URI is not valid. */
    /** When the remote URI is not valid. */
    INVALID_REMOTE_URI,
    INVALID_REMOTE_URI,


    /** When the peer is not reachable. */
    PEER_NOT_REACHABLE,

    /** When invalid credentials are provided. */
    /** When invalid credentials are provided. */
    INVALID_CREDENTIALS,
    INVALID_CREDENTIALS,