Add CallService.abort in telephony.

Change-Id: I7af144a6482c6264355ed40818f765e527d164b3
diff --git a/src/com/android/services/telephony/BaseTelephonyCallService.java b/src/com/android/services/telephony/BaseTelephonyCallService.java
index e0240d0..f8c7804 100644
--- a/src/com/android/services/telephony/BaseTelephonyCallService.java
+++ b/src/com/android/services/telephony/BaseTelephonyCallService.java
@@ -64,10 +64,9 @@
 
     /** {@inheritDoc} */
     @Override
-    public void disconnect(String callId) {
-        // Maybe null if the connection has already disconnected.
+    public void abort(String callId) {
         if (sCallConnections.containsKey(callId)) {
-            sCallConnections.get(callId).disconnect();
+            sCallConnections.get(callId).disconnect(true);
         }
     }
 
@@ -81,6 +80,15 @@
     public void reject(String callId) {
     }
 
+    /** {@inheritDoc} */
+    @Override
+    public void disconnect(String callId) {
+        // Maybe null if the connection has already disconnected.
+        if (sCallConnections.containsKey(callId)) {
+            sCallConnections.get(callId).disconnect(false);
+        }
+    }
+
     /**
      * Initiates the call, should be called by the subclass.
      */
diff --git a/src/com/android/services/telephony/TelephonyCallConnection.java b/src/com/android/services/telephony/TelephonyCallConnection.java
index 278943b..3abeb14 100644
--- a/src/com/android/services/telephony/TelephonyCallConnection.java
+++ b/src/com/android/services/telephony/TelephonyCallConnection.java
@@ -34,10 +34,11 @@
     private static final String TAG = TelephonyCallConnection.class.getSimpleName();
     private static final int EVENT_PRECISE_CALL_STATE_CHANGED = 1;
 
-    private final ICallServiceAdapter mCallServiceAdapter;
     private final String mCallId;
     private final StateHandler mHandler = new StateHandler();
 
+    private ICallServiceAdapter mCallServiceAdapter;
+
     private Connection mConnection;
     private Call.State mOldState = Call.State.IDLE;
 
@@ -55,7 +56,10 @@
         return mCallId;
     }
 
-    void disconnect() {
+    void disconnect(boolean shouldAbort) {
+        if (shouldAbort) {
+            mCallServiceAdapter = null;
+        }
         if (mConnection != null) {
             try {
                 mConnection.hangup();
@@ -66,7 +70,7 @@
     }
 
     private void updateState() {
-        if (mConnection == null) {
+        if (mConnection == null || mCallServiceAdapter == null) {
             return;
         }