blob: 99b68bdef4db5d734b4c23659ecd4e4f5c91e00e [file] [log] [blame]
Ben Gilad9f2bed32013-12-12 17:43:26 -08001package com.android.telecomm;
2
3import com.android.telecomm.exceptions.CallServiceUnavailableException;
4import com.android.telecomm.exceptions.RestrictedCallException;
5
6import java.util.ArrayList;
7import java.util.List;
8
9/** Singleton */
10public class CallsManager {
11
12 private static final CallsManager INSTANCE = new CallsManager();
13
14 private DialerAdapter dialerAdapter;
15
16 private InCallAdapter inCallAdapter;
17
18 private Switchboard switchboard;
19
20 private CallLogManager callLogManager;
21
22 private VoicemailManager voicemailManager;
23
24 private List<OutgoingCallFilter> outgoingCallFilters =
25 new ArrayList<OutgoingCallFilter>();
26
27 private List<IncomingCallFilter> incomingCallFilters =
28 new ArrayList<IncomingCallFilter>();
29
30 // Singleton, private constructor (see getInstance).
31 private CallsManager() {
32 switchboard = new Switchboard();
33 callLogManager = new CallLogManager();
34 voicemailManager = new VoicemailManager(); // As necessary etc.
35 }
36
37 /** Package private */
38 static CallsManager getInstance() {
39 return INSTANCE;
40 }
41
42 /** Package private */
43 // TODO(gilad): Circle back to how we'd want to do this.
44 void addCallService(CallService callService) {
45 if (callService != null) {
46 switchboard.addCallService(callService);
47 callService.setCallServiceAdapter(new CallServiceAdapter(this));
48 }
49 }
50
51 /** Package private */
52 void connectTo(String userInput, ContactInfo contactInfo)
53 throws RestrictedCallException, CallServiceUnavailableException {
54
55 for (OutgoingCallFilter policy : outgoingCallFilters) {
56 policy.validate(userInput, contactInfo);
57 }
58
59 // No objection to issue the call, proceed with trying to put it through.
60 switchboard.placeOutgoingCall(userInput, contactInfo);
61 }
62}