Find ICallServiceProviders on the device.

Uses package manager to find all ICallServiceProviders registered on the
system. This CL does not do the work of actually binding to the
providers.

Change-Id: I63cb3f73727e49542c09edf021fe010adf8ce90f
diff --git a/src/com/android/telecomm/CallsManager.java b/src/com/android/telecomm/CallsManager.java
index a5fdcf7..71c666d 100644
--- a/src/com/android/telecomm/CallsManager.java
+++ b/src/com/android/telecomm/CallsManager.java
@@ -1,7 +1,26 @@
+/*
+ * 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 com.android.telecomm;
 
+import android.content.Context;
+
 import com.android.telecomm.exceptions.CallServiceUnavailableException;
 import com.android.telecomm.exceptions.RestrictedCallException;
+import com.google.common.collect.Lists;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -13,64 +32,58 @@
  * access from other packages specifically refraining from passing the CallsManager instance
  * beyond the com.android.telecomm package boundary.
  */
-public class CallsManager {
+public final class CallsManager {
 
-  private static final CallsManager INSTANCE = new CallsManager();
+    private static final CallsManager INSTANCE = new CallsManager();
 
-  /**
-   * May be unnecessary per off-line discussions (between santoscordon and gilad) since the set
-   * of CallsManager APIs that need to be exposed to the dialer (or any application firing call
-   * intents) may be empty.
-   */
-  private DialerAdapter dialerAdapter;
+    /**
+     * May be unnecessary per off-line discussions (between santoscordon and gilad) since the set
+     * of CallsManager APIs that need to be exposed to the dialer (or any application firing call
+     * intents) may be empty.
+     */
+    private DialerAdapter mDialerAdapter;
 
-  private InCallAdapter inCallAdapter;
+    private InCallAdapter mInCallAdapter;
 
-  private Switchboard switchboard;
+    private Switchboard mSwitchboard;
 
-  private CallLogManager callLogManager;
+    private CallLogManager mCallLogManager;
 
-  private VoicemailManager voicemailManager;
+    private VoicemailManager mVoicemailManager;
 
-  private List<OutgoingCallFilter> outgoingCallFilters =
-      new ArrayList<OutgoingCallFilter>();
+    private List<OutgoingCallFilter> mOutgoingCallFilters = Lists.newArrayList();
 
-  private List<IncomingCallFilter> incomingCallFilters =
-      new ArrayList<IncomingCallFilter>();
+    private List<IncomingCallFilter> mIncomingCallFilters = Lists.newArrayList();
 
-  // Singleton, private constructor (see getInstance).
-  private CallsManager() {
-    switchboard = new Switchboard();
-    callLogManager = new CallLogManager();
-    voicemailManager = new VoicemailManager();  // As necessary etc.
-  }
-
-  static CallsManager getInstance() {
-    return INSTANCE;
-  }
-
-  // TODO(gilad): Circle back to how we'd want to do this.
-  void addCallService(CallService callService) {
-    if (callService != null) {
-      switchboard.addCallService(callService);
-      callService.setCallServiceAdapter(new CallServiceAdapter(this));
-    }
-  }
-
-  /**
-   * Attempts to issue/connect the specified call.  From an (arbitrary) application standpoint,
-   * all that is required to initiate this flow is to fire either of the CALL, CALL_PRIVILEGED,
-   * and CALL_EMERGENCY intents. These are listened to by CallActivity.java which then invokes
-   * this method.
-   */
-  void processOutgoingCallIntent(String handle, ContactInfo contactInfo)
-      throws RestrictedCallException, CallServiceUnavailableException {
-
-    for (OutgoingCallFilter policy : outgoingCallFilters) {
-      policy.validate(handle, contactInfo);
+    static CallsManager getInstance() {
+        return INSTANCE;
     }
 
-    // No objection to issue the call, proceed with trying to put it through.
-    switchboard.placeOutgoingCall(handle, contactInfo);
-  }
+    /**
+     * Private constructor initializes main components of telecomm.
+     */
+    private CallsManager() {
+        mSwitchboard = new Switchboard();
+    }
+
+    /**
+     * Attempts to issue/connect the specified call.  From an (arbitrary) application standpoint,
+     * all that is required to initiate this flow is to fire either of the CALL, CALL_PRIVILEGED,
+     * and CALL_EMERGENCY intents. These are listened to by CallActivity.java which then invokes
+     * this method.
+     *
+     * @param handle The handle to dial.
+     * @param contactInfo Information about the entity being called.
+     * @param context The application context.
+     */
+    void processOutgoingCallIntent(String handle, ContactInfo contactInfo, Context context)
+            throws RestrictedCallException, CallServiceUnavailableException {
+
+        for (OutgoingCallFilter policy : mOutgoingCallFilters) {
+            policy.validate(handle, contactInfo);
+        }
+
+        // No objection to issue the call, proceed with trying to put it through.
+        mSwitchboard.placeOutgoingCall(handle, contactInfo, context);
+    }
 }