OSDN Git Service

Add optional data to incoming calls
authorEvan Charlton <evanc@google.com>
Wed, 5 Mar 2014 16:21:52 +0000 (08:21 -0800)
committerEvan Charlton <evanc@google.com>
Wed, 5 Mar 2014 22:01:52 +0000 (14:01 -0800)
When a CallService creates an incoming call, allow it to pass a Bundle
of arbitrary data along with the intent. This data will be returned to
the CallService via setIncomingCallId. This makes it easier for
CallServices to match up incoming calls with their IDs.

Change-Id: I52e7e1d0788ecd01aa427e76de7ccf4d9b75f1f0

api/current.txt
telecomm/java/android/telecomm/CallService.java
telecomm/java/android/telecomm/ICallService.aidl
telecomm/java/android/telecomm/TelecommConstants.java

index dff5171..b6905c0 100644 (file)
@@ -24264,7 +24264,7 @@ package android.telecomm {
     method public final android.os.IBinder onBind(android.content.Intent);
     method public abstract void reject(java.lang.String);
     method public abstract void setCallServiceAdapter(android.telecomm.ICallServiceAdapter);
-    method public abstract void setIncomingCallId(java.lang.String);
+    method public abstract void setIncomingCallId(java.lang.String, android.os.Bundle);
   }
 
   public final class CallServiceDescriptor implements android.os.Parcelable {
@@ -24324,7 +24324,7 @@ package android.telecomm {
     method public abstract void isCompatibleWith(android.telecomm.CallInfo) throws android.os.RemoteException;
     method public abstract void reject(java.lang.String) throws android.os.RemoteException;
     method public abstract void setCallServiceAdapter(android.telecomm.ICallServiceAdapter) throws android.os.RemoteException;
-    method public abstract void setIncomingCallId(java.lang.String) throws android.os.RemoteException;
+    method public abstract void setIncomingCallId(java.lang.String, android.os.Bundle) throws android.os.RemoteException;
   }
 
   public static abstract class ICallService.Stub extends android.os.Binder implements android.telecomm.ICallService {
@@ -24439,6 +24439,7 @@ package android.telecomm {
     ctor public TelecommConstants();
     field public static final java.lang.String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL";
     field public static final java.lang.String EXTRA_CALL_SERVICE_DESCRIPTOR = "android.intent.extra.CALL_SERVICE_DESCRIPTOR";
+    field public static final java.lang.String EXTRA_INCOMING_CALL_EXTRAS = "android.intent.extra.INCOMING_CALL_EXTRAS";
   }
 
 }
index 0eb96cc..8767ffa 100644 (file)
@@ -18,6 +18,7 @@ package android.telecomm;
 
 import android.app.Service;
 import android.content.Intent;
+import android.os.Bundle;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Message;
@@ -63,7 +64,14 @@ public abstract class CallService extends Service {
                     disconnect((String) msg.obj);
                     break;
                 case MSG_SET_INCOMING_CALL_ID:
-                    setIncomingCallId((String) msg.obj);
+                    SomeArgs args = (SomeArgs) msg.obj;
+                    try {
+                        String callId = (String) args.arg1;
+                        Bundle extras = (Bundle) args.arg2;
+                        setIncomingCallId(callId, extras);
+                    } finally {
+                        args.recycle();
+                    }
                     break;
                 case MSG_ANSWER:
                     answer((String) msg.obj);
@@ -103,8 +111,11 @@ public abstract class CallService extends Service {
         }
 
         @Override
-        public void setIncomingCallId(String callId) {
-            mMessageHandler.obtainMessage(MSG_SET_INCOMING_CALL_ID, callId).sendToTarget();
+        public void setIncomingCallId(String callId, Bundle extras) {
+            SomeArgs args = SomeArgs.obtain();
+            args.arg1 = callId;
+            args.arg2 = extras;
+            mMessageHandler.obtainMessage(MSG_SET_INCOMING_CALL_ID, args).sendToTarget();
         }
 
         @Override
@@ -201,9 +212,14 @@ public abstract class CallService extends Service {
      * additional information about the call through {@link ICallServiceAdapter#handleIncomingCall}.
      * Following that, the call service can update the call at will using the specified call ID.
      *
+     * If a {@link Bundle} was passed (via {@link TelecommConstants#EXTRA_INCOMING_CALL_EXTRAS}) in
+     * with the {@link TelecommConstants#ACTION_INCOMING_CALL} intent, <code>extras</code> will be
+     * populated with this {@link Bundle}. Otherwise, an empty Bundle will be returned.
+     *
      * @param callId The ID of the call.
+     * @param extras The optional extras which were passed in with the intent, or an empty Bundle.
      */
-    public abstract void setIncomingCallId(String callId);
+    public abstract void setIncomingCallId(String callId, Bundle extras);
 
     /**
      * Answers a ringing call identified by callId. Telecomm invokes this method as a result of the
index 6f3c4d4..382bdd5 100644 (file)
@@ -16,6 +16,7 @@
 
 package android.telecomm;
 
+import android.os.Bundle;
 import android.telecomm.CallInfo;
 import android.telecomm.ICallServiceAdapter;
 
@@ -81,9 +82,15 @@ oneway interface ICallService {
      * additional information of the call through {@link ICallServiceAdapter#handleIncomingCall}.
      * Following that, the call service can update the call at will using the specified call ID.
      *
+     * As part of the {@link TelecommConstants#ACTION_INCOMING_CALL} Intent, a  Bundle of extra
+     * data could be sent via {@link TelecommConstants#EXTRA_INCOMING_CALL_EXTRAS}, which is
+     * returned through this method. If no data was given, an empty Bundle will be returned.
+     *
      * @param callId The ID of the call.
+     * @param extras The Bundle of extra information passed via
+     *     {@link TelecommConstants#EXTRA_INCOMING_CALL_EXTRAS}.
      */
-    void setIncomingCallId(String callId);
+    void setIncomingCallId(String callId, in Bundle extras);
 
     /**
      * Answers a ringing call identified by callId. Telecomm invokes this method as a result of the
index b0651c8..564f0cb 100644 (file)
@@ -16,6 +16,8 @@
 
 package android.telecomm;
 
+import android.os.Bundle;
+
 /**
  * Defines constants for use with the Telecomm system.
  */
@@ -42,4 +44,12 @@ public final class TelecommConstants {
      */
     public static final String EXTRA_CALL_SERVICE_DESCRIPTOR =
             "android.intent.extra.CALL_SERVICE_DESCRIPTOR";
+
+    /**
+     * Optional extra for {@link #ACTION_INCOMING_CALL} containing a {@link Bundle} which contains
+     * metadata about the call. This {@link Bundle} will be returned to the {@link CallService} as
+     * part of {@link CallService#setIncomingCallId(String,Bundle)}.
+     */
+    public static final String EXTRA_INCOMING_CALL_EXTRAS =
+            "android.intent.extra.INCOMING_CALL_EXTRAS";
 }