Remove the synchronization
All of the callbacks happen on the same thread; no need to
synchronize. Also move away from TimerTask and use Handler to post
the termination callback.
Change-Id: If684e29686f2c7557cc56057c7f1ec6a1dfd3bcb
diff --git a/src/com/android/telecomm/Switchboard.java b/src/com/android/telecomm/Switchboard.java
index cc01941..e9f9033 100644
--- a/src/com/android/telecomm/Switchboard.java
+++ b/src/com/android/telecomm/Switchboard.java
@@ -56,9 +56,8 @@
* @param context The application context.
*/
void placeOutgoingCall(String handle, ContactInfo contactInfo, Context context) {
- synchronized (mPendingOutgoingCalls) {
- mPendingOutgoingCalls.add(new Call(handle, contactInfo));
- }
+ ThreadUtil.checkOnMainThread();
+ mPendingOutgoingCalls.add(new Call(handle, contactInfo));
callServiceFinder.initiateLookup(context);
}
@@ -73,23 +72,22 @@
* call-services, it should be at liberty to use these just as well.
*/
void setCallServices(List<ICallService> callServices) {
- synchronized (mPendingOutgoingCalls) {
- for (Call pendingCall : mPendingOutgoingCalls) {
- // TODO(gilad): Iterate through the prioritized list of switchboard policies passing
- // to each policy the call object as well as all known call services. Break out of
- // the inner/policy loop as soon as the first matching policy for the call is found.
- // Calls for which no matching policy can be found will be killed by cleanup/monitor
- // thread, see the "monitor" to-do at the top of the file.
+ ThreadUtil.checkOnMainThread();
+ for (Call pendingCall : mPendingOutgoingCalls) {
+ // TODO(gilad): Iterate through the prioritized list of switchboard policies passing
+ // to each policy the call object as well as all known call services. Break out of
+ // the inner/policy loop as soon as the first matching policy for the call is found.
+ // Calls for which no matching policy can be found will be killed by cleanup/monitor
+ // thread, see the "monitor" to-do at the top of the file.
- // Psuedo code (assuming connect to be a future switchboard method):
- //
- // FOR policy IN prioritizedPolicies:
- // IF policy.is_applicable_to(pendingCall, callServices):
- // TRY
- // connect(pendingCall, callServices, policy)
- // mPendingOutgoingCalls.remove(pendingCall)
- // BREAK
- }
+ // Psuedo code (assuming connect to be a future switchboard method):
+ //
+ // FOR policy IN prioritizedPolicies:
+ // IF policy.is_applicable_to(pendingCall, callServices):
+ // TRY
+ // connect(pendingCall, callServices, policy)
+ // mPendingOutgoingCalls.remove(pendingCall)
+ // BREAK
}
}