Add the abort API to ICallService implementations.

Change-Id: Ie9b996b4d23184034811ef5667403ff4e47ae2d9
diff --git a/api/current.txt b/api/current.txt
index dff5171..0c8b872 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -24256,6 +24256,7 @@
 
   public abstract class CallService extends android.app.Service {
     ctor public CallService();
+    method public abstract void abort(java.lang.String);
     method public abstract void answer(java.lang.String);
     method public abstract void call(android.telecomm.CallInfo);
     method public abstract void disconnect(java.lang.String);
@@ -24310,7 +24311,6 @@
   public final class CallState extends java.lang.Enum {
     method public static android.telecomm.CallState valueOf(java.lang.String);
     method public static final android.telecomm.CallState[] values();
-    enum_constant public static final android.telecomm.CallState ABORTED;
     enum_constant public static final android.telecomm.CallState ACTIVE;
     enum_constant public static final android.telecomm.CallState DIALING;
     enum_constant public static final android.telecomm.CallState DISCONNECTED;
@@ -24318,6 +24318,7 @@
   }
 
   public abstract interface ICallService implements android.os.IInterface {
+    method public abstract void abort(java.lang.String) throws android.os.RemoteException;
     method public abstract void answer(java.lang.String) throws android.os.RemoteException;
     method public abstract void call(android.telecomm.CallInfo) throws android.os.RemoteException;
     method public abstract void disconnect(java.lang.String) throws android.os.RemoteException;
diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java
index 0eb96cc..f90ce97 100644
--- a/telecomm/java/android/telecomm/CallService.java
+++ b/telecomm/java/android/telecomm/CallService.java
@@ -59,8 +59,8 @@
                 case MSG_CALL:
                     call((CallInfo) msg.obj);
                     break;
-                case MSG_DISCONNECT:
-                    disconnect((String) msg.obj);
+                case MSG_ABORT:
+                    abort((String) msg.obj);
                     break;
                 case MSG_SET_INCOMING_CALL_ID:
                     setIncomingCallId((String) msg.obj);
@@ -71,6 +71,9 @@
                 case MSG_REJECT:
                     reject((String) msg.obj);
                     break;
+                case MSG_DISCONNECT:
+                    disconnect((String) msg.obj);
+                    break;
                 default:
                     break;
             }
@@ -98,8 +101,8 @@
         }
 
         @Override
-        public void disconnect(String callId) {
-            mMessageHandler.obtainMessage(MSG_DISCONNECT, callId).sendToTarget();
+        public void abort(String callId) {
+            mMessageHandler.obtainMessage(MSG_ABORT, callId).sendToTarget();
         }
 
         @Override
@@ -116,6 +119,11 @@
         public void reject(String callId) {
             mMessageHandler.obtainMessage(MSG_REJECT, callId).sendToTarget();
         }
+
+        @Override
+        public void disconnect(String callId) {
+            mMessageHandler.obtainMessage(MSG_DISCONNECT, callId).sendToTarget();
+        }
     }
 
     // Only used internally by this class.
@@ -127,10 +135,11 @@
             MSG_SET_CALL_SERVICE_ADAPTER = 1,
             MSG_IS_COMPATIBLE_WITH = 2,
             MSG_CALL = 3,
-            MSG_DISCONNECT = 4,
+            MSG_ABORT = 4,
             MSG_SET_INCOMING_CALL_ID = 5,
             MSG_ANSWER = 6,
-            MSG_REJECT = 7;
+            MSG_REJECT = 7,
+            MSG_DISCONNECT = 8;
 
     /**
      * Message handler for consolidating binder callbacks onto a single thread.
@@ -169,7 +178,7 @@
     /**
      * Determines if the CallService can place the specified call. Response is sent via
      * {@link ICallServiceAdapter#setCompatibleWith}. When responding, the correct call ID must be
-     * specified.
+     * specified.  Only used in the context of outgoing calls and call switching (handoff).
      *
      * @param callInfo The details of the relevant call.
      */
@@ -181,18 +190,22 @@
      * dynamically extensible since call providers should be able to implement arbitrary
      * handle-calling systems.  See {@link #isCompatibleWith}. It is expected that the
      * call service respond via {@link ICallServiceAdapter#handleSuccessfulOutgoingCall(String)}
-     * if it can successfully make the call.
+     * if it can successfully make the call.  Only used in the context of outgoing calls.
      *
      * @param callInfo The details of the relevant call.
      */
     public abstract void call(CallInfo callInfo);
 
     /**
-     * Disconnects the specified call.
+     * Aborts the outgoing call attempt. Invoked in the unlikely event that Telecomm decides to
+     * abort an attempt to place a call.  Only ever be invoked after {@link #call} invocations.
+     * After this is invoked, Telecomm does not expect any more updates about the call and will
+     * actively ignore any such update. This is different from {@link #disconnect} where Telecomm
+     * expects confirmation via {@link #markCallAsDisconnected}.
      *
-     * @param callId The ID of the call to disconnect.
+     * @param callId The identifier of the call to abort.
      */
-    public abstract void disconnect(String callId);
+    public abstract void abort(String callId);
 
     /**
      * Receives a new call ID to use with an incoming call. Invoked by Telecomm after it is notified
@@ -220,4 +233,11 @@
      * @param callId The ID of the call.
      */
     public abstract void reject(String callId);
+
+    /**
+     * Disconnects the specified call.
+     *
+     * @param callId The ID of the call to disconnect.
+     */
+    public abstract void disconnect(String callId);
 }
diff --git a/telecomm/java/android/telecomm/CallState.java b/telecomm/java/android/telecomm/CallState.java
index d4a45f9..d699fbd 100644
--- a/telecomm/java/android/telecomm/CallState.java
+++ b/telecomm/java/android/telecomm/CallState.java
@@ -67,6 +67,7 @@
     /**
      * Indicates that the call was attempted (mostly in the context of outgoing, at least at the
      * time of writing) but cancelled before it was successfully connected.
+     * @hide
      */
     ABORTED;
 }
diff --git a/telecomm/java/android/telecomm/ICallService.aidl b/telecomm/java/android/telecomm/ICallService.aidl
index 6f3c4d46..a4c2599 100644
--- a/telecomm/java/android/telecomm/ICallService.aidl
+++ b/telecomm/java/android/telecomm/ICallService.aidl
@@ -48,7 +48,7 @@
      * specified. It is expected that the call service respond within 500 milliseconds. Any response
      * that takes longer than 500 milliseconds will be treated as being incompatible.
      * TODO(santoscordon): 500 ms was arbitrarily chosen and must be confirmed before this
-     * API is made public.
+     * API is made public.  Only used in the context of outgoing calls and call switching (handoff).
      *
      * @param callInfo The details of the relevant call.
      */
@@ -60,7 +60,7 @@
      * dynamically extensible since call providers should be able to implement arbitrary
      * handle-calling systems.  See {@link #isCompatibleWith}. It is expected that the
      * call service respond via {@link ICallServiceAdapter#handleSuccessfulOutgoingCall} if it can
-     * successfully make the call.
+     * successfully make the call.  Only used in the context of outgoing calls.
      * TODO(santoscordon): Figure out how a call service can short-circuit a failure to the adapter.
      *
      * @param callInfo The details of the relevant call.
@@ -68,11 +68,15 @@
     void call(in CallInfo callInfo);
 
     /**
-     * Disconnects the call identified by callId.
+     * Aborts the outgoing call attempt. Invoked in the unlikely event that Telecomm decides to
+     * abort an attempt to place a call.  Only ever be invoked after {@link #call} invocations.
+     * After this is invoked, Telecomm does not expect any more updates about the call and will
+     * actively ignore any such update. This is different from {@link #disconnect} where Telecomm
+     * expects confirmation via {@link #markCallAsDisconnected}.
      *
-     * @param callId The identifier of the call to disconnect.
+     * @param callId The identifier of the call to abort.
      */
-    void disconnect(String callId);
+    void abort(String callId);
 
     /**
      * Receives a new call ID to use with an incoming call. Invoked by Telecomm after it is notified
@@ -100,4 +104,11 @@
      * @param callId The ID of the call.
      */
     void reject(String callId);
+
+    /**
+     * Disconnects the call identified by callId.  Used for outgoing and incoming calls.
+     *
+     * @param callId The identifier of the call to disconnect.
+     */
+    void disconnect(String callId);
 }