FPII-2689:Catch SIP exceptions which can crash Phone process on answer.

There are two exceptions which can be raised when answering a call which
can cause the Phone process to crash on answer.
1. IllegalStateException due to answering a call with an incompatible
codec.
2. IllegalArgumentException due to answering a call with a malformed
SDP.
In both of these cases we catch the exception and reject the call to stop
it from ringing (otherwise it will keep ringing and the user will not be
able to stop it).

The existing CallStateException does not require onReject to be called as
it is thrown when the call has already been disconnected before it can be
answered.
Test: Manual (see bug)
Bug: 31752213

Change-Id: Ie4edb044ca928e0be56f6108ec268204feab49d7
diff --git a/sip/src/com/android/services/telephony/sip/SipConnection.java b/sip/src/com/android/services/telephony/sip/SipConnection.java
index 5df61b7..f855a40 100644
--- a/sip/src/com/android/services/telephony/sip/SipConnection.java
+++ b/sip/src/com/android/services/telephony/sip/SipConnection.java
@@ -22,6 +22,7 @@
 import android.telecom.AudioState;
 import android.telecom.Connection;
 import android.telecom.PhoneAccount;
+import android.util.EventLog;
 import android.util.Log;
 
 import com.android.internal.telephony.Call;
@@ -161,6 +162,18 @@
             }
         } catch (CallStateException e) {
             log("onAnswer, exception: " + e);
+        } catch (IllegalStateException e) {
+            // Call could not be answered due to an invalid audio-codec offered by the caller.  We
+            // will reject the call to stop it from ringing.
+            log("onAnswer, IllegalStateException: " + e);
+            EventLog.writeEvent(0x534e4554, "31752213", -1, "Invalid codec.");
+            onReject();
+        } catch (IllegalArgumentException e) {
+            // Call could not be answered due to an error parsing the SDP.  We will reject the call
+            // to stop it from ringing.
+            log("onAnswer, IllegalArgumentException: " + e);
+            EventLog.writeEvent(0x534e4554, "31752213", -1, "Invalid SDP.");
+            onReject();
         }
     }