SIP: add SERVER_UNREACHABLE error code.

Let SipSession return it when UnknownHostException is caught.
Add DisconnectCause.SERVER_UNREACHABLE in Connection and have SipPhone report
it when receiving SERVER_UNREACHABLE from SipSession.

http://b/issue?id=3061691

Change-Id: I944328ba3ee30c0a9386e89b5c4696d4d9bde000
This commit is contained in:
Hung-ying Tyan
2010-10-05 13:00:13 +08:00
parent 368733b204
commit c6548fd9ed
4 changed files with 11 additions and 2 deletions

View File

@ -40,6 +40,7 @@ public abstract class Connection {
MMI, /* not presently used; dial() returns null */
INVALID_NUMBER, /* invalid dial string */
NUMBER_UNREACHABLE, /* cannot reach the peer */
SERVER_UNREACHABLE, /* cannot reach the server */
INVALID_CREDENTIALS, /* invalid credentials */
OUT_OF_NETWORK, /* calling from out of network is not allowed */
SERVER_ERROR, /* server error */

View File

@ -875,6 +875,9 @@ public class SipPhone extends SipPhoneBase {
public void onError(SipAudioCall call, int errorCode,
String errorMessage) {
switch (errorCode) {
case SipErrorCode.SERVER_UNREACHABLE:
onError(Connection.DisconnectCause.SERVER_UNREACHABLE);
break;
case SipErrorCode.PEER_NOT_REACHABLE:
onError(Connection.DisconnectCause.NUMBER_UNREACHABLE);
break;

View File

@ -61,6 +61,9 @@ public class SipErrorCode {
/** Cross-domain authentication required. */
public static final int CROSS_DOMAIN_AUTHENTICATION = -11;
/** When the server is not reachable. */
public static final int SERVER_UNREACHABLE = -12;
public static String toString(int errorCode) {
switch (errorCode) {
case NO_ERROR:
@ -87,6 +90,8 @@ public class SipErrorCode {
return "DATA_CONNECTION_LOST";
case CROSS_DOMAIN_AUTHENTICATION:
return "CROSS_DOMAIN_AUTHENTICATION";
case SERVER_UNREACHABLE:
return "SERVER_UNREACHABLE";
default:
return "UNKNOWN";
}

View File

@ -480,7 +480,7 @@ class SipSessionGroup implements SipListener {
public void run() {
try {
processCommand(command);
} catch (SipException e) {
} catch (Throwable e) {
Log.w(TAG, "command error: " + command, e);
onError(e);
}
@ -1218,7 +1218,7 @@ class SipSessionGroup implements SipListener {
private int getErrorCode(Throwable exception) {
String message = exception.getMessage();
if (exception instanceof UnknownHostException) {
return SipErrorCode.INVALID_REMOTE_URI;
return SipErrorCode.SERVER_UNREACHABLE;
} else if (exception instanceof IOException) {
return SipErrorCode.SOCKET_ERROR;
} else {