diff options
author | Sailesh Nepal <sail@google.com> | 2014-03-08 18:01:06 -0800 |
---|---|---|
committer | Sailesh Nepal <sail@google.com> | 2014-03-11 16:38:50 -0700 |
commit | ab5d282dd6f487578ae86b2d53d0d8edc9b71747 (patch) | |
tree | 5bdb3946d832b66c6c9d65a41c983b5518d55341 /telecomm/java/android | |
parent | 4d0cf0c53a8b8e331ced0874d39d6ad4a6122ffc (diff) | |
download | frameworks_base-ab5d282dd6f487578ae86b2d53d0d8edc9b71747.zip frameworks_base-ab5d282dd6f487578ae86b2d53d0d8edc9b71747.tar.gz frameworks_base-ab5d282dd6f487578ae86b2d53d0d8edc9b71747.tar.bz2 |
Add wrappers around telecomm interfaces
This CL adds wrappers for:
CallServiceLookupResponse
CallServiceAdapter
IInCallAdapter
IInCallService
This CL also moves all the aidl files into
com.android.internal.telecomm.
Change-Id: I840f023bc545643e8bb719825e7bc78344ee46ee
Diffstat (limited to 'telecomm/java/android')
14 files changed, 297 insertions, 443 deletions
diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index d1d0977..87a5372 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -24,13 +24,15 @@ import android.os.IBinder; import android.os.Message; import com.android.internal.os.SomeArgs; +import com.android.internal.telecomm.ICallService; +import com.android.internal.telecomm.ICallServiceAdapter; /** * Base implementation of CallService which can be used to provide calls for the system * in-call UI. CallService is a one-way service from the framework's CallsManager to any app * that would like to provide calls managed by the default system in-call user interface. * When the service is bound by the framework, CallsManager will call setCallServiceAdapter - * which will provide CallService with an instance of {@link ICallServiceAdapter} to be used + * which will provide CallService with an instance of {@link CallServiceAdapter} to be used * for communicating back to CallsManager. Subsequently, more specific methods of the service * will be called to perform various call actions including making an outgoing call and * disconnected existing calls. @@ -52,7 +54,9 @@ public abstract class CallService extends Service { public void handleMessage(Message msg) { switch (msg.what) { case MSG_SET_CALL_SERVICE_ADAPTER: - setCallServiceAdapter((ICallServiceAdapter) msg.obj); + CallServiceAdapter adapter = + new CallServiceAdapter((ICallServiceAdapter) msg.obj); + setCallServiceAdapter(adapter); break; case MSG_IS_COMPATIBLE_WITH: isCompatibleWith((CallInfo) msg.obj); @@ -177,18 +181,16 @@ public abstract class CallService extends Service { } /** - * Sets an implementation of ICallServiceAdapter for adding new calls and communicating state + * Sets an implementation of CallServiceAdapter for adding new calls and communicating state * changes of existing calls. - * TODO(santoscordon): Should we not reference ICallServiceAdapter directly from here? Should we - * wrap that in a wrapper like we do for CallService/ICallService? * * @param callServiceAdapter Adapter object for communicating call to CallsManager */ - public abstract void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); + public abstract void setCallServiceAdapter(CallServiceAdapter callServiceAdapter); /** * Determines if the CallService can place the specified call. Response is sent via - * {@link ICallServiceAdapter#setCompatibleWith}. When responding, the correct call ID must be + * {@link CallServiceAdapter#setCompatibleWith}. When responding, the correct call ID must be * specified. Only used in the context of outgoing calls and call switching (handoff). * * @param callInfo The details of the relevant call. @@ -200,7 +202,7 @@ public abstract class CallService extends Service { * SIP address, or some other kind of user ID. Note that the set of handle types is * 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)} + * call service respond via {@link CallServiceAdapter#handleSuccessfulOutgoingCall(String)} * if it can successfully make the call. Only used in the context of outgoing calls. * * @param callInfo The details of the relevant call. @@ -212,7 +214,7 @@ public abstract class CallService extends Service { * 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 ICallServiceAdapter.markCallAsDisconnected. + * expects confirmation via CallServiceAdapter.markCallAsDisconnected. * * @param callId The identifier of the call to abort. */ @@ -222,7 +224,7 @@ public abstract class CallService extends Service { * Receives a new call ID to use with an incoming call. Invoked by Telecomm after it is notified * that this call service has a pending incoming call, see * {@link TelecommConstants#ACTION_INCOMING_CALL}. The call service must first give Telecomm - * additional information about the call through {@link ICallServiceAdapter#handleIncomingCall}. + * additional information about the call through {@link CallServiceAdapter#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 diff --git a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl b/telecomm/java/android/telecomm/CallServiceAdapter.java index 2e03d39..a391f34 100644 --- a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl +++ b/telecomm/java/android/telecomm/CallServiceAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 The Android Open Source Project + * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,36 +16,54 @@ package android.telecomm; -import android.telecomm.CallInfo; +import android.os.RemoteException; + +import com.android.internal.telecomm.ICallServiceAdapter; /** * Provides methods for ICallService implementations to interact with the system phone app. * TODO(santoscordon): Need final public-facing comments in this file. */ -oneway interface ICallServiceAdapter { +public final class CallServiceAdapter { + private final ICallServiceAdapter mAdapter; + + /** + * {@hide} + */ + public CallServiceAdapter(ICallServiceAdapter adapter) { + mAdapter = adapter; + } /** * Receives confirmation of a call service's ability to place a call. This method is used in - * response to {@link ICallService#isCompatibleWith}. - * TODO(santoscordon): rename to setIsCompatibleWith(). + * response to {@link CallService#isCompatibleWith}. * * @param callId The identifier of the call for which compatibility is being received. This ID * should correspond to the ID given as part of the call information in - * {@link ICallService#isCompatibleWith}. + * {@link CallService#isCompatibleWith}. * @param isCompatible True if the call service can place the call. */ - void setCompatibleWith(String callId, boolean isCompatible); + public void setIsCompatibleWith(String callId, boolean isCompatible) { + try { + mAdapter.setIsCompatibleWith(callId, isCompatible); + } catch (RemoteException e) { + } + } /** * Provides Telecomm with the details of an incoming call. An invocation of this method must * follow {@link CallService#setIncomingCallId} and use the call ID specified therein. Upon * the invocation of this method, Telecomm will bring up the incoming-call interface where the * user can elect to answer or reject a call. - * TODO(santoscordon): Consider renaming from handle* to notify*. * * @param callInfo The details of the relevant call. */ - void handleIncomingCall(in CallInfo callInfo); + public void notifyIncomingCall(CallInfo callInfo) { + try { + mAdapter.notifyIncomingCall(callInfo); + } catch (RemoteException e) { + } + } /** * Tells Telecomm that an attempt to place the specified outgoing call succeeded. @@ -54,7 +72,12 @@ oneway interface ICallServiceAdapter { * * @param callId The ID of the outgoing call. */ - void handleSuccessfulOutgoingCall(String callId); + public void handleSuccessfulOutgoingCall(String callId) { + try { + mAdapter.handleSuccessfulOutgoingCall(callId); + } catch (RemoteException e) { + } + } /** * Tells Telecomm that an attempt to place the specified outgoing call failed. @@ -62,7 +85,12 @@ oneway interface ICallServiceAdapter { * @param callId The ID of the outgoing call. * @param errorMessage The error associated with the failed call attempt. */ - void handleFailedOutgoingCall(String callId, String errorMessage); + public void handleFailedOutgoingCall(String callId, String errorMessage) { + try { + mAdapter.handleFailedOutgoingCall(callId, errorMessage); + } catch (RemoteException e) { + } + } /** * Sets a call's state to active (e.g., an ongoing call where two parties can actively @@ -70,26 +98,46 @@ oneway interface ICallServiceAdapter { * * @param callId The unique ID of the call whose state is changing to active. */ - void setActive(String callId); + public void setActive(String callId) { + try { + mAdapter.setActive(callId); + } catch (RemoteException e) { + } + } /** * Sets a call's state to ringing (e.g., an inbound ringing call). * * @param callId The unique ID of the call whose state is changing to ringing. */ - void setRinging(String callId); + public void setRinging(String callId) { + try { + mAdapter.setRinging(callId); + } catch (RemoteException e) { + } + } /** * Sets a call's state to dialing (e.g., dialing an outbound call). * * @param callId The unique ID of the call whose state is changing to dialing. */ - void setDialing(String callId); + public void setDialing(String callId) { + try { + mAdapter.setDialing(callId); + } catch (RemoteException e) { + } + } /** * Sets a call's state to disconnected. * * @param callId The unique ID of the call whose state is changing to disconnected. */ - void setDisconnected(String callId); + public void setDisconnected(String callId) { + try { + mAdapter.setDisconnected(callId); + } catch (RemoteException e) { + } + } } diff --git a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl b/telecomm/java/android/telecomm/CallServiceLookupResponse.java index 2f27257..dd35a24 100644 --- a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl +++ b/telecomm/java/android/telecomm/CallServiceLookupResponse.java @@ -16,20 +16,36 @@ package android.telecomm; -import android.os.IBinder; -import android.telecomm.CallServiceDescriptor; +import android.os.RemoteException; + +import com.android.internal.telecomm.ICallServiceLookupResponse; + import java.util.List; /** - * Used by {@link ICallServiceProvider} to return a list of {@link CallServiceDescriptor}s. + * Used by {@link CallServiceProvider} to return a list of {@link CallServiceDescriptor}s. */ -oneway interface ICallServiceLookupResponse { +public final class CallServiceLookupResponse { + private final ICallServiceLookupResponse mResponse; + + /** + * {@hide} + */ + public CallServiceLookupResponse(ICallServiceLookupResponse response) { + mResponse = response; + } + /** * Passes the sorted list of preferred {@link CallServiceDescriptor}s back to Telecomm. Used * in the context of attempting to place a pending outgoing call. * * @param callServiceDescriptors The set of call-service descriptors from - * {@link ICallServiceProvider}. + * {@link CallServiceProvider}. */ - void setCallServiceDescriptors(in List<CallServiceDescriptor> callServiceDescriptors); + public void setCallServiceDescriptors(List<CallServiceDescriptor> callServiceDescriptors) { + try { + mResponse.setCallServiceDescriptors(callServiceDescriptors); + } catch (RemoteException e) { + } + } } diff --git a/telecomm/java/android/telecomm/CallServiceProvider.java b/telecomm/java/android/telecomm/CallServiceProvider.java index 64294d8..5db7e2e 100644 --- a/telecomm/java/android/telecomm/CallServiceProvider.java +++ b/telecomm/java/android/telecomm/CallServiceProvider.java @@ -22,8 +22,8 @@ import android.os.Handler; import android.os.IBinder; import android.os.Message; -import android.telecomm.ICallServiceProvider; -import android.telecomm.ICallServiceLookupResponse; +import com.android.internal.telecomm.ICallServiceLookupResponse; +import com.android.internal.telecomm.ICallServiceProvider; /** * Base implementation of {@link ICallServiceProvider} which extends {@link Service}. This class @@ -45,9 +45,9 @@ public abstract class CallServiceProvider extends Service { public void handleMessage(Message msg) { switch (msg.what) { case MSG_LOOKUP_CALL_SERVICES: - lookupCallServices((ICallServiceLookupResponse) msg.obj); - break; - default: + CallServiceLookupResponse response = + new CallServiceLookupResponse((ICallServiceLookupResponse) msg.obj); + lookupCallServices(response); break; } } @@ -100,10 +100,10 @@ public abstract class CallServiceProvider extends Service { } /** - * Initiates the process to retrieve the list of {@link ICallService}s implemented by + * Initiates the process to retrieve the list of {@link CallServiceDescriptor}s implemented by * this provider. * * @param response The response object through which the list of call services is sent. */ - public abstract void lookupCallServices(ICallServiceLookupResponse response); + public abstract void lookupCallServices(CallServiceLookupResponse response); } diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java index 6937bdf..44181d1 100644 --- a/telecomm/java/android/telecomm/CallServiceSelector.java +++ b/telecomm/java/android/telecomm/CallServiceSelector.java @@ -26,6 +26,9 @@ import android.os.RemoteException; import android.util.Log; import com.android.internal.os.SomeArgs; +import com.android.internal.telecomm.ICallServiceSelector; +import com.android.internal.telecomm.ICallServiceSelectionResponse; +import com.android.internal.telecomm.ICallSwitchabilityResponse; import java.util.List; @@ -108,7 +111,7 @@ public abstract class CallServiceSelector extends Service { } }; - /** Manages the binder calls so that the implementor does not need to deal it. */ + /** Manages the binder calls so that the implementor does not need to deal with it. */ private final class CallServiceSelectorBinder extends ICallServiceSelector.Stub implements CallSwitchabilityResponse, CallServiceSelectionResponse { private ICallSwitchabilityResponse mSwitchabilityResponse; diff --git a/telecomm/java/android/telecomm/ICallService.aidl b/telecomm/java/android/telecomm/ICallService.aidl deleted file mode 100644 index 28f19ca..0000000 --- a/telecomm/java/android/telecomm/ICallService.aidl +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.telecomm; - -import android.os.Bundle; -import android.telecomm.CallInfo; -import android.telecomm.ICallServiceAdapter; - -/** - * Service interface for services which would like to provide calls to be - * managed by the system in-call UI. - * - * This interface provides methods that the android framework can use to deliver commands - * for calls provided by this call service including making new calls and disconnecting - * existing ones. A binding to ICallService implementations exists for two conditions: - * 1) There exists one or more live calls for that call service, - * 2) Prior to an outbound call to test if this call service is compatible with the outgoing call. - * - * TODO(santoscordon): Need final public-facing comments in this file. - */ -oneway interface ICallService { - - /** - * Sets an implementation of ICallServiceAdapter which the call service can use to add new calls - * and communicate state changes of existing calls. This is the first method that is called - * after a the framework binds to the call service. - * - * @param callServiceAdapter Interface to CallsManager for adding and updating calls. - */ - void setCallServiceAdapter(in ICallServiceAdapter callServiceAdapter); - - /** - * Determines if the ICallService can place the specified call. Response is sent via - * {@link ICallServiceAdapter#setCompatibleWith}. When responding, the correct call ID must be - * 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. Only used in the context of outgoing calls and call switching (handoff). - * - * @param callInfo The details of the relevant call. - */ - void isCompatibleWith(in CallInfo callInfo); - - /** - * Attempts to call the relevant party using the specified call's handle, be it a phone number, - * SIP address, or some other kind of user ID. Note that the set of handle types is - * 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. 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. - */ - void call(in CallInfo callInfo); - - /** - * 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 ICallServiceAdapter.markCallAsDisconnected. - * - * @param callId The identifier of the call to abort. - */ - void abort(String callId); - - /** - * Receives a new call ID to use with an incoming call. Invoked by Telecomm after it is notified - * that this call service has a pending incoming call, see - * {@link TelecommConstants#ACTION_INCOMING_CALL}. The call service must first give Telecomm - * 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, in Bundle extras); - - /** - * Answers a ringing call identified by callId. Telecomm invokes this method as a result of the - * user hitting the "answer" button in the incoming call screen. - * - * @param callId The ID of the call. - */ - void answer(String callId); - - /** - * Rejects a ringing call identified by callId. Telecomm invokes this method as a result of the - * user hitting the "reject" button in the incoming call screen. - * - * @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); -} diff --git a/telecomm/java/android/telecomm/ICallServiceProvider.aidl b/telecomm/java/android/telecomm/ICallServiceProvider.aidl deleted file mode 100644 index 8b0a736..0000000 --- a/telecomm/java/android/telecomm/ICallServiceProvider.aidl +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.telecomm; - -import android.telecomm.ICallServiceLookupResponse; - -/** - * Interface for applications interested in providing call-service implementations. Only used in - * outgoing-call scenarios where the best-candidate service to issue the call over may need to be - * decided dynamically (unlike incoming call scenario where the call-service is known). - * - * Intended usage at time of writing is: Call intent received by the CallsManager, which in turn - * gathers and binds all ICallServiceProvider implementations (using the framework). Once bound, the - * CallsManager invokes the lookupCallServices API of each bound provider and waits until - * either all providers reply (asynchronously) or some timeout is met. The resulted list is then - * processed by the CallsManager and its helpers (potentially requesting input from the user) to - * identify the best CallService. The user should obviously be notified upon zero candidates as - * well as all (one or more) candidates failing to issue the call. - */ -oneway interface ICallServiceProvider { - - /** - * Initiates the process to retrieve the list of {@link ICallService}s implemented by - * this provider. - * TODO(santoscordon): Needs comments on how to populate the list within - * ICallServiceLookupResponse and how to handle error conditions. - * - * @param response The response object through which the list of call services is sent. - */ - void lookupCallServices(in ICallServiceLookupResponse response); -} diff --git a/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl b/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl deleted file mode 100644 index 51efb8e..0000000 --- a/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.telecomm; - -import android.os.IBinder; -import android.telecomm.CallServiceDescriptor; -import java.util.List; - -/** - * Used by {@link ICallServiceSelector} to return the preferred list of {@link ICallService} - * implementations with which to connect the corresponding outgoing call. - */ -oneway interface ICallServiceSelectionResponse { - /** - * Records the sorted set of call services that are preferred by the corresponding - * call-service selector. - * - * @param selectedCallServiceDescriptors The prioritized list of preferred call-service - * descriptors to use for completing the call. - */ - void setSelectedCallServiceDescriptors( - in List<CallServiceDescriptor> selectedCallServiceDescriptors); -} diff --git a/telecomm/java/android/telecomm/ICallServiceSelector.aidl b/telecomm/java/android/telecomm/ICallServiceSelector.aidl deleted file mode 100644 index 8ca4c0c..0000000 --- a/telecomm/java/android/telecomm/ICallServiceSelector.aidl +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.telecomm; - -import android.telecomm.CallInfo; -import android.telecomm.CallServiceDescriptor; -import android.telecomm.ICallService; -import android.telecomm.ICallServiceSelectionResponse; -import android.telecomm.ICallSwitchabilityResponse; - -import java.util.List; - -/** - * Interface for call-service selector implementations. - * - * Call-service selectors are ultimately responsible for deciding which of the available call - * service implementations should be used to place an outgoing call, as well as which service - * to switch the call to upon system-provided opportunities to switch call services. - * - * Outgoing call scenario: - * - * Telecomm maintains a prioritized list of call-service selectors. Upon attempting to issue - * outgoing calls, the switchboard iterates through these (starting with the highest-priority - * selector). It then invokes the "select" API below passing -- among other parameters -- the - * list of available call services, excluding fully-utilized services that temporarily aren't - * capable of accommodating additional calls. Once invoked, selectors return a sorted subset - * from the specified list, containing the preferred services through which to place the call. - * Upon empty selection the switchboard continues to the next selector. Otherwise, upon non- - * empty selection, the returned call services are attempted in the specified order. The flow - * is concluded either when the call is placed by one of the specified services (e.g. ringing) - * or upon failure to connect by the time the set of selectors is exhausted. Failed calls are - * essentially abandoned by this flow and then picked up by the switchboard's monitor. - * - * Note that attempted-yet-failed call services within one outgoing-call cycle may be omitted - * from the set passed to the next selector. As for selector priority, at the time of writing - * this is intended to be a blend of built-in priorities (e.g. to handle emergency calls) and - * user-specified preferences (via settings, e.g. electing to use a particular selector prior - * to attempting the system-default call-service selector). - * - * Call-services switching scenario (applying to both incoming and outgoing calls): - * - * The switchboard may invoke any active selector (a selector associated with one or more on- - * going calls) up to once per ongoing call at its discretion (e.g. periodically), once again - * passing the available call services to the "select" API. As in the outgoing-call scenario - * above, returning the empty list means "pass" -- basically indicating that the current call - * service for this call need not be switched at this time. In cases where switching isn't at - * all supported (either for a given call or globally across a given selector) , isSwitchable - * below can return false blindly to suppress all "select" calls beyond the initial one (that - * is used to establish outgoing calls). - */ -oneway interface ICallServiceSelector { - - /** - * Initiates the process to retrieve the sorted set of call services that are preferred by - * this call-service selector. - * - * @param callInfo The details of the relevant call. - * @param callServiceDescriptors The list of call-service descriptors to select from. - * @param response The response object through which the selected service IDs are passed back - * to Telecomm. - */ - void select( - in CallInfo callInfo, - in List<CallServiceDescriptor> callServiceDescriptors, - in ICallServiceSelectionResponse response); - - /** - * Determines if the specified ongoing call can/should be switched from the currently-used - * call service to another. - * - * @param callInfo The details of the relevant call. - * @param response The response object to be populated and returned to switchboard. - */ - void isSwitchable(in CallInfo callInfo, in ICallSwitchabilityResponse response); -} diff --git a/telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl b/telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl deleted file mode 100644 index afb4122..0000000 --- a/telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.telecomm; - -/** - * Used by {@link ICallServiceSelector}s to return whether or not the relevant - * call is switchable. - */ -oneway interface ICallSwitchabilityResponse { - /** - * Records whether or not the corresponding call can potentially be switched to another - * call service. - * - * @param isSwitchable True if the associated call-service selector may be interested - * in switching call services. Setting isSwitchable to true should generally - * guarantee the "select" API of the associated selector to be invoked, hence - * allowing the selector to return either the empty list (meaning pass, don't - * switch) or the prioritized list of call-services to attempt switching to. - */ - void setIsSwitchable(boolean isSwitchable); -} diff --git a/telecomm/java/android/telecomm/IInCallService.aidl b/telecomm/java/android/telecomm/IInCallService.aidl deleted file mode 100644 index bc3a6b6..0000000 --- a/telecomm/java/android/telecomm/IInCallService.aidl +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.telecomm; - -import android.telecomm.CallInfo; -import android.telecomm.IInCallAdapter; - -/** - * This service is implemented by any app that wishes to provide the user-interface for managing - * phone calls. Telecomm binds to this service while there exists a live (active or incoming) - * call, and uses it to notify the in-call app of any live and and recently disconnected calls. - * TODO(santoscordon): Needs more/better description of lifecycle once the interface is better - * defined. - * TODO(santoscordon): What happens if two or more apps on a given decide implement this interface? - */ -oneway interface IInCallService { - - /** - * Provides the in-call app an adapter object through which to send call-commands such as - * answering and rejecting incoming calls, disconnecting active calls, and putting calls in - * special states (mute, hold, etc). - * - * @param inCallAdapter Adapter through which an in-call app can send call-commands to Telecomm. - */ - void setInCallAdapter(in IInCallAdapter inCallAdapter); - - /** - * Indicates to the in-call app that a new call has been created and an appropriate - * user-interface should be built and shown to notify the user. Information about the call - * including its current state is passed in through the callInfo object. - * - * @param callInfo Information about the new call. - */ - void addCall(in CallInfo callInfo); - - /** - * Indicates to the in-call app that a call has moved to the active state. - * TODO(santoscordon): link javadoc to "active" constant once CallState is defined. - * - * @param callId The identifier of the call that became active. - */ - void setActive(String callId); - - /** - * Indicates to the in-call app that a call has been disconnected and the user should be - * notified. - * TODO(santoscordon): link javadoc to "disconnected" constant once CallState is defined. - * TODO(santoscordon): Needs disconnect-cause either as a numberical constant, string or both - * depending on what is ultimately needed to support all scenarios. - * - * @param callId The identifier of the call that was disconnected. - */ - void setDisconnected(String callId); -} diff --git a/telecomm/java/android/telecomm/IInCallAdapter.aidl b/telecomm/java/android/telecomm/InCallAdapter.java index 9fb7d4d..c9bd8c2 100644 --- a/telecomm/java/android/telecomm/IInCallAdapter.aidl +++ b/telecomm/java/android/telecomm/InCallAdapter.java @@ -16,26 +16,42 @@ package android.telecomm; +import android.os.RemoteException; + +import com.android.internal.telecomm.IInCallAdapter; + /** - * Receives commands from {@link IInCallService} implementations which should be executed by - * Telecomm. When Telecomm binds to a {@link IInCallService}, an instance of this class is given to + * Receives commands from {@link InCallService} implementations which should be executed by + * Telecomm. When Telecomm binds to a {@link InCallService}, an instance of this class is given to * the in-call service through which it can manipulate live (active, dialing, ringing) calls. When - * the in-call service is notified of new calls ({@link IInCallService#addCall}), it can use the + * the in-call service is notified of new calls ({@link InCallService#addCall}), it can use the * given call IDs to execute commands such as {@link #answerCall} for incoming calls or * {@link #disconnectCall} for active calls the user would like to end. Some commands are only * appropriate for calls in certain states; please consult each method for such limitations. * TODO(santoscordon): Needs more/better comments once the API is finalized. * TODO(santoscordon): Specify the adapter will stop functioning when there are no more calls. - * TODO(santoscordon): Once we have proper "CallState" constant definitions, consider rewording - * the javadoc to reference those states precisely. */ -oneway interface IInCallAdapter { +public final class InCallAdapter { + private final IInCallAdapter mAdapter; + + /** + * {@hide} + */ + public InCallAdapter(IInCallAdapter adapter) { + mAdapter = adapter; + } + /** * Instructs Telecomm to answer the specified call. * * @param callId The identifier of the call to answer. */ - void answerCall(String callId); + public void answerCall(String callId) { + try { + mAdapter.answerCall(callId); + } catch (RemoteException e) { + } + } /** * Instructs Telecomm to reject the specified call. @@ -44,12 +60,22 @@ oneway interface IInCallAdapter { * * @param callId The identifier of the call to reject. */ - void rejectCall(String callId); + public void rejectCall(String callId) { + try { + mAdapter.rejectCall(callId); + } catch (RemoteException e) { + } + } /** * Instructs Telecomm to disconnect the specified call. * * @param callId The identifier of the call to disconnect. */ - void disconnectCall(String callId); + public void disconnectCall(String callId) { + try { + mAdapter.disconnectCall(callId); + } catch (RemoteException e) { + } + } } diff --git a/telecomm/java/android/telecomm/InCallService.java b/telecomm/java/android/telecomm/InCallService.java new file mode 100644 index 0000000..7819d44 --- /dev/null +++ b/telecomm/java/android/telecomm/InCallService.java @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.app.Service; +import android.content.Intent; +import android.os.Handler; +import android.os.IBinder; +import android.os.Looper; +import android.os.Message; + +import com.android.internal.telecomm.IInCallAdapter; +import com.android.internal.telecomm.IInCallService; + +/** + * This service is implemented by any app that wishes to provide the user-interface for managing + * phone calls. Telecomm binds to this service while there exists a live (active or incoming) + * call, and uses it to notify the in-call app of any live and and recently disconnected calls. + * TODO(santoscordon): Needs more/better description of lifecycle once the interface is better + * defined. + * TODO(santoscordon): What happens if two or more apps on a given device implement this interface? + */ +public abstract class InCallService extends Service { + private static final int MSG_SET_IN_CALL_ADAPTER = 1; + private static final int MSG_ADD_CALL = 2; + private static final int MSG_SET_ACTIVE = 3; + private static final int MSG_SET_DISCONNECTED = 4; + + /** Default Handler used to consolidate binder method calls onto a single thread. */ + private final Handler mHandler = new Handler(Looper.getMainLooper()) { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MSG_SET_IN_CALL_ADAPTER: + InCallAdapter adapter = new InCallAdapter((IInCallAdapter) msg.obj); + setInCallAdapter(adapter); + break; + case MSG_ADD_CALL: + addCall((CallInfo) msg.obj); + break; + case MSG_SET_ACTIVE: + setActive((String) msg.obj); + break; + case MSG_SET_DISCONNECTED: + setDisconnected((String) msg.obj); + break; + default: + break; + } + } + }; + + /** Manages the binder calls so that the implementor does not need to deal with it. */ + private final class InCallServiceBinder extends IInCallService.Stub { + /** {@inheritDoc} */ + @Override + public void setInCallAdapter(IInCallAdapter inCallAdapter) { + mHandler.obtainMessage(MSG_SET_IN_CALL_ADAPTER, inCallAdapter).sendToTarget(); + } + + /** {@inheritDoc} */ + @Override + public void addCall(CallInfo callInfo) { + mHandler.obtainMessage(MSG_ADD_CALL, callInfo).sendToTarget(); + } + + /** {@inheritDoc} */ + @Override + public void setActive(String callId) { + mHandler.obtainMessage(MSG_SET_ACTIVE, callId).sendToTarget(); + } + + /** {@inheritDoc} */ + @Override + public void setDisconnected(String callId) { + mHandler.obtainMessage(MSG_SET_DISCONNECTED, callId).sendToTarget(); + } + } + + private final InCallServiceBinder mBinder; + + protected InCallService() { + mBinder = new InCallServiceBinder(); + } + + @Override + public final IBinder onBind(Intent intent) { + return mBinder; + } + + /** + * Provides the in-call app an adapter object through which to send call-commands such as + * answering and rejecting incoming calls, disconnecting active calls, and putting calls in + * special states (mute, hold, etc). + * + * @param inCallAdapter Adapter through which an in-call app can send call-commands to Telecomm. + */ + protected abstract void setInCallAdapter(InCallAdapter inCallAdapter); + + /** + * Indicates to the in-call app that a new call has been created and an appropriate + * user-interface should be built and shown to notify the user. Information about the call + * including its current state is passed in through the callInfo object. + * + * @param callInfo Information about the new call. + */ + protected abstract void addCall(CallInfo callInfo); + + /** + * Indicates to the in-call app that a call has moved to the {@link CallState#ACTIVE} state. + * + * @param callId The identifier of the call that became active. + */ + protected abstract void setActive(String callId); + + /** + * Indicates to the in-call app that a call has been moved to the + * {@link CallState#DISCONNECTED} and the user should be notified. + * TODO(santoscordon): Needs disconnect-cause either as a numberical constant, string or both + * depending on what is ultimately needed to support all scenarios. + * + * @param callId The identifier of the call that was disconnected. + */ + protected abstract void setDisconnected(String callId); +} diff --git a/telecomm/java/android/telecomm/TelecommConstants.java b/telecomm/java/android/telecomm/TelecommConstants.java index 564f0cb..e6a086a 100644 --- a/telecomm/java/android/telecomm/TelecommConstants.java +++ b/telecomm/java/android/telecomm/TelecommConstants.java @@ -39,6 +39,21 @@ public final class TelecommConstants { public static final String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL"; /** + * The service action used to bind to {@link CallServiceProvider} implementations. + */ + public static final String ACTION_CALL_SERVICE_PROVIDER = CallServiceProvider.class.getName(); + + /** + * The service action used to bind to {@link CallService} implementations. + */ + public static final String ACTION_CALL_SERVICE = CallService.class.getName(); + + /** + * The service action used to bind to {@link CallServiceSelector} implementations. + */ + public static final String ACTION_CALL_SERVICE_SELECTOR = CallServiceSelector.class.getName(); + + /** * Extra for {@link #ACTION_INCOMING_CALL} containing the {@link CallServiceDescriptor} that * describes the call service to use for the incoming call. */ |