SIP: remove dependency on javax.sip.SipException.

Change-Id: I77d289bef1b5e7f1ec0c0408d0bbf96c21085cd7
diff --git a/telephony/java/com/android/internal/telephony/sip/SipCallBase.java b/telephony/java/com/android/internal/telephony/sip/SipCallBase.java
index e7eda4f..7e407b2 100644
--- a/telephony/java/com/android/internal/telephony/sip/SipCallBase.java
+++ b/telephony/java/com/android/internal/telephony/sip/SipCallBase.java
@@ -26,7 +26,6 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import javax.sip.SipException;
 
 abstract class SipCallBase extends Call {
     private static final int MAX_CONNECTIONS_PER_CALL = 5;
diff --git a/telephony/java/com/android/internal/telephony/sip/SipPhone.java b/telephony/java/com/android/internal/telephony/sip/SipPhone.java
index bf1b939..fd90610 100755
--- a/telephony/java/com/android/internal/telephony/sip/SipPhone.java
+++ b/telephony/java/com/android/internal/telephony/sip/SipPhone.java
@@ -24,6 +24,7 @@
 import android.net.rtp.AudioStream;
 import android.net.sip.SipAudioCall;
 import android.net.sip.SipErrorCode;
+import android.net.sip.SipException;
 import android.net.sip.SipManager;
 import android.net.sip.SipProfile;
 import android.net.sip.SipSessionState;
@@ -67,8 +68,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.sip.SipException;
-
 /**
  * {@hide}
  */
diff --git a/voip/java/android/net/sip/SipAudioCall.java b/voip/java/android/net/sip/SipAudioCall.java
index 02f82b3..39083a5 100644
--- a/voip/java/android/net/sip/SipAudioCall.java
+++ b/voip/java/android/net/sip/SipAudioCall.java
@@ -20,8 +20,6 @@
 import android.net.rtp.AudioStream;
 import android.os.Message;
 
-import javax.sip.SipException;
-
 /**
  * Interface for making audio calls over SIP.
  * @hide
diff --git a/voip/java/android/net/sip/SipAudioCallImpl.java b/voip/java/android/net/sip/SipAudioCallImpl.java
index 2e2ca5b..67ba97f 100644
--- a/voip/java/android/net/sip/SipAudioCallImpl.java
+++ b/voip/java/android/net/sip/SipAudioCallImpl.java
@@ -43,7 +43,6 @@
 import java.util.List;
 import java.util.Map;
 import javax.sdp.SdpException;
-import javax.sip.SipException;
 
 /**
  * Class that handles an audio call over SIP. 
diff --git a/voip/java/android/net/sip/SipException.java b/voip/java/android/net/sip/SipException.java
new file mode 100644
index 0000000..d615342
--- /dev/null
+++ b/voip/java/android/net/sip/SipException.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.sip;
+
+/**
+ * @hide
+ */
+public class SipException extends Exception {
+    public SipException() {
+    }
+
+    public SipException(String message) {
+        super(message);
+    }
+
+    public SipException(String message, Throwable cause) {
+        // we want to eliminate the dependency on javax.sip.SipException
+        super(message, ((cause instanceof javax.sip.SipException)
+                && (cause.getCause() != null))
+                ? cause.getCause()
+                : cause);
+    }
+}
diff --git a/voip/java/android/net/sip/SipManager.java b/voip/java/android/net/sip/SipManager.java
index beec8fe..ccae7f9 100644
--- a/voip/java/android/net/sip/SipManager.java
+++ b/voip/java/android/net/sip/SipManager.java
@@ -25,7 +25,6 @@
 import android.os.ServiceManager;
 
 import java.text.ParseException;
-import javax.sip.SipException;
 
 /**
  * The class provides API for various SIP related tasks. Specifically, the API
@@ -501,15 +500,15 @@
         }
 
         @Override
-        public void onRegistrationFailed(ISipSession session, String className,
+        public void onRegistrationFailed(ISipSession session, String errorCode,
                 String message) {
-            mListener.onRegistrationFailed(getUri(session), className, message);
+            mListener.onRegistrationFailed(getUri(session), errorCode, message);
         }
 
         @Override
         public void onRegistrationTimeout(ISipSession session) {
             mListener.onRegistrationFailed(getUri(session),
-                    SipException.class.getName(), "registration timed out");
+                    SipErrorCode.TIME_OUT.toString(), "registration timed out");
         }
     }
 }