Catch SIP exceptions which can crash Phone process on answer. am: eb72c56094 am: d19b83390c am: d232102d70
am: 9058c0b2b7

Change-Id: I52d1d5484c7358f7894d33f7de5015279f1989aa
diff --git a/sip/src/com/android/services/telephony/sip/SipConnection.java b/sip/src/com/android/services/telephony/sip/SipConnection.java
index b10ae56..2dde5b5 100644
--- a/sip/src/com/android/services/telephony/sip/SipConnection.java
+++ b/sip/src/com/android/services/telephony/sip/SipConnection.java
@@ -24,6 +24,7 @@
 import android.telecom.Connection;
 import android.telecom.PhoneAccount;
 import android.telecom.TelecomManager;
+import android.util.EventLog;
 import android.util.Log;
 
 import com.android.internal.telephony.Call;
@@ -181,6 +182,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();
         }
     }