Convert the lists of call-services/selectors in switchboard to sets and pass the set of selectors from the finder.
Change-Id: I649cc20fd4fb25745ae1069db342ae6ee50b2ae2
diff --git a/src/com/android/telecomm/CallServiceFinder.java b/src/com/android/telecomm/CallServiceFinder.java
index 4ee73c3..6cf86b0 100644
--- a/src/com/android/telecomm/CallServiceFinder.java
+++ b/src/com/android/telecomm/CallServiceFinder.java
@@ -77,6 +77,13 @@
private int mNextLookupId = 0;
/**
+ * The set of bound call-services. Only populated via initiateLookup scenarios. Entries should
+ * only be removed upon unbinding.
+ * TODO(gilad): Add the necessary logic to keep this set up to date.
+ */
+ private Set<ICallService> mCallServiceRegistry = Sets.newHashSet();
+
+ /**
* The set of bound call-service providers. Only populated via initiateLookup scenarios.
* Providers should only be removed upon unbinding.
*/
@@ -267,6 +274,7 @@
* queue.
* TODO(gilad): Santos has some POC code to make synchronized (below) unnecessary, either
* move to use that or remove this to-do.
+ * TODO(gilad): callServices should probably be a set, consider refactoring.
*
* @param lookupId The lookup-cycle ID.
* @param providerName The component name of the relevant provider.
@@ -284,6 +292,12 @@
if (mUnregisteredProviders.remove(providerName)) {
mProviderRegistry.add(provider);
+ mCallServiceRegistry.addAll(callServices);
+
+ // TODO(gilad): Introduce a map to retain the association between call services
+ // and the corresponding provider such that mCallServiceRegistry can be updated
+ // upon unregisterProvider calls.
+
if (mUnregisteredProviders.size() < 1) {
terminateLookup(); // No other providers to wait for.
}
@@ -318,8 +332,6 @@
*/
private void updateSwitchboard() {
ThreadUtil.checkOnMainThread();
-
- // TODO(gilad): More here.
- mSwitchboard.setCallServices(null);
+ mSwitchboard.setCallServices(mCallServiceRegistry);
}
}
diff --git a/src/com/android/telecomm/CallServiceSelectorFinder.java b/src/com/android/telecomm/CallServiceSelectorFinder.java
index 50a4393..0270e3d 100644
--- a/src/com/android/telecomm/CallServiceSelectorFinder.java
+++ b/src/com/android/telecomm/CallServiceSelectorFinder.java
@@ -258,9 +258,7 @@
*/
private void terminateLookup() {
mHandler.removeCallbacks(mLookupTerminator);
-
updateSwitchboard();
- mIsLookupInProgress = false;
}
/**
@@ -269,7 +267,7 @@
private void updateSwitchboard() {
ThreadUtil.checkOnMainThread();
- // TODO(gilad): More here.
- mSwitchboard.setSelectors(null);
+ mSwitchboard.setSelectors(mSelectorRegistry);
+ mIsLookupInProgress = false;
}
}
\ No newline at end of file
diff --git a/src/com/android/telecomm/Switchboard.java b/src/com/android/telecomm/Switchboard.java
index 4abebce..52bacd9 100644
--- a/src/com/android/telecomm/Switchboard.java
+++ b/src/com/android/telecomm/Switchboard.java
@@ -48,13 +48,18 @@
private CallServiceSelectorFinder mSelectorFinder = new CallServiceSelectorFinder(this);
- /** TODO(gilad): Add comment, may also want to use a set instead. */
- /** TODO(gilad): Null out once the active-call count goes to zero. */
- private List<ICallService> mCallServices;
+ /**
+ * The set of currently available call-service implementations, see {@link CallServiceFinder}.
+ * TODO(gilad): Null out once the active-call count goes to zero.
+ */
+ private Set<ICallService> mCallServices;
- /** TODO(gilad): Add comment, may also want to use a set instead. */
- /** TODO(gilad): Null out once the active-call count goes to zero. */
- private List<ICallServiceSelector> mSelectors;
+ /**
+ * The set of currently available call-service-selector implementations,
+ * see {@link CallServiceSelectorFinder}.
+ * TODO(gilad): Null out once the active-call count goes to zero.
+ */
+ private Set<ICallServiceSelector> mSelectors;
private Set<Call> mPendingOutgoingCalls = Sets.newHashSet();
@@ -94,15 +99,15 @@
}
/**
- * Persists the specified list of call services and attempts to connect any pending outgoing
- * calls still waiting for a matching call-service to be initiated. Intended to be called by
- * {@link CallServiceFinder} exclusively.
+ * Persists the specified set of call services and attempts to connect any pending outgoing
+ * calls (still waiting for a matching call-service to be initiated). Intended to be called
+ * by {@link CallServiceFinder} exclusively.
*
- * @param callServices The potentially-partial list of call services. Partial since the
- * lookup procedure is time-boxed, such that some providers/call-services may be slow
- * to respond and hence effectively omitted from the specified list.
+ * @param callServices The potentially-partial set of call services. Partial since the lookup
+ * process is time-boxed, such that some providers/call-services may be slow to respond and
+ * hence effectively omitted from the specified list.
*/
- void setCallServices(List<ICallService> callServices) {
+ void setCallServices(Set<ICallService> callServices) {
ThreadUtil.checkOnMainThread();
mCallServices = callServices;
@@ -113,11 +118,11 @@
* Persists the specified list of selectors and attempts to connect any pending outgoing
* calls. Intended to be called by {@link CallServiceSelectorFinder} exclusively.
*
- * @param selectors The potentially-partial list of selectors. Partial since the lookup
- * procedure is time-boxed, such that some selectors may be slow to respond and hence
- * effectively omitted from the specified list.
+ * @param selectors The potentially-partial set of selectors. Partial since the lookup
+ * procedure is time-boxed such that some selectors may be slow to respond and hence
+ * effectively omitted from the specified set.
*/
- void setSelectors(List<ICallServiceSelector> selectors) {
+ void setSelectors(Set<ICallServiceSelector> selectors) {
ThreadUtil.checkOnMainThread();
mSelectors = selectors;