Santos Cordon | 8e8b8d2 | 2013-12-19 14:14:05 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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 | |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 17 | package com.android.server.telecom; |
Ben Gilad | 9f2bed3 | 2013-12-12 17:43:26 -0800 | [diff] [blame] | 18 | |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 19 | import android.content.Context; |
Sailesh Nepal | ce704b9 | 2014-03-17 18:31:43 -0700 | [diff] [blame] | 20 | import android.net.Uri; |
Evan Charlton | a05805b | 2014-03-05 08:21:46 -0800 | [diff] [blame] | 21 | import android.os.Bundle; |
Santos Cordon | cf5b291 | 2014-11-05 21:57:54 -0800 | [diff] [blame] | 22 | import android.os.Handler; |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 23 | import android.os.Trace; |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 24 | import android.provider.CallLog.Calls; |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 25 | import android.telecom.AudioState; |
| 26 | import android.telecom.CallState; |
Ihab Awad | 07bc5ee | 2014-11-12 13:42:52 -0800 | [diff] [blame] | 27 | import android.telecom.Connection; |
Andrew Lee | 701dc00 | 2014-09-11 21:29:12 -0700 | [diff] [blame] | 28 | import android.telecom.DisconnectCause; |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 29 | import android.telecom.GatewayInfo; |
| 30 | import android.telecom.ParcelableConference; |
Tyler Gunn | 6e2b94e | 2014-10-30 11:05:22 -0700 | [diff] [blame] | 31 | import android.telecom.ParcelableConnection; |
Tyler Gunn | 5b452df | 2014-10-01 15:02:58 -0700 | [diff] [blame] | 32 | import android.telecom.PhoneAccount; |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 33 | import android.telecom.PhoneAccountHandle; |
Tyler Gunn | 5b452df | 2014-10-01 15:02:58 -0700 | [diff] [blame] | 34 | import android.telecom.TelecomManager; |
Andrew Lee | 4550623 | 2014-10-22 17:54:33 -0700 | [diff] [blame] | 35 | import android.telecom.VideoProfile; |
Sailesh Nepal | 8aa6a00 | 2014-09-12 10:52:49 -0700 | [diff] [blame] | 36 | import android.telephony.TelephonyManager; |
Santos Cordon | 8e8b8d2 | 2013-12-19 14:14:05 -0800 | [diff] [blame] | 37 | |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 38 | import com.android.internal.util.IndentingPrintWriter; |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 39 | |
Santos Cordon | 4bc0245 | 2014-11-19 15:51:12 -0800 | [diff] [blame] | 40 | import java.util.Collection; |
Jay Shrauner | a82c8f7 | 2014-08-14 15:49:16 -0700 | [diff] [blame] | 41 | import java.util.Collections; |
Ihab Awad | 5b28132 | 2014-09-25 18:25:29 -0700 | [diff] [blame] | 42 | import java.util.HashSet; |
Santos Cordon | 7cdb909 | 2014-07-24 21:33:33 -0700 | [diff] [blame] | 43 | import java.util.List; |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 44 | import java.util.Objects; |
Santos Cordon | a56f276 | 2014-03-24 15:55:53 -0700 | [diff] [blame] | 45 | import java.util.Set; |
Jay Shrauner | a82c8f7 | 2014-08-14 15:49:16 -0700 | [diff] [blame] | 46 | import java.util.concurrent.ConcurrentHashMap; |
Ben Gilad | 9f2bed3 | 2013-12-12 17:43:26 -0800 | [diff] [blame] | 47 | |
Ben Gilad | dd8c608 | 2013-12-30 14:44:08 -0800 | [diff] [blame] | 48 | /** |
| 49 | * Singleton. |
| 50 | * |
Jay Shrauner | acb91eb | 2014-08-08 16:04:53 -0700 | [diff] [blame] | 51 | * NOTE: by design most APIs are package private, use the relevant adapter/s to allow |
Ben Gilad | dd8c608 | 2013-12-30 14:44:08 -0800 | [diff] [blame] | 52 | * access from other packages specifically refraining from passing the CallsManager instance |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 53 | * beyond the com.android.server.telecom package boundary. |
Ben Gilad | dd8c608 | 2013-12-30 14:44:08 -0800 | [diff] [blame] | 54 | */ |
Santos Cordon | 64c7e96 | 2014-07-02 15:15:27 -0700 | [diff] [blame] | 55 | public final class CallsManager extends Call.ListenerBase { |
Ben Gilad | a0d9f75 | 2014-02-26 11:49:03 -0800 | [diff] [blame] | 56 | |
Santos Cordon | df39986 | 2014-08-06 04:39:15 -0700 | [diff] [blame] | 57 | // TODO: Consider renaming this CallsManagerPlugin. |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 58 | interface CallsManagerListener { |
| 59 | void onCallAdded(Call call); |
| 60 | void onCallRemoved(Call call); |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 61 | void onCallStateChanged(Call call, int oldState, int newState); |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 62 | void onConnectionServiceChanged( |
Sailesh Nepal | 8c85dee | 2014-04-07 22:21:40 -0700 | [diff] [blame] | 63 | Call call, |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 64 | ConnectionServiceWrapper oldService, |
| 65 | ConnectionServiceWrapper newService); |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 66 | void onIncomingCallAnswered(Call call); |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 67 | void onIncomingCallRejected(Call call, boolean rejectWithMessage, String textMessage); |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 68 | void onForegroundCallChanged(Call oldForegroundCall, Call newForegroundCall); |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 69 | void onAudioStateChanged(AudioState oldAudioState, AudioState newAudioState); |
Andrew Lee | 5be64bc | 2014-09-08 18:35:15 -0700 | [diff] [blame] | 70 | void onRingbackRequested(Call call, boolean ringback); |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 71 | void onIsConferencedChanged(Call call); |
Andrew Lee | 5be64bc | 2014-09-08 18:35:15 -0700 | [diff] [blame] | 72 | void onIsVoipAudioModeChanged(Call call); |
Andrew Lee | 4a79660 | 2014-07-11 17:23:03 -0700 | [diff] [blame] | 73 | void onVideoStateChanged(Call call); |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 74 | void onCanAddCallChanged(boolean canAddCall); |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 75 | } |
| 76 | |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 77 | /** |
| 78 | * Singleton instance of the {@link CallsManager}, initialized from {@link TelecomService}. |
| 79 | */ |
Santos Cordon | e6a33f2 | 2014-12-02 13:19:00 -0800 | [diff] [blame^] | 80 | private static CallsManager sInstance = null; |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 81 | |
| 82 | private static final String TAG = "CallsManager"; |
Ben Gilad | 9f2bed3 | 2013-12-12 17:43:26 -0800 | [diff] [blame] | 83 | |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 84 | private static final int MAXIMUM_LIVE_CALLS = 1; |
| 85 | private static final int MAXIMUM_HOLD_CALLS = 1; |
| 86 | private static final int MAXIMUM_RINGING_CALLS = 1; |
| 87 | private static final int MAXIMUM_OUTGOING_CALLS = 1; |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 88 | private static final int MAXIMUM_TOP_LEVEL_CALLS = 2; |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 89 | |
| 90 | private static final int[] OUTGOING_CALL_STATES = |
| 91 | {CallState.CONNECTING, CallState.PRE_DIAL_WAIT, CallState.DIALING}; |
| 92 | |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 93 | private static final int[] LIVE_CALL_STATES = |
| 94 | {CallState.CONNECTING, CallState.PRE_DIAL_WAIT, CallState.DIALING, CallState.ACTIVE}; |
| 95 | |
Santos Cordon | 8e8b8d2 | 2013-12-19 14:14:05 -0800 | [diff] [blame] | 96 | /** |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 97 | * The main call repository. Keeps an instance of all live calls. New incoming and outgoing |
| 98 | * calls are added to the map and removed when the calls move to the disconnected state. |
Santos Cordon | cf5b291 | 2014-11-05 21:57:54 -0800 | [diff] [blame] | 99 | * |
Jay Shrauner | a82c8f7 | 2014-08-14 15:49:16 -0700 | [diff] [blame] | 100 | * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is |
| 101 | * load factor before resizing, 1 means we only expect a single thread to |
| 102 | * access the map so make only a single shard |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 103 | */ |
Jay Shrauner | a82c8f7 | 2014-08-14 15:49:16 -0700 | [diff] [blame] | 104 | private final Set<Call> mCalls = Collections.newSetFromMap( |
| 105 | new ConcurrentHashMap<Call, Boolean>(8, 0.9f, 1)); |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 106 | |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 107 | private final ConnectionServiceRepository mConnectionServiceRepository; |
| 108 | private final DtmfLocalTonePlayer mDtmfLocalTonePlayer; |
| 109 | private final InCallController mInCallController; |
Santos Cordon | f3671a6 | 2014-05-29 21:51:53 -0700 | [diff] [blame] | 110 | private final CallAudioManager mCallAudioManager; |
| 111 | private final Ringer mRinger; |
Santos Cordon | 61e6f35 | 2014-12-03 02:53:34 -0800 | [diff] [blame] | 112 | private final InCallWakeLockController mInCallWakeLockController; |
Jay Shrauner | a82c8f7 | 2014-08-14 15:49:16 -0700 | [diff] [blame] | 113 | // For this set initial table size to 16 because we add 13 listeners in |
| 114 | // the CallsManager constructor. |
| 115 | private final Set<CallsManagerListener> mListeners = Collections.newSetFromMap( |
| 116 | new ConcurrentHashMap<CallsManagerListener, Boolean>(16, 0.9f, 1)); |
Santos Cordon | deb8c89 | 2014-05-30 01:38:03 -0700 | [diff] [blame] | 117 | private final HeadsetMediaButton mHeadsetMediaButton; |
Sailesh Nepal | b88795a | 2014-07-15 14:53:27 -0700 | [diff] [blame] | 118 | private final WiredHeadsetManager mWiredHeadsetManager; |
| 119 | private final TtyManager mTtyManager; |
Yorke Lee | d134687 | 2014-07-28 14:38:45 -0700 | [diff] [blame] | 120 | private final ProximitySensorManager mProximitySensorManager; |
Yorke Lee | f86db2e | 2014-09-12 17:56:48 -0700 | [diff] [blame] | 121 | private final PhoneStateBroadcaster mPhoneStateBroadcaster; |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 122 | private final CallLogManager mCallLogManager; |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 123 | private final Context mContext; |
| 124 | private final PhoneAccountRegistrar mPhoneAccountRegistrar; |
| 125 | private final MissedCallNotifier mMissedCallNotifier; |
Ihab Awad | 5b28132 | 2014-09-25 18:25:29 -0700 | [diff] [blame] | 126 | private final Set<Call> mLocallyDisconnectingCalls = new HashSet<>(); |
Santos Cordon | cf5b291 | 2014-11-05 21:57:54 -0800 | [diff] [blame] | 127 | private final Set<Call> mPendingCallsToDisconnect = new HashSet<>(); |
| 128 | /* Handler tied to thread in which CallManager was initialized. */ |
| 129 | private final Handler mHandler = new Handler(); |
Sailesh Nepal | 84fa5f8 | 2014-04-02 11:01:11 -0700 | [diff] [blame] | 130 | |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 131 | private boolean mCanAddCall = true; |
| 132 | |
Sailesh Nepal | 84fa5f8 | 2014-04-02 11:01:11 -0700 | [diff] [blame] | 133 | /** |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 134 | * The call the user is currently interacting with. This is the call that should have audio |
| 135 | * focus and be visible in the in-call UI. |
Santos Cordon | 4e9fffe | 2014-03-04 18:13:41 -0800 | [diff] [blame] | 136 | */ |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 137 | private Call mForegroundCall; |
Santos Cordon | 4e9fffe | 2014-03-04 18:13:41 -0800 | [diff] [blame] | 138 | |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 139 | /** Singleton accessor. */ |
| 140 | static CallsManager getInstance() { |
Santos Cordon | e6a33f2 | 2014-12-02 13:19:00 -0800 | [diff] [blame^] | 141 | return sInstance; |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 142 | } |
Ben Gilad | 9f2bed3 | 2013-12-12 17:43:26 -0800 | [diff] [blame] | 143 | |
Santos Cordon | 8e8b8d2 | 2013-12-19 14:14:05 -0800 | [diff] [blame] | 144 | /** |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 145 | * Sets the static singleton instance. |
| 146 | * |
| 147 | * @param instance The instance to set. |
| 148 | */ |
| 149 | static void initialize(CallsManager instance) { |
Santos Cordon | e6a33f2 | 2014-12-02 13:19:00 -0800 | [diff] [blame^] | 150 | sInstance = instance; |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | /** |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 154 | * Initializes the required Telecom components. |
Santos Cordon | 8e8b8d2 | 2013-12-19 14:14:05 -0800 | [diff] [blame] | 155 | */ |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 156 | CallsManager(Context context, MissedCallNotifier missedCallNotifier, |
| 157 | PhoneAccountRegistrar phoneAccountRegistrar) { |
| 158 | mContext = context; |
| 159 | mPhoneAccountRegistrar = phoneAccountRegistrar; |
| 160 | mMissedCallNotifier = missedCallNotifier; |
| 161 | StatusBarNotifier statusBarNotifier = new StatusBarNotifier(context, this); |
| 162 | mWiredHeadsetManager = new WiredHeadsetManager(context); |
| 163 | mCallAudioManager = new CallAudioManager(context, statusBarNotifier, mWiredHeadsetManager); |
Santos Cordon | c7b8eba | 2014-04-01 15:26:28 -0700 | [diff] [blame] | 164 | InCallTonePlayer.Factory playerFactory = new InCallTonePlayer.Factory(mCallAudioManager); |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 165 | mRinger = new Ringer(mCallAudioManager, this, playerFactory, context); |
| 166 | mHeadsetMediaButton = new HeadsetMediaButton(context, this); |
| 167 | mTtyManager = new TtyManager(context, mWiredHeadsetManager); |
| 168 | mProximitySensorManager = new ProximitySensorManager(context); |
Yorke Lee | f86db2e | 2014-09-12 17:56:48 -0700 | [diff] [blame] | 169 | mPhoneStateBroadcaster = new PhoneStateBroadcaster(); |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 170 | mCallLogManager = new CallLogManager(context); |
| 171 | mInCallController = new InCallController(context); |
| 172 | mDtmfLocalTonePlayer = new DtmfLocalTonePlayer(context); |
| 173 | mConnectionServiceRepository = new ConnectionServiceRepository(mPhoneAccountRegistrar, |
| 174 | context); |
Santos Cordon | 61e6f35 | 2014-12-03 02:53:34 -0800 | [diff] [blame] | 175 | mInCallWakeLockController = new InCallWakeLockController(context, this); |
Santos Cordon | ae19306 | 2014-05-21 21:21:49 -0700 | [diff] [blame] | 176 | |
Santos Cordon | deb8c89 | 2014-05-30 01:38:03 -0700 | [diff] [blame] | 177 | mListeners.add(statusBarNotifier); |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 178 | mListeners.add(mCallLogManager); |
Yorke Lee | f86db2e | 2014-09-12 17:56:48 -0700 | [diff] [blame] | 179 | mListeners.add(mPhoneStateBroadcaster); |
Santos Cordon | f3671a6 | 2014-05-29 21:51:53 -0700 | [diff] [blame] | 180 | mListeners.add(mInCallController); |
Santos Cordon | ae19306 | 2014-05-21 21:21:49 -0700 | [diff] [blame] | 181 | mListeners.add(mRinger); |
Santos Cordon | c7b8eba | 2014-04-01 15:26:28 -0700 | [diff] [blame] | 182 | mListeners.add(new RingbackPlayer(this, playerFactory)); |
| 183 | mListeners.add(new InCallToneMonitor(playerFactory, this)); |
Santos Cordon | a56f276 | 2014-03-24 15:55:53 -0700 | [diff] [blame] | 184 | mListeners.add(mCallAudioManager); |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 185 | mListeners.add(missedCallNotifier); |
Santos Cordon | 92a2d81 | 2014-04-30 15:19:01 -0700 | [diff] [blame] | 186 | mListeners.add(mDtmfLocalTonePlayer); |
Santos Cordon | 8128998 | 2014-06-03 16:03:08 -0700 | [diff] [blame] | 187 | mListeners.add(mHeadsetMediaButton); |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 188 | mListeners.add(RespondViaSmsManager.getInstance()); |
Yorke Lee | d134687 | 2014-07-28 14:38:45 -0700 | [diff] [blame] | 189 | mListeners.add(mProximitySensorManager); |
Santos Cordon | 8e8b8d2 | 2013-12-19 14:14:05 -0800 | [diff] [blame] | 190 | } |
| 191 | |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 192 | @Override |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 193 | public void onSuccessfulOutgoingCall(Call call, int callState) { |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 194 | Log.v(this, "onSuccessfulOutgoingCall, %s", call); |
Yorke Lee | b701f6d | 2014-08-12 14:04:19 -0700 | [diff] [blame] | 195 | |
Tyler Gunn | cde2e50 | 2014-08-12 14:35:58 -0700 | [diff] [blame] | 196 | setCallState(call, callState); |
Yorke Lee | b701f6d | 2014-08-12 14:04:19 -0700 | [diff] [blame] | 197 | if (!mCalls.contains(call)) { |
| 198 | // Call was not added previously in startOutgoingCall due to it being a potential MMI |
| 199 | // code, so add it now. |
| 200 | addCall(call); |
| 201 | } |
| 202 | |
| 203 | // The call's ConnectionService has been updated. |
| 204 | for (CallsManagerListener listener : mListeners) { |
| 205 | listener.onConnectionServiceChanged(call, null, call.getConnectionService()); |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 206 | } |
Santos Cordon | 6cb7ba9 | 2014-05-23 14:09:32 -0700 | [diff] [blame] | 207 | |
| 208 | markCallAsDialing(call); |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | @Override |
Andrew Lee | 701dc00 | 2014-09-11 21:29:12 -0700 | [diff] [blame] | 212 | public void onFailedOutgoingCall(Call call, DisconnectCause disconnectCause) { |
Sailesh Nepal | 5a73b03 | 2014-06-25 15:53:21 -0700 | [diff] [blame] | 213 | Log.v(this, "onFailedOutgoingCall, call: %s", call); |
Yorke Lee | b701f6d | 2014-08-12 14:04:19 -0700 | [diff] [blame] | 214 | |
Andrew Lee | e6288a7 | 2014-10-01 13:50:02 -0700 | [diff] [blame] | 215 | markCallAsRemoved(call); |
Sailesh Nepal | 5a73b03 | 2014-06-25 15:53:21 -0700 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | @Override |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 219 | public void onSuccessfulIncomingCall(Call incomingCall) { |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 220 | Log.d(this, "onSuccessfulIncomingCall"); |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 221 | setCallState(incomingCall, CallState.RINGING); |
| 222 | |
| 223 | if (hasMaximumRingingCalls()) { |
| 224 | incomingCall.reject(false, null); |
| 225 | // since the call was not added to the list of calls, we have to call the missed |
| 226 | // call notifier and the call logger manually. |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 227 | mMissedCallNotifier.showMissedCallNotification(incomingCall); |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 228 | mCallLogManager.logCall(incomingCall, Calls.MISSED_TYPE); |
| 229 | } else { |
| 230 | addCall(incomingCall); |
| 231 | } |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | @Override |
| 235 | public void onFailedIncomingCall(Call call) { |
Tyler Gunn | cde2e50 | 2014-08-12 14:35:58 -0700 | [diff] [blame] | 236 | setCallState(call, CallState.DISCONNECTED); |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 237 | call.removeListener(this); |
Ben Gilad | a0d9f75 | 2014-02-26 11:49:03 -0800 | [diff] [blame] | 238 | } |
| 239 | |
Ihab Awad | cb387ac | 2014-05-28 16:49:38 -0700 | [diff] [blame] | 240 | @Override |
Yorke Lee | 9250e5f | 2014-10-01 13:39:09 -0700 | [diff] [blame] | 241 | public void onSuccessfulUnknownCall(Call call, int callState) { |
| 242 | setCallState(call, callState); |
| 243 | Log.i(this, "onSuccessfulUnknownCall for call %s", call); |
| 244 | addCall(call); |
| 245 | } |
| 246 | |
| 247 | @Override |
| 248 | public void onFailedUnknownCall(Call call) { |
| 249 | Log.i(this, "onFailedUnknownCall for call %s", call); |
| 250 | setCallState(call, CallState.DISCONNECTED); |
| 251 | call.removeListener(this); |
| 252 | } |
| 253 | |
| 254 | @Override |
Andrew Lee | 5be64bc | 2014-09-08 18:35:15 -0700 | [diff] [blame] | 255 | public void onRingbackRequested(Call call, boolean ringback) { |
Ihab Awad | cb387ac | 2014-05-28 16:49:38 -0700 | [diff] [blame] | 256 | for (CallsManagerListener listener : mListeners) { |
Andrew Lee | 5be64bc | 2014-09-08 18:35:15 -0700 | [diff] [blame] | 257 | listener.onRingbackRequested(call, ringback); |
Ihab Awad | cb387ac | 2014-05-28 16:49:38 -0700 | [diff] [blame] | 258 | } |
| 259 | } |
| 260 | |
Evan Charlton | 352105c | 2014-06-03 14:10:54 -0700 | [diff] [blame] | 261 | @Override |
| 262 | public void onPostDialWait(Call call, String remaining) { |
| 263 | mInCallController.onPostDialWait(call, remaining); |
| 264 | } |
| 265 | |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 266 | @Override |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 267 | public void onParentChanged(Call call) { |
Santos Cordon | 66fe882 | 2014-10-10 16:10:58 -0700 | [diff] [blame] | 268 | // parent-child relationship affects which call should be foreground, so do an update. |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 269 | updateCallsManagerState(); |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 270 | for (CallsManagerListener listener : mListeners) { |
| 271 | listener.onIsConferencedChanged(call); |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | @Override |
| 276 | public void onChildrenChanged(Call call) { |
Santos Cordon | 66fe882 | 2014-10-10 16:10:58 -0700 | [diff] [blame] | 277 | // parent-child relationship affects which call should be foreground, so do an update. |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 278 | updateCallsManagerState(); |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 279 | for (CallsManagerListener listener : mListeners) { |
| 280 | listener.onIsConferencedChanged(call); |
| 281 | } |
| 282 | } |
| 283 | |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 284 | @Override |
Andrew Lee | 5be64bc | 2014-09-08 18:35:15 -0700 | [diff] [blame] | 285 | public void onIsVoipAudioModeChanged(Call call) { |
Sailesh Nepal | 7e66957 | 2014-07-08 21:29:12 -0700 | [diff] [blame] | 286 | for (CallsManagerListener listener : mListeners) { |
Andrew Lee | 5be64bc | 2014-09-08 18:35:15 -0700 | [diff] [blame] | 287 | listener.onIsVoipAudioModeChanged(call); |
Sailesh Nepal | 7e66957 | 2014-07-08 21:29:12 -0700 | [diff] [blame] | 288 | } |
| 289 | } |
| 290 | |
Andrew Lee | 4a79660 | 2014-07-11 17:23:03 -0700 | [diff] [blame] | 291 | @Override |
| 292 | public void onVideoStateChanged(Call call) { |
| 293 | for (CallsManagerListener listener : mListeners) { |
| 294 | listener.onVideoStateChanged(call); |
| 295 | } |
| 296 | } |
| 297 | |
Santos Cordon | cf5b291 | 2014-11-05 21:57:54 -0800 | [diff] [blame] | 298 | @Override |
| 299 | public boolean onCanceledViaNewOutgoingCallBroadcast(final Call call) { |
| 300 | mPendingCallsToDisconnect.add(call); |
| 301 | mHandler.postDelayed(new Runnable() { |
| 302 | @Override |
| 303 | public void run() { |
| 304 | if (mPendingCallsToDisconnect.remove(call)) { |
| 305 | Log.i(this, "Delayed disconnection of call: %s", call); |
| 306 | call.disconnect(); |
| 307 | } |
| 308 | } |
| 309 | }, Timeouts.getNewOutgoingCallCancelMillis(mContext.getContentResolver())); |
| 310 | |
| 311 | return true; |
| 312 | } |
| 313 | |
Santos Cordon | 4bc0245 | 2014-11-19 15:51:12 -0800 | [diff] [blame] | 314 | Collection<Call> getCalls() { |
| 315 | return Collections.unmodifiableCollection(mCalls); |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | Call getForegroundCall() { |
| 319 | return mForegroundCall; |
| 320 | } |
| 321 | |
Santos Cordon | ae19306 | 2014-05-21 21:21:49 -0700 | [diff] [blame] | 322 | Ringer getRinger() { |
| 323 | return mRinger; |
| 324 | } |
| 325 | |
Santos Cordon | f3671a6 | 2014-05-29 21:51:53 -0700 | [diff] [blame] | 326 | InCallController getInCallController() { |
| 327 | return mInCallController; |
| 328 | } |
| 329 | |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 330 | boolean hasEmergencyCall() { |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 331 | for (Call call : mCalls) { |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 332 | if (call.isEmergencyCall()) { |
| 333 | return true; |
| 334 | } |
| 335 | } |
| 336 | return false; |
| 337 | } |
| 338 | |
Andrew Lee | 4550623 | 2014-10-22 17:54:33 -0700 | [diff] [blame] | 339 | boolean hasVideoCall() { |
| 340 | for (Call call : mCalls) { |
| 341 | if (call.getVideoState() != VideoProfile.VideoState.AUDIO_ONLY) { |
| 342 | return true; |
| 343 | } |
| 344 | } |
| 345 | return false; |
| 346 | } |
| 347 | |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 348 | AudioState getAudioState() { |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 349 | return mCallAudioManager.getAudioState(); |
| 350 | } |
| 351 | |
Sailesh Nepal | b88795a | 2014-07-15 14:53:27 -0700 | [diff] [blame] | 352 | boolean isTtySupported() { |
| 353 | return mTtyManager.isTtySupported(); |
| 354 | } |
| 355 | |
| 356 | int getCurrentTtyMode() { |
| 357 | return mTtyManager.getCurrentTtyMode(); |
| 358 | } |
| 359 | |
Santos Cordon | 68d1a6b | 2014-09-19 12:25:58 -0700 | [diff] [blame] | 360 | void addListener(CallsManagerListener listener) { |
| 361 | mListeners.add(listener); |
| 362 | } |
| 363 | |
| 364 | void removeListener(CallsManagerListener listener) { |
| 365 | mListeners.remove(listener); |
| 366 | } |
| 367 | |
Santos Cordon | 8e8b8d2 | 2013-12-19 14:14:05 -0800 | [diff] [blame] | 368 | /** |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 369 | * Starts the process to attach the call to a connection service. |
Santos Cordon | 80d9bdc | 2014-02-13 18:28:46 -0800 | [diff] [blame] | 370 | * |
Nancy Chen | bc9ef17 | 2014-08-15 17:11:57 -0700 | [diff] [blame] | 371 | * @param phoneAccountHandle The phone account which contains the component name of the |
| 372 | * connection service to use for this call. |
Evan Charlton | a05805b | 2014-03-05 08:21:46 -0800 | [diff] [blame] | 373 | * @param extras The optional extras Bundle passed with the intent used for the incoming call. |
Santos Cordon | 80d9bdc | 2014-02-13 18:28:46 -0800 | [diff] [blame] | 374 | */ |
Evan Charlton | 8917637 | 2014-07-19 18:23:09 -0700 | [diff] [blame] | 375 | void processIncomingCallIntent(PhoneAccountHandle phoneAccountHandle, Bundle extras) { |
Sailesh Nepal | f1c191d | 2014-03-07 18:17:39 -0800 | [diff] [blame] | 376 | Log.d(this, "processIncomingCallIntent"); |
Sailesh Nepal | 8aa6a00 | 2014-09-12 10:52:49 -0700 | [diff] [blame] | 377 | Uri handle = extras.getParcelable(TelephonyManager.EXTRA_INCOMING_NUMBER); |
Sailesh Nepal | 905dfba | 2014-07-14 08:20:41 -0700 | [diff] [blame] | 378 | Call call = new Call( |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 379 | mContext, |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 380 | mConnectionServiceRepository, |
Sailesh Nepal | 8aa6a00 | 2014-09-12 10:52:49 -0700 | [diff] [blame] | 381 | handle, |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 382 | null /* gatewayInfo */, |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 383 | null /* connectionManagerPhoneAccount */, |
Evan Charlton | 8917637 | 2014-07-19 18:23:09 -0700 | [diff] [blame] | 384 | phoneAccountHandle, |
Sailesh Nepal | 664837f | 2014-07-14 16:31:51 -0700 | [diff] [blame] | 385 | true /* isIncoming */, |
| 386 | false /* isConference */); |
| 387 | |
Sailesh Nepal | 905dfba | 2014-07-14 08:20:41 -0700 | [diff] [blame] | 388 | call.setExtras(extras); |
Santos Cordon | df39986 | 2014-08-06 04:39:15 -0700 | [diff] [blame] | 389 | // TODO: Move this to be a part of addCall() |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 390 | call.addListener(this); |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 391 | call.startCreateConnection(mPhoneAccountRegistrar); |
Ben Gilad | a0d9f75 | 2014-02-26 11:49:03 -0800 | [diff] [blame] | 392 | } |
| 393 | |
Yorke Lee | 9250e5f | 2014-10-01 13:39:09 -0700 | [diff] [blame] | 394 | void addNewUnknownCall(PhoneAccountHandle phoneAccountHandle, Bundle extras) { |
| 395 | Uri handle = extras.getParcelable(TelecomManager.EXTRA_UNKNOWN_CALL_HANDLE); |
| 396 | Log.i(this, "addNewUnknownCall with handle: %s", Log.pii(handle)); |
| 397 | Call call = new Call( |
| 398 | mContext, |
| 399 | mConnectionServiceRepository, |
| 400 | handle, |
| 401 | null /* gatewayInfo */, |
| 402 | null /* connectionManagerPhoneAccount */, |
| 403 | phoneAccountHandle, |
| 404 | // Use onCreateIncomingConnection in TelephonyConnectionService, so that we attach |
| 405 | // to the existing connection instead of trying to create a new one. |
| 406 | true /* isIncoming */, |
| 407 | false /* isConference */); |
Yorke Lee | 9250e5f | 2014-10-01 13:39:09 -0700 | [diff] [blame] | 408 | call.setIsUnknown(true); |
| 409 | call.setExtras(extras); |
| 410 | call.addListener(this); |
| 411 | call.startCreateConnection(mPhoneAccountRegistrar); |
| 412 | } |
| 413 | |
Santos Cordon | cf5b291 | 2014-11-05 21:57:54 -0800 | [diff] [blame] | 414 | private Call getNewOutgoingCall(Uri handle) { |
| 415 | // First check to see if we can reuse any of the calls that are waiting to disconnect. |
| 416 | // See {@link Call#abort} and {@link #onCanceledViaNewOutgoingCall} for more information. |
Yorke Lee | 5997951 | 2014-12-02 01:03:40 -0800 | [diff] [blame] | 417 | Call reusedCall = null; |
Santos Cordon | cf5b291 | 2014-11-05 21:57:54 -0800 | [diff] [blame] | 418 | for (Call pendingCall : mPendingCallsToDisconnect) { |
Yorke Lee | 5997951 | 2014-12-02 01:03:40 -0800 | [diff] [blame] | 419 | if (reusedCall == null && Objects.equals(pendingCall.getHandle(), handle)) { |
Santos Cordon | cf5b291 | 2014-11-05 21:57:54 -0800 | [diff] [blame] | 420 | mPendingCallsToDisconnect.remove(pendingCall); |
| 421 | Log.i(this, "Reusing disconnected call %s", pendingCall); |
Yorke Lee | 5997951 | 2014-12-02 01:03:40 -0800 | [diff] [blame] | 422 | reusedCall = pendingCall; |
| 423 | } else { |
| 424 | pendingCall.disconnect(); |
Santos Cordon | cf5b291 | 2014-11-05 21:57:54 -0800 | [diff] [blame] | 425 | } |
| 426 | } |
Yorke Lee | 5997951 | 2014-12-02 01:03:40 -0800 | [diff] [blame] | 427 | if (reusedCall != null) { |
| 428 | return reusedCall; |
| 429 | } |
Santos Cordon | cf5b291 | 2014-11-05 21:57:54 -0800 | [diff] [blame] | 430 | |
| 431 | // Create a call with original handle. The handle may be changed when the call is attached |
| 432 | // to a connection service, but in most cases will remain the same. |
| 433 | return new Call( |
| 434 | mContext, |
| 435 | mConnectionServiceRepository, |
| 436 | handle, |
| 437 | null /* gatewayInfo */, |
| 438 | null /* connectionManagerPhoneAccount */, |
| 439 | null /* phoneAccountHandle */, |
| 440 | false /* isIncoming */, |
| 441 | false /* isConference */); |
| 442 | } |
| 443 | |
Nancy Chen | 0d3076c | 2014-07-30 14:45:44 -0700 | [diff] [blame] | 444 | /** |
| 445 | * Kicks off the first steps to creating an outgoing call so that InCallUI can launch. |
| 446 | * |
Nancy Chen | a9d91da | 2014-08-12 14:31:06 -0700 | [diff] [blame] | 447 | * @param handle Handle to connect the call with. |
Nancy Chen | bc9ef17 | 2014-08-15 17:11:57 -0700 | [diff] [blame] | 448 | * @param phoneAccountHandle The phone account which contains the component name of the |
| 449 | * connection service to use for this call. |
| 450 | * @param extras The optional extras Bundle passed with the intent used for the incoming call. |
Nancy Chen | 0d3076c | 2014-07-30 14:45:44 -0700 | [diff] [blame] | 451 | */ |
Nancy Chen | a9d91da | 2014-08-12 14:31:06 -0700 | [diff] [blame] | 452 | Call startOutgoingCall(Uri handle, PhoneAccountHandle phoneAccountHandle, Bundle extras) { |
Santos Cordon | cf5b291 | 2014-11-05 21:57:54 -0800 | [diff] [blame] | 453 | Call call = getNewOutgoingCall(handle); |
Nancy Chen | 1c5926f | 2014-09-17 14:44:14 -0700 | [diff] [blame] | 454 | |
| 455 | List<PhoneAccountHandle> accounts = |
| 456 | mPhoneAccountRegistrar.getCallCapablePhoneAccounts(handle.getScheme()); |
| 457 | |
Ihab Awad | 7e2c7f3 | 2014-11-03 09:49:45 -0800 | [diff] [blame] | 458 | Log.v(this, "startOutgoingCall found accounts = " + accounts); |
| 459 | |
Nancy Chen | bc95db9 | 2014-11-24 13:19:18 -0800 | [diff] [blame] | 460 | if (mForegroundCall != null && mForegroundCall.getTargetPhoneAccount() != null) { |
| 461 | // If there is an ongoing call, use the same phone account to place this new call. |
| 462 | phoneAccountHandle = mForegroundCall.getTargetPhoneAccount(); |
| 463 | } |
| 464 | |
Nancy Chen | bc9ef17 | 2014-08-15 17:11:57 -0700 | [diff] [blame] | 465 | // Only dial with the requested phoneAccount if it is still valid. Otherwise treat this call |
| 466 | // as if a phoneAccount was not specified (does the default behavior instead). |
Tyler Gunn | 8e0fef4 | 2014-09-08 18:34:44 -0700 | [diff] [blame] | 467 | // Note: We will not attempt to dial with a requested phoneAccount if it is disabled. |
Nancy Chen | bc9ef17 | 2014-08-15 17:11:57 -0700 | [diff] [blame] | 468 | if (phoneAccountHandle != null) { |
Nancy Chen | 309198e | 2014-09-15 18:02:49 -0700 | [diff] [blame] | 469 | if (!accounts.contains(phoneAccountHandle)) { |
Nancy Chen | bc9ef17 | 2014-08-15 17:11:57 -0700 | [diff] [blame] | 470 | phoneAccountHandle = null; |
| 471 | } |
| 472 | } |
| 473 | |
| 474 | if (phoneAccountHandle == null) { |
Tyler Gunn | 8425357 | 2014-09-02 14:50:05 -0700 | [diff] [blame] | 475 | // No preset account, check if default exists that supports the URI scheme for the |
| 476 | // handle. |
Nancy Chen | bc9ef17 | 2014-08-15 17:11:57 -0700 | [diff] [blame] | 477 | PhoneAccountHandle defaultAccountHandle = |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 478 | mPhoneAccountRegistrar.getDefaultOutgoingPhoneAccount( |
Tyler Gunn | 8425357 | 2014-09-02 14:50:05 -0700 | [diff] [blame] | 479 | handle.getScheme()); |
Nancy Chen | bc9ef17 | 2014-08-15 17:11:57 -0700 | [diff] [blame] | 480 | if (defaultAccountHandle != null) { |
| 481 | phoneAccountHandle = defaultAccountHandle; |
| 482 | } |
| 483 | } |
| 484 | |
Nancy Chen | 1c5926f | 2014-09-17 14:44:14 -0700 | [diff] [blame] | 485 | call.setTargetPhoneAccount(phoneAccountHandle); |
Nancy Chen | bc9ef17 | 2014-08-15 17:11:57 -0700 | [diff] [blame] | 486 | |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 487 | boolean isEmergencyCall = TelephonyUtil.shouldProcessAsEmergency(mContext, |
| 488 | call.getHandle()); |
Tyler Gunn | 5b452df | 2014-10-01 15:02:58 -0700 | [diff] [blame] | 489 | boolean isPotentialInCallMMICode = isPotentialInCallMMICode(handle); |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 490 | |
| 491 | // Do not support any more live calls. Our options are to move a call to hold, disconnect |
| 492 | // a call, or cancel this call altogether. |
Tyler Gunn | 5b452df | 2014-10-01 15:02:58 -0700 | [diff] [blame] | 493 | if (!isPotentialInCallMMICode && !makeRoomForOutgoingCall(call, isEmergencyCall)) { |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 494 | // just cancel at this point. |
Yorke Lee | 5997951 | 2014-12-02 01:03:40 -0800 | [diff] [blame] | 495 | Log.i(this, "No remaining room for outgoing call: %s", call); |
Santos Cordon | cf5b291 | 2014-11-05 21:57:54 -0800 | [diff] [blame] | 496 | if (mCalls.contains(call)) { |
| 497 | // This call can already exist if it is a reused call, |
| 498 | // See {@link #getNewOutgoingCall}. |
| 499 | call.disconnect(); |
| 500 | } |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 501 | return null; |
| 502 | } |
| 503 | |
Nancy Chen | 8d92f45 | 2014-10-20 21:43:44 -0700 | [diff] [blame] | 504 | boolean needsAccountSelection = phoneAccountHandle == null && accounts.size() > 1 && |
| 505 | !isEmergencyCall; |
| 506 | |
| 507 | if (needsAccountSelection) { |
Nancy Chen | bc9ef17 | 2014-08-15 17:11:57 -0700 | [diff] [blame] | 508 | // This is the state where the user is expected to select an account |
| 509 | call.setState(CallState.PRE_DIAL_WAIT); |
Nancy Chen | 1c5926f | 2014-09-17 14:44:14 -0700 | [diff] [blame] | 510 | extras.putParcelableList(android.telecom.Call.AVAILABLE_PHONE_ACCOUNTS, accounts); |
Nancy Chen | bc9ef17 | 2014-08-15 17:11:57 -0700 | [diff] [blame] | 511 | } else { |
| 512 | call.setState(CallState.CONNECTING); |
| 513 | } |
Nancy Chen | 0d3076c | 2014-07-30 14:45:44 -0700 | [diff] [blame] | 514 | |
Nancy Chen | 1c5926f | 2014-09-17 14:44:14 -0700 | [diff] [blame] | 515 | call.setExtras(extras); |
| 516 | |
Tyler Gunn | 504eb83 | 2014-10-13 14:15:27 -0700 | [diff] [blame] | 517 | // Do not add the call if it is a potential MMI code. |
Nancy Chen | 8d92f45 | 2014-10-20 21:43:44 -0700 | [diff] [blame] | 518 | if ((isPotentialMMICode(handle) || isPotentialInCallMMICode) && !needsAccountSelection) { |
Yorke Lee | b701f6d | 2014-08-12 14:04:19 -0700 | [diff] [blame] | 519 | call.addListener(this); |
Santos Cordon | cf5b291 | 2014-11-05 21:57:54 -0800 | [diff] [blame] | 520 | } else if (!mCalls.contains(call)) { |
| 521 | // We check if mCalls already contains the call because we could potentially be reusing |
| 522 | // a call which was previously added (See {@link #getNewOutgoingCall}). |
Tyler Gunn | 5b452df | 2014-10-01 15:02:58 -0700 | [diff] [blame] | 523 | addCall(call); |
Yorke Lee | b701f6d | 2014-08-12 14:04:19 -0700 | [diff] [blame] | 524 | } |
Nancy Chen | 0d3076c | 2014-07-30 14:45:44 -0700 | [diff] [blame] | 525 | |
| 526 | return call; |
| 527 | } |
| 528 | |
Ben Gilad | a0d9f75 | 2014-02-26 11:49:03 -0800 | [diff] [blame] | 529 | /** |
Yorke Lee | 3350163 | 2014-03-17 19:24:12 -0700 | [diff] [blame] | 530 | * Attempts to issue/connect the specified call. |
Santos Cordon | 8e8b8d2 | 2013-12-19 14:14:05 -0800 | [diff] [blame] | 531 | * |
Yorke Lee | 3350163 | 2014-03-17 19:24:12 -0700 | [diff] [blame] | 532 | * @param handle Handle to connect the call with. |
Yorke Lee | 3350163 | 2014-03-17 19:24:12 -0700 | [diff] [blame] | 533 | * @param gatewayInfo Optional gateway information that can be used to route the call to the |
Nancy Chen | 53ceedc | 2014-07-08 18:56:51 -0700 | [diff] [blame] | 534 | * actual dialed handle via a gateway provider. May be null. |
Sai Cheemalapati | b7157e9 | 2014-06-11 17:51:55 -0700 | [diff] [blame] | 535 | * @param speakerphoneOn Whether or not to turn the speakerphone on once the call connects. |
Tyler Gunn | c4abd91 | 2014-07-08 14:22:10 -0700 | [diff] [blame] | 536 | * @param videoState The desired video state for the outgoing call. |
Santos Cordon | 8e8b8d2 | 2013-12-19 14:14:05 -0800 | [diff] [blame] | 537 | */ |
Nancy Chen | bc9ef17 | 2014-08-15 17:11:57 -0700 | [diff] [blame] | 538 | void placeOutgoingCall(Call call, Uri handle, GatewayInfo gatewayInfo, boolean speakerphoneOn, |
| 539 | int videoState) { |
Nancy Chen | 0d3076c | 2014-07-30 14:45:44 -0700 | [diff] [blame] | 540 | if (call == null) { |
| 541 | // don't do anything if the call no longer exists |
| 542 | Log.i(this, "Canceling unknown call."); |
Santos Cordon | b7af09e | 2014-08-06 04:30:01 -0700 | [diff] [blame] | 543 | return; |
| 544 | } |
| 545 | |
Nancy Chen | 201b437 | 2014-09-08 14:18:24 -0700 | [diff] [blame] | 546 | final Uri uriHandle = (gatewayInfo == null) ? handle : gatewayInfo.getGatewayAddress(); |
Yorke Lee | 3350163 | 2014-03-17 19:24:12 -0700 | [diff] [blame] | 547 | |
| 548 | if (gatewayInfo == null) { |
Santos Cordon | b58f453 | 2014-05-29 11:59:06 -0700 | [diff] [blame] | 549 | Log.i(this, "Creating a new outgoing call with handle: %s", Log.piiHandle(uriHandle)); |
Yorke Lee | 3350163 | 2014-03-17 19:24:12 -0700 | [diff] [blame] | 550 | } else { |
| 551 | Log.i(this, "Creating a new outgoing call with gateway handle: %s, original handle: %s", |
| 552 | Log.pii(uriHandle), Log.pii(handle)); |
| 553 | } |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 554 | |
Nancy Chen | 0d3076c | 2014-07-30 14:45:44 -0700 | [diff] [blame] | 555 | call.setHandle(uriHandle); |
| 556 | call.setGatewayInfo(gatewayInfo); |
Sai Cheemalapati | b7157e9 | 2014-06-11 17:51:55 -0700 | [diff] [blame] | 557 | call.setStartWithSpeakerphoneOn(speakerphoneOn); |
Tyler Gunn | c4abd91 | 2014-07-08 14:22:10 -0700 | [diff] [blame] | 558 | call.setVideoState(videoState); |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 559 | |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 560 | boolean isEmergencyCall = TelephonyUtil.shouldProcessAsEmergency(mContext, |
| 561 | call.getHandle()); |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 562 | if (isEmergencyCall) { |
Ihab Awad | 69eb0f5 | 2014-07-18 11:20:37 -0700 | [diff] [blame] | 563 | // Emergency -- CreateConnectionProcessor will choose accounts automatically |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 564 | call.setTargetPhoneAccount(null); |
Nancy Chen | 53ceedc | 2014-07-08 18:56:51 -0700 | [diff] [blame] | 565 | } |
Nancy Chen | d9de92c | 2014-07-21 16:09:13 -0700 | [diff] [blame] | 566 | |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 567 | if (call.getTargetPhoneAccount() != null || isEmergencyCall) { |
Nancy Chen | bc9ef17 | 2014-08-15 17:11:57 -0700 | [diff] [blame] | 568 | // If the account has been set, proceed to place the outgoing call. |
| 569 | // Otherwise the connection will be initiated when the account is set by the user. |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 570 | call.startCreateConnection(mPhoneAccountRegistrar); |
Nancy Chen | d9de92c | 2014-07-21 16:09:13 -0700 | [diff] [blame] | 571 | } |
Yorke Lee | f98fb57 | 2014-03-05 10:56:55 -0800 | [diff] [blame] | 572 | } |
| 573 | |
| 574 | /** |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 575 | * Attempts to start a conference call for the specified call. |
| 576 | * |
Santos Cordon | 12d6182 | 2014-07-29 16:02:20 -0700 | [diff] [blame] | 577 | * @param call The call to conference. |
| 578 | * @param otherCall The other call to conference with. |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 579 | */ |
Santos Cordon | 12d6182 | 2014-07-29 16:02:20 -0700 | [diff] [blame] | 580 | void conference(Call call, Call otherCall) { |
Santos Cordon | 0fbe632 | 2014-08-14 04:04:25 -0700 | [diff] [blame] | 581 | call.conferenceWith(otherCall); |
Santos Cordon | a161070 | 2014-06-04 20:22:56 -0700 | [diff] [blame] | 582 | } |
| 583 | |
| 584 | /** |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 585 | * Instructs Telecom to answer the specified call. Intended to be invoked by the in-call |
| 586 | * app through {@link InCallAdapter} after Telecom notifies it of an incoming call followed by |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 587 | * the user opting to answer said call. |
Andrew Lee | 38931d0 | 2014-07-16 10:17:36 -0700 | [diff] [blame] | 588 | * |
| 589 | * @param call The call to answer. |
| 590 | * @param videoState The video state in which to answer the call. |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 591 | */ |
Andrew Lee | 38931d0 | 2014-07-16 10:17:36 -0700 | [diff] [blame] | 592 | void answerCall(Call call, int videoState) { |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 593 | if (!mCalls.contains(call)) { |
| 594 | Log.i(this, "Request to answer a non-existent call %s", call); |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 595 | } else { |
Santos Cordon | 40f78c2 | 2014-04-07 02:11:42 -0700 | [diff] [blame] | 596 | // If the foreground call is not the ringing call and it is currently isActive() or |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 597 | // STATE_DIALING, put it on hold before answering the call. |
Santos Cordon | 40f78c2 | 2014-04-07 02:11:42 -0700 | [diff] [blame] | 598 | if (mForegroundCall != null && mForegroundCall != call && |
| 599 | (mForegroundCall.isActive() || |
| 600 | mForegroundCall.getState() == CallState.DIALING)) { |
Ihab Awad | 07bc5ee | 2014-11-12 13:42:52 -0800 | [diff] [blame] | 601 | if (0 == (mForegroundCall.getConnectionCapabilities() |
| 602 | & Connection.CAPABILITY_HOLD)) { |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 603 | // This call does not support hold. If it is from a different connection |
| 604 | // service, then disconnect it, otherwise allow the connection service to |
| 605 | // figure out the right states. |
| 606 | if (mForegroundCall.getConnectionService() != call.getConnectionService()) { |
| 607 | mForegroundCall.disconnect(); |
| 608 | } |
| 609 | } else { |
| 610 | Log.v(this, "Holding active/dialing call %s before answering incoming call %s.", |
| 611 | mForegroundCall, call); |
| 612 | mForegroundCall.hold(); |
| 613 | } |
Santos Cordon | df39986 | 2014-08-06 04:39:15 -0700 | [diff] [blame] | 614 | // TODO: Wait until we get confirmation of the active call being |
Santos Cordon | 40f78c2 | 2014-04-07 02:11:42 -0700 | [diff] [blame] | 615 | // on-hold before answering the new call. |
Santos Cordon | df39986 | 2014-08-06 04:39:15 -0700 | [diff] [blame] | 616 | // TODO: Import logic from CallManager.acceptCall() |
Santos Cordon | 40f78c2 | 2014-04-07 02:11:42 -0700 | [diff] [blame] | 617 | } |
| 618 | |
Santos Cordon | a56f276 | 2014-03-24 15:55:53 -0700 | [diff] [blame] | 619 | for (CallsManagerListener listener : mListeners) { |
| 620 | listener.onIncomingCallAnswered(call); |
| 621 | } |
Santos Cordon | 4e9fffe | 2014-03-04 18:13:41 -0800 | [diff] [blame] | 622 | |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 623 | // We do not update the UI until we get confirmation of the answer() through |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 624 | // {@link #markCallAsActive}. |
Andrew Lee | 38931d0 | 2014-07-16 10:17:36 -0700 | [diff] [blame] | 625 | call.answer(videoState); |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 626 | } |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 627 | } |
| 628 | |
| 629 | /** |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 630 | * Instructs Telecom to reject the specified call. Intended to be invoked by the in-call |
| 631 | * app through {@link InCallAdapter} after Telecom notifies it of an incoming call followed by |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 632 | * the user opting to reject said call. |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 633 | */ |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 634 | void rejectCall(Call call, boolean rejectWithMessage, String textMessage) { |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 635 | if (!mCalls.contains(call)) { |
| 636 | Log.i(this, "Request to reject a non-existent call %s", call); |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 637 | } else { |
Santos Cordon | a56f276 | 2014-03-24 15:55:53 -0700 | [diff] [blame] | 638 | for (CallsManagerListener listener : mListeners) { |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 639 | listener.onIncomingCallRejected(call, rejectWithMessage, textMessage); |
Santos Cordon | a56f276 | 2014-03-24 15:55:53 -0700 | [diff] [blame] | 640 | } |
Ihab Awad | ff7493a | 2014-06-10 13:47:44 -0700 | [diff] [blame] | 641 | call.reject(rejectWithMessage, textMessage); |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 642 | } |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 643 | } |
| 644 | |
| 645 | /** |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 646 | * Instructs Telecom to play the specified DTMF tone within the specified call. |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 647 | * |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 648 | * @param digit The DTMF digit to play. |
| 649 | */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 650 | void playDtmfTone(Call call, char digit) { |
| 651 | if (!mCalls.contains(call)) { |
| 652 | Log.i(this, "Request to play DTMF in a non-existent call %s", call); |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 653 | } else { |
| 654 | call.playDtmfTone(digit); |
Santos Cordon | 92a2d81 | 2014-04-30 15:19:01 -0700 | [diff] [blame] | 655 | mDtmfLocalTonePlayer.playTone(call, digit); |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 656 | } |
| 657 | } |
| 658 | |
| 659 | /** |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 660 | * Instructs Telecom to stop the currently playing DTMF tone, if any. |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 661 | */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 662 | void stopDtmfTone(Call call) { |
| 663 | if (!mCalls.contains(call)) { |
| 664 | Log.i(this, "Request to stop DTMF in a non-existent call %s", call); |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 665 | } else { |
| 666 | call.stopDtmfTone(); |
Santos Cordon | 92a2d81 | 2014-04-30 15:19:01 -0700 | [diff] [blame] | 667 | mDtmfLocalTonePlayer.stopTone(call); |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 668 | } |
| 669 | } |
| 670 | |
| 671 | /** |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 672 | * Instructs Telecom to continue (or not) the current post-dial DTMF string, if any. |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 673 | */ |
Evan Charlton | 352105c | 2014-06-03 14:10:54 -0700 | [diff] [blame] | 674 | void postDialContinue(Call call, boolean proceed) { |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 675 | if (!mCalls.contains(call)) { |
| 676 | Log.i(this, "Request to continue post-dial string in a non-existent call %s", call); |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 677 | } else { |
Evan Charlton | 352105c | 2014-06-03 14:10:54 -0700 | [diff] [blame] | 678 | call.postDialContinue(proceed); |
Ihab Awad | 74549ec | 2014-03-10 15:33:25 -0700 | [diff] [blame] | 679 | } |
| 680 | } |
| 681 | |
| 682 | /** |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 683 | * Instructs Telecom to disconnect the specified call. Intended to be invoked by the |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 684 | * in-call app through {@link InCallAdapter} for an ongoing call. This is usually triggered by |
| 685 | * the user hitting the end-call button. |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 686 | */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 687 | void disconnectCall(Call call) { |
Santos Cordon | 682fe6b | 2014-05-20 08:56:39 -0700 | [diff] [blame] | 688 | Log.v(this, "disconnectCall %s", call); |
| 689 | |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 690 | if (!mCalls.contains(call)) { |
| 691 | Log.w(this, "Unknown call (%s) asked to disconnect", call); |
Santos Cordon | 049b7b6 | 2014-01-30 05:34:26 -0800 | [diff] [blame] | 692 | } else { |
Ihab Awad | 5b28132 | 2014-09-25 18:25:29 -0700 | [diff] [blame] | 693 | mLocallyDisconnectingCalls.add(call); |
Santos Cordon | 049b7b6 | 2014-01-30 05:34:26 -0800 | [diff] [blame] | 694 | call.disconnect(); |
| 695 | } |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 696 | } |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 697 | |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 698 | /** |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 699 | * Instructs Telecom to disconnect all calls. |
Tyler Gunn | 61b9210 | 2014-08-19 07:42:20 -0700 | [diff] [blame] | 700 | */ |
| 701 | void disconnectAllCalls() { |
| 702 | Log.v(this, "disconnectAllCalls"); |
| 703 | |
| 704 | for (Call call : mCalls) { |
| 705 | disconnectCall(call); |
| 706 | } |
| 707 | } |
| 708 | |
Nancy Chen | bc9ef17 | 2014-08-15 17:11:57 -0700 | [diff] [blame] | 709 | |
Tyler Gunn | 61b9210 | 2014-08-19 07:42:20 -0700 | [diff] [blame] | 710 | /** |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 711 | * Instructs Telecom to put the specified call on hold. Intended to be invoked by the |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 712 | * in-call app through {@link InCallAdapter} for an ongoing call. This is usually triggered by |
| 713 | * the user hitting the hold button during an active call. |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 714 | */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 715 | void holdCall(Call call) { |
| 716 | if (!mCalls.contains(call)) { |
| 717 | Log.w(this, "Unknown call (%s) asked to be put on hold", call); |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 718 | } else { |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 719 | Log.d(this, "Putting call on hold: (%s)", call); |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 720 | call.hold(); |
| 721 | } |
| 722 | } |
| 723 | |
| 724 | /** |
Tyler Gunn | 7cc70b4 | 2014-09-12 22:17:27 -0700 | [diff] [blame] | 725 | * Instructs Telecom to release the specified call from hold. Intended to be invoked by |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 726 | * the in-call app through {@link InCallAdapter} for an ongoing call. This is usually triggered |
| 727 | * by the user hitting the hold button during a held call. |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 728 | */ |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 729 | void unholdCall(Call call) { |
| 730 | if (!mCalls.contains(call)) { |
| 731 | Log.w(this, "Unknown call (%s) asked to be removed from hold", call); |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 732 | } else { |
Santos Cordon | c7e85d4 | 2014-05-22 02:51:48 -0700 | [diff] [blame] | 733 | Log.d(this, "unholding call: (%s)", call); |
Sai Cheemalapati | 45b3e3f | 2014-08-15 09:33:00 -0700 | [diff] [blame] | 734 | for (Call c : mCalls) { |
| 735 | if (c != null && c.isAlive() && c != call) { |
| 736 | c.hold(); |
| 737 | } |
| 738 | } |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 739 | call.unhold(); |
| 740 | } |
| 741 | } |
| 742 | |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 743 | /** Called by the in-call UI to change the mute state. */ |
| 744 | void mute(boolean shouldMute) { |
| 745 | mCallAudioManager.mute(shouldMute); |
| 746 | } |
| 747 | |
| 748 | /** |
| 749 | * Called by the in-call UI to change the audio route, for example to change from earpiece to |
| 750 | * speaker phone. |
| 751 | */ |
| 752 | void setAudioRoute(int route) { |
| 753 | mCallAudioManager.setAudioRoute(route); |
| 754 | } |
| 755 | |
Yorke Lee | d134687 | 2014-07-28 14:38:45 -0700 | [diff] [blame] | 756 | /** Called by the in-call UI to turn the proximity sensor on. */ |
| 757 | void turnOnProximitySensor() { |
| 758 | mProximitySensorManager.turnOn(); |
| 759 | } |
| 760 | |
| 761 | /** |
| 762 | * Called by the in-call UI to turn the proximity sensor off. |
| 763 | * @param screenOnImmediately If true, the screen will be turned on immediately. Otherwise, |
| 764 | * the screen will be kept off until the proximity sensor goes negative. |
| 765 | */ |
| 766 | void turnOffProximitySensor(boolean screenOnImmediately) { |
| 767 | mProximitySensorManager.turnOff(screenOnImmediately); |
| 768 | } |
| 769 | |
Nancy Chen | f5e5d3c | 2014-10-21 18:45:56 -0700 | [diff] [blame] | 770 | void phoneAccountSelected(Call call, PhoneAccountHandle account, boolean setDefault) { |
Nancy Chen | 53ceedc | 2014-07-08 18:56:51 -0700 | [diff] [blame] | 771 | if (!mCalls.contains(call)) { |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 772 | Log.i(this, "Attempted to add account to unknown call %s", call); |
Nancy Chen | 53ceedc | 2014-07-08 18:56:51 -0700 | [diff] [blame] | 773 | } else { |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 774 | // TODO: There is an odd race condition here. Since NewOutgoingCallIntentBroadcaster and |
| 775 | // the PRE_DIAL_WAIT sequence run in parallel, if the user selects an account before the |
| 776 | // NEW_OUTGOING_CALL sequence finishes, we'll start the call immediately without |
| 777 | // respecting a rewritten number or a canceled number. This is unlikely since |
| 778 | // NEW_OUTGOING_CALL sequence, in practice, runs a lot faster than the user selecting |
| 779 | // a phone account from the in-call UI. |
Ihab Awad | b78b276 | 2014-07-25 15:16:23 -0700 | [diff] [blame] | 780 | call.setTargetPhoneAccount(account); |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 781 | |
| 782 | // Note: emergency calls never go through account selection dialog so they never |
| 783 | // arrive here. |
| 784 | if (makeRoomForOutgoingCall(call, false /* isEmergencyCall */)) { |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 785 | call.startCreateConnection(mPhoneAccountRegistrar); |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 786 | } else { |
| 787 | call.disconnect(); |
| 788 | } |
Nancy Chen | f5e5d3c | 2014-10-21 18:45:56 -0700 | [diff] [blame] | 789 | |
| 790 | if (setDefault) { |
| 791 | mPhoneAccountRegistrar.setUserSelectedOutgoingPhoneAccount(account); |
| 792 | } |
Nancy Chen | 53ceedc | 2014-07-08 18:56:51 -0700 | [diff] [blame] | 793 | } |
| 794 | } |
| 795 | |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 796 | /** Called when the audio state changes. */ |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 797 | void onAudioStateChanged(AudioState oldAudioState, AudioState newAudioState) { |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 798 | Log.v(this, "onAudioStateChanged, audioState: %s -> %s", oldAudioState, newAudioState); |
Santos Cordon | a56f276 | 2014-03-24 15:55:53 -0700 | [diff] [blame] | 799 | for (CallsManagerListener listener : mListeners) { |
| 800 | listener.onAudioStateChanged(oldAudioState, newAudioState); |
| 801 | } |
Sailesh Nepal | 6aca10a | 2014-03-24 16:11:02 -0700 | [diff] [blame] | 802 | } |
| 803 | |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 804 | void markCallAsRinging(Call call) { |
| 805 | setCallState(call, CallState.RINGING); |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 806 | } |
| 807 | |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 808 | void markCallAsDialing(Call call) { |
| 809 | setCallState(call, CallState.DIALING); |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 810 | } |
| 811 | |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 812 | void markCallAsActive(Call call) { |
| 813 | setCallState(call, CallState.ACTIVE); |
Sailesh Nepal | 84fa5f8 | 2014-04-02 11:01:11 -0700 | [diff] [blame] | 814 | |
Sai Cheemalapati | b7157e9 | 2014-06-11 17:51:55 -0700 | [diff] [blame] | 815 | if (call.getStartWithSpeakerphoneOn()) { |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 816 | setAudioRoute(AudioState.ROUTE_SPEAKER); |
Sai Cheemalapati | b7157e9 | 2014-06-11 17:51:55 -0700 | [diff] [blame] | 817 | } |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 818 | } |
| 819 | |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 820 | void markCallAsOnHold(Call call) { |
| 821 | setCallState(call, CallState.ON_HOLD); |
Yorke Lee | cdf3ebd | 2014-03-12 18:31:41 -0700 | [diff] [blame] | 822 | } |
| 823 | |
Santos Cordon | 049b7b6 | 2014-01-30 05:34:26 -0800 | [diff] [blame] | 824 | /** |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 825 | * Marks the specified call as STATE_DISCONNECTED and notifies the in-call app. If this was the |
| 826 | * last live call, then also disconnect from the in-call controller. |
Santos Cordon | 049b7b6 | 2014-01-30 05:34:26 -0800 | [diff] [blame] | 827 | * |
Andrew Lee | 701dc00 | 2014-09-11 21:29:12 -0700 | [diff] [blame] | 828 | * @param disconnectCause The disconnect cause, see {@link android.telecomm.DisconnectCause}. |
Santos Cordon | 049b7b6 | 2014-01-30 05:34:26 -0800 | [diff] [blame] | 829 | */ |
Andrew Lee | 701dc00 | 2014-09-11 21:29:12 -0700 | [diff] [blame] | 830 | void markCallAsDisconnected(Call call, DisconnectCause disconnectCause) { |
| 831 | call.setDisconnectCause(disconnectCause); |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 832 | setCallState(call, CallState.DISCONNECTED); |
Sailesh Nepal | 6ab6fb7 | 2014-04-01 20:03:19 -0700 | [diff] [blame] | 833 | } |
| 834 | |
Ben Gilad | a0d9f75 | 2014-02-26 11:49:03 -0800 | [diff] [blame] | 835 | /** |
Ihab Awad | a02bef5 | 2014-08-13 18:18:42 -0700 | [diff] [blame] | 836 | * Removes an existing disconnected call, and notifies the in-call app. |
| 837 | */ |
| 838 | void markCallAsRemoved(Call call) { |
| 839 | removeCall(call); |
Ihab Awad | 5b28132 | 2014-09-25 18:25:29 -0700 | [diff] [blame] | 840 | if (mLocallyDisconnectingCalls.contains(call)) { |
| 841 | mLocallyDisconnectingCalls.remove(call); |
| 842 | if (mForegroundCall != null && mForegroundCall.getState() == CallState.ON_HOLD) { |
| 843 | mForegroundCall.unhold(); |
| 844 | } |
| 845 | } |
Ihab Awad | a02bef5 | 2014-08-13 18:18:42 -0700 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | /** |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 849 | * Cleans up any calls currently associated with the specified connection service when the |
Sailesh Nepal | 905dfba | 2014-07-14 08:20:41 -0700 | [diff] [blame] | 850 | * service binder disconnects unexpectedly. |
Santos Cordon | 4b2c119 | 2014-03-19 18:15:38 -0700 | [diff] [blame] | 851 | * |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 852 | * @param service The connection service that disconnected. |
Santos Cordon | 4b2c119 | 2014-03-19 18:15:38 -0700 | [diff] [blame] | 853 | */ |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 854 | void handleConnectionServiceDeath(ConnectionServiceWrapper service) { |
Jay Shrauner | acb91eb | 2014-08-08 16:04:53 -0700 | [diff] [blame] | 855 | if (service != null) { |
Jay Shrauner | a82c8f7 | 2014-08-14 15:49:16 -0700 | [diff] [blame] | 856 | for (Call call : mCalls) { |
Jay Shrauner | acb91eb | 2014-08-08 16:04:53 -0700 | [diff] [blame] | 857 | if (call.getConnectionService() == service) { |
Yorke Lee | 2af16b6 | 2014-11-11 17:36:57 -0800 | [diff] [blame] | 858 | if (call.getState() != CallState.DISCONNECTED) { |
| 859 | markCallAsDisconnected(call, new DisconnectCause(DisconnectCause.ERROR)); |
| 860 | } |
| 861 | markCallAsRemoved(call); |
Jay Shrauner | acb91eb | 2014-08-08 16:04:53 -0700 | [diff] [blame] | 862 | } |
Santos Cordon | 4b2c119 | 2014-03-19 18:15:38 -0700 | [diff] [blame] | 863 | } |
| 864 | } |
| 865 | } |
| 866 | |
Santos Cordon | deb8c89 | 2014-05-30 01:38:03 -0700 | [diff] [blame] | 867 | boolean hasAnyCalls() { |
| 868 | return !mCalls.isEmpty(); |
| 869 | } |
| 870 | |
Santos Cordon | c7e85d4 | 2014-05-22 02:51:48 -0700 | [diff] [blame] | 871 | boolean hasActiveOrHoldingCall() { |
Santos Cordon | 23baed3 | 2014-06-27 14:45:39 -0700 | [diff] [blame] | 872 | return getFirstCallWithState(CallState.ACTIVE, CallState.ON_HOLD) != null; |
Santos Cordon | c7e85d4 | 2014-05-22 02:51:48 -0700 | [diff] [blame] | 873 | } |
| 874 | |
| 875 | boolean hasRingingCall() { |
Santos Cordon | 23baed3 | 2014-06-27 14:45:39 -0700 | [diff] [blame] | 876 | return getFirstCallWithState(CallState.RINGING) != null; |
Santos Cordon | c7e85d4 | 2014-05-22 02:51:48 -0700 | [diff] [blame] | 877 | } |
| 878 | |
Santos Cordon | deb8c89 | 2014-05-30 01:38:03 -0700 | [diff] [blame] | 879 | boolean onMediaButton(int type) { |
| 880 | if (hasAnyCalls()) { |
| 881 | if (HeadsetMediaButton.SHORT_PRESS == type) { |
| 882 | Call ringingCall = getFirstCallWithState(CallState.RINGING); |
| 883 | if (ringingCall == null) { |
| 884 | mCallAudioManager.toggleMute(); |
| 885 | return true; |
| 886 | } else { |
Andrew Lee | 38931d0 | 2014-07-16 10:17:36 -0700 | [diff] [blame] | 887 | ringingCall.answer(ringingCall.getVideoState()); |
Santos Cordon | deb8c89 | 2014-05-30 01:38:03 -0700 | [diff] [blame] | 888 | return true; |
| 889 | } |
| 890 | } else if (HeadsetMediaButton.LONG_PRESS == type) { |
| 891 | Log.d(this, "handleHeadsetHook: longpress -> hangup"); |
| 892 | Call callToHangup = getFirstCallWithState( |
| 893 | CallState.RINGING, CallState.DIALING, CallState.ACTIVE, CallState.ON_HOLD); |
| 894 | if (callToHangup != null) { |
| 895 | callToHangup.disconnect(); |
| 896 | return true; |
| 897 | } |
| 898 | } |
| 899 | } |
| 900 | return false; |
| 901 | } |
| 902 | |
| 903 | /** |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 904 | * Returns true if telecom supports adding another top-level call. |
Santos Cordon | 10838c2 | 2014-06-11 17:36:04 -0700 | [diff] [blame] | 905 | */ |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 906 | boolean canAddCall() { |
Andrew Lee | 113ad62 | 2014-12-01 18:33:10 -0800 | [diff] [blame] | 907 | if (getFirstCallWithState(OUTGOING_CALL_STATES) != null) { |
| 908 | return false; |
| 909 | } |
| 910 | |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 911 | int count = 0; |
| 912 | for (Call call : mCalls) { |
| 913 | if (call.isEmergencyCall()) { |
| 914 | // We never support add call if one of the calls is an emergency call. |
| 915 | return false; |
| 916 | } else if (call.getParentCall() == null) { |
| 917 | count++; |
| 918 | } |
Santos Cordon | 10838c2 | 2014-06-11 17:36:04 -0700 | [diff] [blame] | 919 | |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 920 | // We do not check states for canAddCall. We treat disconnected calls the same |
| 921 | // and wait until they are removed instead. If we didn't count disconnected calls, |
| 922 | // we could put InCallServices into a state where they are showing two calls but |
| 923 | // also support add-call. Technically it's right, but overall looks better (UI-wise) |
| 924 | // and acts better if we wait until the call is removed. |
| 925 | if (count >= MAXIMUM_TOP_LEVEL_CALLS) { |
Santos Cordon | 10838c2 | 2014-06-11 17:36:04 -0700 | [diff] [blame] | 926 | return false; |
| 927 | } |
| 928 | } |
| 929 | return true; |
| 930 | } |
| 931 | |
Santos Cordon | 68d1a6b | 2014-09-19 12:25:58 -0700 | [diff] [blame] | 932 | Call getRingingCall() { |
| 933 | return getFirstCallWithState(CallState.RINGING); |
| 934 | } |
| 935 | |
| 936 | Call getActiveCall() { |
| 937 | return getFirstCallWithState(CallState.ACTIVE); |
| 938 | } |
| 939 | |
Nancy Chen | 05a9e40 | 2014-09-26 14:14:32 -0700 | [diff] [blame] | 940 | Call getDialingCall() { |
| 941 | return getFirstCallWithState(CallState.DIALING); |
Santos Cordon | 68d1a6b | 2014-09-19 12:25:58 -0700 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | Call getHeldCall() { |
| 945 | return getFirstCallWithState(CallState.ON_HOLD); |
| 946 | } |
| 947 | |
Santos Cordon | c0ca76e | 2014-10-21 15:54:19 -0700 | [diff] [blame] | 948 | int getNumHeldCalls() { |
| 949 | int count = 0; |
| 950 | for (Call call : mCalls) { |
| 951 | if (call.getParentCall() == null && call.getState() == CallState.ON_HOLD) { |
| 952 | count++; |
| 953 | } |
| 954 | } |
| 955 | return count; |
| 956 | } |
| 957 | |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 958 | Call getFirstCallWithState(int... states) { |
| 959 | return getFirstCallWithState(null, states); |
| 960 | } |
| 961 | |
Santos Cordon | 10838c2 | 2014-06-11 17:36:04 -0700 | [diff] [blame] | 962 | /** |
Santos Cordon | deb8c89 | 2014-05-30 01:38:03 -0700 | [diff] [blame] | 963 | * Returns the first call that it finds with the given states. The states are treated as having |
| 964 | * priority order so that any call with the first state will be returned before any call with |
| 965 | * states listed later in the parameter list. |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 966 | * |
| 967 | * @param callToSkip Call that this method should skip while searching |
Santos Cordon | deb8c89 | 2014-05-30 01:38:03 -0700 | [diff] [blame] | 968 | */ |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 969 | Call getFirstCallWithState(Call callToSkip, int... states) { |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 970 | for (int currentState : states) { |
Santos Cordon | 23baed3 | 2014-06-27 14:45:39 -0700 | [diff] [blame] | 971 | // check the foreground first |
| 972 | if (mForegroundCall != null && mForegroundCall.getState() == currentState) { |
| 973 | return mForegroundCall; |
| 974 | } |
| 975 | |
Santos Cordon | deb8c89 | 2014-05-30 01:38:03 -0700 | [diff] [blame] | 976 | for (Call call : mCalls) { |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 977 | if (Objects.equals(callToSkip, call)) { |
| 978 | continue; |
| 979 | } |
| 980 | |
| 981 | // Only operate on top-level calls |
| 982 | if (call.getParentCall() != null) { |
| 983 | continue; |
| 984 | } |
| 985 | |
Santos Cordon | deb8c89 | 2014-05-30 01:38:03 -0700 | [diff] [blame] | 986 | if (currentState == call.getState()) { |
| 987 | return call; |
| 988 | } |
| 989 | } |
| 990 | } |
| 991 | return null; |
| 992 | } |
| 993 | |
Santos Cordon | 0fbe632 | 2014-08-14 04:04:25 -0700 | [diff] [blame] | 994 | Call createConferenceCall( |
| 995 | PhoneAccountHandle phoneAccount, |
| 996 | ParcelableConference parcelableConference) { |
| 997 | Call call = new Call( |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 998 | mContext, |
Santos Cordon | 0fbe632 | 2014-08-14 04:04:25 -0700 | [diff] [blame] | 999 | mConnectionServiceRepository, |
| 1000 | null /* handle */, |
| 1001 | null /* gatewayInfo */, |
| 1002 | null /* connectionManagerPhoneAccount */, |
| 1003 | phoneAccount, |
| 1004 | false /* isIncoming */, |
| 1005 | true /* isConference */); |
| 1006 | |
| 1007 | setCallState(call, Call.getStateFromConnectionState(parcelableConference.getState())); |
Ihab Awad | 07bc5ee | 2014-11-12 13:42:52 -0800 | [diff] [blame] | 1008 | call.setConnectionCapabilities(parcelableConference.getConnectionCapabilities()); |
Santos Cordon | 0fbe632 | 2014-08-14 04:04:25 -0700 | [diff] [blame] | 1009 | |
| 1010 | // TODO: Move this to be a part of addCall() |
| 1011 | call.addListener(this); |
| 1012 | addCall(call); |
| 1013 | return call; |
| 1014 | } |
| 1015 | |
Yorke Lee | f86db2e | 2014-09-12 17:56:48 -0700 | [diff] [blame] | 1016 | /** |
| 1017 | * @return the call state currently tracked by {@link PhoneStateBroadcaster} |
| 1018 | */ |
| 1019 | int getCallState() { |
| 1020 | return mPhoneStateBroadcaster.getCallState(); |
| 1021 | } |
Nancy Chen | bc9ef17 | 2014-08-15 17:11:57 -0700 | [diff] [blame] | 1022 | |
Santos Cordon | 4b2c119 | 2014-03-19 18:15:38 -0700 | [diff] [blame] | 1023 | /** |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 1024 | * Retrieves the {@link PhoneAccountRegistrar}. |
| 1025 | * |
| 1026 | * @return The {@link PhoneAccountRegistrar}. |
| 1027 | */ |
| 1028 | PhoneAccountRegistrar getPhoneAccountRegistrar() { |
| 1029 | return mPhoneAccountRegistrar; |
| 1030 | } |
| 1031 | |
| 1032 | /** |
| 1033 | * Retrieves the {@link MissedCallNotifier} |
| 1034 | * @return The {@link MissedCallNotifier}. |
| 1035 | */ |
| 1036 | MissedCallNotifier getMissedCallNotifier() { |
| 1037 | return mMissedCallNotifier; |
| 1038 | } |
| 1039 | |
| 1040 | /** |
Ben Gilad | a0d9f75 | 2014-02-26 11:49:03 -0800 | [diff] [blame] | 1041 | * Adds the specified call to the main list of live calls. |
| 1042 | * |
| 1043 | * @param call The call to add. |
| 1044 | */ |
| 1045 | private void addCall(Call call) { |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1046 | Trace.beginSection("addCall"); |
Yorke Lee | b701f6d | 2014-08-12 14:04:19 -0700 | [diff] [blame] | 1047 | Log.v(this, "addCall(%s)", call); |
Yorke Lee | b701f6d | 2014-08-12 14:04:19 -0700 | [diff] [blame] | 1048 | call.addListener(this); |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 1049 | mCalls.add(call); |
Santos Cordon | 40f78c2 | 2014-04-07 02:11:42 -0700 | [diff] [blame] | 1050 | |
Santos Cordon | df39986 | 2014-08-06 04:39:15 -0700 | [diff] [blame] | 1051 | // TODO: Update mForegroundCall prior to invoking |
Santos Cordon | 40f78c2 | 2014-04-07 02:11:42 -0700 | [diff] [blame] | 1052 | // onCallAdded for calls which immediately take the foreground (like the first call). |
Santos Cordon | a56f276 | 2014-03-24 15:55:53 -0700 | [diff] [blame] | 1053 | for (CallsManagerListener listener : mListeners) { |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1054 | if (Log.SYSTRACE_DEBUG) { |
| 1055 | Trace.beginSection(listener.getClass().toString() + " addCall"); |
| 1056 | } |
Santos Cordon | a56f276 | 2014-03-24 15:55:53 -0700 | [diff] [blame] | 1057 | listener.onCallAdded(call); |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1058 | if (Log.SYSTRACE_DEBUG) { |
| 1059 | Trace.endSection(); |
| 1060 | } |
Santos Cordon | a56f276 | 2014-03-24 15:55:53 -0700 | [diff] [blame] | 1061 | } |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 1062 | updateCallsManagerState(); |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1063 | Trace.endSection(); |
Ben Gilad | a0d9f75 | 2014-02-26 11:49:03 -0800 | [diff] [blame] | 1064 | } |
| 1065 | |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 1066 | private void removeCall(Call call) { |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1067 | Trace.beginSection("removeCall"); |
Santos Cordon | c499c1c | 2014-04-14 17:13:14 -0700 | [diff] [blame] | 1068 | Log.v(this, "removeCall(%s)", call); |
Sailesh Nepal | 4857f47 | 2014-04-07 22:26:27 -0700 | [diff] [blame] | 1069 | |
Santos Cordon | 672321e | 2014-08-21 14:38:58 -0700 | [diff] [blame] | 1070 | call.setParentCall(null); // need to clean up parent relationship before destroying. |
Santos Cordon | 766d04f | 2014-05-06 10:28:25 -0700 | [diff] [blame] | 1071 | call.removeListener(this); |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 1072 | call.clearConnectionService(); |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 1073 | |
| 1074 | boolean shouldNotify = false; |
| 1075 | if (mCalls.contains(call)) { |
| 1076 | mCalls.remove(call); |
| 1077 | shouldNotify = true; |
Santos Cordon | a56f276 | 2014-03-24 15:55:53 -0700 | [diff] [blame] | 1078 | } |
Ben Gilad | a0d9f75 | 2014-02-26 11:49:03 -0800 | [diff] [blame] | 1079 | |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 1080 | // Only broadcast changes for calls that are being tracked. |
| 1081 | if (shouldNotify) { |
| 1082 | for (CallsManagerListener listener : mListeners) { |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1083 | if (Log.SYSTRACE_DEBUG) { |
| 1084 | Trace.beginSection(listener.getClass().toString() + " onCallRemoved"); |
| 1085 | } |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 1086 | listener.onCallRemoved(call); |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1087 | if (Log.SYSTRACE_DEBUG) { |
| 1088 | Trace.endSection(); |
| 1089 | } |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 1090 | } |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 1091 | updateCallsManagerState(); |
Yorke Lee | 604a90f | 2014-10-20 12:13:32 -0700 | [diff] [blame] | 1092 | } |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1093 | Trace.endSection(); |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 1094 | } |
Evan Charlton | 5c670a9 | 2014-03-06 14:58:20 -0800 | [diff] [blame] | 1095 | |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 1096 | /** |
Santos Cordon | 1ae2b85 | 2014-03-19 03:03:10 -0700 | [diff] [blame] | 1097 | * Sets the specified state on the specified call. |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 1098 | * |
| 1099 | * @param call The call. |
| 1100 | * @param newState The new state of the call. |
| 1101 | */ |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 1102 | private void setCallState(Call call, int newState) { |
Jay Shrauner | acb91eb | 2014-08-08 16:04:53 -0700 | [diff] [blame] | 1103 | if (call == null) { |
| 1104 | return; |
| 1105 | } |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 1106 | int oldState = call.getState(); |
Nancy Chen | 308ab8b | 2014-09-02 16:18:30 -0700 | [diff] [blame] | 1107 | Log.i(this, "setCallState %s -> %s, call: %s", CallState.toString(oldState), |
| 1108 | CallState.toString(newState), call); |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 1109 | if (newState != oldState) { |
| 1110 | // Unfortunately, in the telephony world the radio is king. So if the call notifies |
| 1111 | // us that the call is in a particular state, we allow it even if it doesn't make |
Ihab Awad | 6fb37c8 | 2014-08-07 19:48:57 -0700 | [diff] [blame] | 1112 | // sense (e.g., STATE_ACTIVE -> STATE_RINGING). |
Santos Cordon | df39986 | 2014-08-06 04:39:15 -0700 | [diff] [blame] | 1113 | // TODO: Consider putting a stop to the above and turning CallState |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 1114 | // into a well-defined state machine. |
Santos Cordon | df39986 | 2014-08-06 04:39:15 -0700 | [diff] [blame] | 1115 | // TODO: Define expected state transitions here, and log when an |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 1116 | // unexpected transition occurs. |
| 1117 | call.setState(newState); |
| 1118 | |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1119 | Trace.beginSection("onCallStateChanged"); |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 1120 | // Only broadcast state change for calls that are being tracked. |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 1121 | if (mCalls.contains(call)) { |
Santos Cordon | a56f276 | 2014-03-24 15:55:53 -0700 | [diff] [blame] | 1122 | for (CallsManagerListener listener : mListeners) { |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1123 | if (Log.SYSTRACE_DEBUG) { |
| 1124 | Trace.beginSection(listener.getClass().toString() + " onCallStateChanged"); |
| 1125 | } |
Santos Cordon | a56f276 | 2014-03-24 15:55:53 -0700 | [diff] [blame] | 1126 | listener.onCallStateChanged(call, oldState, newState); |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1127 | if (Log.SYSTRACE_DEBUG) { |
| 1128 | Trace.endSection(); |
| 1129 | } |
Santos Cordon | a56f276 | 2014-03-24 15:55:53 -0700 | [diff] [blame] | 1130 | } |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 1131 | updateCallsManagerState(); |
Santos Cordon | 4e9fffe | 2014-03-04 18:13:41 -0800 | [diff] [blame] | 1132 | } |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1133 | Trace.endSection(); |
Santos Cordon | 4e9fffe | 2014-03-04 18:13:41 -0800 | [diff] [blame] | 1134 | } |
| 1135 | } |
| 1136 | |
| 1137 | /** |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 1138 | * Checks which call should be visible to the user and have audio focus. |
Evan Charlton | 5c670a9 | 2014-03-06 14:58:20 -0800 | [diff] [blame] | 1139 | */ |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 1140 | private void updateForegroundCall() { |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1141 | Trace.beginSection("updateForegroundCall"); |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 1142 | Call newForegroundCall = null; |
Sailesh Nepal | e59bb19 | 2014-04-01 18:33:59 -0700 | [diff] [blame] | 1143 | for (Call call : mCalls) { |
Santos Cordon | df39986 | 2014-08-06 04:39:15 -0700 | [diff] [blame] | 1144 | // TODO: Foreground-ness needs to be explicitly set. No call, regardless |
Sailesh Nepal | c92c436 | 2014-07-04 18:33:21 -0700 | [diff] [blame] | 1145 | // of its state will be foreground by default and instead the connection service should |
| 1146 | // be notified when its calls enter and exit foreground state. Foreground will mean that |
Santos Cordon | 40f78c2 | 2014-04-07 02:11:42 -0700 | [diff] [blame] | 1147 | // the call should play audio and listen to microphone if it wants. |
| 1148 | |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 1149 | // Only top-level calls can be in foreground |
| 1150 | if (call.getParentCall() != null) { |
| 1151 | continue; |
| 1152 | } |
| 1153 | |
Santos Cordon | 40f78c2 | 2014-04-07 02:11:42 -0700 | [diff] [blame] | 1154 | // Active calls have priority. |
| 1155 | if (call.isActive()) { |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 1156 | newForegroundCall = call; |
Evan Charlton | 5c670a9 | 2014-03-06 14:58:20 -0800 | [diff] [blame] | 1157 | break; |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 1158 | } |
Santos Cordon | 40f78c2 | 2014-04-07 02:11:42 -0700 | [diff] [blame] | 1159 | |
| 1160 | if (call.isAlive() || call.getState() == CallState.RINGING) { |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 1161 | newForegroundCall = call; |
Santos Cordon | 40f78c2 | 2014-04-07 02:11:42 -0700 | [diff] [blame] | 1162 | // Don't break in case there's an active call that has priority. |
Santos Cordon | 4e9fffe | 2014-03-04 18:13:41 -0800 | [diff] [blame] | 1163 | } |
| 1164 | } |
Santos Cordon | 4e9fffe | 2014-03-04 18:13:41 -0800 | [diff] [blame] | 1165 | |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 1166 | if (newForegroundCall != mForegroundCall) { |
Santos Cordon | 40f78c2 | 2014-04-07 02:11:42 -0700 | [diff] [blame] | 1167 | Log.v(this, "Updating foreground call, %s -> %s.", mForegroundCall, newForegroundCall); |
Sailesh Nepal | 810735e | 2014-03-18 18:15:46 -0700 | [diff] [blame] | 1168 | Call oldForegroundCall = mForegroundCall; |
| 1169 | mForegroundCall = newForegroundCall; |
Ihab Awad | 5b28132 | 2014-09-25 18:25:29 -0700 | [diff] [blame] | 1170 | |
Santos Cordon | a56f276 | 2014-03-24 15:55:53 -0700 | [diff] [blame] | 1171 | for (CallsManagerListener listener : mListeners) { |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1172 | if (Log.SYSTRACE_DEBUG) { |
| 1173 | Trace.beginSection(listener.getClass().toString() + " updateForegroundCall"); |
| 1174 | } |
Santos Cordon | a56f276 | 2014-03-24 15:55:53 -0700 | [diff] [blame] | 1175 | listener.onForegroundCallChanged(oldForegroundCall, mForegroundCall); |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1176 | if (Log.SYSTRACE_DEBUG) { |
| 1177 | Trace.endSection(); |
| 1178 | } |
Santos Cordon | a56f276 | 2014-03-24 15:55:53 -0700 | [diff] [blame] | 1179 | } |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 1180 | } |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1181 | Trace.endSection(); |
Santos Cordon | 681663d | 2014-01-30 04:32:15 -0800 | [diff] [blame] | 1182 | } |
Yorke Lee | b701f6d | 2014-08-12 14:04:19 -0700 | [diff] [blame] | 1183 | |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 1184 | private void updateCanAddCall() { |
| 1185 | boolean newCanAddCall = canAddCall(); |
| 1186 | if (newCanAddCall != mCanAddCall) { |
| 1187 | mCanAddCall = newCanAddCall; |
| 1188 | for (CallsManagerListener listener : mListeners) { |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1189 | if (Log.SYSTRACE_DEBUG) { |
| 1190 | Trace.beginSection(listener.getClass().toString() + " updateCanAddCall"); |
| 1191 | } |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 1192 | listener.onCanAddCallChanged(mCanAddCall); |
Yorke Lee | e4a9c41 | 2014-11-14 16:59:42 -0800 | [diff] [blame] | 1193 | if (Log.SYSTRACE_DEBUG) { |
| 1194 | Trace.endSection(); |
| 1195 | } |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 1196 | } |
| 1197 | } |
| 1198 | } |
| 1199 | |
| 1200 | private void updateCallsManagerState() { |
| 1201 | updateForegroundCall(); |
| 1202 | updateCanAddCall(); |
| 1203 | } |
| 1204 | |
Yorke Lee | b701f6d | 2014-08-12 14:04:19 -0700 | [diff] [blame] | 1205 | private boolean isPotentialMMICode(Uri handle) { |
| 1206 | return (handle != null && handle.getSchemeSpecificPart() != null |
| 1207 | && handle.getSchemeSpecificPart().contains("#")); |
| 1208 | } |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 1209 | |
Tyler Gunn | 5b452df | 2014-10-01 15:02:58 -0700 | [diff] [blame] | 1210 | /** |
| 1211 | * Determines if a dialed number is potentially an In-Call MMI code. In-Call MMI codes are |
| 1212 | * MMI codes which can be dialed when one or more calls are in progress. |
| 1213 | * <P> |
| 1214 | * Checks for numbers formatted similar to the MMI codes defined in: |
| 1215 | * {@link com.android.internal.telephony.gsm.GSMPhone#handleInCallMmiCommands(String)} |
| 1216 | * and |
| 1217 | * {@link com.android.internal.telephony.imsphone.ImsPhone#handleInCallMmiCommands(String)} |
| 1218 | * |
| 1219 | * @param handle The URI to call. |
| 1220 | * @return {@code True} if the URI represents a number which could be an in-call MMI code. |
| 1221 | */ |
| 1222 | private boolean isPotentialInCallMMICode(Uri handle) { |
| 1223 | if (handle != null && handle.getSchemeSpecificPart() != null && |
| 1224 | handle.getScheme().equals(PhoneAccount.SCHEME_TEL)) { |
| 1225 | |
| 1226 | String dialedNumber = handle.getSchemeSpecificPart(); |
| 1227 | return (dialedNumber.equals("0") || |
| 1228 | (dialedNumber.startsWith("1") && dialedNumber.length() <= 2) || |
| 1229 | (dialedNumber.startsWith("2") && dialedNumber.length() <= 2) || |
| 1230 | dialedNumber.equals("3") || |
| 1231 | dialedNumber.equals("4") || |
| 1232 | dialedNumber.equals("5")); |
| 1233 | } |
| 1234 | return false; |
| 1235 | } |
| 1236 | |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 1237 | private int getNumCallsWithState(int... states) { |
| 1238 | int count = 0; |
| 1239 | for (int state : states) { |
| 1240 | for (Call call : mCalls) { |
Santos Cordon | 91bd74c | 2014-11-07 16:10:22 -0800 | [diff] [blame] | 1241 | if (call.getParentCall() == null && call.getState() == state) { |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 1242 | count++; |
| 1243 | } |
| 1244 | } |
| 1245 | } |
| 1246 | return count; |
| 1247 | } |
| 1248 | |
| 1249 | private boolean hasMaximumLiveCalls() { |
| 1250 | return MAXIMUM_LIVE_CALLS <= getNumCallsWithState(LIVE_CALL_STATES); |
| 1251 | } |
| 1252 | |
| 1253 | private boolean hasMaximumHoldingCalls() { |
| 1254 | return MAXIMUM_HOLD_CALLS <= getNumCallsWithState(CallState.ON_HOLD); |
| 1255 | } |
| 1256 | |
| 1257 | private boolean hasMaximumRingingCalls() { |
| 1258 | return MAXIMUM_RINGING_CALLS <= getNumCallsWithState(CallState.RINGING); |
| 1259 | } |
| 1260 | |
| 1261 | private boolean hasMaximumOutgoingCalls() { |
| 1262 | return MAXIMUM_OUTGOING_CALLS <= getNumCallsWithState(OUTGOING_CALL_STATES); |
| 1263 | } |
| 1264 | |
| 1265 | private boolean makeRoomForOutgoingCall(Call call, boolean isEmergency) { |
| 1266 | if (hasMaximumLiveCalls()) { |
| 1267 | // NOTE: If the amount of live calls changes beyond 1, this logic will probably |
| 1268 | // have to change. |
| 1269 | Call liveCall = getFirstCallWithState(call, LIVE_CALL_STATES); |
| 1270 | |
Santos Cordon | d176650 | 2014-09-26 15:45:39 -0700 | [diff] [blame] | 1271 | if (call == liveCall) { |
| 1272 | // If the call is already the foreground call, then we are golden. |
| 1273 | // This can happen after the user selects an account in the PRE_DIAL_WAIT |
| 1274 | // state since the call was already populated into the list. |
| 1275 | return true; |
| 1276 | } |
| 1277 | |
Andrew Lee | e659518 | 2014-09-23 18:43:05 -0700 | [diff] [blame] | 1278 | if (hasMaximumOutgoingCalls()) { |
| 1279 | // Disconnect the current outgoing call if it's not an emergency call. If the user |
| 1280 | // tries to make two outgoing calls to different emergency call numbers, we will try |
| 1281 | // to connect the first outgoing call. |
| 1282 | if (isEmergency) { |
| 1283 | Call outgoingCall = getFirstCallWithState(OUTGOING_CALL_STATES); |
| 1284 | if (!outgoingCall.isEmergencyCall()) { |
| 1285 | outgoingCall.disconnect(); |
| 1286 | return true; |
| 1287 | } |
| 1288 | } |
| 1289 | return false; |
| 1290 | } |
| 1291 | |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 1292 | if (hasMaximumHoldingCalls()) { |
| 1293 | // There is no more room for any more calls, unless it's an emergency. |
| 1294 | if (isEmergency) { |
| 1295 | // Kill the current active call, this is easier then trying to disconnect a |
| 1296 | // holding call and hold an active call. |
| 1297 | liveCall.disconnect(); |
| 1298 | return true; |
| 1299 | } |
| 1300 | return false; // No more room! |
| 1301 | } |
| 1302 | |
| 1303 | // We have room for at least one more holding call at this point. |
| 1304 | |
| 1305 | // First thing, if we are trying to make a call with the same phone account as the live |
| 1306 | // call, then allow it so that the connection service can make its own decision about |
| 1307 | // how to handle the new call relative to the current one. |
| 1308 | if (Objects.equals(liveCall.getTargetPhoneAccount(), call.getTargetPhoneAccount())) { |
| 1309 | return true; |
| 1310 | } else if (call.getTargetPhoneAccount() == null) { |
| 1311 | // Without a phone account, we can't say reliably that the call will fail. |
| 1312 | // If the user chooses the same phone account as the live call, then it's |
| 1313 | // still possible that the call can be made (like with CDMA calls not supporting |
| 1314 | // hold but they still support adding a call by going immediately into conference |
| 1315 | // mode). Return true here and we'll run this code again after user chooses an |
| 1316 | // account. |
| 1317 | return true; |
| 1318 | } |
| 1319 | |
| 1320 | // Try to hold the live call before attempting the new outgoing call. |
Ihab Awad | 07bc5ee | 2014-11-12 13:42:52 -0800 | [diff] [blame] | 1321 | if (liveCall.can(Connection.CAPABILITY_HOLD)) { |
Santos Cordon | f193ba4 | 2014-09-12 06:37:39 -0700 | [diff] [blame] | 1322 | liveCall.hold(); |
| 1323 | return true; |
| 1324 | } |
| 1325 | |
| 1326 | // The live call cannot be held so we're out of luck here. There's no room. |
| 1327 | return false; |
| 1328 | } |
| 1329 | return true; |
| 1330 | } |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 1331 | |
| 1332 | /** |
Tyler Gunn | 6e2b94e | 2014-10-30 11:05:22 -0700 | [diff] [blame] | 1333 | * Creates a new call for an existing connection. |
| 1334 | * |
| 1335 | * @param callId The id of the new call. |
| 1336 | * @param connection The connection information. |
| 1337 | * @return The new call. |
| 1338 | */ |
| 1339 | Call createCallForExistingConnection(String callId, ParcelableConnection connection) { |
| 1340 | Call call = new Call( |
| 1341 | mContext, |
| 1342 | mConnectionServiceRepository, |
| 1343 | connection.getHandle() /* handle */, |
| 1344 | null /* gatewayInfo */, |
| 1345 | null /* connectionManagerPhoneAccount */, |
| 1346 | connection.getPhoneAccount(), /* targetPhoneAccountHandle */ |
| 1347 | false /* isIncoming */, |
| 1348 | false /* isConference */); |
| 1349 | |
| 1350 | setCallState(call, Call.getStateFromConnectionState(connection.getState())); |
Ihab Awad | 07bc5ee | 2014-11-12 13:42:52 -0800 | [diff] [blame] | 1351 | call.setConnectionCapabilities(connection.getConnectionCapabilities()); |
Tyler Gunn | 6e2b94e | 2014-10-30 11:05:22 -0700 | [diff] [blame] | 1352 | call.setCallerDisplayName(connection.getCallerDisplayName(), |
| 1353 | connection.getCallerDisplayNamePresentation()); |
| 1354 | |
| 1355 | call.addListener(this); |
| 1356 | addCall(call); |
| 1357 | |
| 1358 | return call; |
| 1359 | } |
| 1360 | |
| 1361 | /** |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 1362 | * Dumps the state of the {@link CallsManager}. |
| 1363 | * |
| 1364 | * @param pw The {@code IndentingPrintWriter} to write the state to. |
| 1365 | */ |
| 1366 | public void dump(IndentingPrintWriter pw) { |
| 1367 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG); |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 1368 | if (mCalls != null) { |
| 1369 | pw.println("mCalls: "); |
| 1370 | pw.increaseIndent(); |
| 1371 | for (Call call : mCalls) { |
| 1372 | pw.println(call); |
| 1373 | } |
| 1374 | pw.decreaseIndent(); |
| 1375 | } |
Tyler Gunn | 9787e0e | 2014-10-14 14:36:12 -0700 | [diff] [blame] | 1376 | pw.println("mForegroundCall: " + (mForegroundCall == null ? "none" : mForegroundCall)); |
| 1377 | |
| 1378 | if (mCallAudioManager != null) { |
| 1379 | pw.println("mCallAudioManager:"); |
| 1380 | pw.increaseIndent(); |
| 1381 | mCallAudioManager.dump(pw); |
| 1382 | pw.decreaseIndent(); |
| 1383 | } |
| 1384 | |
| 1385 | if (mTtyManager != null) { |
| 1386 | pw.println("mTtyManager:"); |
| 1387 | pw.increaseIndent(); |
| 1388 | mTtyManager.dump(pw); |
| 1389 | pw.decreaseIndent(); |
| 1390 | } |
| 1391 | |
| 1392 | if (mInCallController != null) { |
| 1393 | pw.println("mInCallController:"); |
| 1394 | pw.increaseIndent(); |
| 1395 | mInCallController.dump(pw); |
| 1396 | pw.decreaseIndent(); |
| 1397 | } |
| 1398 | |
| 1399 | if (mConnectionServiceRepository != null) { |
| 1400 | pw.println("mConnectionServiceRepository:"); |
| 1401 | pw.increaseIndent(); |
| 1402 | mConnectionServiceRepository.dump(pw); |
| 1403 | pw.decreaseIndent(); |
| 1404 | } |
Tyler Gunn | 91d43cf | 2014-09-17 12:19:39 -0700 | [diff] [blame] | 1405 | } |
Ben Gilad | 9f2bed3 | 2013-12-12 17:43:26 -0800 | [diff] [blame] | 1406 | } |