Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 17 | package android.telecom; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 18 | |
Santos Cordon | 5c6fa95 | 2014-07-20 17:47:12 -0700 | [diff] [blame] | 19 | import android.annotation.SdkConstant; |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 20 | import android.app.Service; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 21 | import android.content.ComponentName; |
Santos Cordon | 5c6fa95 | 2014-07-20 17:47:12 -0700 | [diff] [blame] | 22 | import android.content.Intent; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 23 | import android.net.Uri; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 24 | import android.os.Bundle; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 25 | import android.os.Handler; |
| 26 | import android.os.IBinder; |
| 27 | import android.os.Looper; |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 28 | import android.os.Message; |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 29 | import android.os.ParcelFileDescriptor; |
| 30 | import android.os.RemoteException; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 31 | import android.telecom.Logging.Session; |
Andrew Lee | 1418576 | 2014-07-25 09:41:56 -0700 | [diff] [blame] | 32 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 33 | import com.android.internal.os.SomeArgs; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 34 | import com.android.internal.telecom.IConnectionService; |
| 35 | import com.android.internal.telecom.IConnectionServiceAdapter; |
| 36 | import com.android.internal.telecom.RemoteServiceCallback; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 37 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 38 | import java.util.ArrayList; |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 39 | import java.util.Collection; |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 40 | import java.util.Collections; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 41 | import java.util.List; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 42 | import java.util.Map; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 43 | import java.util.UUID; |
mike dooley | 95e8070 | 2014-09-18 14:07:52 -0700 | [diff] [blame] | 44 | import java.util.concurrent.ConcurrentHashMap; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 45 | |
| 46 | /** |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 47 | * An abstract service that should be implemented by any apps which either: |
| 48 | * <ol> |
| 49 | * <li>Can make phone calls (VoIP or otherwise) and want those calls to be integrated into the |
| 50 | * built-in phone app. Referred to as a <b>system managed</b> {@link ConnectionService}.</li> |
| 51 | * <li>Are a standalone calling app and don't want their calls to be integrated into the |
| 52 | * built-in phone app. Referred to as a <b>self managed</b> {@link ConnectionService}.</li> |
| 53 | * </ol> |
| 54 | * Once implemented, the {@link ConnectionService} needs to take the following steps so that Telecom |
| 55 | * will bind to it: |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 56 | * <p> |
| 57 | * 1. <i>Registration in AndroidManifest.xml</i> |
| 58 | * <br/> |
| 59 | * <pre> |
| 60 | * <service android:name="com.example.package.MyConnectionService" |
| 61 | * android:label="@string/some_label_for_my_connection_service" |
Yorke Lee | 249c12e | 2015-05-13 15:59:29 -0700 | [diff] [blame] | 62 | * android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"> |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 63 | * <intent-filter> |
| 64 | * <action android:name="android.telecom.ConnectionService" /> |
| 65 | * </intent-filter> |
| 66 | * </service> |
| 67 | * </pre> |
| 68 | * <p> |
| 69 | * 2. <i> Registration of {@link PhoneAccount} with {@link TelecomManager}.</i> |
| 70 | * <br/> |
| 71 | * See {@link PhoneAccount} and {@link TelecomManager#registerPhoneAccount} for more information. |
| 72 | * <p> |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 73 | * System managed {@link ConnectionService}s must be enabled by the user in the phone app settings |
| 74 | * before Telecom will bind to them. Self-manged {@link ConnectionService}s must be granted the |
| 75 | * appropriate permission before Telecom will bind to them. |
| 76 | * <p> |
| 77 | * Once registered and enabled by the user in the phone app settings or granted permission, telecom |
| 78 | * will bind to a {@link ConnectionService} implementation when it wants that |
| 79 | * {@link ConnectionService} to place a call or the service has indicated that is has an incoming |
| 80 | * call through {@link TelecomManager#addNewIncomingCall}. The {@link ConnectionService} can then |
| 81 | * expect a call to {@link #onCreateIncomingConnection} or {@link #onCreateOutgoingConnection} |
| 82 | * wherein it should provide a new instance of a {@link Connection} object. It is through this |
| 83 | * {@link Connection} object that telecom receives state updates and the {@link ConnectionService} |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 84 | * receives call-commands such as answer, reject, hold and disconnect. |
| 85 | * <p> |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 86 | * When there are no more live calls, telecom will unbind from the {@link ConnectionService}. |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 87 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 88 | public abstract class ConnectionService extends Service { |
Santos Cordon | 5c6fa95 | 2014-07-20 17:47:12 -0700 | [diff] [blame] | 89 | /** |
| 90 | * The {@link Intent} that must be declared as handled by the service. |
| 91 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 92 | @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION) |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 93 | public static final String SERVICE_INTERFACE = "android.telecom.ConnectionService"; |
Santos Cordon | 5c6fa95 | 2014-07-20 17:47:12 -0700 | [diff] [blame] | 94 | |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 95 | // Flag controlling whether PII is emitted into the logs |
Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 96 | private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 97 | |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 98 | // Session Definitions |
| 99 | private static final String SESSION_HANDLER = "H."; |
| 100 | private static final String SESSION_ADD_CS_ADAPTER = "CS.aCSA"; |
| 101 | private static final String SESSION_REMOVE_CS_ADAPTER = "CS.rCSA"; |
| 102 | private static final String SESSION_CREATE_CONN = "CS.crCo"; |
Tyler Gunn | d104a4f | 2017-05-12 10:04:49 -0700 | [diff] [blame] | 103 | private static final String SESSION_CREATE_CONN_COMPLETE = "CS.crCoC"; |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 104 | private static final String SESSION_CREATE_CONN_FAILED = "CS.crCoF"; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 105 | private static final String SESSION_ABORT = "CS.ab"; |
| 106 | private static final String SESSION_ANSWER = "CS.an"; |
| 107 | private static final String SESSION_ANSWER_VIDEO = "CS.anV"; |
| 108 | private static final String SESSION_REJECT = "CS.r"; |
| 109 | private static final String SESSION_REJECT_MESSAGE = "CS.rWM"; |
| 110 | private static final String SESSION_SILENCE = "CS.s"; |
| 111 | private static final String SESSION_DISCONNECT = "CS.d"; |
| 112 | private static final String SESSION_HOLD = "CS.h"; |
| 113 | private static final String SESSION_UNHOLD = "CS.u"; |
| 114 | private static final String SESSION_CALL_AUDIO_SC = "CS.cASC"; |
| 115 | private static final String SESSION_PLAY_DTMF = "CS.pDT"; |
| 116 | private static final String SESSION_STOP_DTMF = "CS.sDT"; |
| 117 | private static final String SESSION_CONFERENCE = "CS.c"; |
| 118 | private static final String SESSION_SPLIT_CONFERENCE = "CS.sFC"; |
| 119 | private static final String SESSION_MERGE_CONFERENCE = "CS.mC"; |
| 120 | private static final String SESSION_SWAP_CONFERENCE = "CS.sC"; |
| 121 | private static final String SESSION_POST_DIAL_CONT = "CS.oPDC"; |
| 122 | private static final String SESSION_PULL_EXTERNAL_CALL = "CS.pEC"; |
| 123 | private static final String SESSION_SEND_CALL_EVENT = "CS.sCE"; |
| 124 | private static final String SESSION_EXTRAS_CHANGED = "CS.oEC"; |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 125 | private static final String SESSION_START_RTT = "CS.+RTT"; |
| 126 | private static final String SESSION_STOP_RTT = "CS.-RTT"; |
| 127 | private static final String SESSION_RTT_UPGRADE_RESPONSE = "CS.rTRUR"; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 128 | |
Ihab Awad | 8aecfed | 2014-08-08 17:06:11 -0700 | [diff] [blame] | 129 | private static final int MSG_ADD_CONNECTION_SERVICE_ADAPTER = 1; |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 130 | private static final int MSG_CREATE_CONNECTION = 2; |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 131 | private static final int MSG_ABORT = 3; |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 132 | private static final int MSG_ANSWER = 4; |
| 133 | private static final int MSG_REJECT = 5; |
| 134 | private static final int MSG_DISCONNECT = 6; |
| 135 | private static final int MSG_HOLD = 7; |
| 136 | private static final int MSG_UNHOLD = 8; |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 137 | private static final int MSG_ON_CALL_AUDIO_STATE_CHANGED = 9; |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 138 | private static final int MSG_PLAY_DTMF_TONE = 10; |
| 139 | private static final int MSG_STOP_DTMF_TONE = 11; |
| 140 | private static final int MSG_CONFERENCE = 12; |
| 141 | private static final int MSG_SPLIT_FROM_CONFERENCE = 13; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 142 | private static final int MSG_ON_POST_DIAL_CONTINUE = 14; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 143 | private static final int MSG_REMOVE_CONNECTION_SERVICE_ADAPTER = 16; |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 144 | private static final int MSG_ANSWER_VIDEO = 17; |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 145 | private static final int MSG_MERGE_CONFERENCE = 18; |
| 146 | private static final int MSG_SWAP_CONFERENCE = 19; |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 147 | private static final int MSG_REJECT_WITH_MESSAGE = 20; |
Bryce Lee | cac5077 | 2015-11-17 15:13:29 -0800 | [diff] [blame] | 148 | private static final int MSG_SILENCE = 21; |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 149 | private static final int MSG_PULL_EXTERNAL_CALL = 22; |
| 150 | private static final int MSG_SEND_CALL_EVENT = 23; |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 151 | private static final int MSG_ON_EXTRAS_CHANGED = 24; |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 152 | private static final int MSG_CREATE_CONNECTION_FAILED = 25; |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 153 | private static final int MSG_ON_START_RTT = 26; |
| 154 | private static final int MSG_ON_STOP_RTT = 27; |
| 155 | private static final int MSG_RTT_UPGRADE_RESPONSE = 28; |
Tyler Gunn | d104a4f | 2017-05-12 10:04:49 -0700 | [diff] [blame] | 156 | private static final int MSG_CREATE_CONNECTION_COMPLETE = 29; |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 157 | |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 158 | private static Connection sNullConnection; |
| 159 | |
mike dooley | 95e8070 | 2014-09-18 14:07:52 -0700 | [diff] [blame] | 160 | private final Map<String, Connection> mConnectionById = new ConcurrentHashMap<>(); |
| 161 | private final Map<Connection, String> mIdByConnection = new ConcurrentHashMap<>(); |
| 162 | private final Map<String, Conference> mConferenceById = new ConcurrentHashMap<>(); |
| 163 | private final Map<Conference, String> mIdByConference = new ConcurrentHashMap<>(); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 164 | private final RemoteConnectionManager mRemoteConnectionManager = |
| 165 | new RemoteConnectionManager(this); |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 166 | private final List<Runnable> mPreInitializationConnectionRequests = new ArrayList<>(); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 167 | private final ConnectionServiceAdapter mAdapter = new ConnectionServiceAdapter(); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 168 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 169 | private boolean mAreAccountsInitialized = false; |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 170 | private Conference sNullConference; |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 171 | private Object mIdSyncRoot = new Object(); |
| 172 | private int mId = 0; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 173 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 174 | private final IBinder mBinder = new IConnectionService.Stub() { |
| 175 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 176 | public void addConnectionServiceAdapter(IConnectionServiceAdapter adapter, |
| 177 | Session.Info sessionInfo) { |
| 178 | Log.startSession(sessionInfo, SESSION_ADD_CS_ADAPTER); |
| 179 | try { |
| 180 | SomeArgs args = SomeArgs.obtain(); |
| 181 | args.arg1 = adapter; |
| 182 | args.arg2 = Log.createSubsession(); |
| 183 | mHandler.obtainMessage(MSG_ADD_CONNECTION_SERVICE_ADAPTER, args).sendToTarget(); |
| 184 | } finally { |
| 185 | Log.endSession(); |
| 186 | } |
Ihab Awad | 8aecfed | 2014-08-08 17:06:11 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 189 | public void removeConnectionServiceAdapter(IConnectionServiceAdapter adapter, |
| 190 | Session.Info sessionInfo) { |
| 191 | Log.startSession(sessionInfo, SESSION_REMOVE_CS_ADAPTER); |
| 192 | try { |
| 193 | SomeArgs args = SomeArgs.obtain(); |
| 194 | args.arg1 = adapter; |
| 195 | args.arg2 = Log.createSubsession(); |
| 196 | mHandler.obtainMessage(MSG_REMOVE_CONNECTION_SERVICE_ADAPTER, args).sendToTarget(); |
| 197 | } finally { |
| 198 | Log.endSession(); |
| 199 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | @Override |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 203 | public void createConnection( |
| 204 | PhoneAccountHandle connectionManagerPhoneAccount, |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 205 | String id, |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 206 | ConnectionRequest request, |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 207 | boolean isIncoming, |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 208 | boolean isUnknown, |
| 209 | Session.Info sessionInfo) { |
| 210 | Log.startSession(sessionInfo, SESSION_CREATE_CONN); |
| 211 | try { |
| 212 | SomeArgs args = SomeArgs.obtain(); |
| 213 | args.arg1 = connectionManagerPhoneAccount; |
| 214 | args.arg2 = id; |
| 215 | args.arg3 = request; |
| 216 | args.arg4 = Log.createSubsession(); |
| 217 | args.argi1 = isIncoming ? 1 : 0; |
| 218 | args.argi2 = isUnknown ? 1 : 0; |
| 219 | mHandler.obtainMessage(MSG_CREATE_CONNECTION, args).sendToTarget(); |
| 220 | } finally { |
| 221 | Log.endSession(); |
| 222 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | @Override |
Tyler Gunn | d104a4f | 2017-05-12 10:04:49 -0700 | [diff] [blame] | 226 | public void createConnectionComplete(String id, Session.Info sessionInfo) { |
| 227 | Log.startSession(sessionInfo, SESSION_CREATE_CONN_COMPLETE); |
| 228 | try { |
| 229 | SomeArgs args = SomeArgs.obtain(); |
| 230 | args.arg1 = id; |
| 231 | args.arg2 = Log.createSubsession(); |
| 232 | mHandler.obtainMessage(MSG_CREATE_CONNECTION_COMPLETE, args).sendToTarget(); |
| 233 | } finally { |
| 234 | Log.endSession(); |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | @Override |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 239 | public void createConnectionFailed( |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 240 | PhoneAccountHandle connectionManagerPhoneAccount, |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 241 | String callId, |
| 242 | ConnectionRequest request, |
| 243 | boolean isIncoming, |
| 244 | Session.Info sessionInfo) { |
| 245 | Log.startSession(sessionInfo, SESSION_CREATE_CONN_FAILED); |
| 246 | try { |
| 247 | SomeArgs args = SomeArgs.obtain(); |
| 248 | args.arg1 = callId; |
| 249 | args.arg2 = request; |
| 250 | args.arg3 = Log.createSubsession(); |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 251 | args.arg4 = connectionManagerPhoneAccount; |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 252 | args.argi1 = isIncoming ? 1 : 0; |
| 253 | mHandler.obtainMessage(MSG_CREATE_CONNECTION_FAILED, args).sendToTarget(); |
| 254 | } finally { |
| 255 | Log.endSession(); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 260 | public void abort(String callId, Session.Info sessionInfo) { |
| 261 | Log.startSession(sessionInfo, SESSION_ABORT); |
| 262 | try { |
| 263 | SomeArgs args = SomeArgs.obtain(); |
| 264 | args.arg1 = callId; |
| 265 | args.arg2 = Log.createSubsession(); |
| 266 | mHandler.obtainMessage(MSG_ABORT, args).sendToTarget(); |
| 267 | } finally { |
| 268 | Log.endSession(); |
| 269 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 273 | public void answerVideo(String callId, int videoState, Session.Info sessionInfo) { |
| 274 | Log.startSession(sessionInfo, SESSION_ANSWER_VIDEO); |
| 275 | try { |
| 276 | SomeArgs args = SomeArgs.obtain(); |
| 277 | args.arg1 = callId; |
| 278 | args.arg2 = Log.createSubsession(); |
| 279 | args.argi1 = videoState; |
| 280 | mHandler.obtainMessage(MSG_ANSWER_VIDEO, args).sendToTarget(); |
| 281 | } finally { |
| 282 | Log.endSession(); |
| 283 | } |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 287 | public void answer(String callId, Session.Info sessionInfo) { |
| 288 | Log.startSession(sessionInfo, SESSION_ANSWER); |
| 289 | try { |
| 290 | SomeArgs args = SomeArgs.obtain(); |
| 291 | args.arg1 = callId; |
| 292 | args.arg2 = Log.createSubsession(); |
| 293 | mHandler.obtainMessage(MSG_ANSWER, args).sendToTarget(); |
| 294 | } finally { |
| 295 | Log.endSession(); |
| 296 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 300 | public void reject(String callId, Session.Info sessionInfo) { |
| 301 | Log.startSession(sessionInfo, SESSION_REJECT); |
| 302 | try { |
| 303 | SomeArgs args = SomeArgs.obtain(); |
| 304 | args.arg1 = callId; |
| 305 | args.arg2 = Log.createSubsession(); |
| 306 | mHandler.obtainMessage(MSG_REJECT, args).sendToTarget(); |
| 307 | } finally { |
| 308 | Log.endSession(); |
| 309 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 313 | public void rejectWithMessage(String callId, String message, Session.Info sessionInfo) { |
| 314 | Log.startSession(sessionInfo, SESSION_REJECT_MESSAGE); |
| 315 | try { |
| 316 | SomeArgs args = SomeArgs.obtain(); |
| 317 | args.arg1 = callId; |
| 318 | args.arg2 = message; |
| 319 | args.arg3 = Log.createSubsession(); |
| 320 | mHandler.obtainMessage(MSG_REJECT_WITH_MESSAGE, args).sendToTarget(); |
| 321 | } finally { |
| 322 | Log.endSession(); |
| 323 | } |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 327 | public void silence(String callId, Session.Info sessionInfo) { |
| 328 | Log.startSession(sessionInfo, SESSION_SILENCE); |
| 329 | try { |
| 330 | SomeArgs args = SomeArgs.obtain(); |
| 331 | args.arg1 = callId; |
| 332 | args.arg2 = Log.createSubsession(); |
| 333 | mHandler.obtainMessage(MSG_SILENCE, args).sendToTarget(); |
| 334 | } finally { |
| 335 | Log.endSession(); |
| 336 | } |
Bryce Lee | cac5077 | 2015-11-17 15:13:29 -0800 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 340 | public void disconnect(String callId, Session.Info sessionInfo) { |
| 341 | Log.startSession(sessionInfo, SESSION_DISCONNECT); |
| 342 | try { |
| 343 | SomeArgs args = SomeArgs.obtain(); |
| 344 | args.arg1 = callId; |
| 345 | args.arg2 = Log.createSubsession(); |
| 346 | mHandler.obtainMessage(MSG_DISCONNECT, args).sendToTarget(); |
| 347 | } finally { |
| 348 | Log.endSession(); |
| 349 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 353 | public void hold(String callId, Session.Info sessionInfo) { |
| 354 | Log.startSession(sessionInfo, SESSION_HOLD); |
| 355 | try { |
| 356 | SomeArgs args = SomeArgs.obtain(); |
| 357 | args.arg1 = callId; |
| 358 | args.arg2 = Log.createSubsession(); |
| 359 | mHandler.obtainMessage(MSG_HOLD, args).sendToTarget(); |
| 360 | } finally { |
| 361 | Log.endSession(); |
| 362 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 366 | public void unhold(String callId, Session.Info sessionInfo) { |
| 367 | Log.startSession(sessionInfo, SESSION_UNHOLD); |
| 368 | try { |
| 369 | SomeArgs args = SomeArgs.obtain(); |
| 370 | args.arg1 = callId; |
| 371 | args.arg2 = Log.createSubsession(); |
| 372 | mHandler.obtainMessage(MSG_UNHOLD, args).sendToTarget(); |
| 373 | } finally { |
| 374 | Log.endSession(); |
| 375 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 379 | public void onCallAudioStateChanged(String callId, CallAudioState callAudioState, |
| 380 | Session.Info sessionInfo) { |
| 381 | Log.startSession(sessionInfo, SESSION_CALL_AUDIO_SC); |
| 382 | try { |
| 383 | SomeArgs args = SomeArgs.obtain(); |
| 384 | args.arg1 = callId; |
| 385 | args.arg2 = callAudioState; |
| 386 | args.arg3 = Log.createSubsession(); |
| 387 | mHandler.obtainMessage(MSG_ON_CALL_AUDIO_STATE_CHANGED, args).sendToTarget(); |
| 388 | } finally { |
| 389 | Log.endSession(); |
| 390 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 394 | public void playDtmfTone(String callId, char digit, Session.Info sessionInfo) { |
| 395 | Log.startSession(sessionInfo, SESSION_PLAY_DTMF); |
| 396 | try { |
| 397 | SomeArgs args = SomeArgs.obtain(); |
| 398 | args.arg1 = digit; |
| 399 | args.arg2 = callId; |
| 400 | args.arg3 = Log.createSubsession(); |
| 401 | mHandler.obtainMessage(MSG_PLAY_DTMF_TONE, args).sendToTarget(); |
| 402 | } finally { |
| 403 | Log.endSession(); |
| 404 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 408 | public void stopDtmfTone(String callId, Session.Info sessionInfo) { |
| 409 | Log.startSession(sessionInfo, SESSION_STOP_DTMF); |
| 410 | try { |
| 411 | SomeArgs args = SomeArgs.obtain(); |
| 412 | args.arg1 = callId; |
| 413 | args.arg2 = Log.createSubsession(); |
| 414 | mHandler.obtainMessage(MSG_STOP_DTMF_TONE, args).sendToTarget(); |
| 415 | } finally { |
| 416 | Log.endSession(); |
| 417 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 421 | public void conference(String callId1, String callId2, Session.Info sessionInfo) { |
| 422 | Log.startSession(sessionInfo, SESSION_CONFERENCE); |
| 423 | try { |
| 424 | SomeArgs args = SomeArgs.obtain(); |
| 425 | args.arg1 = callId1; |
| 426 | args.arg2 = callId2; |
| 427 | args.arg3 = Log.createSubsession(); |
| 428 | mHandler.obtainMessage(MSG_CONFERENCE, args).sendToTarget(); |
| 429 | } finally { |
| 430 | Log.endSession(); |
| 431 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 435 | public void splitFromConference(String callId, Session.Info sessionInfo) { |
| 436 | Log.startSession(sessionInfo, SESSION_SPLIT_CONFERENCE); |
| 437 | try { |
| 438 | SomeArgs args = SomeArgs.obtain(); |
| 439 | args.arg1 = callId; |
| 440 | args.arg2 = Log.createSubsession(); |
| 441 | mHandler.obtainMessage(MSG_SPLIT_FROM_CONFERENCE, args).sendToTarget(); |
| 442 | } finally { |
| 443 | Log.endSession(); |
| 444 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 448 | public void mergeConference(String callId, Session.Info sessionInfo) { |
| 449 | Log.startSession(sessionInfo, SESSION_MERGE_CONFERENCE); |
| 450 | try { |
| 451 | SomeArgs args = SomeArgs.obtain(); |
| 452 | args.arg1 = callId; |
| 453 | args.arg2 = Log.createSubsession(); |
| 454 | mHandler.obtainMessage(MSG_MERGE_CONFERENCE, args).sendToTarget(); |
| 455 | } finally { |
| 456 | Log.endSession(); |
| 457 | } |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 461 | public void swapConference(String callId, Session.Info sessionInfo) { |
| 462 | Log.startSession(sessionInfo, SESSION_SWAP_CONFERENCE); |
| 463 | try { |
| 464 | SomeArgs args = SomeArgs.obtain(); |
| 465 | args.arg1 = callId; |
| 466 | args.arg2 = Log.createSubsession(); |
| 467 | mHandler.obtainMessage(MSG_SWAP_CONFERENCE, args).sendToTarget(); |
| 468 | } finally { |
| 469 | Log.endSession(); |
| 470 | } |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 474 | public void onPostDialContinue(String callId, boolean proceed, Session.Info sessionInfo) { |
| 475 | Log.startSession(sessionInfo, SESSION_POST_DIAL_CONT); |
| 476 | try { |
| 477 | SomeArgs args = SomeArgs.obtain(); |
| 478 | args.arg1 = callId; |
| 479 | args.arg2 = Log.createSubsession(); |
| 480 | args.argi1 = proceed ? 1 : 0; |
| 481 | mHandler.obtainMessage(MSG_ON_POST_DIAL_CONTINUE, args).sendToTarget(); |
| 482 | } finally { |
| 483 | Log.endSession(); |
| 484 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 485 | } |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 486 | |
| 487 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 488 | public void pullExternalCall(String callId, Session.Info sessionInfo) { |
| 489 | Log.startSession(sessionInfo, SESSION_PULL_EXTERNAL_CALL); |
| 490 | try { |
| 491 | SomeArgs args = SomeArgs.obtain(); |
| 492 | args.arg1 = callId; |
| 493 | args.arg2 = Log.createSubsession(); |
| 494 | mHandler.obtainMessage(MSG_PULL_EXTERNAL_CALL, args).sendToTarget(); |
| 495 | } finally { |
| 496 | Log.endSession(); |
| 497 | } |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 501 | public void sendCallEvent(String callId, String event, Bundle extras, |
| 502 | Session.Info sessionInfo) { |
| 503 | Log.startSession(sessionInfo, SESSION_SEND_CALL_EVENT); |
| 504 | try { |
| 505 | SomeArgs args = SomeArgs.obtain(); |
| 506 | args.arg1 = callId; |
| 507 | args.arg2 = event; |
| 508 | args.arg3 = extras; |
| 509 | args.arg4 = Log.createSubsession(); |
| 510 | mHandler.obtainMessage(MSG_SEND_CALL_EVENT, args).sendToTarget(); |
| 511 | } finally { |
| 512 | Log.endSession(); |
| 513 | } |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 514 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 515 | |
| 516 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 517 | public void onExtrasChanged(String callId, Bundle extras, Session.Info sessionInfo) { |
| 518 | Log.startSession(sessionInfo, SESSION_EXTRAS_CHANGED); |
| 519 | try { |
| 520 | SomeArgs args = SomeArgs.obtain(); |
| 521 | args.arg1 = callId; |
| 522 | args.arg2 = extras; |
| 523 | args.arg3 = Log.createSubsession(); |
| 524 | mHandler.obtainMessage(MSG_ON_EXTRAS_CHANGED, args).sendToTarget(); |
| 525 | } finally { |
| 526 | Log.endSession(); |
| 527 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 528 | } |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 529 | |
| 530 | @Override |
| 531 | public void startRtt(String callId, ParcelFileDescriptor fromInCall, |
| 532 | ParcelFileDescriptor toInCall, Session.Info sessionInfo) throws RemoteException { |
| 533 | Log.startSession(sessionInfo, SESSION_START_RTT); |
| 534 | try { |
| 535 | SomeArgs args = SomeArgs.obtain(); |
| 536 | args.arg1 = callId; |
| 537 | args.arg2 = new Connection.RttTextStream(toInCall, fromInCall); |
| 538 | args.arg3 = Log.createSubsession(); |
| 539 | mHandler.obtainMessage(MSG_ON_START_RTT, args).sendToTarget(); |
| 540 | } finally { |
| 541 | Log.endSession(); |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | @Override |
| 546 | public void stopRtt(String callId, Session.Info sessionInfo) throws RemoteException { |
| 547 | Log.startSession(sessionInfo, SESSION_STOP_RTT); |
| 548 | try { |
| 549 | SomeArgs args = SomeArgs.obtain(); |
| 550 | args.arg1 = callId; |
| 551 | args.arg2 = Log.createSubsession(); |
| 552 | mHandler.obtainMessage(MSG_ON_STOP_RTT, args).sendToTarget(); |
| 553 | } finally { |
| 554 | Log.endSession(); |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | @Override |
| 559 | public void respondToRttUpgradeRequest(String callId, ParcelFileDescriptor fromInCall, |
| 560 | ParcelFileDescriptor toInCall, Session.Info sessionInfo) throws RemoteException { |
| 561 | Log.startSession(sessionInfo, SESSION_RTT_UPGRADE_RESPONSE); |
| 562 | try { |
| 563 | SomeArgs args = SomeArgs.obtain(); |
| 564 | args.arg1 = callId; |
| 565 | if (toInCall == null || fromInCall == null) { |
| 566 | args.arg2 = null; |
| 567 | } else { |
| 568 | args.arg2 = new Connection.RttTextStream(toInCall, fromInCall); |
| 569 | } |
| 570 | args.arg3 = Log.createSubsession(); |
| 571 | mHandler.obtainMessage(MSG_RTT_UPGRADE_RESPONSE, args).sendToTarget(); |
| 572 | } finally { |
| 573 | Log.endSession(); |
| 574 | } |
| 575 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 576 | }; |
| 577 | |
| 578 | private final Handler mHandler = new Handler(Looper.getMainLooper()) { |
| 579 | @Override |
| 580 | public void handleMessage(Message msg) { |
| 581 | switch (msg.what) { |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 582 | case MSG_ADD_CONNECTION_SERVICE_ADAPTER: { |
| 583 | SomeArgs args = (SomeArgs) msg.obj; |
| 584 | try { |
| 585 | IConnectionServiceAdapter adapter = (IConnectionServiceAdapter) args.arg1; |
| 586 | Log.continueSession((Session) args.arg2, |
| 587 | SESSION_HANDLER + SESSION_ADD_CS_ADAPTER); |
| 588 | mAdapter.addAdapter(adapter); |
| 589 | onAdapterAttached(); |
| 590 | } finally { |
| 591 | args.recycle(); |
| 592 | Log.endSession(); |
| 593 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 594 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 595 | } |
| 596 | case MSG_REMOVE_CONNECTION_SERVICE_ADAPTER: { |
| 597 | SomeArgs args = (SomeArgs) msg.obj; |
| 598 | try { |
| 599 | Log.continueSession((Session) args.arg2, |
| 600 | SESSION_HANDLER + SESSION_REMOVE_CS_ADAPTER); |
| 601 | mAdapter.removeAdapter((IConnectionServiceAdapter) args.arg1); |
| 602 | } finally { |
| 603 | args.recycle(); |
| 604 | Log.endSession(); |
| 605 | } |
Ihab Awad | 8aecfed | 2014-08-08 17:06:11 -0700 | [diff] [blame] | 606 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 607 | } |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 608 | case MSG_CREATE_CONNECTION: { |
| 609 | SomeArgs args = (SomeArgs) msg.obj; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 610 | Log.continueSession((Session) args.arg4, SESSION_HANDLER + SESSION_CREATE_CONN); |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 611 | try { |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 612 | final PhoneAccountHandle connectionManagerPhoneAccount = |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 613 | (PhoneAccountHandle) args.arg1; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 614 | final String id = (String) args.arg2; |
| 615 | final ConnectionRequest request = (ConnectionRequest) args.arg3; |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 616 | final boolean isIncoming = args.argi1 == 1; |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 617 | final boolean isUnknown = args.argi2 == 1; |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 618 | if (!mAreAccountsInitialized) { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 619 | Log.d(this, "Enqueueing pre-init request %s", id); |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 620 | mPreInitializationConnectionRequests.add( |
| 621 | new android.telecom.Logging.Runnable( |
| 622 | SESSION_HANDLER + SESSION_CREATE_CONN + ".pICR", |
| 623 | null /*lock*/) { |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 624 | @Override |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 625 | public void loggedRun() { |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 626 | createConnection( |
| 627 | connectionManagerPhoneAccount, |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 628 | id, |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 629 | request, |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 630 | isIncoming, |
| 631 | isUnknown); |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 632 | } |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 633 | }.prepare()); |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 634 | } else { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 635 | createConnection( |
| 636 | connectionManagerPhoneAccount, |
| 637 | id, |
| 638 | request, |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 639 | isIncoming, |
| 640 | isUnknown); |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 641 | } |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 642 | } finally { |
| 643 | args.recycle(); |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 644 | Log.endSession(); |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 645 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 646 | break; |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 647 | } |
Tyler Gunn | d104a4f | 2017-05-12 10:04:49 -0700 | [diff] [blame] | 648 | case MSG_CREATE_CONNECTION_COMPLETE: { |
| 649 | SomeArgs args = (SomeArgs) msg.obj; |
| 650 | Log.continueSession((Session) args.arg2, |
| 651 | SESSION_HANDLER + SESSION_CREATE_CONN_COMPLETE); |
| 652 | try { |
| 653 | final String id = (String) args.arg1; |
| 654 | if (!mAreAccountsInitialized) { |
| 655 | Log.d(this, "Enqueueing pre-init request %s", id); |
| 656 | mPreInitializationConnectionRequests.add( |
| 657 | new android.telecom.Logging.Runnable( |
| 658 | SESSION_HANDLER + SESSION_CREATE_CONN_COMPLETE |
| 659 | + ".pICR", |
| 660 | null /*lock*/) { |
| 661 | @Override |
| 662 | public void loggedRun() { |
| 663 | notifyCreateConnectionComplete(id); |
| 664 | } |
| 665 | }.prepare()); |
| 666 | } else { |
| 667 | notifyCreateConnectionComplete(id); |
| 668 | } |
| 669 | } finally { |
| 670 | args.recycle(); |
| 671 | Log.endSession(); |
| 672 | } |
| 673 | break; |
| 674 | } |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 675 | case MSG_CREATE_CONNECTION_FAILED: { |
| 676 | SomeArgs args = (SomeArgs) msg.obj; |
| 677 | Log.continueSession((Session) args.arg3, SESSION_HANDLER + |
| 678 | SESSION_CREATE_CONN_FAILED); |
| 679 | try { |
| 680 | final String id = (String) args.arg1; |
| 681 | final ConnectionRequest request = (ConnectionRequest) args.arg2; |
| 682 | final boolean isIncoming = args.argi1 == 1; |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 683 | final PhoneAccountHandle connectionMgrPhoneAccount = |
| 684 | (PhoneAccountHandle) args.arg4; |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 685 | if (!mAreAccountsInitialized) { |
| 686 | Log.d(this, "Enqueueing pre-init request %s", id); |
| 687 | mPreInitializationConnectionRequests.add( |
| 688 | new android.telecom.Logging.Runnable( |
| 689 | SESSION_HANDLER + SESSION_CREATE_CONN_FAILED + ".pICR", |
| 690 | null /*lock*/) { |
| 691 | @Override |
| 692 | public void loggedRun() { |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 693 | createConnectionFailed(connectionMgrPhoneAccount, id, |
| 694 | request, isIncoming); |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 695 | } |
| 696 | }.prepare()); |
| 697 | } else { |
| 698 | Log.i(this, "createConnectionFailed %s", id); |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 699 | createConnectionFailed(connectionMgrPhoneAccount, id, request, |
| 700 | isIncoming); |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 701 | } |
| 702 | } finally { |
| 703 | args.recycle(); |
| 704 | Log.endSession(); |
| 705 | } |
| 706 | break; |
| 707 | } |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 708 | case MSG_ABORT: { |
| 709 | SomeArgs args = (SomeArgs) msg.obj; |
| 710 | Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_ABORT); |
| 711 | try { |
| 712 | abort((String) args.arg1); |
| 713 | } finally { |
| 714 | args.recycle(); |
| 715 | Log.endSession(); |
| 716 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 717 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 718 | } |
| 719 | case MSG_ANSWER: { |
| 720 | SomeArgs args = (SomeArgs) msg.obj; |
| 721 | Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_ANSWER); |
| 722 | try { |
| 723 | answer((String) args.arg1); |
| 724 | } finally { |
| 725 | args.recycle(); |
| 726 | Log.endSession(); |
| 727 | } |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 728 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 729 | } |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 730 | case MSG_ANSWER_VIDEO: { |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 731 | SomeArgs args = (SomeArgs) msg.obj; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 732 | Log.continueSession((Session) args.arg2, |
| 733 | SESSION_HANDLER + SESSION_ANSWER_VIDEO); |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 734 | try { |
| 735 | String callId = (String) args.arg1; |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 736 | int videoState = args.argi1; |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 737 | answerVideo(callId, videoState); |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 738 | } finally { |
| 739 | args.recycle(); |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 740 | Log.endSession(); |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 741 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 742 | break; |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 743 | } |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 744 | case MSG_REJECT: { |
| 745 | SomeArgs args = (SomeArgs) msg.obj; |
| 746 | Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_REJECT); |
| 747 | try { |
| 748 | reject((String) args.arg1); |
| 749 | } finally { |
| 750 | args.recycle(); |
| 751 | Log.endSession(); |
| 752 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 753 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 754 | } |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 755 | case MSG_REJECT_WITH_MESSAGE: { |
| 756 | SomeArgs args = (SomeArgs) msg.obj; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 757 | Log.continueSession((Session) args.arg3, |
| 758 | SESSION_HANDLER + SESSION_REJECT_MESSAGE); |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 759 | try { |
| 760 | reject((String) args.arg1, (String) args.arg2); |
| 761 | } finally { |
| 762 | args.recycle(); |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 763 | Log.endSession(); |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 764 | } |
| 765 | break; |
| 766 | } |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 767 | case MSG_DISCONNECT: { |
| 768 | SomeArgs args = (SomeArgs) msg.obj; |
| 769 | Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_DISCONNECT); |
| 770 | try { |
| 771 | disconnect((String) args.arg1); |
| 772 | } finally { |
| 773 | args.recycle(); |
| 774 | Log.endSession(); |
| 775 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 776 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 777 | } |
| 778 | case MSG_SILENCE: { |
| 779 | SomeArgs args = (SomeArgs) msg.obj; |
| 780 | Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_SILENCE); |
| 781 | try { |
| 782 | silence((String) args.arg1); |
| 783 | } finally { |
| 784 | args.recycle(); |
| 785 | Log.endSession(); |
| 786 | } |
Bryce Lee | cac5077 | 2015-11-17 15:13:29 -0800 | [diff] [blame] | 787 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 788 | } |
| 789 | case MSG_HOLD: { |
| 790 | SomeArgs args = (SomeArgs) msg.obj; |
| 791 | Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_REJECT); |
| 792 | try { |
| 793 | hold((String) args.arg1); |
| 794 | } finally { |
| 795 | args.recycle(); |
| 796 | Log.endSession(); |
| 797 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 798 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 799 | } |
| 800 | case MSG_UNHOLD: { |
| 801 | SomeArgs args = (SomeArgs) msg.obj; |
| 802 | Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_UNHOLD); |
| 803 | try { |
| 804 | unhold((String) args.arg1); |
| 805 | } finally { |
| 806 | args.recycle(); |
| 807 | Log.endSession(); |
| 808 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 809 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 810 | } |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 811 | case MSG_ON_CALL_AUDIO_STATE_CHANGED: { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 812 | SomeArgs args = (SomeArgs) msg.obj; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 813 | Log.continueSession((Session) args.arg3, |
| 814 | SESSION_HANDLER + SESSION_CALL_AUDIO_SC); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 815 | try { |
| 816 | String callId = (String) args.arg1; |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 817 | CallAudioState audioState = (CallAudioState) args.arg2; |
| 818 | onCallAudioStateChanged(callId, new CallAudioState(audioState)); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 819 | } finally { |
| 820 | args.recycle(); |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 821 | Log.endSession(); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 822 | } |
| 823 | break; |
| 824 | } |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 825 | case MSG_PLAY_DTMF_TONE: { |
| 826 | SomeArgs args = (SomeArgs) msg.obj; |
| 827 | try { |
| 828 | Log.continueSession((Session) args.arg3, |
| 829 | SESSION_HANDLER + SESSION_PLAY_DTMF); |
| 830 | playDtmfTone((String) args.arg2, (char) args.arg1); |
| 831 | } finally { |
| 832 | args.recycle(); |
| 833 | Log.endSession(); |
| 834 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 835 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 836 | } |
| 837 | case MSG_STOP_DTMF_TONE: { |
| 838 | SomeArgs args = (SomeArgs) msg.obj; |
| 839 | try { |
| 840 | Log.continueSession((Session) args.arg2, |
| 841 | SESSION_HANDLER + SESSION_STOP_DTMF); |
| 842 | stopDtmfTone((String) args.arg1); |
| 843 | } finally { |
| 844 | args.recycle(); |
| 845 | Log.endSession(); |
| 846 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 847 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 848 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 849 | case MSG_CONFERENCE: { |
| 850 | SomeArgs args = (SomeArgs) msg.obj; |
| 851 | try { |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 852 | Log.continueSession((Session) args.arg3, |
| 853 | SESSION_HANDLER + SESSION_CONFERENCE); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 854 | String callId1 = (String) args.arg1; |
| 855 | String callId2 = (String) args.arg2; |
| 856 | conference(callId1, callId2); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 857 | } finally { |
| 858 | args.recycle(); |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 859 | Log.endSession(); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 860 | } |
| 861 | break; |
| 862 | } |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 863 | case MSG_SPLIT_FROM_CONFERENCE: { |
| 864 | SomeArgs args = (SomeArgs) msg.obj; |
| 865 | try { |
| 866 | Log.continueSession((Session) args.arg2, |
| 867 | SESSION_HANDLER + SESSION_SPLIT_CONFERENCE); |
| 868 | splitFromConference((String) args.arg1); |
| 869 | } finally { |
| 870 | args.recycle(); |
| 871 | Log.endSession(); |
| 872 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 873 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 874 | } |
| 875 | case MSG_MERGE_CONFERENCE: { |
| 876 | SomeArgs args = (SomeArgs) msg.obj; |
| 877 | try { |
| 878 | Log.continueSession((Session) args.arg2, |
| 879 | SESSION_HANDLER + SESSION_MERGE_CONFERENCE); |
| 880 | mergeConference((String) args.arg1); |
| 881 | } finally { |
| 882 | args.recycle(); |
| 883 | Log.endSession(); |
| 884 | } |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 885 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 886 | } |
| 887 | case MSG_SWAP_CONFERENCE: { |
| 888 | SomeArgs args = (SomeArgs) msg.obj; |
| 889 | try { |
| 890 | Log.continueSession((Session) args.arg2, |
| 891 | SESSION_HANDLER + SESSION_SWAP_CONFERENCE); |
| 892 | swapConference((String) args.arg1); |
| 893 | } finally { |
| 894 | args.recycle(); |
| 895 | Log.endSession(); |
| 896 | } |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 897 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 898 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 899 | case MSG_ON_POST_DIAL_CONTINUE: { |
| 900 | SomeArgs args = (SomeArgs) msg.obj; |
| 901 | try { |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 902 | Log.continueSession((Session) args.arg2, |
| 903 | SESSION_HANDLER + SESSION_POST_DIAL_CONT); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 904 | String callId = (String) args.arg1; |
| 905 | boolean proceed = (args.argi1 == 1); |
| 906 | onPostDialContinue(callId, proceed); |
| 907 | } finally { |
| 908 | args.recycle(); |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 909 | Log.endSession(); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 910 | } |
| 911 | break; |
| 912 | } |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 913 | case MSG_PULL_EXTERNAL_CALL: { |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 914 | SomeArgs args = (SomeArgs) msg.obj; |
| 915 | try { |
| 916 | Log.continueSession((Session) args.arg2, |
| 917 | SESSION_HANDLER + SESSION_PULL_EXTERNAL_CALL); |
| 918 | pullExternalCall((String) args.arg1); |
| 919 | } finally { |
| 920 | args.recycle(); |
| 921 | Log.endSession(); |
| 922 | } |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 923 | break; |
| 924 | } |
| 925 | case MSG_SEND_CALL_EVENT: { |
| 926 | SomeArgs args = (SomeArgs) msg.obj; |
| 927 | try { |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 928 | Log.continueSession((Session) args.arg4, |
| 929 | SESSION_HANDLER + SESSION_SEND_CALL_EVENT); |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 930 | String callId = (String) args.arg1; |
| 931 | String event = (String) args.arg2; |
| 932 | Bundle extras = (Bundle) args.arg3; |
| 933 | sendCallEvent(callId, event, extras); |
| 934 | } finally { |
| 935 | args.recycle(); |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 936 | Log.endSession(); |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 937 | } |
| 938 | break; |
| 939 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 940 | case MSG_ON_EXTRAS_CHANGED: { |
| 941 | SomeArgs args = (SomeArgs) msg.obj; |
| 942 | try { |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 943 | Log.continueSession((Session) args.arg3, |
| 944 | SESSION_HANDLER + SESSION_EXTRAS_CHANGED); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 945 | String callId = (String) args.arg1; |
| 946 | Bundle extras = (Bundle) args.arg2; |
| 947 | handleExtrasChanged(callId, extras); |
| 948 | } finally { |
| 949 | args.recycle(); |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 950 | Log.endSession(); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 951 | } |
| 952 | break; |
| 953 | } |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 954 | case MSG_ON_START_RTT: { |
| 955 | SomeArgs args = (SomeArgs) msg.obj; |
| 956 | try { |
| 957 | Log.continueSession((Session) args.arg3, |
| 958 | SESSION_HANDLER + SESSION_START_RTT); |
| 959 | String callId = (String) args.arg1; |
| 960 | Connection.RttTextStream rttTextStream = |
| 961 | (Connection.RttTextStream) args.arg2; |
| 962 | startRtt(callId, rttTextStream); |
| 963 | } finally { |
| 964 | args.recycle(); |
| 965 | Log.endSession(); |
| 966 | } |
| 967 | break; |
| 968 | } |
| 969 | case MSG_ON_STOP_RTT: { |
| 970 | SomeArgs args = (SomeArgs) msg.obj; |
| 971 | try { |
| 972 | Log.continueSession((Session) args.arg2, |
| 973 | SESSION_HANDLER + SESSION_STOP_RTT); |
| 974 | String callId = (String) args.arg1; |
| 975 | stopRtt(callId); |
| 976 | } finally { |
| 977 | args.recycle(); |
| 978 | Log.endSession(); |
| 979 | } |
| 980 | break; |
| 981 | } |
| 982 | case MSG_RTT_UPGRADE_RESPONSE: { |
| 983 | SomeArgs args = (SomeArgs) msg.obj; |
| 984 | try { |
| 985 | Log.continueSession((Session) args.arg3, |
| 986 | SESSION_HANDLER + SESSION_RTT_UPGRADE_RESPONSE); |
| 987 | String callId = (String) args.arg1; |
| 988 | Connection.RttTextStream rttTextStream = |
| 989 | (Connection.RttTextStream) args.arg2; |
| 990 | handleRttUpgradeResponse(callId, rttTextStream); |
| 991 | } finally { |
| 992 | args.recycle(); |
| 993 | Log.endSession(); |
| 994 | } |
| 995 | break; |
| 996 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 997 | default: |
| 998 | break; |
| 999 | } |
| 1000 | } |
| 1001 | }; |
| 1002 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1003 | private final Conference.Listener mConferenceListener = new Conference.Listener() { |
| 1004 | @Override |
| 1005 | public void onStateChanged(Conference conference, int oldState, int newState) { |
| 1006 | String id = mIdByConference.get(conference); |
| 1007 | switch (newState) { |
| 1008 | case Connection.STATE_ACTIVE: |
| 1009 | mAdapter.setActive(id); |
| 1010 | break; |
| 1011 | case Connection.STATE_HOLDING: |
| 1012 | mAdapter.setOnHold(id); |
| 1013 | break; |
| 1014 | case Connection.STATE_DISCONNECTED: |
| 1015 | // handled by onDisconnected |
| 1016 | break; |
| 1017 | } |
| 1018 | } |
| 1019 | |
| 1020 | @Override |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1021 | public void onDisconnected(Conference conference, DisconnectCause disconnectCause) { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1022 | String id = mIdByConference.get(conference); |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1023 | mAdapter.setDisconnected(id, disconnectCause); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1024 | } |
| 1025 | |
| 1026 | @Override |
| 1027 | public void onConnectionAdded(Conference conference, Connection connection) { |
| 1028 | } |
| 1029 | |
| 1030 | @Override |
| 1031 | public void onConnectionRemoved(Conference conference, Connection connection) { |
| 1032 | } |
| 1033 | |
| 1034 | @Override |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 1035 | public void onConferenceableConnectionsChanged( |
| 1036 | Conference conference, List<Connection> conferenceableConnections) { |
| 1037 | mAdapter.setConferenceableConnections( |
| 1038 | mIdByConference.get(conference), |
| 1039 | createConnectionIdList(conferenceableConnections)); |
| 1040 | } |
| 1041 | |
| 1042 | @Override |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1043 | public void onDestroyed(Conference conference) { |
| 1044 | removeConference(conference); |
| 1045 | } |
| 1046 | |
| 1047 | @Override |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1048 | public void onConnectionCapabilitiesChanged( |
| 1049 | Conference conference, |
| 1050 | int connectionCapabilities) { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1051 | String id = mIdByConference.get(conference); |
| 1052 | Log.d(this, "call capabilities: conference: %s", |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1053 | Connection.capabilitiesToString(connectionCapabilities)); |
| 1054 | mAdapter.setConnectionCapabilities(id, connectionCapabilities); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1055 | } |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1056 | |
| 1057 | @Override |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1058 | public void onConnectionPropertiesChanged( |
| 1059 | Conference conference, |
| 1060 | int connectionProperties) { |
| 1061 | String id = mIdByConference.get(conference); |
| 1062 | Log.d(this, "call capabilities: conference: %s", |
| 1063 | Connection.propertiesToString(connectionProperties)); |
| 1064 | mAdapter.setConnectionProperties(id, connectionProperties); |
| 1065 | } |
| 1066 | |
| 1067 | @Override |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1068 | public void onVideoStateChanged(Conference c, int videoState) { |
| 1069 | String id = mIdByConference.get(c); |
| 1070 | Log.d(this, "onVideoStateChanged set video state %d", videoState); |
| 1071 | mAdapter.setVideoState(id, videoState); |
| 1072 | } |
| 1073 | |
| 1074 | @Override |
| 1075 | public void onVideoProviderChanged(Conference c, Connection.VideoProvider videoProvider) { |
| 1076 | String id = mIdByConference.get(c); |
| 1077 | Log.d(this, "onVideoProviderChanged: Connection: %s, VideoProvider: %s", c, |
| 1078 | videoProvider); |
| 1079 | mAdapter.setVideoProvider(id, videoProvider); |
| 1080 | } |
Andrew Lee | 0f51da3 | 2015-04-16 13:11:55 -0700 | [diff] [blame] | 1081 | |
| 1082 | @Override |
Andrew Lee | edc625f | 2015-04-14 13:38:12 -0700 | [diff] [blame] | 1083 | public void onStatusHintsChanged(Conference conference, StatusHints statusHints) { |
| 1084 | String id = mIdByConference.get(conference); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1085 | if (id != null) { |
| 1086 | mAdapter.setStatusHints(id, statusHints); |
| 1087 | } |
Andrew Lee | edc625f | 2015-04-14 13:38:12 -0700 | [diff] [blame] | 1088 | } |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1089 | |
| 1090 | @Override |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1091 | public void onExtrasChanged(Conference c, Bundle extras) { |
| 1092 | String id = mIdByConference.get(c); |
| 1093 | if (id != null) { |
| 1094 | mAdapter.putExtras(id, extras); |
| 1095 | } |
| 1096 | } |
| 1097 | |
| 1098 | @Override |
| 1099 | public void onExtrasRemoved(Conference c, List<String> keys) { |
| 1100 | String id = mIdByConference.get(c); |
| 1101 | if (id != null) { |
| 1102 | mAdapter.removeExtras(id, keys); |
| 1103 | } |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1104 | } |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1105 | }; |
| 1106 | |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1107 | private final Connection.Listener mConnectionListener = new Connection.Listener() { |
| 1108 | @Override |
| 1109 | public void onStateChanged(Connection c, int state) { |
| 1110 | String id = mIdByConnection.get(c); |
Ihab Awad | 42b30e1 | 2014-05-22 09:49:34 -0700 | [diff] [blame] | 1111 | Log.d(this, "Adapter set state %s %s", id, Connection.stateToString(state)); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1112 | switch (state) { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1113 | case Connection.STATE_ACTIVE: |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1114 | mAdapter.setActive(id); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1115 | break; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1116 | case Connection.STATE_DIALING: |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1117 | mAdapter.setDialing(id); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1118 | break; |
Tyler Gunn | c96b5e0 | 2016-07-07 22:53:57 -0700 | [diff] [blame] | 1119 | case Connection.STATE_PULLING_CALL: |
| 1120 | mAdapter.setPulling(id); |
| 1121 | break; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1122 | case Connection.STATE_DISCONNECTED: |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1123 | // Handled in onDisconnected() |
| 1124 | break; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1125 | case Connection.STATE_HOLDING: |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1126 | mAdapter.setOnHold(id); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1127 | break; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1128 | case Connection.STATE_NEW: |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1129 | // Nothing to tell Telecom |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1130 | break; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1131 | case Connection.STATE_RINGING: |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1132 | mAdapter.setRinging(id); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1133 | break; |
| 1134 | } |
| 1135 | } |
| 1136 | |
| 1137 | @Override |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1138 | public void onDisconnected(Connection c, DisconnectCause disconnectCause) { |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1139 | String id = mIdByConnection.get(c); |
Andrew Lee | 2678639 | 2014-09-16 18:14:59 -0700 | [diff] [blame] | 1140 | Log.d(this, "Adapter set disconnected %s", disconnectCause); |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1141 | mAdapter.setDisconnected(id, disconnectCause); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1142 | } |
| 1143 | |
| 1144 | @Override |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1145 | public void onVideoStateChanged(Connection c, int videoState) { |
| 1146 | String id = mIdByConnection.get(c); |
| 1147 | Log.d(this, "Adapter set video state %d", videoState); |
| 1148 | mAdapter.setVideoState(id, videoState); |
| 1149 | } |
| 1150 | |
| 1151 | @Override |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1152 | public void onAddressChanged(Connection c, Uri address, int presentation) { |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1153 | String id = mIdByConnection.get(c); |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1154 | mAdapter.setAddress(id, address, presentation); |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1155 | } |
| 1156 | |
| 1157 | @Override |
| 1158 | public void onCallerDisplayNameChanged( |
| 1159 | Connection c, String callerDisplayName, int presentation) { |
| 1160 | String id = mIdByConnection.get(c); |
| 1161 | mAdapter.setCallerDisplayName(id, callerDisplayName, presentation); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1162 | } |
| 1163 | |
| 1164 | @Override |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1165 | public void onDestroyed(Connection c) { |
| 1166 | removeConnection(c); |
| 1167 | } |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 1168 | |
| 1169 | @Override |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1170 | public void onPostDialWait(Connection c, String remaining) { |
Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 1171 | String id = mIdByConnection.get(c); |
| 1172 | Log.d(this, "Adapter onPostDialWait %s, %s", c, remaining); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1173 | mAdapter.onPostDialWait(id, remaining); |
Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 1174 | } |
| 1175 | |
| 1176 | @Override |
Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 1177 | public void onPostDialChar(Connection c, char nextChar) { |
| 1178 | String id = mIdByConnection.get(c); |
| 1179 | Log.d(this, "Adapter onPostDialChar %s, %s", c, nextChar); |
| 1180 | mAdapter.onPostDialChar(id, nextChar); |
| 1181 | } |
| 1182 | |
| 1183 | @Override |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1184 | public void onRingbackRequested(Connection c, boolean ringback) { |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 1185 | String id = mIdByConnection.get(c); |
| 1186 | Log.d(this, "Adapter onRingback %b", ringback); |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1187 | mAdapter.setRingbackRequested(id, ringback); |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 1188 | } |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1189 | |
| 1190 | @Override |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1191 | public void onConnectionCapabilitiesChanged(Connection c, int capabilities) { |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1192 | String id = mIdByConnection.get(c); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1193 | Log.d(this, "capabilities: parcelableconnection: %s", |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1194 | Connection.capabilitiesToString(capabilities)); |
| 1195 | mAdapter.setConnectionCapabilities(id, capabilities); |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1196 | } |
| 1197 | |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1198 | @Override |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1199 | public void onConnectionPropertiesChanged(Connection c, int properties) { |
| 1200 | String id = mIdByConnection.get(c); |
| 1201 | Log.d(this, "properties: parcelableconnection: %s", |
| 1202 | Connection.propertiesToString(properties)); |
| 1203 | mAdapter.setConnectionProperties(id, properties); |
| 1204 | } |
| 1205 | |
| 1206 | @Override |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1207 | public void onVideoProviderChanged(Connection c, Connection.VideoProvider videoProvider) { |
Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 1208 | String id = mIdByConnection.get(c); |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1209 | Log.d(this, "onVideoProviderChanged: Connection: %s, VideoProvider: %s", c, |
| 1210 | videoProvider); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1211 | mAdapter.setVideoProvider(id, videoProvider); |
Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 1212 | } |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 1213 | |
| 1214 | @Override |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 1215 | public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) { |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 1216 | String id = mIdByConnection.get(c); |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1217 | mAdapter.setIsVoipAudioMode(id, isVoip); |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 1218 | } |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1219 | |
| 1220 | @Override |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 1221 | public void onStatusHintsChanged(Connection c, StatusHints statusHints) { |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1222 | String id = mIdByConnection.get(c); |
| 1223 | mAdapter.setStatusHints(id, statusHints); |
| 1224 | } |
Sailesh Nepal | 2ab88cc | 2014-07-18 14:49:18 -0700 | [diff] [blame] | 1225 | |
| 1226 | @Override |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1227 | public void onConferenceablesChanged( |
Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 1228 | Connection connection, List<Conferenceable> conferenceables) { |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 1229 | mAdapter.setConferenceableConnections( |
| 1230 | mIdByConnection.get(connection), |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1231 | createIdList(conferenceables)); |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1232 | } |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1233 | |
| 1234 | @Override |
| 1235 | public void onConferenceChanged(Connection connection, Conference conference) { |
| 1236 | String id = mIdByConnection.get(connection); |
| 1237 | if (id != null) { |
| 1238 | String conferenceId = null; |
| 1239 | if (conference != null) { |
| 1240 | conferenceId = mIdByConference.get(conference); |
| 1241 | } |
| 1242 | mAdapter.setIsConferenced(id, conferenceId); |
| 1243 | } |
| 1244 | } |
Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 1245 | |
| 1246 | @Override |
| 1247 | public void onConferenceMergeFailed(Connection connection) { |
| 1248 | String id = mIdByConnection.get(connection); |
| 1249 | if (id != null) { |
| 1250 | mAdapter.onConferenceMergeFailed(id); |
| 1251 | } |
| 1252 | } |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1253 | |
| 1254 | @Override |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1255 | public void onExtrasChanged(Connection c, Bundle extras) { |
| 1256 | String id = mIdByConnection.get(c); |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1257 | if (id != null) { |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1258 | mAdapter.putExtras(id, extras); |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1259 | } |
| 1260 | } |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 1261 | |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1262 | @Override |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1263 | public void onExtrasRemoved(Connection c, List<String> keys) { |
| 1264 | String id = mIdByConnection.get(c); |
| 1265 | if (id != null) { |
| 1266 | mAdapter.removeExtras(id, keys); |
| 1267 | } |
| 1268 | } |
| 1269 | |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 1270 | @Override |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1271 | public void onConnectionEvent(Connection connection, String event, Bundle extras) { |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 1272 | String id = mIdByConnection.get(connection); |
| 1273 | if (id != null) { |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1274 | mAdapter.onConnectionEvent(id, event, extras); |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 1275 | } |
| 1276 | } |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1277 | |
| 1278 | @Override |
| 1279 | public void onAudioRouteChanged(Connection c, int audioRoute) { |
| 1280 | String id = mIdByConnection.get(c); |
| 1281 | if (id != null) { |
| 1282 | mAdapter.setAudioRoute(id, audioRoute); |
| 1283 | } |
| 1284 | } |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1285 | |
| 1286 | @Override |
| 1287 | public void onRttInitiationSuccess(Connection c) { |
| 1288 | String id = mIdByConnection.get(c); |
| 1289 | if (id != null) { |
| 1290 | mAdapter.onRttInitiationSuccess(id); |
| 1291 | } |
| 1292 | } |
| 1293 | |
| 1294 | @Override |
| 1295 | public void onRttInitiationFailure(Connection c, int reason) { |
| 1296 | String id = mIdByConnection.get(c); |
| 1297 | if (id != null) { |
| 1298 | mAdapter.onRttInitiationFailure(id, reason); |
| 1299 | } |
| 1300 | } |
| 1301 | |
| 1302 | @Override |
| 1303 | public void onRttSessionRemotelyTerminated(Connection c) { |
| 1304 | String id = mIdByConnection.get(c); |
| 1305 | if (id != null) { |
| 1306 | mAdapter.onRttSessionRemotelyTerminated(id); |
| 1307 | } |
| 1308 | } |
| 1309 | |
| 1310 | @Override |
| 1311 | public void onRemoteRttRequest(Connection c) { |
| 1312 | String id = mIdByConnection.get(c); |
| 1313 | if (id != null) { |
| 1314 | mAdapter.onRemoteRttRequest(id); |
| 1315 | } |
| 1316 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1317 | }; |
| 1318 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1319 | /** {@inheritDoc} */ |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1320 | @Override |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1321 | public final IBinder onBind(Intent intent) { |
| 1322 | return mBinder; |
| 1323 | } |
| 1324 | |
Santos Cordon | 29f2f2e | 2014-09-11 19:50:24 -0700 | [diff] [blame] | 1325 | /** {@inheritDoc} */ |
| 1326 | @Override |
| 1327 | public boolean onUnbind(Intent intent) { |
| 1328 | endAllConnections(); |
| 1329 | return super.onUnbind(intent); |
| 1330 | } |
| 1331 | |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 1332 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1333 | * This can be used by telecom to either create a new outgoing call or attach to an existing |
| 1334 | * incoming call. In either case, telecom will cycle through a set of services and call |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 1335 | * createConnection util a connection service cancels the process or completes it successfully. |
| 1336 | */ |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1337 | private void createConnection( |
| 1338 | final PhoneAccountHandle callManagerAccount, |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1339 | final String callId, |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1340 | final ConnectionRequest request, |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 1341 | boolean isIncoming, |
| 1342 | boolean isUnknown) { |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1343 | Log.d(this, "createConnection, callManagerAccount: %s, callId: %s, request: %s, " + |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 1344 | "isIncoming: %b, isUnknown: %b", callManagerAccount, callId, request, |
| 1345 | isIncoming, |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 1346 | isUnknown); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1347 | |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 1348 | Connection connection = isUnknown ? onCreateUnknownConnection(callManagerAccount, request) |
| 1349 | : isIncoming ? onCreateIncomingConnection(callManagerAccount, request) |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1350 | : onCreateOutgoingConnection(callManagerAccount, request); |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1351 | Log.d(this, "createConnection, connection: %s", connection); |
| 1352 | if (connection == null) { |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1353 | connection = Connection.createFailedConnection( |
| 1354 | new DisconnectCause(DisconnectCause.ERROR)); |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 1355 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1356 | |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 1357 | connection.setTelecomCallId(callId); |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1358 | if (connection.getState() != Connection.STATE_DISCONNECTED) { |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1359 | addConnection(callId, connection); |
| 1360 | } |
| 1361 | |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1362 | Uri address = connection.getAddress(); |
| 1363 | String number = address == null ? "null" : address.getSchemeSpecificPart(); |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1364 | Log.v(this, "createConnection, number: %s, state: %s, capabilities: %s, properties: %s", |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1365 | Connection.toLogSafePhoneNumber(number), |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1366 | Connection.stateToString(connection.getState()), |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1367 | Connection.capabilitiesToString(connection.getConnectionCapabilities()), |
| 1368 | Connection.propertiesToString(connection.getConnectionProperties())); |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1369 | |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1370 | Log.d(this, "createConnection, calling handleCreateConnectionSuccessful %s", callId); |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1371 | mAdapter.handleCreateConnectionComplete( |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1372 | callId, |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1373 | request, |
| 1374 | new ParcelableConnection( |
| 1375 | request.getAccountHandle(), |
| 1376 | connection.getState(), |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1377 | connection.getConnectionCapabilities(), |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1378 | connection.getConnectionProperties(), |
Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 1379 | connection.getSupportedAudioRoutes(), |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1380 | connection.getAddress(), |
| 1381 | connection.getAddressPresentation(), |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1382 | connection.getCallerDisplayName(), |
| 1383 | connection.getCallerDisplayNamePresentation(), |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1384 | connection.getVideoProvider() == null ? |
| 1385 | null : connection.getVideoProvider().getInterface(), |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 1386 | connection.getVideoState(), |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1387 | connection.isRingbackRequested(), |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 1388 | connection.getAudioModeIsVoip(), |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 1389 | connection.getConnectTimeMillis(), |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1390 | connection.getStatusHints(), |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1391 | connection.getDisconnectCause(), |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1392 | createIdList(connection.getConferenceables()), |
| 1393 | connection.getExtras())); |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1394 | |
| 1395 | if (isIncoming && request.shouldShowIncomingCallUi() && |
| 1396 | (connection.getConnectionProperties() & Connection.PROPERTY_SELF_MANAGED) == |
| 1397 | Connection.PROPERTY_SELF_MANAGED) { |
| 1398 | // Tell ConnectionService to show its incoming call UX. |
| 1399 | connection.onShowIncomingCallUi(); |
| 1400 | } |
Shriram Ganesh | 6bf35ac | 2014-12-11 17:53:38 -0800 | [diff] [blame] | 1401 | if (isUnknown) { |
| 1402 | triggerConferenceRecalculate(); |
| 1403 | } |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1404 | } |
| 1405 | |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 1406 | private void createConnectionFailed(final PhoneAccountHandle callManagerAccount, |
| 1407 | final String callId, final ConnectionRequest request, |
| 1408 | boolean isIncoming) { |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 1409 | |
| 1410 | Log.i(this, "createConnectionFailed %s", callId); |
| 1411 | if (isIncoming) { |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 1412 | onCreateIncomingConnectionFailed(callManagerAccount, request); |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 1413 | } else { |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 1414 | onCreateOutgoingConnectionFailed(callManagerAccount, request); |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 1415 | } |
| 1416 | } |
| 1417 | |
Tyler Gunn | d104a4f | 2017-05-12 10:04:49 -0700 | [diff] [blame] | 1418 | /** |
| 1419 | * Called by Telecom when the creation of a new Connection has completed and it is now added |
| 1420 | * to Telecom. |
| 1421 | * @param callId The ID of the connection. |
| 1422 | */ |
| 1423 | private void notifyCreateConnectionComplete(final String callId) { |
| 1424 | Log.i(this, "notifyCreateConnectionComplete %s", callId); |
| 1425 | onCreateConnectionComplete(findConnectionForAction(callId, |
| 1426 | "notifyCreateConnectionComplete")); |
| 1427 | } |
| 1428 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1429 | private void abort(String callId) { |
Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 1430 | Log.d(this, "abort %s", callId); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1431 | findConnectionForAction(callId, "abort").onAbort(); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1432 | } |
| 1433 | |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 1434 | private void answerVideo(String callId, int videoState) { |
| 1435 | Log.d(this, "answerVideo %s", callId); |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 1436 | findConnectionForAction(callId, "answer").onAnswer(videoState); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1437 | } |
| 1438 | |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 1439 | private void answer(String callId) { |
| 1440 | Log.d(this, "answer %s", callId); |
| 1441 | findConnectionForAction(callId, "answer").onAnswer(); |
| 1442 | } |
| 1443 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1444 | private void reject(String callId) { |
Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 1445 | Log.d(this, "reject %s", callId); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1446 | findConnectionForAction(callId, "reject").onReject(); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1447 | } |
| 1448 | |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 1449 | private void reject(String callId, String rejectWithMessage) { |
| 1450 | Log.d(this, "reject %s with message", callId); |
| 1451 | findConnectionForAction(callId, "reject").onReject(rejectWithMessage); |
| 1452 | } |
| 1453 | |
Bryce Lee | cac5077 | 2015-11-17 15:13:29 -0800 | [diff] [blame] | 1454 | private void silence(String callId) { |
| 1455 | Log.d(this, "silence %s", callId); |
| 1456 | findConnectionForAction(callId, "silence").onSilence(); |
| 1457 | } |
| 1458 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1459 | private void disconnect(String callId) { |
Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 1460 | Log.d(this, "disconnect %s", callId); |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 1461 | if (mConnectionById.containsKey(callId)) { |
| 1462 | findConnectionForAction(callId, "disconnect").onDisconnect(); |
| 1463 | } else { |
| 1464 | findConferenceForAction(callId, "disconnect").onDisconnect(); |
| 1465 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1466 | } |
| 1467 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1468 | private void hold(String callId) { |
Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 1469 | Log.d(this, "hold %s", callId); |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 1470 | if (mConnectionById.containsKey(callId)) { |
| 1471 | findConnectionForAction(callId, "hold").onHold(); |
| 1472 | } else { |
| 1473 | findConferenceForAction(callId, "hold").onHold(); |
| 1474 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1475 | } |
| 1476 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1477 | private void unhold(String callId) { |
Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 1478 | Log.d(this, "unhold %s", callId); |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 1479 | if (mConnectionById.containsKey(callId)) { |
| 1480 | findConnectionForAction(callId, "unhold").onUnhold(); |
| 1481 | } else { |
| 1482 | findConferenceForAction(callId, "unhold").onUnhold(); |
| 1483 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1484 | } |
| 1485 | |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 1486 | private void onCallAudioStateChanged(String callId, CallAudioState callAudioState) { |
| 1487 | Log.d(this, "onAudioStateChanged %s %s", callId, callAudioState); |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 1488 | if (mConnectionById.containsKey(callId)) { |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 1489 | findConnectionForAction(callId, "onCallAudioStateChanged").setCallAudioState( |
| 1490 | callAudioState); |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 1491 | } else { |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 1492 | findConferenceForAction(callId, "onCallAudioStateChanged").setCallAudioState( |
| 1493 | callAudioState); |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 1494 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1495 | } |
| 1496 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1497 | private void playDtmfTone(String callId, char digit) { |
| 1498 | Log.d(this, "playDtmfTone %s %c", callId, digit); |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 1499 | if (mConnectionById.containsKey(callId)) { |
| 1500 | findConnectionForAction(callId, "playDtmfTone").onPlayDtmfTone(digit); |
| 1501 | } else { |
| 1502 | findConferenceForAction(callId, "playDtmfTone").onPlayDtmfTone(digit); |
| 1503 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1504 | } |
| 1505 | |
| 1506 | private void stopDtmfTone(String callId) { |
| 1507 | Log.d(this, "stopDtmfTone %s", callId); |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 1508 | if (mConnectionById.containsKey(callId)) { |
| 1509 | findConnectionForAction(callId, "stopDtmfTone").onStopDtmfTone(); |
| 1510 | } else { |
| 1511 | findConferenceForAction(callId, "stopDtmfTone").onStopDtmfTone(); |
| 1512 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1513 | } |
| 1514 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1515 | private void conference(String callId1, String callId2) { |
| 1516 | Log.d(this, "conference %s, %s", callId1, callId2); |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 1517 | |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1518 | // Attempt to get second connection or conference. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1519 | Connection connection2 = findConnectionForAction(callId2, "conference"); |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1520 | Conference conference2 = getNullConference(); |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1521 | if (connection2 == getNullConnection()) { |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1522 | conference2 = findConferenceForAction(callId2, "conference"); |
| 1523 | if (conference2 == getNullConference()) { |
| 1524 | Log.w(this, "Connection2 or Conference2 missing in conference request %s.", |
| 1525 | callId2); |
| 1526 | return; |
| 1527 | } |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1528 | } |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1529 | |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1530 | // Attempt to get first connection or conference and perform merge. |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 1531 | Connection connection1 = findConnectionForAction(callId1, "conference"); |
| 1532 | if (connection1 == getNullConnection()) { |
| 1533 | Conference conference1 = findConferenceForAction(callId1, "addConnection"); |
| 1534 | if (conference1 == getNullConference()) { |
| 1535 | Log.w(this, |
| 1536 | "Connection1 or Conference1 missing in conference request %s.", |
| 1537 | callId1); |
| 1538 | } else { |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1539 | // Call 1 is a conference. |
| 1540 | if (connection2 != getNullConnection()) { |
| 1541 | // Call 2 is a connection so merge via call 1 (conference). |
| 1542 | conference1.onMerge(connection2); |
| 1543 | } else { |
| 1544 | // Call 2 is ALSO a conference; this should never happen. |
| 1545 | Log.wtf(this, "There can only be one conference and an attempt was made to " + |
| 1546 | "merge two conferences."); |
| 1547 | return; |
| 1548 | } |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 1549 | } |
| 1550 | } else { |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1551 | // Call 1 is a connection. |
| 1552 | if (conference2 != getNullConference()) { |
| 1553 | // Call 2 is a conference, so merge via call 2. |
| 1554 | conference2.onMerge(connection1); |
| 1555 | } else { |
| 1556 | // Call 2 is a connection, so merge together. |
| 1557 | onConference(connection1, connection2); |
| 1558 | } |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 1559 | } |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 1560 | } |
| 1561 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1562 | private void splitFromConference(String callId) { |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1563 | Log.d(this, "splitFromConference(%s)", callId); |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 1564 | |
| 1565 | Connection connection = findConnectionForAction(callId, "splitFromConference"); |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1566 | if (connection == getNullConnection()) { |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 1567 | Log.w(this, "Connection missing in conference request %s.", callId); |
| 1568 | return; |
| 1569 | } |
| 1570 | |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 1571 | Conference conference = connection.getConference(); |
| 1572 | if (conference != null) { |
| 1573 | conference.onSeparate(connection); |
| 1574 | } |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 1575 | } |
| 1576 | |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 1577 | private void mergeConference(String callId) { |
| 1578 | Log.d(this, "mergeConference(%s)", callId); |
| 1579 | Conference conference = findConferenceForAction(callId, "mergeConference"); |
| 1580 | if (conference != null) { |
| 1581 | conference.onMerge(); |
| 1582 | } |
| 1583 | } |
| 1584 | |
| 1585 | private void swapConference(String callId) { |
| 1586 | Log.d(this, "swapConference(%s)", callId); |
| 1587 | Conference conference = findConferenceForAction(callId, "swapConference"); |
| 1588 | if (conference != null) { |
| 1589 | conference.onSwap(); |
| 1590 | } |
| 1591 | } |
| 1592 | |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1593 | /** |
| 1594 | * Notifies a {@link Connection} of a request to pull an external call. |
| 1595 | * |
| 1596 | * See {@link Call#pullExternalCall()}. |
| 1597 | * |
| 1598 | * @param callId The ID of the call to pull. |
| 1599 | */ |
| 1600 | private void pullExternalCall(String callId) { |
| 1601 | Log.d(this, "pullExternalCall(%s)", callId); |
| 1602 | Connection connection = findConnectionForAction(callId, "pullExternalCall"); |
| 1603 | if (connection != null) { |
| 1604 | connection.onPullExternalCall(); |
| 1605 | } |
| 1606 | } |
| 1607 | |
| 1608 | /** |
| 1609 | * Notifies a {@link Connection} of a call event. |
| 1610 | * |
| 1611 | * See {@link Call#sendCallEvent(String, Bundle)}. |
| 1612 | * |
| 1613 | * @param callId The ID of the call receiving the event. |
| 1614 | * @param event The event. |
| 1615 | * @param extras Extras associated with the event. |
| 1616 | */ |
| 1617 | private void sendCallEvent(String callId, String event, Bundle extras) { |
| 1618 | Log.d(this, "sendCallEvent(%s, %s)", callId, event); |
| 1619 | Connection connection = findConnectionForAction(callId, "sendCallEvent"); |
| 1620 | if (connection != null) { |
| 1621 | connection.onCallEvent(event, extras); |
| 1622 | } |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1623 | } |
| 1624 | |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1625 | /** |
| 1626 | * Notifies a {@link Connection} or {@link Conference} of a change to the extras from Telecom. |
| 1627 | * <p> |
| 1628 | * These extra changes can originate from Telecom itself, or from an {@link InCallService} via |
| 1629 | * the {@link android.telecom.Call#putExtra(String, boolean)}, |
| 1630 | * {@link android.telecom.Call#putExtra(String, int)}, |
| 1631 | * {@link android.telecom.Call#putExtra(String, String)}, |
| 1632 | * {@link Call#removeExtras(List)}. |
| 1633 | * |
| 1634 | * @param callId The ID of the call receiving the event. |
| 1635 | * @param extras The new extras bundle. |
| 1636 | */ |
| 1637 | private void handleExtrasChanged(String callId, Bundle extras) { |
| 1638 | Log.d(this, "handleExtrasChanged(%s, %s)", callId, extras); |
| 1639 | if (mConnectionById.containsKey(callId)) { |
| 1640 | findConnectionForAction(callId, "handleExtrasChanged").handleExtrasChanged(extras); |
| 1641 | } else if (mConferenceById.containsKey(callId)) { |
| 1642 | findConferenceForAction(callId, "handleExtrasChanged").handleExtrasChanged(extras); |
| 1643 | } |
| 1644 | } |
| 1645 | |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1646 | private void startRtt(String callId, Connection.RttTextStream rttTextStream) { |
| 1647 | Log.d(this, "startRtt(%s)", callId); |
| 1648 | if (mConnectionById.containsKey(callId)) { |
| 1649 | findConnectionForAction(callId, "startRtt").onStartRtt(rttTextStream); |
| 1650 | } else if (mConferenceById.containsKey(callId)) { |
| 1651 | Log.w(this, "startRtt called on a conference."); |
| 1652 | } |
| 1653 | } |
| 1654 | |
| 1655 | private void stopRtt(String callId) { |
| 1656 | Log.d(this, "stopRtt(%s)", callId); |
| 1657 | if (mConnectionById.containsKey(callId)) { |
| 1658 | findConnectionForAction(callId, "stopRtt").onStopRtt(); |
Hall Liu | ffa4a81 | 2017-03-02 16:11:00 -0800 | [diff] [blame] | 1659 | findConnectionForAction(callId, "stopRtt").unsetRttProperty(); |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1660 | } else if (mConferenceById.containsKey(callId)) { |
| 1661 | Log.w(this, "stopRtt called on a conference."); |
| 1662 | } |
| 1663 | } |
| 1664 | |
| 1665 | private void handleRttUpgradeResponse(String callId, Connection.RttTextStream rttTextStream) { |
| 1666 | Log.d(this, "handleRttUpgradeResponse(%s, %s)", callId, rttTextStream == null); |
| 1667 | if (mConnectionById.containsKey(callId)) { |
| 1668 | findConnectionForAction(callId, "handleRttUpgradeResponse") |
| 1669 | .handleRttUpgradeResponse(rttTextStream); |
| 1670 | } else if (mConferenceById.containsKey(callId)) { |
| 1671 | Log.w(this, "handleRttUpgradeResponse called on a conference."); |
| 1672 | } |
| 1673 | } |
| 1674 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1675 | private void onPostDialContinue(String callId, boolean proceed) { |
Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 1676 | Log.d(this, "onPostDialContinue(%s)", callId); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1677 | findConnectionForAction(callId, "stopDtmfTone").onPostDialContinue(proceed); |
Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 1678 | } |
| 1679 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1680 | private void onAdapterAttached() { |
Ihab Awad | 9c3f188 | 2014-06-30 21:17:13 -0700 | [diff] [blame] | 1681 | if (mAreAccountsInitialized) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1682 | // No need to query again if we already did it. |
| 1683 | return; |
| 1684 | } |
| 1685 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1686 | mAdapter.queryRemoteConnectionServices(new RemoteServiceCallback.Stub() { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1687 | @Override |
| 1688 | public void onResult( |
| 1689 | final List<ComponentName> componentNames, |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1690 | final List<IBinder> services) { |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 1691 | mHandler.post(new android.telecom.Logging.Runnable("oAA.qRCS.oR", null /*lock*/) { |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1692 | @Override |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 1693 | public void loggedRun() { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1694 | for (int i = 0; i < componentNames.size() && i < services.size(); i++) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1695 | mRemoteConnectionManager.addConnectionService( |
| 1696 | componentNames.get(i), |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1697 | IConnectionService.Stub.asInterface(services.get(i))); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1698 | } |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 1699 | onAccountsInitialized(); |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 1700 | Log.d(this, "remote connection services found: " + services); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1701 | } |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 1702 | }.prepare()); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1703 | } |
| 1704 | |
| 1705 | @Override |
| 1706 | public void onError() { |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 1707 | mHandler.post(new android.telecom.Logging.Runnable("oAA.qRCS.oE", null /*lock*/) { |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1708 | @Override |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 1709 | public void loggedRun() { |
Ihab Awad | 9c3f188 | 2014-06-30 21:17:13 -0700 | [diff] [blame] | 1710 | mAreAccountsInitialized = true; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1711 | } |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 1712 | }.prepare()); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1713 | } |
| 1714 | }); |
| 1715 | } |
| 1716 | |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1717 | /** |
| 1718 | * Ask some other {@code ConnectionService} to create a {@code RemoteConnection} given an |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 1719 | * incoming request. This is used by {@code ConnectionService}s that are registered with |
| 1720 | * {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER} and want to be able to manage |
| 1721 | * SIM-based incoming calls. |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1722 | * |
| 1723 | * @param connectionManagerPhoneAccount See description at |
| 1724 | * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}. |
| 1725 | * @param request Details about the incoming call. |
| 1726 | * @return The {@code Connection} object to satisfy this call, or {@code null} to |
| 1727 | * not handle the call. |
| 1728 | */ |
| 1729 | public final RemoteConnection createRemoteIncomingConnection( |
| 1730 | PhoneAccountHandle connectionManagerPhoneAccount, |
| 1731 | ConnectionRequest request) { |
| 1732 | return mRemoteConnectionManager.createRemoteConnection( |
| 1733 | connectionManagerPhoneAccount, request, true); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1734 | } |
| 1735 | |
| 1736 | /** |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1737 | * Ask some other {@code ConnectionService} to create a {@code RemoteConnection} given an |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 1738 | * outgoing request. This is used by {@code ConnectionService}s that are registered with |
| 1739 | * {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER} and want to be able to use the |
| 1740 | * SIM-based {@code ConnectionService} to place its outgoing calls. |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1741 | * |
| 1742 | * @param connectionManagerPhoneAccount See description at |
| 1743 | * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}. |
Cuihtlauac ALVARADO | 0b3b2a5 | 2016-09-13 14:49:41 +0200 | [diff] [blame] | 1744 | * @param request Details about the outgoing call. |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1745 | * @return The {@code Connection} object to satisfy this call, or {@code null} to |
| 1746 | * not handle the call. |
| 1747 | */ |
| 1748 | public final RemoteConnection createRemoteOutgoingConnection( |
| 1749 | PhoneAccountHandle connectionManagerPhoneAccount, |
| 1750 | ConnectionRequest request) { |
| 1751 | return mRemoteConnectionManager.createRemoteConnection( |
| 1752 | connectionManagerPhoneAccount, request, false); |
| 1753 | } |
| 1754 | |
| 1755 | /** |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 1756 | * Indicates to the relevant {@code RemoteConnectionService} that the specified |
| 1757 | * {@link RemoteConnection}s should be merged into a conference call. |
| 1758 | * <p> |
| 1759 | * If the conference request is successful, the method {@link #onRemoteConferenceAdded} will |
| 1760 | * be invoked. |
| 1761 | * |
| 1762 | * @param remoteConnection1 The first of the remote connections to conference. |
| 1763 | * @param remoteConnection2 The second of the remote connections to conference. |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 1764 | */ |
| 1765 | public final void conferenceRemoteConnections( |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 1766 | RemoteConnection remoteConnection1, |
| 1767 | RemoteConnection remoteConnection2) { |
| 1768 | mRemoteConnectionManager.conferenceRemoteConnections(remoteConnection1, remoteConnection2); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 1769 | } |
| 1770 | |
| 1771 | /** |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1772 | * Adds a new conference call. When a conference call is created either as a result of an |
| 1773 | * explicit request via {@link #onConference} or otherwise, the connection service should supply |
| 1774 | * an instance of {@link Conference} by invoking this method. A conference call provided by this |
| 1775 | * method will persist until {@link Conference#destroy} is invoked on the conference instance. |
| 1776 | * |
| 1777 | * @param conference The new conference object. |
| 1778 | */ |
| 1779 | public final void addConference(Conference conference) { |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1780 | Log.d(this, "addConference: conference=%s", conference); |
| 1781 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1782 | String id = addConferenceInternal(conference); |
| 1783 | if (id != null) { |
| 1784 | List<String> connectionIds = new ArrayList<>(2); |
| 1785 | for (Connection connection : conference.getConnections()) { |
| 1786 | if (mIdByConnection.containsKey(connection)) { |
| 1787 | connectionIds.add(mIdByConnection.get(connection)); |
| 1788 | } |
| 1789 | } |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 1790 | conference.setTelecomCallId(id); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1791 | ParcelableConference parcelableConference = new ParcelableConference( |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 1792 | conference.getPhoneAccountHandle(), |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1793 | conference.getState(), |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1794 | conference.getConnectionCapabilities(), |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1795 | conference.getConnectionProperties(), |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 1796 | connectionIds, |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1797 | conference.getVideoProvider() == null ? |
| 1798 | null : conference.getVideoProvider().getInterface(), |
| 1799 | conference.getVideoState(), |
Andrew Lee | 3e3e2f2 | 2015-04-16 13:48:43 -0700 | [diff] [blame] | 1800 | conference.getConnectTimeMillis(), |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1801 | conference.getStatusHints(), |
| 1802 | conference.getExtras()); |
Andrew Lee | 0f51da3 | 2015-04-16 13:11:55 -0700 | [diff] [blame] | 1803 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1804 | mAdapter.addConferenceCall(id, parcelableConference); |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1805 | mAdapter.setVideoProvider(id, conference.getVideoProvider()); |
| 1806 | mAdapter.setVideoState(id, conference.getVideoState()); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1807 | |
| 1808 | // Go through any child calls and set the parent. |
| 1809 | for (Connection connection : conference.getConnections()) { |
| 1810 | String connectionId = mIdByConnection.get(connection); |
| 1811 | if (connectionId != null) { |
| 1812 | mAdapter.setIsConferenced(connectionId, id); |
| 1813 | } |
| 1814 | } |
| 1815 | } |
| 1816 | } |
| 1817 | |
| 1818 | /** |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 1819 | * Adds a connection created by the {@link ConnectionService} and informs telecom of the new |
| 1820 | * connection. |
| 1821 | * |
| 1822 | * @param phoneAccountHandle The phone account handle for the connection. |
| 1823 | * @param connection The connection to add. |
| 1824 | */ |
| 1825 | public final void addExistingConnection(PhoneAccountHandle phoneAccountHandle, |
| 1826 | Connection connection) { |
Tyler Gunn | 78da781 | 2017-05-09 14:34:57 -0700 | [diff] [blame] | 1827 | addExistingConnection(phoneAccountHandle, connection, null /* conference */); |
| 1828 | } |
| 1829 | |
| 1830 | /** |
| 1831 | * Adds a connection created by the {@link ConnectionService} and informs telecom of the new |
| 1832 | * connection. |
| 1833 | * |
| 1834 | * @param phoneAccountHandle The phone account handle for the connection. |
| 1835 | * @param connection The connection to add. |
| 1836 | * @param conference The parent conference of the new connection. |
| 1837 | * @hide |
| 1838 | */ |
| 1839 | public final void addExistingConnection(PhoneAccountHandle phoneAccountHandle, |
| 1840 | Connection connection, Conference conference) { |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 1841 | |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 1842 | String id = addExistingConnectionInternal(phoneAccountHandle, connection); |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 1843 | if (id != null) { |
| 1844 | List<String> emptyList = new ArrayList<>(0); |
Tyler Gunn | 78da781 | 2017-05-09 14:34:57 -0700 | [diff] [blame] | 1845 | String conferenceId = null; |
| 1846 | if (conference != null) { |
| 1847 | conferenceId = mIdByConference.get(conference); |
| 1848 | } |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 1849 | |
| 1850 | ParcelableConnection parcelableConnection = new ParcelableConnection( |
| 1851 | phoneAccountHandle, |
| 1852 | connection.getState(), |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1853 | connection.getConnectionCapabilities(), |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1854 | connection.getConnectionProperties(), |
Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 1855 | connection.getSupportedAudioRoutes(), |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 1856 | connection.getAddress(), |
| 1857 | connection.getAddressPresentation(), |
| 1858 | connection.getCallerDisplayName(), |
| 1859 | connection.getCallerDisplayNamePresentation(), |
| 1860 | connection.getVideoProvider() == null ? |
| 1861 | null : connection.getVideoProvider().getInterface(), |
| 1862 | connection.getVideoState(), |
| 1863 | connection.isRingbackRequested(), |
| 1864 | connection.getAudioModeIsVoip(), |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 1865 | connection.getConnectTimeMillis(), |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 1866 | connection.getStatusHints(), |
| 1867 | connection.getDisconnectCause(), |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1868 | emptyList, |
Tyler Gunn | 78da781 | 2017-05-09 14:34:57 -0700 | [diff] [blame] | 1869 | connection.getExtras(), |
| 1870 | conferenceId); |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 1871 | mAdapter.addExistingConnection(id, parcelableConnection); |
| 1872 | } |
| 1873 | } |
| 1874 | |
| 1875 | /** |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1876 | * Returns all the active {@code Connection}s for which this {@code ConnectionService} |
| 1877 | * has taken responsibility. |
| 1878 | * |
| 1879 | * @return A collection of {@code Connection}s created by this {@code ConnectionService}. |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1880 | */ |
Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 1881 | public final Collection<Connection> getAllConnections() { |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1882 | return mConnectionById.values(); |
| 1883 | } |
| 1884 | |
| 1885 | /** |
Santos Cordon | a6018b9 | 2016-02-16 14:23:12 -0800 | [diff] [blame] | 1886 | * Returns all the active {@code Conference}s for which this {@code ConnectionService} |
| 1887 | * has taken responsibility. |
| 1888 | * |
| 1889 | * @return A collection of {@code Conference}s created by this {@code ConnectionService}. |
| 1890 | */ |
| 1891 | public final Collection<Conference> getAllConferences() { |
| 1892 | return mConferenceById.values(); |
| 1893 | } |
| 1894 | |
| 1895 | /** |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1896 | * Create a {@code Connection} given an incoming request. This is used to attach to existing |
| 1897 | * incoming calls. |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1898 | * |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1899 | * @param connectionManagerPhoneAccount See description at |
| 1900 | * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}. |
| 1901 | * @param request Details about the incoming call. |
| 1902 | * @return The {@code Connection} object to satisfy this call, or {@code null} to |
| 1903 | * not handle the call. |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1904 | */ |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1905 | public Connection onCreateIncomingConnection( |
| 1906 | PhoneAccountHandle connectionManagerPhoneAccount, |
| 1907 | ConnectionRequest request) { |
| 1908 | return null; |
| 1909 | } |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 1910 | |
| 1911 | /** |
Tyler Gunn | d104a4f | 2017-05-12 10:04:49 -0700 | [diff] [blame] | 1912 | * Called after the {@link Connection} returned by |
| 1913 | * {@link #onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)} |
| 1914 | * or {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)} has been |
| 1915 | * added to the {@link ConnectionService} and sent to Telecom. |
| 1916 | * |
| 1917 | * @param connection the {@link Connection}. |
| 1918 | * @hide |
| 1919 | */ |
| 1920 | public void onCreateConnectionComplete(Connection connection) { |
| 1921 | } |
| 1922 | |
| 1923 | /** |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1924 | * Called by Telecom to inform the {@link ConnectionService} that its request to create a new |
| 1925 | * incoming {@link Connection} was denied. |
| 1926 | * <p> |
| 1927 | * Used when a self-managed {@link ConnectionService} attempts to create a new incoming |
| 1928 | * {@link Connection}, but Telecom has determined that the call cannot be allowed at this time. |
| 1929 | * The {@link ConnectionService} is responsible for silently rejecting the new incoming |
| 1930 | * {@link Connection}. |
| 1931 | * <p> |
| 1932 | * See {@link TelecomManager#isIncomingCallPermitted(PhoneAccountHandle)} for more information. |
| 1933 | * |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 1934 | * @param connectionManagerPhoneAccount See description at |
| 1935 | * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}. |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1936 | * @param request The incoming connection request. |
| 1937 | */ |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 1938 | public void onCreateIncomingConnectionFailed(PhoneAccountHandle connectionManagerPhoneAccount, |
| 1939 | ConnectionRequest request) { |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1940 | } |
| 1941 | |
| 1942 | /** |
| 1943 | * Called by Telecom to inform the {@link ConnectionService} that its request to create a new |
| 1944 | * outgoing {@link Connection} was denied. |
| 1945 | * <p> |
| 1946 | * Used when a self-managed {@link ConnectionService} attempts to create a new outgoing |
| 1947 | * {@link Connection}, but Telecom has determined that the call cannot be placed at this time. |
| 1948 | * The {@link ConnectionService} is responisible for informing the user that the |
| 1949 | * {@link Connection} cannot be made at this time. |
| 1950 | * <p> |
| 1951 | * See {@link TelecomManager#isOutgoingCallPermitted(PhoneAccountHandle)} for more information. |
| 1952 | * |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 1953 | * @param connectionManagerPhoneAccount See description at |
| 1954 | * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}. |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1955 | * @param request The outgoing connection request. |
| 1956 | */ |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 1957 | public void onCreateOutgoingConnectionFailed(PhoneAccountHandle connectionManagerPhoneAccount, |
| 1958 | ConnectionRequest request) { |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1959 | } |
| 1960 | |
| 1961 | /** |
Shriram Ganesh | 6bf35ac | 2014-12-11 17:53:38 -0800 | [diff] [blame] | 1962 | * Trigger recalculate functinality for conference calls. This is used when a Telephony |
| 1963 | * Connection is part of a conference controller but is not yet added to Connection |
| 1964 | * Service and hence cannot be added to the conference call. |
| 1965 | * |
| 1966 | * @hide |
| 1967 | */ |
| 1968 | public void triggerConferenceRecalculate() { |
| 1969 | } |
| 1970 | |
| 1971 | /** |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1972 | * Create a {@code Connection} given an outgoing request. This is used to initiate new |
| 1973 | * outgoing calls. |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 1974 | * |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1975 | * @param connectionManagerPhoneAccount The connection manager account to use for managing |
| 1976 | * this call. |
| 1977 | * <p> |
| 1978 | * If this parameter is not {@code null}, it means that this {@code ConnectionService} |
| 1979 | * has registered one or more {@code PhoneAccount}s having |
| 1980 | * {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER}. This parameter will contain |
| 1981 | * one of these {@code PhoneAccount}s, while the {@code request} will contain another |
| 1982 | * (usually but not always distinct) {@code PhoneAccount} to be used for actually |
| 1983 | * making the connection. |
| 1984 | * <p> |
| 1985 | * If this parameter is {@code null}, it means that this {@code ConnectionService} is |
| 1986 | * being asked to make a direct connection. The |
| 1987 | * {@link ConnectionRequest#getAccountHandle()} of parameter {@code request} will be |
| 1988 | * a {@code PhoneAccount} registered by this {@code ConnectionService} to use for |
| 1989 | * making the connection. |
| 1990 | * @param request Details about the outgoing call. |
| 1991 | * @return The {@code Connection} object to satisfy this call, or the result of an invocation |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1992 | * of {@link Connection#createFailedConnection(DisconnectCause)} to not handle the call. |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 1993 | */ |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1994 | public Connection onCreateOutgoingConnection( |
| 1995 | PhoneAccountHandle connectionManagerPhoneAccount, |
| 1996 | ConnectionRequest request) { |
| 1997 | return null; |
| 1998 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1999 | |
| 2000 | /** |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 2001 | * Create a {@code Connection} for a new unknown call. An unknown call is a call originating |
| 2002 | * from the ConnectionService that was neither a user-initiated outgoing call, nor an incoming |
| 2003 | * call created using |
| 2004 | * {@code TelecomManager#addNewIncomingCall(PhoneAccountHandle, android.os.Bundle)}. |
| 2005 | * |
Yorke Lee | 770ed6e | 2014-10-06 18:58:52 -0700 | [diff] [blame] | 2006 | * @hide |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 2007 | */ |
| 2008 | public Connection onCreateUnknownConnection(PhoneAccountHandle connectionManagerPhoneAccount, |
| 2009 | ConnectionRequest request) { |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 2010 | return null; |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 2011 | } |
| 2012 | |
| 2013 | /** |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2014 | * Conference two specified connections. Invoked when the user has made a request to merge the |
| 2015 | * specified connections into a conference call. In response, the connection service should |
| 2016 | * create an instance of {@link Conference} and pass it into {@link #addConference}. |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 2017 | * |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2018 | * @param connection1 A connection to merge into a conference call. |
| 2019 | * @param connection2 A connection to merge into a conference call. |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 2020 | */ |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2021 | public void onConference(Connection connection1, Connection connection2) {} |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 2022 | |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 2023 | /** |
| 2024 | * Indicates that a remote conference has been created for existing {@link RemoteConnection}s. |
| 2025 | * When this method is invoked, this {@link ConnectionService} should create its own |
| 2026 | * representation of the conference call and send it to telecom using {@link #addConference}. |
| 2027 | * <p> |
| 2028 | * This is only relevant to {@link ConnectionService}s which are registered with |
| 2029 | * {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER}. |
| 2030 | * |
| 2031 | * @param conference The remote conference call. |
| 2032 | */ |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 2033 | public void onRemoteConferenceAdded(RemoteConference conference) {} |
| 2034 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2035 | /** |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 2036 | * Called when an existing connection is added remotely. |
| 2037 | * @param connection The existing connection which was added. |
| 2038 | */ |
| 2039 | public void onRemoteExistingConnectionAdded(RemoteConnection connection) {} |
| 2040 | |
| 2041 | /** |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2042 | * @hide |
| 2043 | */ |
| 2044 | public boolean containsConference(Conference conference) { |
| 2045 | return mIdByConference.containsKey(conference); |
| 2046 | } |
| 2047 | |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 2048 | /** {@hide} */ |
| 2049 | void addRemoteConference(RemoteConference remoteConference) { |
| 2050 | onRemoteConferenceAdded(remoteConference); |
| 2051 | } |
| 2052 | |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 2053 | /** {@hide} */ |
| 2054 | void addRemoteExistingConnection(RemoteConnection remoteConnection) { |
| 2055 | onRemoteExistingConnectionAdded(remoteConnection); |
| 2056 | } |
| 2057 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 2058 | private void onAccountsInitialized() { |
| 2059 | mAreAccountsInitialized = true; |
| 2060 | for (Runnable r : mPreInitializationConnectionRequests) { |
| 2061 | r.run(); |
| 2062 | } |
| 2063 | mPreInitializationConnectionRequests.clear(); |
| 2064 | } |
| 2065 | |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 2066 | /** |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2067 | * Adds an existing connection to the list of connections, identified by a new call ID unique |
| 2068 | * to this connection service. |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 2069 | * |
| 2070 | * @param connection The connection. |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2071 | * @return The ID of the connection (e.g. the call-id). |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 2072 | */ |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2073 | private String addExistingConnectionInternal(PhoneAccountHandle handle, Connection connection) { |
| 2074 | String id; |
Tyler Gunn | cd6ccfd | 2016-10-17 15:48:19 -0700 | [diff] [blame] | 2075 | |
| 2076 | if (connection.getExtras() != null && connection.getExtras() |
| 2077 | .containsKey(Connection.EXTRA_ORIGINAL_CONNECTION_ID)) { |
| 2078 | id = connection.getExtras().getString(Connection.EXTRA_ORIGINAL_CONNECTION_ID); |
| 2079 | Log.d(this, "addExistingConnectionInternal - conn %s reusing original id %s", |
| 2080 | connection.getTelecomCallId(), id); |
| 2081 | } else if (handle == null) { |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2082 | // If no phone account handle was provided, we cannot be sure the call ID is unique, |
| 2083 | // so just use a random UUID. |
| 2084 | id = UUID.randomUUID().toString(); |
| 2085 | } else { |
| 2086 | // Phone account handle was provided, so use the ConnectionService class name as a |
| 2087 | // prefix for a unique incremental call ID. |
| 2088 | id = handle.getComponentName().getClassName() + "@" + getNextCallId(); |
| 2089 | } |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 2090 | addConnection(id, connection); |
| 2091 | return id; |
| 2092 | } |
| 2093 | |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2094 | private void addConnection(String callId, Connection connection) { |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2095 | connection.setTelecomCallId(callId); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2096 | mConnectionById.put(callId, connection); |
| 2097 | mIdByConnection.put(connection, callId); |
| 2098 | connection.addConnectionListener(mConnectionListener); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2099 | connection.setConnectionService(this); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2100 | } |
| 2101 | |
Anthony Lee | 30e6584 | 2014-11-06 16:30:53 -0800 | [diff] [blame] | 2102 | /** {@hide} */ |
| 2103 | protected void removeConnection(Connection connection) { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2104 | connection.unsetConnectionService(this); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2105 | connection.removeConnectionListener(mConnectionListener); |
Chenjie Luo | e370b53 | 2016-05-12 16:59:43 -0700 | [diff] [blame] | 2106 | String id = mIdByConnection.get(connection); |
| 2107 | if (id != null) { |
| 2108 | mConnectionById.remove(id); |
| 2109 | mIdByConnection.remove(connection); |
| 2110 | mAdapter.removeCall(id); |
| 2111 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2112 | } |
| 2113 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2114 | private String addConferenceInternal(Conference conference) { |
Tyler Gunn | cd6ccfd | 2016-10-17 15:48:19 -0700 | [diff] [blame] | 2115 | String originalId = null; |
| 2116 | if (conference.getExtras() != null && conference.getExtras() |
| 2117 | .containsKey(Connection.EXTRA_ORIGINAL_CONNECTION_ID)) { |
| 2118 | originalId = conference.getExtras().getString(Connection.EXTRA_ORIGINAL_CONNECTION_ID); |
| 2119 | Log.d(this, "addConferenceInternal: conf %s reusing original id %s", |
| 2120 | conference.getTelecomCallId(), |
| 2121 | originalId); |
| 2122 | } |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2123 | if (mIdByConference.containsKey(conference)) { |
| 2124 | Log.w(this, "Re-adding an existing conference: %s.", conference); |
| 2125 | } else if (conference != null) { |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2126 | // Conferences do not (yet) have a PhoneAccountHandle associated with them, so we |
| 2127 | // cannot determine a ConnectionService class name to associate with the ID, so use |
| 2128 | // a unique UUID (for now). |
Tyler Gunn | cd6ccfd | 2016-10-17 15:48:19 -0700 | [diff] [blame] | 2129 | String id = originalId == null ? UUID.randomUUID().toString() : originalId; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2130 | mConferenceById.put(id, conference); |
| 2131 | mIdByConference.put(conference, id); |
| 2132 | conference.addListener(mConferenceListener); |
| 2133 | return id; |
| 2134 | } |
| 2135 | |
| 2136 | return null; |
| 2137 | } |
| 2138 | |
| 2139 | private void removeConference(Conference conference) { |
| 2140 | if (mIdByConference.containsKey(conference)) { |
| 2141 | conference.removeListener(mConferenceListener); |
| 2142 | |
| 2143 | String id = mIdByConference.get(conference); |
| 2144 | mConferenceById.remove(id); |
| 2145 | mIdByConference.remove(conference); |
| 2146 | mAdapter.removeCall(id); |
| 2147 | } |
| 2148 | } |
| 2149 | |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2150 | private Connection findConnectionForAction(String callId, String action) { |
| 2151 | if (mConnectionById.containsKey(callId)) { |
| 2152 | return mConnectionById.get(callId); |
| 2153 | } |
Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 2154 | Log.w(this, "%s - Cannot find Connection %s", action, callId); |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 2155 | return getNullConnection(); |
| 2156 | } |
| 2157 | |
| 2158 | static synchronized Connection getNullConnection() { |
| 2159 | if (sNullConnection == null) { |
| 2160 | sNullConnection = new Connection() {}; |
| 2161 | } |
| 2162 | return sNullConnection; |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2163 | } |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 2164 | |
| 2165 | private Conference findConferenceForAction(String conferenceId, String action) { |
| 2166 | if (mConferenceById.containsKey(conferenceId)) { |
| 2167 | return mConferenceById.get(conferenceId); |
| 2168 | } |
| 2169 | Log.w(this, "%s - Cannot find conference %s", action, conferenceId); |
| 2170 | return getNullConference(); |
| 2171 | } |
| 2172 | |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 2173 | private List<String> createConnectionIdList(List<Connection> connections) { |
| 2174 | List<String> ids = new ArrayList<>(); |
| 2175 | for (Connection c : connections) { |
| 2176 | if (mIdByConnection.containsKey(c)) { |
| 2177 | ids.add(mIdByConnection.get(c)); |
| 2178 | } |
| 2179 | } |
| 2180 | Collections.sort(ids); |
| 2181 | return ids; |
| 2182 | } |
| 2183 | |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2184 | /** |
| 2185 | * Builds a list of {@link Connection} and {@link Conference} IDs based on the list of |
Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 2186 | * {@link Conferenceable}s passed in. |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2187 | * |
Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 2188 | * @param conferenceables The {@link Conferenceable} connections and conferences. |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2189 | * @return List of string conference and call Ids. |
| 2190 | */ |
Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 2191 | private List<String> createIdList(List<Conferenceable> conferenceables) { |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2192 | List<String> ids = new ArrayList<>(); |
Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 2193 | for (Conferenceable c : conferenceables) { |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2194 | // Only allow Connection and Conference conferenceables. |
| 2195 | if (c instanceof Connection) { |
| 2196 | Connection connection = (Connection) c; |
| 2197 | if (mIdByConnection.containsKey(connection)) { |
| 2198 | ids.add(mIdByConnection.get(connection)); |
| 2199 | } |
| 2200 | } else if (c instanceof Conference) { |
| 2201 | Conference conference = (Conference) c; |
| 2202 | if (mIdByConference.containsKey(conference)) { |
| 2203 | ids.add(mIdByConference.get(conference)); |
| 2204 | } |
| 2205 | } |
| 2206 | } |
| 2207 | Collections.sort(ids); |
| 2208 | return ids; |
| 2209 | } |
| 2210 | |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 2211 | private Conference getNullConference() { |
| 2212 | if (sNullConference == null) { |
| 2213 | sNullConference = new Conference(null) {}; |
| 2214 | } |
| 2215 | return sNullConference; |
| 2216 | } |
Santos Cordon | 29f2f2e | 2014-09-11 19:50:24 -0700 | [diff] [blame] | 2217 | |
| 2218 | private void endAllConnections() { |
| 2219 | // Unbound from telecomm. We should end all connections and conferences. |
| 2220 | for (Connection connection : mIdByConnection.keySet()) { |
| 2221 | // only operate on top-level calls. Conference calls will be removed on their own. |
| 2222 | if (connection.getConference() == null) { |
| 2223 | connection.onDisconnect(); |
| 2224 | } |
| 2225 | } |
| 2226 | for (Conference conference : mIdByConference.keySet()) { |
| 2227 | conference.onDisconnect(); |
| 2228 | } |
| 2229 | } |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2230 | |
| 2231 | /** |
| 2232 | * Retrieves the next call ID as maintainted by the connection service. |
| 2233 | * |
| 2234 | * @return The call ID. |
| 2235 | */ |
| 2236 | private int getNextCallId() { |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 2237 | synchronized (mIdSyncRoot) { |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2238 | return ++mId; |
| 2239 | } |
| 2240 | } |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 2241 | } |