Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server.telecom; |
| 18 | |
Ihab Awad | 8d5d9dd | 2015-03-12 11:11:06 -0700 | [diff] [blame] | 19 | import com.android.internal.annotations.VisibleForTesting; |
Hall Liu | 486cb19 | 2016-10-21 18:23:33 -0700 | [diff] [blame] | 20 | import com.android.server.telecom.bluetooth.BluetoothDeviceManager; |
| 21 | import com.android.server.telecom.bluetooth.BluetoothRouteManager; |
Hall Liu | 784a496 | 2018-03-06 11:03:17 -0800 | [diff] [blame] | 22 | import com.android.server.telecom.bluetooth.BluetoothStateReceiver; |
Hall Liu | ecda554 | 2015-12-04 11:31:31 -0800 | [diff] [blame] | 23 | import com.android.server.telecom.components.UserCallIntentProcessor; |
| 24 | import com.android.server.telecom.components.UserCallIntentProcessorFactory; |
Tyler Gunn | 2b17f23 | 2017-03-08 08:51:00 -0800 | [diff] [blame] | 25 | import com.android.server.telecom.ui.IncomingCallNotifier; |
Tony Mak | a993094 | 2016-01-15 10:57:14 +0000 | [diff] [blame] | 26 | import com.android.server.telecom.ui.MissedCallNotifierImpl.MissedCallNotifierImplFactory; |
| 27 | import com.android.server.telecom.BluetoothPhoneServiceImpl.BluetoothPhoneServiceImplFactory; |
| 28 | import com.android.server.telecom.CallAudioManager.AudioServiceFactory; |
Hall Liu | 7c92832 | 2016-12-06 18:15:39 -0800 | [diff] [blame] | 29 | import com.android.server.telecom.DefaultDialerCache.DefaultDialerManagerAdapter; |
Ihab Awad | 8d5d9dd | 2015-03-12 11:11:06 -0700 | [diff] [blame] | 30 | |
Tyler Gunn | b5e7d80 | 2015-10-21 08:17:38 -0700 | [diff] [blame] | 31 | import android.Manifest; |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 32 | import android.content.BroadcastReceiver; |
| 33 | import android.content.Context; |
| 34 | import android.content.Intent; |
| 35 | import android.content.IntentFilter; |
Tyler Gunn | 2b17f23 | 2017-03-08 08:51:00 -0800 | [diff] [blame] | 36 | import android.content.pm.ApplicationInfo; |
| 37 | import android.content.pm.PackageManager; |
Hall Liu | 9ccc43d | 2015-12-15 14:18:33 -0800 | [diff] [blame] | 38 | import android.net.Uri; |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 39 | import android.os.UserHandle; |
Brad Ebinger | a3eccfe | 2016-10-05 15:45:22 -0700 | [diff] [blame] | 40 | import android.telecom.Log; |
Tyler Gunn | 2b17f23 | 2017-03-08 08:51:00 -0800 | [diff] [blame] | 41 | import android.telecom.PhoneAccountHandle; |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 42 | |
Hall Liu | 9ccc43d | 2015-12-15 14:18:33 -0800 | [diff] [blame] | 43 | import java.io.FileNotFoundException; |
| 44 | import java.io.InputStream; |
| 45 | |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 46 | /** |
| 47 | * Top-level Application class for Telecom. |
| 48 | */ |
Hall Liu | 3037ac6 | 2016-09-22 14:40:03 -0700 | [diff] [blame] | 49 | public class TelecomSystem { |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 50 | |
| 51 | /** |
| 52 | * This interface is implemented by system-instantiated components (e.g., Services and |
| 53 | * Activity-s) that wish to use the TelecomSystem but would like to be testable. Such a |
| 54 | * component should implement the getTelecomSystem() method to return the global singleton, |
| 55 | * and use its own method. Tests can subclass the component to return a non-singleton. |
| 56 | * |
| 57 | * A refactoring goal for Telecom is to limit use of the TelecomSystem singleton to those |
| 58 | * system-instantiated components, and have all other parts of the system just take all their |
| 59 | * dependencies as explicit arguments to their constructor or other methods. |
| 60 | */ |
| 61 | public interface Component { |
| 62 | TelecomSystem getTelecomSystem(); |
| 63 | } |
| 64 | |
Ihab Awad | 8d5d9dd | 2015-03-12 11:11:06 -0700 | [diff] [blame] | 65 | |
| 66 | /** |
| 67 | * Tagging interface for the object used for synchronizing multi-threaded operations in |
| 68 | * the Telecom system. |
| 69 | */ |
| 70 | public interface SyncRoot { |
| 71 | } |
| 72 | |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 73 | private static final IntentFilter USER_SWITCHED_FILTER = |
| 74 | new IntentFilter(Intent.ACTION_USER_SWITCHED); |
| 75 | |
Tony Mak | a993094 | 2016-01-15 10:57:14 +0000 | [diff] [blame] | 76 | private static final IntentFilter USER_STARTING_FILTER = |
| 77 | new IntentFilter(Intent.ACTION_USER_STARTING); |
| 78 | |
Hall Liu | 3037ac6 | 2016-09-22 14:40:03 -0700 | [diff] [blame] | 79 | private static final IntentFilter BOOT_COMPLETE_FILTER = |
| 80 | new IntentFilter(Intent.ACTION_BOOT_COMPLETED); |
| 81 | |
Tyler Gunn | b5e7d80 | 2015-10-21 08:17:38 -0700 | [diff] [blame] | 82 | /** Intent filter for dialer secret codes. */ |
| 83 | private static final IntentFilter DIALER_SECRET_CODE_FILTER; |
| 84 | |
| 85 | /** |
| 86 | * Initializes the dialer secret code intent filter. Setup to handle the various secret codes |
| 87 | * which can be dialed (e.g. in format *#*#code#*#*) to trigger various behavior in Telecom. |
| 88 | */ |
| 89 | static { |
| 90 | DIALER_SECRET_CODE_FILTER = new IntentFilter( |
| 91 | "android.provider.Telephony.SECRET_CODE"); |
| 92 | DIALER_SECRET_CODE_FILTER.addDataScheme("android_secret_code"); |
| 93 | DIALER_SECRET_CODE_FILTER |
| 94 | .addDataAuthority(DialerCodeReceiver.TELECOM_SECRET_CODE_DEBUG_ON, null); |
| 95 | DIALER_SECRET_CODE_FILTER |
| 96 | .addDataAuthority(DialerCodeReceiver.TELECOM_SECRET_CODE_DEBUG_OFF, null); |
| 97 | DIALER_SECRET_CODE_FILTER |
| 98 | .addDataAuthority(DialerCodeReceiver.TELECOM_SECRET_CODE_MARK, null); |
| 99 | } |
| 100 | |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 101 | private static TelecomSystem INSTANCE = null; |
| 102 | |
Ihab Awad | 8d5d9dd | 2015-03-12 11:11:06 -0700 | [diff] [blame] | 103 | private final SyncRoot mLock = new SyncRoot() { }; |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 104 | private final MissedCallNotifier mMissedCallNotifier; |
Tyler Gunn | 2b17f23 | 2017-03-08 08:51:00 -0800 | [diff] [blame] | 105 | private final IncomingCallNotifier mIncomingCallNotifier; |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 106 | private final PhoneAccountRegistrar mPhoneAccountRegistrar; |
| 107 | private final CallsManager mCallsManager; |
| 108 | private final RespondViaSmsManager mRespondViaSmsManager; |
| 109 | private final Context mContext; |
| 110 | private final BluetoothPhoneServiceImpl mBluetoothPhoneServiceImpl; |
| 111 | private final CallIntentProcessor mCallIntentProcessor; |
| 112 | private final TelecomBroadcastIntentProcessor mTelecomBroadcastIntentProcessor; |
| 113 | private final TelecomServiceImpl mTelecomServiceImpl; |
Ihab Awad | 8d5d9dd | 2015-03-12 11:11:06 -0700 | [diff] [blame] | 114 | private final ContactsAsyncHelper mContactsAsyncHelper; |
Tyler Gunn | b5e7d80 | 2015-10-21 08:17:38 -0700 | [diff] [blame] | 115 | private final DialerCodeReceiver mDialerCodeReceiver; |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 116 | |
Hall Liu | 3037ac6 | 2016-09-22 14:40:03 -0700 | [diff] [blame] | 117 | private boolean mIsBootComplete = false; |
| 118 | |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 119 | private final BroadcastReceiver mUserSwitchedReceiver = new BroadcastReceiver() { |
| 120 | @Override |
| 121 | public void onReceive(Context context, Intent intent) { |
Brad Ebinger | 58f3658 | 2016-01-21 14:20:07 -0800 | [diff] [blame] | 122 | Log.startSession("TSSwR.oR"); |
| 123 | try { |
Hall Liu | 3037ac6 | 2016-09-22 14:40:03 -0700 | [diff] [blame] | 124 | synchronized (mLock) { |
| 125 | int userHandleId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0); |
| 126 | UserHandle currentUserHandle = new UserHandle(userHandleId); |
| 127 | mPhoneAccountRegistrar.setCurrentUserHandle(currentUserHandle); |
| 128 | mCallsManager.onUserSwitch(currentUserHandle); |
| 129 | } |
Brad Ebinger | 58f3658 | 2016-01-21 14:20:07 -0800 | [diff] [blame] | 130 | } finally { |
| 131 | Log.endSession(); |
| 132 | } |
Tony Mak | a993094 | 2016-01-15 10:57:14 +0000 | [diff] [blame] | 133 | } |
| 134 | }; |
| 135 | |
| 136 | private final BroadcastReceiver mUserStartingReceiver = new BroadcastReceiver() { |
| 137 | @Override |
| 138 | public void onReceive(Context context, Intent intent) { |
Brad Ebinger | 58f3658 | 2016-01-21 14:20:07 -0800 | [diff] [blame] | 139 | Log.startSession("TSStR.oR"); |
| 140 | try { |
Hall Liu | 3037ac6 | 2016-09-22 14:40:03 -0700 | [diff] [blame] | 141 | synchronized (mLock) { |
| 142 | int userHandleId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0); |
| 143 | UserHandle addingUserHandle = new UserHandle(userHandleId); |
| 144 | mCallsManager.onUserStarting(addingUserHandle); |
| 145 | } |
| 146 | } finally { |
| 147 | Log.endSession(); |
| 148 | } |
| 149 | } |
| 150 | }; |
| 151 | |
| 152 | private final BroadcastReceiver mBootCompletedReceiver = new BroadcastReceiver() { |
| 153 | @Override |
| 154 | public void onReceive(Context context, Intent intent) { |
| 155 | Log.startSession("TSBCR.oR"); |
| 156 | try { |
| 157 | synchronized (mLock) { |
| 158 | mIsBootComplete = true; |
| 159 | mCallsManager.onBootCompleted(); |
| 160 | } |
Brad Ebinger | 58f3658 | 2016-01-21 14:20:07 -0800 | [diff] [blame] | 161 | } finally { |
| 162 | Log.endSession(); |
| 163 | } |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 164 | } |
| 165 | }; |
| 166 | |
| 167 | public static TelecomSystem getInstance() { |
| 168 | return INSTANCE; |
| 169 | } |
| 170 | |
| 171 | public static void setInstance(TelecomSystem instance) { |
| 172 | if (INSTANCE != null) { |
Hall Liu | 3037ac6 | 2016-09-22 14:40:03 -0700 | [diff] [blame] | 173 | Log.w("TelecomSystem", "Attempt to set TelecomSystem.INSTANCE twice"); |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 174 | } |
| 175 | Log.i(TelecomSystem.class, "TelecomSystem.INSTANCE being set"); |
| 176 | INSTANCE = instance; |
| 177 | } |
| 178 | |
Ihab Awad | 8de7691 | 2015-02-17 12:25:52 -0800 | [diff] [blame] | 179 | public TelecomSystem( |
| 180 | Context context, |
Tony Mak | a993094 | 2016-01-15 10:57:14 +0000 | [diff] [blame] | 181 | MissedCallNotifierImplFactory missedCallNotifierImplFactory, |
Ihab Awad | abcbce4 | 2015-04-07 14:04:01 -0700 | [diff] [blame] | 182 | CallerInfoAsyncQueryFactory callerInfoAsyncQueryFactory, |
Ihab Awad | 8de7691 | 2015-02-17 12:25:52 -0800 | [diff] [blame] | 183 | HeadsetMediaButtonFactory headsetMediaButtonFactory, |
| 184 | ProximitySensorManagerFactory proximitySensorManagerFactory, |
Hall Liu | 8fb1fb7 | 2015-10-22 15:24:40 -0700 | [diff] [blame] | 185 | InCallWakeLockControllerFactory inCallWakeLockControllerFactory, |
Tony Mak | a993094 | 2016-01-15 10:57:14 +0000 | [diff] [blame] | 186 | AudioServiceFactory audioServiceFactory, |
| 187 | BluetoothPhoneServiceImplFactory |
Brad Ebinger | 7ade5e2 | 2016-04-05 18:43:50 -0700 | [diff] [blame] | 188 | bluetoothPhoneServiceImplFactory, |
Pengquan Meng | 606ff7f | 2017-12-20 16:13:04 -0800 | [diff] [blame] | 189 | ConnectionServiceFocusManager.ConnectionServiceFocusManagerFactory |
| 190 | connectionServiceFocusManagerFactory, |
Hall Liu | 6d4b66d | 2016-04-01 16:31:13 -0700 | [diff] [blame] | 191 | Timeouts.Adapter timeoutsAdapter, |
Brad Ebinger | 6e8f3d7 | 2016-06-20 11:35:42 -0700 | [diff] [blame] | 192 | AsyncRingtonePlayer asyncRingtonePlayer, |
Tyler Gunn | eaaf074 | 2016-09-15 15:36:38 -0700 | [diff] [blame] | 193 | PhoneNumberUtilsAdapter phoneNumberUtilsAdapter, |
Brad Ebinger | 7bba111 | 2017-06-08 13:57:28 -0700 | [diff] [blame] | 194 | IncomingCallNotifier incomingCallNotifier, |
Tyler Gunn | 02e00dd | 2017-08-24 15:44:02 -0700 | [diff] [blame] | 195 | InCallTonePlayer.ToneGeneratorFactory toneGeneratorFactory, |
Tyler Gunn | 8bb2b01 | 2017-08-04 09:28:59 -0700 | [diff] [blame] | 196 | ClockProxy clockProxy) { |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 197 | mContext = context.getApplicationContext(); |
Brad Ebinger | a3eccfe | 2016-10-05 15:45:22 -0700 | [diff] [blame] | 198 | LogUtils.initLogging(mContext); |
Hall Liu | 7c92832 | 2016-12-06 18:15:39 -0800 | [diff] [blame] | 199 | DefaultDialerManagerAdapter defaultDialerAdapter = |
| 200 | new DefaultDialerCache.DefaultDialerManagerAdapterImpl(); |
| 201 | |
| 202 | DefaultDialerCache defaultDialerCache = new DefaultDialerCache(mContext, |
| 203 | defaultDialerAdapter, mLock); |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 204 | |
Brad Ebinger | 83bc411 | 2016-04-01 15:30:14 -0700 | [diff] [blame] | 205 | Log.startSession("TS.init"); |
Tyler Gunn | 2b17f23 | 2017-03-08 08:51:00 -0800 | [diff] [blame] | 206 | mPhoneAccountRegistrar = new PhoneAccountRegistrar(mContext, defaultDialerCache, |
| 207 | new PhoneAccountRegistrar.AppLabelProxy() { |
| 208 | @Override |
| 209 | public CharSequence getAppLabel(String packageName) { |
| 210 | PackageManager pm = mContext.getPackageManager(); |
| 211 | try { |
| 212 | ApplicationInfo info = pm.getApplicationInfo(packageName, 0); |
| 213 | return pm.getApplicationLabel(info); |
| 214 | } catch (PackageManager.NameNotFoundException nnfe) { |
| 215 | Log.w(this, "Could not determine package name."); |
| 216 | } |
| 217 | |
| 218 | return null; |
| 219 | } |
| 220 | }); |
Hall Liu | 9ccc43d | 2015-12-15 14:18:33 -0800 | [diff] [blame] | 221 | mContactsAsyncHelper = new ContactsAsyncHelper( |
| 222 | new ContactsAsyncHelper.ContentResolverAdapter() { |
| 223 | @Override |
| 224 | public InputStream openInputStream(Context context, Uri uri) |
| 225 | throws FileNotFoundException { |
| 226 | return context.getContentResolver().openInputStream(uri); |
| 227 | } |
| 228 | }); |
Hall Liu | 486cb19 | 2016-10-21 18:23:33 -0700 | [diff] [blame] | 229 | BluetoothDeviceManager bluetoothDeviceManager = new BluetoothDeviceManager(mContext, |
| 230 | new BluetoothAdapterProxy(), mLock); |
| 231 | BluetoothRouteManager bluetoothRouteManager = new BluetoothRouteManager(mContext, mLock, |
| 232 | bluetoothDeviceManager, new Timeouts.Adapter()); |
Hall Liu | 784a496 | 2018-03-06 11:03:17 -0800 | [diff] [blame] | 233 | BluetoothStateReceiver bluetoothStateReceiver = new BluetoothStateReceiver( |
| 234 | bluetoothDeviceManager, bluetoothRouteManager); |
| 235 | mContext.registerReceiver(bluetoothStateReceiver, BluetoothStateReceiver.INTENT_FILTER); |
| 236 | |
Hall Liu | f62630a | 2015-10-27 14:53:39 -0700 | [diff] [blame] | 237 | WiredHeadsetManager wiredHeadsetManager = new WiredHeadsetManager(mContext); |
Santos Cordon | f78a72f | 2016-01-21 22:10:32 +0000 | [diff] [blame] | 238 | SystemStateProvider systemStateProvider = new SystemStateProvider(mContext); |
Hall Liu | f62630a | 2015-10-27 14:53:39 -0700 | [diff] [blame] | 239 | |
Tony Mak | a993094 | 2016-01-15 10:57:14 +0000 | [diff] [blame] | 240 | mMissedCallNotifier = missedCallNotifierImplFactory |
Hall Liu | 7c92832 | 2016-12-06 18:15:39 -0800 | [diff] [blame] | 241 | .makeMissedCallNotifierImpl(mContext, mPhoneAccountRegistrar, defaultDialerCache); |
Santos Cordon | 501b9b3 | 2016-03-07 14:40:07 -0800 | [diff] [blame] | 242 | |
mike dooley | 66f26d1 | 2016-12-19 13:25:47 -0800 | [diff] [blame] | 243 | EmergencyCallHelper emergencyCallHelper = new EmergencyCallHelper(mContext, |
mike dooley | 21fb1af | 2016-12-05 14:25:53 -0800 | [diff] [blame] | 244 | mContext.getResources().getString(R.string.ui_default_package), timeoutsAdapter); |
| 245 | |
Tyler Gunn | c74b3e2 | 2017-11-07 15:03:24 -0800 | [diff] [blame] | 246 | InCallControllerFactory inCallControllerFactory = new InCallControllerFactory() { |
| 247 | @Override |
| 248 | public InCallController create(Context context, SyncRoot lock, |
| 249 | CallsManager callsManager, SystemStateProvider systemStateProvider, |
| 250 | DefaultDialerCache defaultDialerCache, Timeouts.Adapter timeoutsAdapter, |
| 251 | EmergencyCallHelper emergencyCallHelper) { |
| 252 | return new InCallController(context, lock, callsManager, systemStateProvider, |
| 253 | defaultDialerCache, timeoutsAdapter, emergencyCallHelper); |
| 254 | } |
| 255 | }; |
| 256 | |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 257 | mCallsManager = new CallsManager( |
Ihab Awad | 8de7691 | 2015-02-17 12:25:52 -0800 | [diff] [blame] | 258 | mContext, |
Ihab Awad | 8d5d9dd | 2015-03-12 11:11:06 -0700 | [diff] [blame] | 259 | mLock, |
| 260 | mContactsAsyncHelper, |
Ihab Awad | abcbce4 | 2015-04-07 14:04:01 -0700 | [diff] [blame] | 261 | callerInfoAsyncQueryFactory, |
Ihab Awad | 8de7691 | 2015-02-17 12:25:52 -0800 | [diff] [blame] | 262 | mMissedCallNotifier, |
| 263 | mPhoneAccountRegistrar, |
| 264 | headsetMediaButtonFactory, |
| 265 | proximitySensorManagerFactory, |
Hall Liu | 8fb1fb7 | 2015-10-22 15:24:40 -0700 | [diff] [blame] | 266 | inCallWakeLockControllerFactory, |
Pengquan Meng | 606ff7f | 2017-12-20 16:13:04 -0800 | [diff] [blame] | 267 | connectionServiceFocusManagerFactory, |
Hall Liu | f62630a | 2015-10-27 14:53:39 -0700 | [diff] [blame] | 268 | audioServiceFactory, |
Hall Liu | 486cb19 | 2016-10-21 18:23:33 -0700 | [diff] [blame] | 269 | bluetoothRouteManager, |
Santos Cordon | f78a72f | 2016-01-21 22:10:32 +0000 | [diff] [blame] | 270 | wiredHeadsetManager, |
Santos Cordon | 501b9b3 | 2016-03-07 14:40:07 -0800 | [diff] [blame] | 271 | systemStateProvider, |
Hall Liu | 7c92832 | 2016-12-06 18:15:39 -0800 | [diff] [blame] | 272 | defaultDialerCache, |
Hall Liu | 6d4b66d | 2016-04-01 16:31:13 -0700 | [diff] [blame] | 273 | timeoutsAdapter, |
Brad Ebinger | 6e8f3d7 | 2016-06-20 11:35:42 -0700 | [diff] [blame] | 274 | asyncRingtonePlayer, |
Tyler Gunn | eaaf074 | 2016-09-15 15:36:38 -0700 | [diff] [blame] | 275 | phoneNumberUtilsAdapter, |
Brad Ebinger | 7bba111 | 2017-06-08 13:57:28 -0700 | [diff] [blame] | 276 | emergencyCallHelper, |
Tyler Gunn | 02e00dd | 2017-08-24 15:44:02 -0700 | [diff] [blame] | 277 | toneGeneratorFactory, |
Tyler Gunn | c74b3e2 | 2017-11-07 15:03:24 -0800 | [diff] [blame] | 278 | clockProxy, |
Hall Liu | 784a496 | 2018-03-06 11:03:17 -0800 | [diff] [blame] | 279 | bluetoothStateReceiver, |
Tyler Gunn | c74b3e2 | 2017-11-07 15:03:24 -0800 | [diff] [blame] | 280 | inCallControllerFactory); |
Ihab Awad | 8de7691 | 2015-02-17 12:25:52 -0800 | [diff] [blame] | 281 | |
Tyler Gunn | 2b17f23 | 2017-03-08 08:51:00 -0800 | [diff] [blame] | 282 | mIncomingCallNotifier = incomingCallNotifier; |
| 283 | incomingCallNotifier.setCallsManagerProxy(new IncomingCallNotifier.CallsManagerProxy() { |
| 284 | @Override |
| 285 | public boolean hasCallsForOtherPhoneAccount(PhoneAccountHandle phoneAccountHandle) { |
| 286 | return mCallsManager.hasCallsForOtherPhoneAccount(phoneAccountHandle); |
| 287 | } |
| 288 | |
| 289 | @Override |
| 290 | public int getNumCallsForOtherPhoneAccount(PhoneAccountHandle phoneAccountHandle) { |
| 291 | return mCallsManager.getNumCallsForOtherPhoneAccount(phoneAccountHandle); |
| 292 | } |
| 293 | |
| 294 | @Override |
| 295 | public Call getActiveCall() { |
| 296 | return mCallsManager.getActiveCall(); |
| 297 | } |
| 298 | }); |
| 299 | mCallsManager.setIncomingCallNotifier(mIncomingCallNotifier); |
| 300 | |
Ihab Awad | 8d5d9dd | 2015-03-12 11:11:06 -0700 | [diff] [blame] | 301 | mRespondViaSmsManager = new RespondViaSmsManager(mCallsManager, mLock); |
Ihab Awad | 8de7691 | 2015-02-17 12:25:52 -0800 | [diff] [blame] | 302 | mCallsManager.setRespondViaSmsManager(mRespondViaSmsManager); |
| 303 | |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 304 | mContext.registerReceiver(mUserSwitchedReceiver, USER_SWITCHED_FILTER); |
Tony Mak | a993094 | 2016-01-15 10:57:14 +0000 | [diff] [blame] | 305 | mContext.registerReceiver(mUserStartingReceiver, USER_STARTING_FILTER); |
Hall Liu | 3037ac6 | 2016-09-22 14:40:03 -0700 | [diff] [blame] | 306 | mContext.registerReceiver(mBootCompletedReceiver, BOOT_COMPLETE_FILTER); |
Tony Mak | a993094 | 2016-01-15 10:57:14 +0000 | [diff] [blame] | 307 | |
Hall Liu | b3979ee | 2015-11-11 16:21:25 -0800 | [diff] [blame] | 308 | mBluetoothPhoneServiceImpl = bluetoothPhoneServiceImplFactory.makeBluetoothPhoneServiceImpl( |
Ihab Awad | 8d5d9dd | 2015-03-12 11:11:06 -0700 | [diff] [blame] | 309 | mContext, mLock, mCallsManager, mPhoneAccountRegistrar); |
Ihab Awad | 8de7691 | 2015-02-17 12:25:52 -0800 | [diff] [blame] | 310 | mCallIntentProcessor = new CallIntentProcessor(mContext, mCallsManager); |
| 311 | mTelecomBroadcastIntentProcessor = new TelecomBroadcastIntentProcessor( |
| 312 | mContext, mCallsManager); |
Tyler Gunn | b5e7d80 | 2015-10-21 08:17:38 -0700 | [diff] [blame] | 313 | |
| 314 | // Register the receiver for the dialer secret codes, used to enable extended logging. |
| 315 | mDialerCodeReceiver = new DialerCodeReceiver(mCallsManager); |
| 316 | mContext.registerReceiver(mDialerCodeReceiver, DIALER_SECRET_CODE_FILTER, |
| 317 | Manifest.permission.CONTROL_INCALL_EXPERIENCE, null); |
| 318 | |
Ihab Awad | 8d5d9dd | 2015-03-12 11:11:06 -0700 | [diff] [blame] | 319 | mTelecomServiceImpl = new TelecomServiceImpl( |
Hall Liu | ecda554 | 2015-12-04 11:31:31 -0800 | [diff] [blame] | 320 | mContext, mCallsManager, mPhoneAccountRegistrar, |
| 321 | new CallIntentProcessor.AdapterImpl(), |
| 322 | new UserCallIntentProcessorFactory() { |
| 323 | @Override |
| 324 | public UserCallIntentProcessor create(Context context, UserHandle userHandle) { |
| 325 | return new UserCallIntentProcessor(context, userHandle); |
| 326 | } |
| 327 | }, |
Hall Liu | 7c92832 | 2016-12-06 18:15:39 -0800 | [diff] [blame] | 328 | defaultDialerCache, |
Hall Liu | 0a6dd30 | 2015-12-16 15:06:49 -0800 | [diff] [blame] | 329 | new TelecomServiceImpl.SubscriptionManagerAdapterImpl(), |
Hall Liu | ecda554 | 2015-12-04 11:31:31 -0800 | [diff] [blame] | 330 | mLock); |
Brad Ebinger | 83bc411 | 2016-04-01 15:30:14 -0700 | [diff] [blame] | 331 | Log.endSession(); |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 332 | } |
| 333 | |
Ihab Awad | 8d5d9dd | 2015-03-12 11:11:06 -0700 | [diff] [blame] | 334 | @VisibleForTesting |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 335 | public PhoneAccountRegistrar getPhoneAccountRegistrar() { |
| 336 | return mPhoneAccountRegistrar; |
| 337 | } |
| 338 | |
Hall Liu | 9ecbb1c | 2016-04-14 14:35:48 -0700 | [diff] [blame] | 339 | @VisibleForTesting |
| 340 | public CallsManager getCallsManager() { |
| 341 | return mCallsManager; |
| 342 | } |
| 343 | |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 344 | public BluetoothPhoneServiceImpl getBluetoothPhoneServiceImpl() { |
| 345 | return mBluetoothPhoneServiceImpl; |
| 346 | } |
| 347 | |
| 348 | public CallIntentProcessor getCallIntentProcessor() { |
| 349 | return mCallIntentProcessor; |
| 350 | } |
| 351 | |
| 352 | public TelecomBroadcastIntentProcessor getTelecomBroadcastIntentProcessor() { |
| 353 | return mTelecomBroadcastIntentProcessor; |
| 354 | } |
| 355 | |
| 356 | public TelecomServiceImpl getTelecomServiceImpl() { |
| 357 | return mTelecomServiceImpl; |
| 358 | } |
Ihab Awad | 8d5d9dd | 2015-03-12 11:11:06 -0700 | [diff] [blame] | 359 | |
| 360 | public Object getLock() { |
| 361 | return mLock; |
| 362 | } |
Hall Liu | 3037ac6 | 2016-09-22 14:40:03 -0700 | [diff] [blame] | 363 | |
| 364 | public boolean isBootComplete() { |
| 365 | return mIsBootComplete; |
| 366 | } |
Ihab Awad | 78a5e6b | 2015-02-06 10:13:05 -0800 | [diff] [blame] | 367 | } |