summaryrefslogtreecommitdiffstats
path: root/telecomm
diff options
context:
space:
mode:
authorSailesh Nepal <sail@google.com>2014-04-01 20:09:57 -0700
committerSailesh Nepal <sail@google.com>2014-04-01 20:15:04 -0700
commit8d20561554e159f31a30075c23cfeb6d477aa27e (patch)
tree0448cd04e56f085243db9c7ae8503241b9293eb2 /telecomm
parent67e2fe292f6f505acecc89c7b455adddcebb1018 (diff)
downloadframeworks_base-8d20561554e159f31a30075c23cfeb6d477aa27e.zip
frameworks_base-8d20561554e159f31a30075c23cfeb6d477aa27e.tar.gz
frameworks_base-8d20561554e159f31a30075c23cfeb6d477aa27e.tar.bz2
Add CallServiceSelectorAdapter
Previously the selector would communicate with Telecomm using callbacks. For handoff, it's easier to communicate using an adapter. Bug: 13643568 Change-Id: Ida5859a3b5b15c9fa1c533f27a3e14fd0d7c36af
Diffstat (limited to 'telecomm')
-rw-r--r--telecomm/java/android/telecomm/CallServiceSelector.java157
-rw-r--r--telecomm/java/android/telecomm/CallServiceSelectorAdapter.java72
-rw-r--r--telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl14
-rw-r--r--telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl24
-rw-r--r--telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl65
-rw-r--r--telecomm/java/com/android/internal/telecomm/ICallServiceSelectorAdapter.aidl (renamed from telecomm/java/com/android/internal/telecomm/ICallServiceSelectionResponse.aidl)27
-rw-r--r--telecomm/java/com/android/internal/telecomm/ICallSwitchabilityResponse.aidl36
7 files changed, 130 insertions, 265 deletions
diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java
index 44181d1..8eec142 100644
--- a/telecomm/java/android/telecomm/CallServiceSelector.java
+++ b/telecomm/java/android/telecomm/CallServiceSelector.java
@@ -23,145 +23,58 @@ import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
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 com.android.internal.telecomm.ICallServiceSelectorAdapter;
import java.util.List;
/**
* Allows for the organization of {@link CallService}s for outbound calls. Given a call and list of
* {@link CallService} IDs, order the list in terms of priority and return it using
- * {@link #select(CallInfo, List, CallServiceSelectionResponse)}. <br />
- * <br />
- * Also determine whether a call is switchable (can be moved between {@link CallService}s) or not
- * using {@link #isSwitchable(CallInfo, CallSwitchabilityResponse)}.
+ * {@link #select(CallInfo, List)}.
*/
public abstract class CallServiceSelector extends Service {
- private static final String TAG = CallServiceSelector.class.getSimpleName();
-
- /**
- * Used to tell {@link #mHandler} to move the call to
- * {@link CallServiceSelector#isSwitchable(CallInfo, CallSwitchabilityResponse)} to the main
- * thread.
- */
- private static final int MSG_IS_SWITCHABLE = 1;
-
- /**
- * Used to tell {@link #mHandler} to move the call to
- * {@link #select(CallInfo, List, CallServiceSelectionResponse)} to the main thread.
- */
- private static final int MSG_SELECT_CALL_SERVICES = 2;
-
- /**
- * Listens for responses from the {@link CallServiceSelector} and passes them back through the
- * Binder interface. This must be called from
- * {@link CallServiceSelector#isSwitchable(CallInfo, CallSwitchabilityResponse)}.
- */
- public interface CallSwitchabilityResponse {
- /**
- * Mark a call as switchable (or not). This must be called by
- * {@link CallServiceSelector#isSwitchable(CallInfo, CallSwitchabilityResponse)}.
- *
- * @param isSwitchable Whether the call was switchable or not.
- */
- void setSwitchable(boolean isSwitchable);
- }
-
- /**
- * Listens for responses from the {@link CallServiceSelector} and passes them back through the
- * Binder interface. This must be called from
- * {@link CallServiceSelector#select(CallInfo, List, CallServiceSelectionResponse)}.
- */
- public interface CallServiceSelectionResponse {
- /**
- * Sets the prioritized {@link CallServiceDescriptor}s for the given {@link CallInfo}. This
- * must be called by
- * {@link CallServiceSelector#select(CallInfo, List, CallServiceSelectionResponse)}.
- *
- * @param callServices The prioritized {@link CallServiceDescriptor}s.
- */
- void setSelectedCallServices(List<CallServiceDescriptor> callServices);
- }
+ private static final int MSG_SET_CALL_SERVICE_SELECTOR_ADAPTER = 0;
+ private static final int MSG_SELECT = 1;
/** Handler to move client-bound method calls to the main thread. */
private final Handler mHandler = new Handler(Looper.getMainLooper()) {
- @SuppressWarnings("unchecked")
@Override
public void handleMessage(Message msg) {
- final SomeArgs args = (SomeArgs) msg.obj;
- try {
- switch (msg.what) {
- case MSG_IS_SWITCHABLE:
- isSwitchable((CallInfo) args.arg1, (CallSwitchabilityResponse) args.arg2);
- break;
- case MSG_SELECT_CALL_SERVICES:
- select((CallInfo) args.arg1, (List<CallServiceDescriptor>) args.arg2,
- (CallServiceSelectionResponse) args.arg3);
- break;
- }
- } finally {
- if (args != null) {
- args.recycle();
- }
+ switch (msg.what) {
+ case MSG_SET_CALL_SERVICE_SELECTOR_ADAPTER:
+ CallServiceSelectorAdapter adapter = new CallServiceSelectorAdapter(
+ (ICallServiceSelectorAdapter) msg.obj);
+ setCallServiceSelectorAdapter(adapter);
+ break;
+ case MSG_SELECT:
+ SomeArgs args = (SomeArgs) msg.obj;
+ try {
+ select((CallInfo) args.arg1, (List<CallServiceDescriptor>) args.arg2);
+ } finally {
+ args.recycle();
+ }
+ break;
}
}
};
/** 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;
- private ICallServiceSelectionResponse mSelectionResponse;
-
+ private final class CallServiceSelectorBinder extends ICallServiceSelector.Stub {
@Override
- public void isSwitchable(CallInfo callInfo, ICallSwitchabilityResponse response)
- throws RemoteException {
- mSwitchabilityResponse = response;
- SomeArgs args = SomeArgs.obtain();
- args.arg1 = callInfo;
- args.arg2 = this;
- mHandler.obtainMessage(MSG_IS_SWITCHABLE, args).sendToTarget();
+ public void setCallServiceSelectorAdapter(ICallServiceSelectorAdapter adapter) {
+ mHandler.obtainMessage(MSG_SET_CALL_SERVICE_SELECTOR_ADAPTER, adapter)
+ .sendToTarget();
}
@Override
- public void select(CallInfo callInfo, List<CallServiceDescriptor> descriptors,
- ICallServiceSelectionResponse response) throws RemoteException {
- mSelectionResponse = response;
+ public void select(CallInfo callInfo, List<CallServiceDescriptor> descriptors) {
SomeArgs args = SomeArgs.obtain();
args.arg1 = callInfo;
args.arg2 = descriptors;
- args.arg3 = this;
- mHandler.obtainMessage(MSG_SELECT_CALL_SERVICES, args).sendToTarget();
- }
-
- @Override
- public void setSwitchable(boolean isSwitchable) {
- if (mSwitchabilityResponse != null) {
- try {
- mSwitchabilityResponse.setIsSwitchable(isSwitchable);
- } catch (RemoteException e) {
- Log.d(TAG, "Failed to set switchability", e);
- }
- } else {
- Log.wtf(TAG, "Switchability response object not set");
- }
- }
-
- @Override
- public void setSelectedCallServices(List<CallServiceDescriptor> callServices) {
- if (mSelectionResponse != null) {
- try {
- mSelectionResponse.setSelectedCallServiceDescriptors(callServices);
- } catch (RemoteException e) {
- Log.d(TAG, "Failed to set call services", e);
- }
- } else {
- Log.wtf(TAG, "Selector response object not set");
- }
+ mHandler.obtainMessage(MSG_SELECT, args).sendToTarget();
}
}
@@ -177,31 +90,19 @@ public abstract class CallServiceSelector extends Service {
}
/**
- * Determines whether the given call is switchable. That is, whether the call can be moved to
- * another {@link CallService} seamlessly. Once this is determined, the result is passed to the
- * given {@link CallSwitchabilityResponse} listener.<br />
- * <br />
- * This method is called on the main thread and is not safe to block.
+ * Sets an adapter that allows the selector to communicate with Telecomm.
*
- * @param callInfo The call being potentially switched between {@link CallService}s.
- * @param response The {@link CallSwitchabilityResponse} listener to call back with the result.
+ * @param adapter Adapter object for communicating with Telecomm.
*/
- protected abstract void isSwitchable(CallInfo callInfo, CallSwitchabilityResponse response);
+ protected abstract void setCallServiceSelectorAdapter(CallServiceSelectorAdapter adapter);
/**
* Given a list of {@link CallServiceDescriptor}s, order them into a prioritized list and return
- * them through the given {@link CallServiceSelectionResponse} listener.<br />
- * <br />
- * This method is called on the UI thread and is not safe to block.
+ * them through {@link CallServiceSelectorAdapter#select}.
*
* @param callInfo The call being placed using the {@link CallService}s.
* @param descriptors The descriptors of the available {@link CallService}s with which to place
* the call.
- * @param response The {@link CallServiceSelectionResponse} listener to call back with the
- * result.
*/
- protected abstract void select(
- CallInfo callInfo,
- List<CallServiceDescriptor> descriptors,
- CallServiceSelectionResponse response);
+ protected abstract void select(CallInfo callInfo, List<CallServiceDescriptor> descriptors);
}
diff --git a/telecomm/java/android/telecomm/CallServiceSelectorAdapter.java b/telecomm/java/android/telecomm/CallServiceSelectorAdapter.java
new file mode 100644
index 0000000..8635f1a
--- /dev/null
+++ b/telecomm/java/android/telecomm/CallServiceSelectorAdapter.java
@@ -0,0 +1,72 @@
+/*
+ * 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.net.Uri;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.telecomm.CallServiceDescriptor;
+
+import com.android.internal.telecomm.ICallServiceSelectorAdapter;
+
+import java.util.List;
+
+/**
+ * Provides methods for ICallServiceSelector implementations to interact with Telecomm.
+ */
+public final class CallServiceSelectorAdapter {
+ private final ICallServiceSelectorAdapter mAdapter;
+
+ /**
+ * {@hide}
+ */
+ public CallServiceSelectorAdapter(ICallServiceSelectorAdapter adapter) {
+ mAdapter = adapter;
+ }
+
+ /**
+ * Records the sorted set of call services that are preferred by the corresponding
+ * call-service selector.
+ *
+ * @param callId The ID of the call to complete.
+ * @param selectedCallServiceDescriptors The prioritized list of preferred call-service
+ * descriptors to use for completing the call.
+ */
+ public void setSelectedCallServices(
+ String callId,
+ List<CallServiceDescriptor> selectedCallServiceDescriptors) {
+ try {
+ mAdapter.setSelectedCallServices(callId, selectedCallServiceDescriptors);
+ } catch (RemoteException e) {
+ }
+ }
+
+ /**
+ * Associates handoff information with an ongoing call. Calls can switch from one call service
+ * to another. Setting handle to a non-null value marks the call as switchable.
+ *
+ * @param callId The ID of the call to set handoff information for.
+ * @param handle The handle used to place the call when switching.
+ * @param extras Optional extra that's attached to the call.
+ */
+ public void setHandoffInfo(String callId, Uri handle, Bundle extras) {
+ try {
+ mAdapter.setHandoffInfo(callId, handle, extras);
+ } catch (RemoteException e) {
+ }
+ }
+}
diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl
index 97fa834..10d73be 100644
--- a/telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl
+++ b/telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl
@@ -21,16 +21,12 @@ import android.telecomm.CallServiceDescriptor;
import java.util.List;
/**
- * Used by {@link ICallServiceProvider} to return a list of {@link CallServiceDescriptor}s.
- * {@hide}
+ * Internal remote interface for call service lookup response.
+ *
+ * @see android.telecomm.CallServiceLookupResponse
+ *
+ * @hide
*/
oneway interface ICallServiceLookupResponse {
- /**
- * 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}.
- */
void setCallServiceDescriptors(in List<CallServiceDescriptor> callServiceDescriptors);
}
diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl
index 39feddd..96daeed 100644
--- a/telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl
+++ b/telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl
@@ -21,28 +21,12 @@ import android.telecomm.CallServiceDescriptor;
import com.android.internal.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).
+ * Internal remote interface for call service providers.
*
- * 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.
- * {@hide}
+ * @see android.telecomm.CallServiceProvider
+ *
+ * @hide
*/
oneway interface ICallServiceProvider {
-
- /**
- * Initiates the process to retrieve the list of {@link CallServiceDescriptor}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/com/android/internal/telecomm/ICallServiceSelector.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl
index 3b73d9b..0dd3855 100644
--- a/telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl
+++ b/telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl
@@ -20,72 +20,19 @@ import android.telecomm.CallInfo;
import android.telecomm.CallServiceDescriptor;
import com.android.internal.telecomm.ICallService;
-import com.android.internal.telecomm.ICallServiceSelectionResponse;
-import com.android.internal.telecomm.ICallSwitchabilityResponse;
+import com.android.internal.telecomm.ICallServiceSelectorAdapter;
import java.util.List;
/**
- * Interface for call-service selector implementations.
+ * Internal remote interface for call service selectors.
*
- * 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.
+ * @see android.telecomm.CallServiceSelector
*
- * 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).
- * {@hide}
+ * @hide
*/
oneway interface ICallServiceSelector {
+ void setCallServiceSelectorAdapter(in ICallServiceSelectorAdapter adapter);
- /**
- * 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);
+ void select(in CallInfo callInfo, in List<CallServiceDescriptor> callServiceDescriptors);
}
diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceSelectionResponse.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceSelectorAdapter.aidl
index 8270aa5..1b281b9 100644
--- a/telecomm/java/com/android/internal/telecomm/ICallServiceSelectionResponse.aidl
+++ b/telecomm/java/com/android/internal/telecomm/ICallServiceSelectorAdapter.aidl
@@ -16,23 +16,24 @@
package com.android.internal.telecomm;
-import android.os.IBinder;
+import android.net.Uri;
+import android.os.Bundle;
+import android.telecomm.CallInfo;
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.
- * {@hide}
+ * Internal remote interface for call service selector adapter.
+ *
+ * @see android.telecomm.CallServiceSelectorAdapter
+ *
+ * @hide
*/
-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(
+oneway interface ICallServiceSelectorAdapter {
+ void setSelectedCallServices(
+ String callId,
in List<CallServiceDescriptor> selectedCallServiceDescriptors);
+
+ void setHandoffInfo(String callId, in Uri handle, in Bundle extras);
}
diff --git a/telecomm/java/com/android/internal/telecomm/ICallSwitchabilityResponse.aidl b/telecomm/java/com/android/internal/telecomm/ICallSwitchabilityResponse.aidl
deleted file mode 100644
index 9a7e9e5..0000000
--- a/telecomm/java/com/android/internal/telecomm/ICallSwitchabilityResponse.aidl
+++ /dev/null
@@ -1,36 +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 com.android.internal.telecomm;
-
-/**
- * Used by {@link ICallServiceSelector}s to return whether or not the relevant
- * call is switchable.
- * {@hide}
- */
-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);
-}