The packages/services/Telecomm counterpart of ag/420591.
Change-Id: I42ec26518d9391704fe5d0443867b00e635fc845
diff --git a/src/com/android/telecomm/CallServiceRepository.java b/src/com/android/telecomm/CallServiceRepository.java
index 23fffca..510db49 100644
--- a/src/com/android/telecomm/CallServiceRepository.java
+++ b/src/com/android/telecomm/CallServiceRepository.java
@@ -22,11 +22,8 @@
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.os.Handler;
-import android.os.IBinder;
import android.os.Looper;
-import android.os.RemoteException;
-import android.telecomm.CallServiceInfo;
-import android.telecomm.ICallService;
+import android.telecomm.CallServiceDescriptor;
import android.telecomm.ICallServiceLookupResponse;
import android.telecomm.ICallServiceProvider;
import android.util.Log;
@@ -43,9 +40,9 @@
/**
* Uses package manager to find all implementations of {@link ICallServiceProvider} and uses them to
- * get a list of bindable {@link ICallServices}. Ultimately returns a list of call services as
- * {@link CallServiceWrapper}s. The resulting call services may or may not be bound at the end of the
- * lookup.
+ * get the corresponding list of call-service descriptor. Ultimately returns a list of call services
+ * as {@link CallServiceWrapper}s. The resulting call services may or may not be bound at the end of
+ * the lookup.
* TODO(santoscordon): Add performance timing to async calls.
* TODO(santoscordon): Need to unbind/remove unused call services stored in the cache.
*/
@@ -174,24 +171,24 @@
}
/**
- * Creates and returns the call service for the specified {@link CallServiceInfo}. Inserts newly
- * created entries into the cache, see {@link #mCallServiceCache}, or if a cached version
- * already exists, returns that instead. All newly created instances will not yet be bound,
- * however cached versions may or may not be bound.
+ * Creates and returns the call service for the specified call-service descriptor. Inserts
+ * newly created entries into the cache, see {@link #mCallServiceCache}, or if a cached
+ * version already exists, returns that instead. All newly created instances will not yet
+ * be bound, however cached versions may or may not be bound.
*
- * @param info The call service descriptor.
+ * @param descriptor The call service descriptor.
* @return The call service.
*/
- CallServiceWrapper getCallService(CallServiceInfo info) {
- Preconditions.checkNotNull(info);
+ CallServiceWrapper getCallService(CallServiceDescriptor descriptor) {
+ Preconditions.checkNotNull(descriptor);
// TODO(santoscordon): Rename getServiceComponent to getComponentName.
- ComponentName componentName = info.getServiceComponent();
+ ComponentName componentName = descriptor.getServiceComponent();
CallServiceWrapper callService = mCallServiceCache.get(componentName);
if (callService == null) {
CallServiceAdapter adapter = new CallServiceAdapter(mOutgoingCallsManager);
- callService = new CallServiceWrapper(info, adapter);
+ callService = new CallServiceWrapper(descriptor, adapter);
mCallServiceCache.put(componentName, callService);
}
@@ -259,15 +256,14 @@
// Query the provider for {@link ICallService} implementations.
provider.lookupCallServices(new ICallServiceLookupResponse.Stub() {
- // TODO(santoscordon): Rename CallServiceInfo to CallServiceDescriptor and update
- // this method name to setCallServiceDescriptors.
@Override
- public void setCallServices(final List<CallServiceInfo> callServiceInfos) {
+ public void setCallServiceDescriptors(
+ final List<CallServiceDescriptor> callServiceDescriptors) {
// TODO(santoscordon): Do we need Binder.clear/restoreCallingIdentity()?
mHandler.post(new Runnable() {
@Override public void run() {
processCallServices(
- providerName, provider, Sets.newHashSet(callServiceInfos));
+ providerName, provider, Sets.newHashSet(callServiceDescriptors));
}
});
}
@@ -286,30 +282,30 @@
}
/**
- * Processes the {@link CallServiceInfo}s for the specified provider and performs the necessary
- * bookkeeping to potentially return control to the switchboard before the timeout for the
- * current lookup cycle.
+ * Processes the {@link CallServiceDescriptor}s for the specified provider, and performs the
+ * necessary bookkeeping to potentially return control to the switchboard before the timeout
+ * for the current lookup cycle.
*
* @param providerName The component name of the relevant provider.
* @param provider The provider associated with callServices.
- * @param callServiceInfos The set of call service infos to process.
+ * @param callServiceDescriptors The set of call service descriptors to process.
*/
private void processCallServices(
ComponentName providerName,
CallServiceProviderWrapper provider,
- Set<CallServiceInfo> callServiceInfos) {
+ Set<CallServiceDescriptor> callServiceDescriptors) {
Preconditions.checkNotNull(provider);
- Preconditions.checkNotNull(callServiceInfos);
+ Preconditions.checkNotNull(callServiceDescriptors);
ThreadUtil.checkOnMainThread();
- // We only need the provider for retrieving the call-service info set, so unbind here.
+ // The set of call-service descriptors is available, unbind the provider.
provider.unbind();
if (mOutstandingProviders.contains(providerName)) {
// Add all the call services from this provider to the call-service cache.
- for (CallServiceInfo info : callServiceInfos) {
- getCallService(info);
+ for (CallServiceDescriptor descriptor : callServiceDescriptors) {
+ getCallService(descriptor);
}
removeOutstandingProvider(providerName);
diff --git a/src/com/android/telecomm/CallServiceWrapper.java b/src/com/android/telecomm/CallServiceWrapper.java
index 2ff1cfc..941c6ee 100644
--- a/src/com/android/telecomm/CallServiceWrapper.java
+++ b/src/com/android/telecomm/CallServiceWrapper.java
@@ -16,11 +16,10 @@
package com.android.telecomm;
-import android.content.ComponentName;
import android.os.IBinder;
import android.os.RemoteException;
import android.telecomm.CallInfo;
-import android.telecomm.CallServiceInfo;
+import android.telecomm.CallServiceDescriptor;
import android.telecomm.ICallService;
import android.telecomm.ICallServiceAdapter;
import android.util.Log;
@@ -43,7 +42,7 @@
private static final String TAG = CallServiceWrapper.class.getSimpleName();
/** The descriptor of this call service as supplied by the call-service provider. */
- private final CallServiceInfo mCallServiceInfo;
+ private final CallServiceDescriptor mDescriptor;
/**
* The adapter used by the underlying call-service implementation to communicate with Telecomm.
@@ -56,17 +55,17 @@
/**
* Creates a call-service provider for the specified component.
*
- * @param info The call-service descriptor from {@link ICallServiceProvider#lookupCallServices}.
+ * @param descriptor The call-service descriptor from {@link ICallServiceProvider#lookupCallServices}.
* @param adapter The call-service adapter.
*/
- public CallServiceWrapper(CallServiceInfo info, CallServiceAdapter adapter) {
- super(CALL_SERVICE_ACTION, info.getServiceComponent());
- mCallServiceInfo = info;
+ public CallServiceWrapper(CallServiceDescriptor descriptor, CallServiceAdapter adapter) {
+ super(CALL_SERVICE_ACTION, descriptor.getServiceComponent());
+ mDescriptor = descriptor;
mAdapter = adapter;
}
- public CallServiceInfo getInfo() {
- return mCallServiceInfo;
+ public CallServiceDescriptor getDescriptor() {
+ return mDescriptor;
}
/** See {@link ICallService#setCallServiceAdapter}. */
diff --git a/src/com/android/telecomm/CallsManager.java b/src/com/android/telecomm/CallsManager.java
index ff224e5..3bfcb03 100644
--- a/src/com/android/telecomm/CallsManager.java
+++ b/src/com/android/telecomm/CallsManager.java
@@ -17,9 +17,8 @@
package com.android.telecomm;
import android.content.Context;
-import android.telecomm.CallServiceInfo;
+import android.telecomm.CallServiceDescriptor;
import android.telecomm.CallState;
-import android.text.TextUtils;
import android.util.Log;
import com.android.telecomm.exceptions.RestrictedCallException;
@@ -91,16 +90,16 @@
* service that an incoming call actually exists for the specified call token. Upon success,
* execution returns to {@link #handleSuccessfulIncomingCall} to start the in-call UI.
*
- * @param callServiceInfo The details of the call service to use for this incoming call.
+ * @param descriptor The descriptor of the call service to use for this incoming call.
* @param callToken The token used by the call service to identify the incoming call.
*/
- void processIncomingCallIntent(CallServiceInfo callServiceInfo, String callToken) {
+ void processIncomingCallIntent(CallServiceDescriptor descriptor, String callToken) {
// Create a call with no handle. Eventually, switchboard will update the call with
// additional information from the call service, but for now we just need one to pass around
// with a unique call ID.
Call call = new Call(null, null);
- mSwitchboard.confirmIncomingCall(call, callServiceInfo, callToken);
+ mSwitchboard.confirmIncomingCall(call, descriptor, callToken);
}
/**
diff --git a/src/com/android/telecomm/OutgoingCallProcessor.java b/src/com/android/telecomm/OutgoingCallProcessor.java
index 34649f0..bfe8cbc 100644
--- a/src/com/android/telecomm/OutgoingCallProcessor.java
+++ b/src/com/android/telecomm/OutgoingCallProcessor.java
@@ -24,7 +24,7 @@
import android.os.Looper;
import android.os.RemoteException;
import android.telecomm.CallState;
-import android.telecomm.CallServiceInfo;
+import android.telecomm.CallServiceDescriptor;
import android.telecomm.ICallServiceSelectionResponse;
import android.telecomm.ICallServiceSelector;
@@ -37,10 +37,11 @@
/**
* Utility class to place a call using the specified set of call-services and ordered selectors.
- * Iterates through the selectors and gets a sorted list of supported call service infos for each
- * selector. Upon receiving each sorted list (one list per selector), each of the corresponding
- * call services is then attempted until either the outgoing call is placed, the attempted call
- * is aborted (by the switchboard), or the list is exhausted -- whichever occurs first.
+ * Iterates through the selectors and gets a sorted list of supported call-service descriptors
+ * for each selector. Upon receiving each sorted list (one list per selector), each of the
+ * corresponding call services is then attempted until either the outgoing call is placed, the
+ * attempted call is aborted (by the switchboard), or the list is exhausted -- whichever occurs
+ * first.
*
* Except for the abort case, all other scenarios should terminate with the switchboard notified
* of the result.
@@ -57,9 +58,9 @@
private final Call mCall;
/**
- * The duplicate-free list of currently-available call-service infos.
+ * The duplicate-free list of currently-available call-service descriptors.
*/
- private final List<CallServiceInfo> mCallServiceInfos = Lists.newArrayList();
+ private final List<CallServiceDescriptor> mCallServiceDescriptors = Lists.newArrayList();
/**
* The map of currently-available call-service implementations keyed by call-service ID.
@@ -80,9 +81,9 @@
private final Switchboard mSwitchboard;
/**
- * The iterator over the currently-selected ordered list of call-service infos.
+ * The iterator over the currently-selected ordered list of call-service descriptors.
*/
- private Iterator<CallServiceInfo> mCallServiceInfoIterator;
+ private Iterator<CallServiceDescriptor> mCallServiceDescriptorIterator;
private Iterator<ICallServiceSelector> mSelectorIterator;
@@ -97,9 +98,9 @@
/**
* Persists the specified parameters and iterates through the prioritized list of selectors
* passing to each selector (read-only versions of) the call object and all available call-
- * service infos. Stops once a matching selector is found. Calls with no matching selectors
- * will eventually be killed by the cleanup/monitor switchboard handler, which will in turn
- * call the abort method of this processor via {@link OutgoingCallsManager}.
+ * service descriptors. Stops once a matching selector is found. Calls with no matching
+ * selectors will eventually be killed by the cleanup/monitor switchboard handler, which will
+ * in turn call the abort method of this processor via {@link OutgoingCallsManager}.
*
* @param call The call to place.
* @param callServices The available call-service implementations.
@@ -124,12 +125,12 @@
mOutgoingCallsManager = outgoingCallsManager;
mSwitchboard = switchboard;
- // Populate the list and map of call-service infos. The list is needed since
+ // Populate the list and map of call-service descriptors. The list is needed since
// it's being passed down to selectors.
for (CallServiceWrapper callService : callServices) {
- CallServiceInfo info = callService.getInfo();
- mCallServiceInfos.add(info);
- mCallServicesById.put(info.getCallServiceId(), callService);
+ CallServiceDescriptor descriptor = callService.getDescriptor();
+ mCallServiceDescriptors.add(descriptor);
+ mCallServicesById.put(descriptor.getCallServiceId(), callService);
}
}
@@ -139,7 +140,7 @@
void process() {
ThreadUtil.checkOnMainThread();
- if (mSelectors.isEmpty() || mCallServiceInfos.isEmpty()) {
+ if (mSelectors.isEmpty() || mCallServiceDescriptors.isEmpty()) {
// TODO(gilad): Consider adding a failure message/type to differentiate the various
// cases, or potentially throw an exception in this case.
mOutgoingCallsManager.handleFailedOutgoingCall(mCall);
@@ -196,7 +197,7 @@
ICallServiceSelector selector = mSelectorIterator.next();
ICallServiceSelectionResponse.Stub response = createSelectionResponse();
try {
- selector.select(mCall.toCallInfo(), mCallServiceInfos, response);
+ selector.select(mCall.toCallInfo(), mCallServiceDescriptors, response);
} catch (RemoteException e) {
attemptNextSelector();
}
@@ -211,12 +212,12 @@
*/
private ICallServiceSelectionResponse.Stub createSelectionResponse() {
return new ICallServiceSelectionResponse.Stub() {
- @Override public void setSelectedCallServiceInfos(
- final List<CallServiceInfo> selectedCallServiceInfos) {
+ @Override public void setSelectedCallServiceDescriptors(
+ final List<CallServiceDescriptor> selectedCallServiceDescriptors) {
Runnable runnable = new Runnable() {
@Override public void run() {
- processSelectedCallServiceInfos(selectedCallServiceInfos);
+ processSelectedCallServiceDescriptors(selectedCallServiceDescriptors);
}
};
@@ -226,34 +227,37 @@
}
/**
- * Persists the ordered-list of call-service infos as selected by the current selector and
- * starts iterating through the corresponding call services in the continuing attempt to
- * place the call.
+ * Persists the ordered-list of call-service descriptor as selected by the current selector and
+ * starts iterating through the corresponding call services continuing the attempt to place the
+ * call.
*
- * @selectedCallServiceInfos The (ordered) list of call service infos.
+ * @selectedCallServiceDescriptors The (ordered) list of call-service descriptor.
*/
- private void processSelectedCallServiceInfos(List<CallServiceInfo> selectedCallServiceInfos) {
- if (selectedCallServiceInfos == null || selectedCallServiceInfos.isEmpty()) {
+ private void processSelectedCallServiceDescriptors(
+ List<CallServiceDescriptor> selectedCallServiceDescriptors) {
+
+ if (selectedCallServiceDescriptors == null || selectedCallServiceDescriptors.isEmpty()) {
attemptNextSelector();
- } else if (mCallServiceInfoIterator == null) {
- mCallServiceInfoIterator = selectedCallServiceInfos.iterator();
+ } else if (mCallServiceDescriptorIterator == null) {
+ mCallServiceDescriptorIterator = selectedCallServiceDescriptors.iterator();
attemptNextCallService();
}
}
/**
- * Attempts to place the call using the call service specified by the next call-service info of
- * mCallServiceInfoIterator. If there are no more call services to attempt, the process continues
- * to the next call-service selector via {@link #attemptNextSelector}.
+ * Attempts to place the call using the call service specified by the next call-service
+ * descriptor of mCallServiceDescriptorIterator. If there are no more call services to
+ * attempt, the process continues to the next call-service selector via
+ * {@link #attemptNextSelector}.
*/
private void attemptNextCallService() {
if (mIsAborted) {
return;
}
- if (mCallServiceInfoIterator.hasNext()) {
- CallServiceInfo info = mCallServiceInfoIterator.next();
- mCallService = mCallServicesById.get(info.getCallServiceId());
+ if (mCallServiceDescriptorIterator.hasNext()) {
+ CallServiceDescriptor descriptor = mCallServiceDescriptorIterator.next();
+ mCallService = mCallServicesById.get(descriptor.getCallServiceId());
if (mCallService == null) {
attemptNextCallService();
} else {
@@ -268,7 +272,7 @@
mCallService.bind(callback);
}
} else {
- mCallServiceInfoIterator = null;
+ mCallServiceDescriptorIterator = null;
resetCallService();
attemptNextSelector();
}
diff --git a/src/com/android/telecomm/Switchboard.java b/src/com/android/telecomm/Switchboard.java
index 34398d2..d2c5bf9 100644
--- a/src/com/android/telecomm/Switchboard.java
+++ b/src/com/android/telecomm/Switchboard.java
@@ -22,7 +22,7 @@
import android.os.Handler;
import android.os.Looper;
-import android.telecomm.CallServiceInfo;
+import android.telecomm.CallServiceDescriptor;
import android.telecomm.ICallServiceSelector;
import java.util.Collection;
@@ -134,11 +134,11 @@
* on the result.
*
* @param call The call object.
- * @param callServiceInfo The details of the call service.
+ * @param descriptor The relevant call-service descriptor.
* @param callToken The token used by the call service to identify the incoming call.
*/
- void confirmIncomingCall(Call call, CallServiceInfo callServiceInfo, String callToken) {
- CallServiceWrapper callService = mCallServiceRepository.getCallService(callServiceInfo);
+ void confirmIncomingCall(Call call, CallServiceDescriptor descriptor, String callToken) {
+ CallServiceWrapper callService = mCallServiceRepository.getCallService(descriptor);
mIncomingCallsManager.confirmIncomingCall(call, callService, callToken);
}
diff --git a/src/com/android/telecomm/TelecommReceiver.java b/src/com/android/telecomm/TelecommReceiver.java
index 1e0bac2..c98de88 100644
--- a/src/com/android/telecomm/TelecommReceiver.java
+++ b/src/com/android/telecomm/TelecommReceiver.java
@@ -19,8 +19,7 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.telecomm.CallServiceInfo;
-import android.text.TextUtils;
+import android.telecomm.CallServiceDescriptor;
import android.util.Log;
import com.google.common.base.Strings;
@@ -38,7 +37,7 @@
* in the intent extras. A new call object along with the token (also provided in the intent
* extras) will ultimately be sent to the call service indicating that Telecomm has received its
* incoming call.
- * Extras used: {@link #EXTRA_CALL_SERVICE_INFO}, {@link #EXTRA_INCOMING_CALL_TOKEN}
+ * Extras used: {@link #EXTRA_CALL_SERVICE_DESCRIPTOR}, {@link #EXTRA_INCOMING_CALL_TOKEN}
* TODO(santoscordon): As this gets finalized, this should eventually move to TelecommConstants.
* TODO(santoscordon): Expose a new service like TelephonyManager for Telecomm and expose
* a method for incoming calls instead of forcing the call service to build and send an Intent.
@@ -46,9 +45,9 @@
public static final String ACTION_INCOMING_CALL = "com.android.telecomm.INCOMING_CALL";
/**
- * The {@link CallServiceInfo} describing the call service for an incoming call.
+ * The {@link CallServiceDescriptor} describing the call service for an incoming call.
*/
- static final String EXTRA_CALL_SERVICE_INFO = "com.android.telecomm.CALL_SERVICE_INFO";
+ static final String EXTRA_CALL_SERVICE_DESCRIPTOR = "com.android.telecomm.CALL_SERVICE_DESCRIPTOR";
/**
* A String-based token used to identify the incoming call. Telecomm will use this token when
@@ -76,15 +75,17 @@
* @param intent The incoming call intent.
*/
private void handleIncomingCall(Intent intent) {
- CallServiceInfo info = intent.getParcelableExtra(EXTRA_CALL_SERVICE_INFO);
- String callToken = Strings.emptyToNull(intent.getStringExtra(EXTRA_INCOMING_CALL_TOKEN));
-
- if (callToken == null || info == null) {
- Log.w(TAG, "Rejecting incoming call due to lack of data. callServiceInfo: [" + info +
- "], callToken: [" + callToken + "]");
+ CallServiceDescriptor descriptor = intent.getParcelableExtra(EXTRA_CALL_SERVICE_DESCRIPTOR);
+ if (descriptor == null) {
+ Log.w(TAG, "Rejecting incoming call due to null descriptor");
return;
}
+ String token = Strings.emptyToNull(intent.getStringExtra(EXTRA_INCOMING_CALL_TOKEN));
+ if (token == null) {
+ Log.w(TAG, "Rejecting incoming call due to null token");
+ }
+
// TODO(santoscordon): Notify CallsManager.
}
}