blob: c5fc4365df7abe8f17d887937f5f66ad7a6fcfce [file] [log] [blame]
Ihab Awad542e0ea2014-05-16 10:22:16 -07001/*
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 Gunnef9f6f92014-09-12 22:16:17 -070017package android.telecom;
Ihab Awad542e0ea2014-05-16 10:22:16 -070018
Tyler Gunn5567d742019-10-31 13:04:37 -070019import android.annotation.NonNull;
20import android.annotation.Nullable;
Santos Cordon5c6fa952014-07-20 17:47:12 -070021import android.annotation.SdkConstant;
Tyler Gunn5567d742019-10-31 13:04:37 -070022import android.annotation.SystemApi;
Hall Liueb7c9ea2021-03-09 20:24:50 -080023import android.annotation.TestApi;
Sailesh Nepal2a46b902014-07-04 17:21:07 -070024import android.app.Service;
Santos Cordon52d8a152014-06-17 19:08:45 -070025import android.content.ComponentName;
Santos Cordon5c6fa952014-07-20 17:47:12 -070026import android.content.Intent;
Ihab Awad542e0ea2014-05-16 10:22:16 -070027import android.net.Uri;
Santos Cordon6b7f9552015-05-27 17:21:45 -070028import android.os.Bundle;
Santos Cordon52d8a152014-06-17 19:08:45 -070029import android.os.Handler;
30import android.os.IBinder;
31import android.os.Looper;
Sailesh Nepal2a46b902014-07-04 17:21:07 -070032import android.os.Message;
Hall Liub64ac4c2017-02-06 10:49:48 -080033import android.os.ParcelFileDescriptor;
34import android.os.RemoteException;
Brad Ebingerb32d4f82016-10-24 16:40:49 -070035import android.telecom.Logging.Session;
Andrew Lee14185762014-07-25 09:41:56 -070036
Brad Ebinger99f17ce2019-09-11 18:06:51 -070037import com.android.internal.annotations.VisibleForTesting;
Sailesh Nepal2a46b902014-07-04 17:21:07 -070038import com.android.internal.os.SomeArgs;
Tyler Gunnef9f6f92014-09-12 22:16:17 -070039import com.android.internal.telecom.IConnectionService;
40import com.android.internal.telecom.IConnectionServiceAdapter;
41import com.android.internal.telecom.RemoteServiceCallback;
Santos Cordon52d8a152014-06-17 19:08:45 -070042
Ihab Awad5d0410f2014-07-30 10:07:40 -070043import java.util.ArrayList;
Santos Cordonb6939982014-06-04 20:20:58 -070044import java.util.Collection;
Santos Cordon7c7bc7f2014-07-28 18:15:48 -070045import java.util.Collections;
Santos Cordon52d8a152014-06-17 19:08:45 -070046import java.util.List;
Ihab Awad542e0ea2014-05-16 10:22:16 -070047import java.util.Map;
Santos Cordon823fd3c2014-08-07 18:35:18 -070048import java.util.UUID;
mike dooley95e80702014-09-18 14:07:52 -070049import java.util.concurrent.ConcurrentHashMap;
Ihab Awad542e0ea2014-05-16 10:22:16 -070050
51/**
Tyler Gunnf5035432017-01-09 09:43:12 -080052 * An abstract service that should be implemented by any apps which either:
53 * <ol>
54 * <li>Can make phone calls (VoIP or otherwise) and want those calls to be integrated into the
55 * built-in phone app. Referred to as a <b>system managed</b> {@link ConnectionService}.</li>
56 * <li>Are a standalone calling app and don't want their calls to be integrated into the
57 * built-in phone app. Referred to as a <b>self managed</b> {@link ConnectionService}.</li>
58 * </ol>
59 * Once implemented, the {@link ConnectionService} needs to take the following steps so that Telecom
60 * will bind to it:
Santos Cordona663f862014-10-29 13:49:58 -070061 * <p>
62 * 1. <i>Registration in AndroidManifest.xml</i>
63 * <br/>
64 * <pre>
65 * &lt;service android:name="com.example.package.MyConnectionService"
66 * android:label="@string/some_label_for_my_connection_service"
Yorke Lee249c12e2015-05-13 15:59:29 -070067 * android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"&gt;
Santos Cordona663f862014-10-29 13:49:58 -070068 * &lt;intent-filter&gt;
69 * &lt;action android:name="android.telecom.ConnectionService" /&gt;
70 * &lt;/intent-filter&gt;
71 * &lt;/service&gt;
72 * </pre>
73 * <p>
74 * 2. <i> Registration of {@link PhoneAccount} with {@link TelecomManager}.</i>
75 * <br/>
76 * See {@link PhoneAccount} and {@link TelecomManager#registerPhoneAccount} for more information.
77 * <p>
Tyler Gunnf5035432017-01-09 09:43:12 -080078 * System managed {@link ConnectionService}s must be enabled by the user in the phone app settings
kopriva82c591b2018-10-08 15:57:00 -070079 * before Telecom will bind to them. Self-managed {@link ConnectionService}s must be granted the
Tyler Gunnf5035432017-01-09 09:43:12 -080080 * appropriate permission before Telecom will bind to them.
81 * <p>
82 * Once registered and enabled by the user in the phone app settings or granted permission, telecom
83 * will bind to a {@link ConnectionService} implementation when it wants that
84 * {@link ConnectionService} to place a call or the service has indicated that is has an incoming
85 * call through {@link TelecomManager#addNewIncomingCall}. The {@link ConnectionService} can then
86 * expect a call to {@link #onCreateIncomingConnection} or {@link #onCreateOutgoingConnection}
87 * wherein it should provide a new instance of a {@link Connection} object. It is through this
88 * {@link Connection} object that telecom receives state updates and the {@link ConnectionService}
Santos Cordona663f862014-10-29 13:49:58 -070089 * receives call-commands such as answer, reject, hold and disconnect.
90 * <p>
Tyler Gunnf5035432017-01-09 09:43:12 -080091 * When there are no more live calls, telecom will unbind from the {@link ConnectionService}.
Ihab Awad542e0ea2014-05-16 10:22:16 -070092 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -070093public abstract class ConnectionService extends Service {
Santos Cordon5c6fa952014-07-20 17:47:12 -070094 /**
95 * The {@link Intent} that must be declared as handled by the service.
96 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -070097 @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
Tyler Gunnef9f6f92014-09-12 22:16:17 -070098 public static final String SERVICE_INTERFACE = "android.telecom.ConnectionService";
Santos Cordon5c6fa952014-07-20 17:47:12 -070099
Tyler Gunn8bf76572017-04-06 15:30:08 -0700100 /**
101 * Boolean extra used by Telecom to inform a {@link ConnectionService} that the purpose of it
102 * being asked to create a new outgoing {@link Connection} is to perform a handover of an
103 * ongoing call on the device from another {@link PhoneAccount}/{@link ConnectionService}. Will
104 * be specified in the {@link ConnectionRequest#getExtras()} passed by Telecom when
105 * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)} is called.
106 * <p>
Tyler Gunn727c6bd2017-04-11 09:51:40 -0700107 * When your {@link ConnectionService} receives this extra, it should communicate the fact that
108 * this is a handover to the other device's matching {@link ConnectionService}. That
Tyler Gunn8bf76572017-04-06 15:30:08 -0700109 * {@link ConnectionService} will continue the handover using
110 * {@link TelecomManager#addNewIncomingCall(PhoneAccountHandle, Bundle)}, specifying
Tyler Gunn727c6bd2017-04-11 09:51:40 -0700111 * {@link TelecomManager#EXTRA_IS_HANDOVER}. Telecom will match the phone numbers of the
112 * handover call on the other device with ongoing calls for {@link ConnectionService}s which
113 * support {@link PhoneAccount#EXTRA_SUPPORTS_HANDOVER_FROM}.
Tyler Gunn8bf76572017-04-06 15:30:08 -0700114 * @hide
115 */
116 public static final String EXTRA_IS_HANDOVER = TelecomManager.EXTRA_IS_HANDOVER;
117
Ihab Awad542e0ea2014-05-16 10:22:16 -0700118 // Flag controlling whether PII is emitted into the logs
Ihab Awad60ac30b2014-05-20 22:32:12 -0700119 private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG);
Ihab Awad542e0ea2014-05-16 10:22:16 -0700120
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700121 // Session Definitions
122 private static final String SESSION_HANDLER = "H.";
123 private static final String SESSION_ADD_CS_ADAPTER = "CS.aCSA";
124 private static final String SESSION_REMOVE_CS_ADAPTER = "CS.rCSA";
125 private static final String SESSION_CREATE_CONN = "CS.crCo";
Tyler Gunn041a1fe2017-05-12 10:04:49 -0700126 private static final String SESSION_CREATE_CONN_COMPLETE = "CS.crCoC";
Tyler Gunn44e01912017-01-31 10:49:05 -0800127 private static final String SESSION_CREATE_CONN_FAILED = "CS.crCoF";
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700128 private static final String SESSION_ABORT = "CS.ab";
129 private static final String SESSION_ANSWER = "CS.an";
130 private static final String SESSION_ANSWER_VIDEO = "CS.anV";
Pooja Jaind34698d2017-12-28 14:15:31 +0530131 private static final String SESSION_DEFLECT = "CS.def";
Ravi Palurif4b38e72020-02-05 12:35:41 +0530132 private static final String SESSION_TRANSFER = "CS.trans";
133 private static final String SESSION_CONSULTATIVE_TRANSFER = "CS.cTrans";
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700134 private static final String SESSION_REJECT = "CS.r";
135 private static final String SESSION_REJECT_MESSAGE = "CS.rWM";
136 private static final String SESSION_SILENCE = "CS.s";
137 private static final String SESSION_DISCONNECT = "CS.d";
138 private static final String SESSION_HOLD = "CS.h";
139 private static final String SESSION_UNHOLD = "CS.u";
140 private static final String SESSION_CALL_AUDIO_SC = "CS.cASC";
Grace Jiae99fde92021-01-19 14:58:01 -0800141 private static final String SESSION_USING_ALTERNATIVE_UI = "CS.uAU";
142 private static final String SESSION_TRACKED_BY_NON_UI_SERVICE = "CS.tBNUS";
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700143 private static final String SESSION_PLAY_DTMF = "CS.pDT";
144 private static final String SESSION_STOP_DTMF = "CS.sDT";
145 private static final String SESSION_CONFERENCE = "CS.c";
146 private static final String SESSION_SPLIT_CONFERENCE = "CS.sFC";
147 private static final String SESSION_MERGE_CONFERENCE = "CS.mC";
148 private static final String SESSION_SWAP_CONFERENCE = "CS.sC";
Ravi Paluri404babb2020-01-23 19:02:44 +0530149 private static final String SESSION_ADD_PARTICIPANT = "CS.aP";
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700150 private static final String SESSION_POST_DIAL_CONT = "CS.oPDC";
151 private static final String SESSION_PULL_EXTERNAL_CALL = "CS.pEC";
152 private static final String SESSION_SEND_CALL_EVENT = "CS.sCE";
Hall Liu49cabcc2021-01-15 11:41:48 -0800153 private static final String SESSION_CALL_FILTERING_COMPLETED = "CS.oCFC";
Tyler Gunn79bc1ec2018-01-22 15:17:54 -0800154 private static final String SESSION_HANDOVER_COMPLETE = "CS.hC";
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700155 private static final String SESSION_EXTRAS_CHANGED = "CS.oEC";
Hall Liub64ac4c2017-02-06 10:49:48 -0800156 private static final String SESSION_START_RTT = "CS.+RTT";
Hall Liua549fed2018-02-09 16:40:03 -0800157 private static final String SESSION_UPDATE_RTT_PIPES = "CS.uRTT";
Hall Liub64ac4c2017-02-06 10:49:48 -0800158 private static final String SESSION_STOP_RTT = "CS.-RTT";
159 private static final String SESSION_RTT_UPGRADE_RESPONSE = "CS.rTRUR";
Pengquan Meng731c1a32017-11-21 18:01:13 -0800160 private static final String SESSION_CONNECTION_SERVICE_FOCUS_LOST = "CS.cSFL";
161 private static final String SESSION_CONNECTION_SERVICE_FOCUS_GAINED = "CS.cSFG";
Sanket Padawe4cc8ed52017-12-04 16:22:20 -0800162 private static final String SESSION_HANDOVER_FAILED = "CS.haF";
Ravi Paluri80aa2142019-12-02 11:57:37 +0530163 private static final String SESSION_CREATE_CONF = "CS.crConf";
164 private static final String SESSION_CREATE_CONF_COMPLETE = "CS.crConfC";
165 private static final String SESSION_CREATE_CONF_FAILED = "CS.crConfF";
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700166
Ihab Awad8aecfed2014-08-08 17:06:11 -0700167 private static final int MSG_ADD_CONNECTION_SERVICE_ADAPTER = 1;
Sailesh Nepalc5b01572014-07-14 16:29:44 -0700168 private static final int MSG_CREATE_CONNECTION = 2;
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700169 private static final int MSG_ABORT = 3;
Sailesh Nepalc5b01572014-07-14 16:29:44 -0700170 private static final int MSG_ANSWER = 4;
171 private static final int MSG_REJECT = 5;
172 private static final int MSG_DISCONNECT = 6;
173 private static final int MSG_HOLD = 7;
174 private static final int MSG_UNHOLD = 8;
Yorke Lee4af59352015-05-13 14:14:54 -0700175 private static final int MSG_ON_CALL_AUDIO_STATE_CHANGED = 9;
Sailesh Nepalc5b01572014-07-14 16:29:44 -0700176 private static final int MSG_PLAY_DTMF_TONE = 10;
177 private static final int MSG_STOP_DTMF_TONE = 11;
178 private static final int MSG_CONFERENCE = 12;
179 private static final int MSG_SPLIT_FROM_CONFERENCE = 13;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700180 private static final int MSG_ON_POST_DIAL_CONTINUE = 14;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700181 private static final int MSG_REMOVE_CONNECTION_SERVICE_ADAPTER = 16;
Tyler Gunnbe74de02014-08-29 14:51:48 -0700182 private static final int MSG_ANSWER_VIDEO = 17;
Santos Cordona4868042014-09-04 17:39:22 -0700183 private static final int MSG_MERGE_CONFERENCE = 18;
184 private static final int MSG_SWAP_CONFERENCE = 19;
Bryce Lee81901682015-08-28 16:38:02 -0700185 private static final int MSG_REJECT_WITH_MESSAGE = 20;
Bryce Leecac50772015-11-17 15:13:29 -0800186 private static final int MSG_SILENCE = 21;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700187 private static final int MSG_PULL_EXTERNAL_CALL = 22;
188 private static final int MSG_SEND_CALL_EVENT = 23;
Tyler Gunndee56a82016-03-23 16:06:34 -0700189 private static final int MSG_ON_EXTRAS_CHANGED = 24;
Tyler Gunn44e01912017-01-31 10:49:05 -0800190 private static final int MSG_CREATE_CONNECTION_FAILED = 25;
Hall Liub64ac4c2017-02-06 10:49:48 -0800191 private static final int MSG_ON_START_RTT = 26;
192 private static final int MSG_ON_STOP_RTT = 27;
193 private static final int MSG_RTT_UPGRADE_RESPONSE = 28;
Tyler Gunn041a1fe2017-05-12 10:04:49 -0700194 private static final int MSG_CREATE_CONNECTION_COMPLETE = 29;
Pengquan Meng731c1a32017-11-21 18:01:13 -0800195 private static final int MSG_CONNECTION_SERVICE_FOCUS_LOST = 30;
196 private static final int MSG_CONNECTION_SERVICE_FOCUS_GAINED = 31;
Sanket Padawe4cc8ed52017-12-04 16:22:20 -0800197 private static final int MSG_HANDOVER_FAILED = 32;
Tyler Gunn79bc1ec2018-01-22 15:17:54 -0800198 private static final int MSG_HANDOVER_COMPLETE = 33;
Pooja Jaind34698d2017-12-28 14:15:31 +0530199 private static final int MSG_DEFLECT = 34;
Ravi Paluri80aa2142019-12-02 11:57:37 +0530200 private static final int MSG_CREATE_CONFERENCE = 35;
201 private static final int MSG_CREATE_CONFERENCE_COMPLETE = 36;
202 private static final int MSG_CREATE_CONFERENCE_FAILED = 37;
Tyler Gunnfacfdee2020-01-23 13:10:37 -0800203 private static final int MSG_REJECT_WITH_REASON = 38;
Ravi Paluri404babb2020-01-23 19:02:44 +0530204 private static final int MSG_ADD_PARTICIPANT = 39;
Ravi Palurif4b38e72020-02-05 12:35:41 +0530205 private static final int MSG_EXPLICIT_CALL_TRANSFER = 40;
206 private static final int MSG_EXPLICIT_CALL_TRANSFER_CONSULTATIVE = 41;
Hall Liu49cabcc2021-01-15 11:41:48 -0800207 private static final int MSG_ON_CALL_FILTERING_COMPLETED = 42;
Grace Jiae99fde92021-01-19 14:58:01 -0800208 private static final int MSG_ON_USING_ALTERNATIVE_UI = 43;
209 private static final int MSG_ON_TRACKED_BY_NON_UI_SERVICE = 44;
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700210
Sailesh Nepalcf7020b2014-08-20 10:07:19 -0700211 private static Connection sNullConnection;
212
mike dooley95e80702014-09-18 14:07:52 -0700213 private final Map<String, Connection> mConnectionById = new ConcurrentHashMap<>();
214 private final Map<Connection, String> mIdByConnection = new ConcurrentHashMap<>();
215 private final Map<String, Conference> mConferenceById = new ConcurrentHashMap<>();
216 private final Map<Conference, String> mIdByConference = new ConcurrentHashMap<>();
Ihab Awadb8e85c72014-08-23 20:34:57 -0700217 private final RemoteConnectionManager mRemoteConnectionManager =
218 new RemoteConnectionManager(this);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700219 private final List<Runnable> mPreInitializationConnectionRequests = new ArrayList<>();
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700220 private final ConnectionServiceAdapter mAdapter = new ConnectionServiceAdapter();
Ihab Awad542e0ea2014-05-16 10:22:16 -0700221
Santos Cordon823fd3c2014-08-07 18:35:18 -0700222 private boolean mAreAccountsInitialized = false;
Santos Cordon0159ac02014-08-21 14:28:11 -0700223 private Conference sNullConference;
Tyler Gunnf0500bd2015-09-01 10:59:48 -0700224 private Object mIdSyncRoot = new Object();
225 private int mId = 0;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700226
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700227 private final IBinder mBinder = new IConnectionService.Stub() {
228 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700229 public void addConnectionServiceAdapter(IConnectionServiceAdapter adapter,
230 Session.Info sessionInfo) {
231 Log.startSession(sessionInfo, SESSION_ADD_CS_ADAPTER);
232 try {
233 SomeArgs args = SomeArgs.obtain();
234 args.arg1 = adapter;
235 args.arg2 = Log.createSubsession();
236 mHandler.obtainMessage(MSG_ADD_CONNECTION_SERVICE_ADAPTER, args).sendToTarget();
237 } finally {
238 Log.endSession();
239 }
Ihab Awad8aecfed2014-08-08 17:06:11 -0700240 }
241
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700242 public void removeConnectionServiceAdapter(IConnectionServiceAdapter adapter,
243 Session.Info sessionInfo) {
244 Log.startSession(sessionInfo, SESSION_REMOVE_CS_ADAPTER);
245 try {
246 SomeArgs args = SomeArgs.obtain();
247 args.arg1 = adapter;
248 args.arg2 = Log.createSubsession();
249 mHandler.obtainMessage(MSG_REMOVE_CONNECTION_SERVICE_ADAPTER, args).sendToTarget();
250 } finally {
251 Log.endSession();
252 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700253 }
254
255 @Override
Ihab Awadf8b69882014-07-25 15:14:01 -0700256 public void createConnection(
257 PhoneAccountHandle connectionManagerPhoneAccount,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700258 String id,
Ihab Awadf8b69882014-07-25 15:14:01 -0700259 ConnectionRequest request,
Yorke Leec3cf9822014-10-02 09:38:39 -0700260 boolean isIncoming,
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700261 boolean isUnknown,
262 Session.Info sessionInfo) {
263 Log.startSession(sessionInfo, SESSION_CREATE_CONN);
264 try {
265 SomeArgs args = SomeArgs.obtain();
266 args.arg1 = connectionManagerPhoneAccount;
267 args.arg2 = id;
268 args.arg3 = request;
269 args.arg4 = Log.createSubsession();
270 args.argi1 = isIncoming ? 1 : 0;
271 args.argi2 = isUnknown ? 1 : 0;
272 mHandler.obtainMessage(MSG_CREATE_CONNECTION, args).sendToTarget();
273 } finally {
274 Log.endSession();
275 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700276 }
277
278 @Override
Tyler Gunn041a1fe2017-05-12 10:04:49 -0700279 public void createConnectionComplete(String id, Session.Info sessionInfo) {
280 Log.startSession(sessionInfo, SESSION_CREATE_CONN_COMPLETE);
281 try {
282 SomeArgs args = SomeArgs.obtain();
283 args.arg1 = id;
284 args.arg2 = Log.createSubsession();
285 mHandler.obtainMessage(MSG_CREATE_CONNECTION_COMPLETE, args).sendToTarget();
286 } finally {
287 Log.endSession();
288 }
289 }
290
291 @Override
Tyler Gunn44e01912017-01-31 10:49:05 -0800292 public void createConnectionFailed(
Tyler Gunn159f35c2017-03-02 09:28:37 -0800293 PhoneAccountHandle connectionManagerPhoneAccount,
Tyler Gunn44e01912017-01-31 10:49:05 -0800294 String callId,
295 ConnectionRequest request,
296 boolean isIncoming,
297 Session.Info sessionInfo) {
298 Log.startSession(sessionInfo, SESSION_CREATE_CONN_FAILED);
299 try {
300 SomeArgs args = SomeArgs.obtain();
301 args.arg1 = callId;
302 args.arg2 = request;
303 args.arg3 = Log.createSubsession();
Tyler Gunn159f35c2017-03-02 09:28:37 -0800304 args.arg4 = connectionManagerPhoneAccount;
Tyler Gunn44e01912017-01-31 10:49:05 -0800305 args.argi1 = isIncoming ? 1 : 0;
306 mHandler.obtainMessage(MSG_CREATE_CONNECTION_FAILED, args).sendToTarget();
307 } finally {
308 Log.endSession();
309 }
310 }
311
312 @Override
Ravi Paluri80aa2142019-12-02 11:57:37 +0530313 public void createConference(
314 PhoneAccountHandle connectionManagerPhoneAccount,
315 String id,
316 ConnectionRequest request,
317 boolean isIncoming,
318 boolean isUnknown,
319 Session.Info sessionInfo) {
320 Log.startSession(sessionInfo, SESSION_CREATE_CONF);
321 try {
322 SomeArgs args = SomeArgs.obtain();
323 args.arg1 = connectionManagerPhoneAccount;
324 args.arg2 = id;
325 args.arg3 = request;
326 args.arg4 = Log.createSubsession();
327 args.argi1 = isIncoming ? 1 : 0;
328 args.argi2 = isUnknown ? 1 : 0;
329 mHandler.obtainMessage(MSG_CREATE_CONFERENCE, args).sendToTarget();
330 } finally {
331 Log.endSession();
332 }
333 }
334
335 @Override
336 public void createConferenceComplete(String id, Session.Info sessionInfo) {
337 Log.startSession(sessionInfo, SESSION_CREATE_CONF_COMPLETE);
338 try {
339 SomeArgs args = SomeArgs.obtain();
340 args.arg1 = id;
341 args.arg2 = Log.createSubsession();
342 mHandler.obtainMessage(MSG_CREATE_CONFERENCE_COMPLETE, args).sendToTarget();
343 } finally {
344 Log.endSession();
345 }
346 }
347
348 @Override
349 public void createConferenceFailed(
350 PhoneAccountHandle connectionManagerPhoneAccount,
351 String callId,
352 ConnectionRequest request,
353 boolean isIncoming,
354 Session.Info sessionInfo) {
355 Log.startSession(sessionInfo, SESSION_CREATE_CONF_FAILED);
356 try {
357 SomeArgs args = SomeArgs.obtain();
358 args.arg1 = callId;
359 args.arg2 = request;
360 args.arg3 = Log.createSubsession();
361 args.arg4 = connectionManagerPhoneAccount;
362 args.argi1 = isIncoming ? 1 : 0;
363 mHandler.obtainMessage(MSG_CREATE_CONFERENCE_FAILED, args).sendToTarget();
364 } finally {
365 Log.endSession();
366 }
367 }
368
369 @Override
Sanket Padawe4cc8ed52017-12-04 16:22:20 -0800370 public void handoverFailed(String callId, ConnectionRequest request, int reason,
371 Session.Info sessionInfo) {
372 Log.startSession(sessionInfo, SESSION_HANDOVER_FAILED);
373 try {
374 SomeArgs args = SomeArgs.obtain();
375 args.arg1 = callId;
376 args.arg2 = request;
377 args.arg3 = Log.createSubsession();
378 args.arg4 = reason;
379 mHandler.obtainMessage(MSG_HANDOVER_FAILED, args).sendToTarget();
380 } finally {
381 Log.endSession();
382 }
383 }
384
385 @Override
Tyler Gunn79bc1ec2018-01-22 15:17:54 -0800386 public void handoverComplete(String callId, Session.Info sessionInfo) {
387 Log.startSession(sessionInfo, SESSION_HANDOVER_COMPLETE);
388 try {
389 SomeArgs args = SomeArgs.obtain();
390 args.arg1 = callId;
391 args.arg2 = Log.createSubsession();
392 mHandler.obtainMessage(MSG_HANDOVER_COMPLETE, args).sendToTarget();
393 } finally {
394 Log.endSession();
395 }
396 }
397
398 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700399 public void abort(String callId, Session.Info sessionInfo) {
400 Log.startSession(sessionInfo, SESSION_ABORT);
401 try {
402 SomeArgs args = SomeArgs.obtain();
403 args.arg1 = callId;
404 args.arg2 = Log.createSubsession();
405 mHandler.obtainMessage(MSG_ABORT, args).sendToTarget();
406 } finally {
407 Log.endSession();
408 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700409 }
410
411 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700412 public void answerVideo(String callId, int videoState, Session.Info sessionInfo) {
413 Log.startSession(sessionInfo, SESSION_ANSWER_VIDEO);
414 try {
415 SomeArgs args = SomeArgs.obtain();
416 args.arg1 = callId;
417 args.arg2 = Log.createSubsession();
418 args.argi1 = videoState;
419 mHandler.obtainMessage(MSG_ANSWER_VIDEO, args).sendToTarget();
420 } finally {
421 Log.endSession();
422 }
Tyler Gunnbe74de02014-08-29 14:51:48 -0700423 }
424
425 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700426 public void answer(String callId, Session.Info sessionInfo) {
427 Log.startSession(sessionInfo, SESSION_ANSWER);
428 try {
429 SomeArgs args = SomeArgs.obtain();
430 args.arg1 = callId;
431 args.arg2 = Log.createSubsession();
432 mHandler.obtainMessage(MSG_ANSWER, args).sendToTarget();
433 } finally {
434 Log.endSession();
435 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700436 }
437
438 @Override
Pooja Jaind34698d2017-12-28 14:15:31 +0530439 public void deflect(String callId, Uri address, Session.Info sessionInfo) {
440 Log.startSession(sessionInfo, SESSION_DEFLECT);
441 try {
442 SomeArgs args = SomeArgs.obtain();
443 args.arg1 = callId;
444 args.arg2 = address;
445 args.arg3 = Log.createSubsession();
446 mHandler.obtainMessage(MSG_DEFLECT, args).sendToTarget();
447 } finally {
448 Log.endSession();
449 }
450 }
451
452 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700453 public void reject(String callId, Session.Info sessionInfo) {
454 Log.startSession(sessionInfo, SESSION_REJECT);
455 try {
456 SomeArgs args = SomeArgs.obtain();
457 args.arg1 = callId;
458 args.arg2 = Log.createSubsession();
459 mHandler.obtainMessage(MSG_REJECT, args).sendToTarget();
460 } finally {
461 Log.endSession();
462 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700463 }
464
465 @Override
Tyler Gunnfacfdee2020-01-23 13:10:37 -0800466 public void rejectWithReason(String callId,
467 @android.telecom.Call.RejectReason int rejectReason, Session.Info sessionInfo) {
468 Log.startSession(sessionInfo, SESSION_REJECT);
469 try {
470 SomeArgs args = SomeArgs.obtain();
471 args.arg1 = callId;
472 args.argi1 = rejectReason;
473 args.arg2 = Log.createSubsession();
474 mHandler.obtainMessage(MSG_REJECT_WITH_REASON, args).sendToTarget();
475 } finally {
476 Log.endSession();
477 }
478 }
479
480 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700481 public void rejectWithMessage(String callId, String message, Session.Info sessionInfo) {
482 Log.startSession(sessionInfo, SESSION_REJECT_MESSAGE);
483 try {
484 SomeArgs args = SomeArgs.obtain();
485 args.arg1 = callId;
486 args.arg2 = message;
487 args.arg3 = Log.createSubsession();
488 mHandler.obtainMessage(MSG_REJECT_WITH_MESSAGE, args).sendToTarget();
489 } finally {
490 Log.endSession();
491 }
Bryce Lee81901682015-08-28 16:38:02 -0700492 }
493
494 @Override
Ravi Palurif4b38e72020-02-05 12:35:41 +0530495 public void transfer(@NonNull String callId, @NonNull Uri number,
496 boolean isConfirmationRequired, Session.Info sessionInfo) {
497 Log.startSession(sessionInfo, SESSION_TRANSFER);
498 try {
499 SomeArgs args = SomeArgs.obtain();
500 args.arg1 = callId;
501 args.arg2 = number;
502 args.argi1 = isConfirmationRequired ? 1 : 0;
503 args.arg3 = Log.createSubsession();
504 mHandler.obtainMessage(MSG_EXPLICIT_CALL_TRANSFER, args).sendToTarget();
505 } finally {
506 Log.endSession();
507 }
508 }
509
510 @Override
511 public void consultativeTransfer(@NonNull String callId, @NonNull String otherCallId,
512 Session.Info sessionInfo) {
513 Log.startSession(sessionInfo, SESSION_CONSULTATIVE_TRANSFER);
514 try {
515 SomeArgs args = SomeArgs.obtain();
516 args.arg1 = callId;
517 args.arg2 = otherCallId;
518 args.arg3 = Log.createSubsession();
519 mHandler.obtainMessage(
520 MSG_EXPLICIT_CALL_TRANSFER_CONSULTATIVE, args).sendToTarget();
521 } finally {
522 Log.endSession();
523 }
524 }
525
526 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700527 public void silence(String callId, Session.Info sessionInfo) {
528 Log.startSession(sessionInfo, SESSION_SILENCE);
529 try {
530 SomeArgs args = SomeArgs.obtain();
531 args.arg1 = callId;
532 args.arg2 = Log.createSubsession();
533 mHandler.obtainMessage(MSG_SILENCE, args).sendToTarget();
534 } finally {
535 Log.endSession();
536 }
Bryce Leecac50772015-11-17 15:13:29 -0800537 }
538
539 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700540 public void disconnect(String callId, Session.Info sessionInfo) {
541 Log.startSession(sessionInfo, SESSION_DISCONNECT);
542 try {
543 SomeArgs args = SomeArgs.obtain();
544 args.arg1 = callId;
545 args.arg2 = Log.createSubsession();
546 mHandler.obtainMessage(MSG_DISCONNECT, args).sendToTarget();
547 } finally {
548 Log.endSession();
549 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700550 }
551
552 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700553 public void hold(String callId, Session.Info sessionInfo) {
554 Log.startSession(sessionInfo, SESSION_HOLD);
555 try {
556 SomeArgs args = SomeArgs.obtain();
557 args.arg1 = callId;
558 args.arg2 = Log.createSubsession();
559 mHandler.obtainMessage(MSG_HOLD, args).sendToTarget();
560 } finally {
561 Log.endSession();
562 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700563 }
564
565 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700566 public void unhold(String callId, Session.Info sessionInfo) {
567 Log.startSession(sessionInfo, SESSION_UNHOLD);
568 try {
569 SomeArgs args = SomeArgs.obtain();
570 args.arg1 = callId;
571 args.arg2 = Log.createSubsession();
572 mHandler.obtainMessage(MSG_UNHOLD, args).sendToTarget();
573 } finally {
574 Log.endSession();
575 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700576 }
577
578 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700579 public void onCallAudioStateChanged(String callId, CallAudioState callAudioState,
580 Session.Info sessionInfo) {
581 Log.startSession(sessionInfo, SESSION_CALL_AUDIO_SC);
582 try {
583 SomeArgs args = SomeArgs.obtain();
584 args.arg1 = callId;
585 args.arg2 = callAudioState;
586 args.arg3 = Log.createSubsession();
587 mHandler.obtainMessage(MSG_ON_CALL_AUDIO_STATE_CHANGED, args).sendToTarget();
588 } finally {
589 Log.endSession();
590 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700591 }
592
593 @Override
Grace Jiae99fde92021-01-19 14:58:01 -0800594 public void onUsingAlternativeUi(String callId, boolean usingAlternativeUiShowing,
595 Session.Info sessionInfo) {
596 Log.startSession(sessionInfo, SESSION_USING_ALTERNATIVE_UI);
597 try {
598 SomeArgs args = SomeArgs.obtain();
599 args.arg1 = callId;
600 args.arg2 = usingAlternativeUiShowing;
601 args.arg3 = Log.createSubsession();
602 mHandler.obtainMessage(MSG_ON_USING_ALTERNATIVE_UI, args).sendToTarget();
603 } finally {
604 Log.endSession();
605 }
606 }
607
608 @Override
609 public void onTrackedByNonUiService(String callId, boolean isTracked,
610 Session.Info sessionInfo) {
611 Log.startSession(sessionInfo, SESSION_TRACKED_BY_NON_UI_SERVICE);
612 try {
613 SomeArgs args = SomeArgs.obtain();
614 args.arg1 = callId;
615 args.arg2 = isTracked;
616 args.arg3 = Log.createSubsession();
617 mHandler.obtainMessage(MSG_ON_TRACKED_BY_NON_UI_SERVICE, args).sendToTarget();
618 } finally {
619 Log.endSession();
620 }
621 }
622
623 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700624 public void playDtmfTone(String callId, char digit, Session.Info sessionInfo) {
625 Log.startSession(sessionInfo, SESSION_PLAY_DTMF);
626 try {
627 SomeArgs args = SomeArgs.obtain();
628 args.arg1 = digit;
629 args.arg2 = callId;
630 args.arg3 = Log.createSubsession();
631 mHandler.obtainMessage(MSG_PLAY_DTMF_TONE, args).sendToTarget();
632 } finally {
633 Log.endSession();
634 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700635 }
636
637 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700638 public void stopDtmfTone(String callId, Session.Info sessionInfo) {
639 Log.startSession(sessionInfo, SESSION_STOP_DTMF);
640 try {
641 SomeArgs args = SomeArgs.obtain();
642 args.arg1 = callId;
643 args.arg2 = Log.createSubsession();
644 mHandler.obtainMessage(MSG_STOP_DTMF_TONE, args).sendToTarget();
645 } finally {
646 Log.endSession();
647 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700648 }
649
650 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700651 public void conference(String callId1, String callId2, Session.Info sessionInfo) {
652 Log.startSession(sessionInfo, SESSION_CONFERENCE);
653 try {
654 SomeArgs args = SomeArgs.obtain();
655 args.arg1 = callId1;
656 args.arg2 = callId2;
657 args.arg3 = Log.createSubsession();
658 mHandler.obtainMessage(MSG_CONFERENCE, args).sendToTarget();
659 } finally {
660 Log.endSession();
661 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700662 }
663
664 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700665 public void splitFromConference(String callId, Session.Info sessionInfo) {
666 Log.startSession(sessionInfo, SESSION_SPLIT_CONFERENCE);
667 try {
668 SomeArgs args = SomeArgs.obtain();
669 args.arg1 = callId;
670 args.arg2 = Log.createSubsession();
671 mHandler.obtainMessage(MSG_SPLIT_FROM_CONFERENCE, args).sendToTarget();
672 } finally {
673 Log.endSession();
674 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700675 }
676
677 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700678 public void mergeConference(String callId, Session.Info sessionInfo) {
679 Log.startSession(sessionInfo, SESSION_MERGE_CONFERENCE);
680 try {
681 SomeArgs args = SomeArgs.obtain();
682 args.arg1 = callId;
683 args.arg2 = Log.createSubsession();
684 mHandler.obtainMessage(MSG_MERGE_CONFERENCE, args).sendToTarget();
685 } finally {
686 Log.endSession();
687 }
Santos Cordona4868042014-09-04 17:39:22 -0700688 }
689
690 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700691 public void swapConference(String callId, Session.Info sessionInfo) {
692 Log.startSession(sessionInfo, SESSION_SWAP_CONFERENCE);
693 try {
694 SomeArgs args = SomeArgs.obtain();
695 args.arg1 = callId;
696 args.arg2 = Log.createSubsession();
697 mHandler.obtainMessage(MSG_SWAP_CONFERENCE, args).sendToTarget();
698 } finally {
699 Log.endSession();
700 }
Santos Cordona4868042014-09-04 17:39:22 -0700701 }
702
703 @Override
Ravi Paluri404babb2020-01-23 19:02:44 +0530704 public void addConferenceParticipants(String callId, List<Uri> participants,
705 Session.Info sessionInfo) {
706 Log.startSession(sessionInfo, SESSION_ADD_PARTICIPANT);
707 try {
708 SomeArgs args = SomeArgs.obtain();
709 args.arg1 = callId;
710 args.arg2 = participants;
711 args.arg3 = Log.createSubsession();
712 mHandler.obtainMessage(MSG_ADD_PARTICIPANT, args).sendToTarget();
713 } finally {
714 Log.endSession();
715 }
716 }
717
718 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700719 public void onPostDialContinue(String callId, boolean proceed, Session.Info sessionInfo) {
720 Log.startSession(sessionInfo, SESSION_POST_DIAL_CONT);
721 try {
722 SomeArgs args = SomeArgs.obtain();
723 args.arg1 = callId;
724 args.arg2 = Log.createSubsession();
725 args.argi1 = proceed ? 1 : 0;
726 mHandler.obtainMessage(MSG_ON_POST_DIAL_CONTINUE, args).sendToTarget();
727 } finally {
728 Log.endSession();
729 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700730 }
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700731
732 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700733 public void pullExternalCall(String callId, Session.Info sessionInfo) {
734 Log.startSession(sessionInfo, SESSION_PULL_EXTERNAL_CALL);
735 try {
736 SomeArgs args = SomeArgs.obtain();
737 args.arg1 = callId;
738 args.arg2 = Log.createSubsession();
739 mHandler.obtainMessage(MSG_PULL_EXTERNAL_CALL, args).sendToTarget();
740 } finally {
741 Log.endSession();
742 }
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700743 }
744
745 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700746 public void sendCallEvent(String callId, String event, Bundle extras,
747 Session.Info sessionInfo) {
748 Log.startSession(sessionInfo, SESSION_SEND_CALL_EVENT);
749 try {
750 SomeArgs args = SomeArgs.obtain();
751 args.arg1 = callId;
752 args.arg2 = event;
753 args.arg3 = extras;
754 args.arg4 = Log.createSubsession();
755 mHandler.obtainMessage(MSG_SEND_CALL_EVENT, args).sendToTarget();
756 } finally {
757 Log.endSession();
758 }
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700759 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700760
761 @Override
Hall Liu73903142021-02-18 18:41:41 -0800762 public void onCallFilteringCompleted(String callId,
763 Connection.CallFilteringCompletionInfo completionInfo,
Hall Liu49cabcc2021-01-15 11:41:48 -0800764 Session.Info sessionInfo) {
765 Log.startSession(sessionInfo, SESSION_CALL_FILTERING_COMPLETED);
766 try {
767 SomeArgs args = SomeArgs.obtain();
768 args.arg1 = callId;
Hall Liu73903142021-02-18 18:41:41 -0800769 args.arg2 = completionInfo;
770 args.arg3 = Log.createSubsession();
Hall Liu49cabcc2021-01-15 11:41:48 -0800771 mHandler.obtainMessage(MSG_ON_CALL_FILTERING_COMPLETED, args).sendToTarget();
772 } finally {
773 Log.endSession();
774 }
775 }
776
777 @Override
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700778 public void onExtrasChanged(String callId, Bundle extras, Session.Info sessionInfo) {
779 Log.startSession(sessionInfo, SESSION_EXTRAS_CHANGED);
780 try {
781 SomeArgs args = SomeArgs.obtain();
782 args.arg1 = callId;
783 args.arg2 = extras;
784 args.arg3 = Log.createSubsession();
785 mHandler.obtainMessage(MSG_ON_EXTRAS_CHANGED, args).sendToTarget();
786 } finally {
787 Log.endSession();
788 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700789 }
Hall Liub64ac4c2017-02-06 10:49:48 -0800790
791 @Override
792 public void startRtt(String callId, ParcelFileDescriptor fromInCall,
793 ParcelFileDescriptor toInCall, Session.Info sessionInfo) throws RemoteException {
794 Log.startSession(sessionInfo, SESSION_START_RTT);
795 try {
796 SomeArgs args = SomeArgs.obtain();
797 args.arg1 = callId;
798 args.arg2 = new Connection.RttTextStream(toInCall, fromInCall);
799 args.arg3 = Log.createSubsession();
800 mHandler.obtainMessage(MSG_ON_START_RTT, args).sendToTarget();
801 } finally {
802 Log.endSession();
803 }
804 }
805
806 @Override
807 public void stopRtt(String callId, Session.Info sessionInfo) throws RemoteException {
808 Log.startSession(sessionInfo, SESSION_STOP_RTT);
809 try {
810 SomeArgs args = SomeArgs.obtain();
811 args.arg1 = callId;
812 args.arg2 = Log.createSubsession();
813 mHandler.obtainMessage(MSG_ON_STOP_RTT, args).sendToTarget();
814 } finally {
815 Log.endSession();
816 }
817 }
818
819 @Override
820 public void respondToRttUpgradeRequest(String callId, ParcelFileDescriptor fromInCall,
821 ParcelFileDescriptor toInCall, Session.Info sessionInfo) throws RemoteException {
822 Log.startSession(sessionInfo, SESSION_RTT_UPGRADE_RESPONSE);
823 try {
824 SomeArgs args = SomeArgs.obtain();
825 args.arg1 = callId;
826 if (toInCall == null || fromInCall == null) {
827 args.arg2 = null;
828 } else {
829 args.arg2 = new Connection.RttTextStream(toInCall, fromInCall);
830 }
831 args.arg3 = Log.createSubsession();
832 mHandler.obtainMessage(MSG_RTT_UPGRADE_RESPONSE, args).sendToTarget();
833 } finally {
834 Log.endSession();
835 }
836 }
Pengquan Meng731c1a32017-11-21 18:01:13 -0800837
838 @Override
839 public void connectionServiceFocusLost(Session.Info sessionInfo) throws RemoteException {
840 Log.startSession(sessionInfo, SESSION_CONNECTION_SERVICE_FOCUS_LOST);
841 try {
842 mHandler.obtainMessage(MSG_CONNECTION_SERVICE_FOCUS_LOST).sendToTarget();
843 } finally {
844 Log.endSession();
845 }
846 }
847
848 @Override
849 public void connectionServiceFocusGained(Session.Info sessionInfo) throws RemoteException {
850 Log.startSession(sessionInfo, SESSION_CONNECTION_SERVICE_FOCUS_GAINED);
851 try {
852 mHandler.obtainMessage(MSG_CONNECTION_SERVICE_FOCUS_GAINED).sendToTarget();
853 } finally {
854 Log.endSession();
855 }
856 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700857 };
858
859 private final Handler mHandler = new Handler(Looper.getMainLooper()) {
860 @Override
861 public void handleMessage(Message msg) {
862 switch (msg.what) {
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700863 case MSG_ADD_CONNECTION_SERVICE_ADAPTER: {
864 SomeArgs args = (SomeArgs) msg.obj;
865 try {
866 IConnectionServiceAdapter adapter = (IConnectionServiceAdapter) args.arg1;
867 Log.continueSession((Session) args.arg2,
868 SESSION_HANDLER + SESSION_ADD_CS_ADAPTER);
869 mAdapter.addAdapter(adapter);
870 onAdapterAttached();
871 } finally {
872 args.recycle();
873 Log.endSession();
874 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700875 break;
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700876 }
877 case MSG_REMOVE_CONNECTION_SERVICE_ADAPTER: {
878 SomeArgs args = (SomeArgs) msg.obj;
879 try {
880 Log.continueSession((Session) args.arg2,
881 SESSION_HANDLER + SESSION_REMOVE_CS_ADAPTER);
882 mAdapter.removeAdapter((IConnectionServiceAdapter) args.arg1);
883 } finally {
884 args.recycle();
885 Log.endSession();
886 }
Ihab Awad8aecfed2014-08-08 17:06:11 -0700887 break;
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700888 }
Ihab Awadf8b69882014-07-25 15:14:01 -0700889 case MSG_CREATE_CONNECTION: {
890 SomeArgs args = (SomeArgs) msg.obj;
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700891 Log.continueSession((Session) args.arg4, SESSION_HANDLER + SESSION_CREATE_CONN);
Ihab Awadf8b69882014-07-25 15:14:01 -0700892 try {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700893 final PhoneAccountHandle connectionManagerPhoneAccount =
Ihab Awadf8b69882014-07-25 15:14:01 -0700894 (PhoneAccountHandle) args.arg1;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700895 final String id = (String) args.arg2;
896 final ConnectionRequest request = (ConnectionRequest) args.arg3;
Ihab Awad5d0410f2014-07-30 10:07:40 -0700897 final boolean isIncoming = args.argi1 == 1;
Yorke Leec3cf9822014-10-02 09:38:39 -0700898 final boolean isUnknown = args.argi2 == 1;
Ihab Awad5d0410f2014-07-30 10:07:40 -0700899 if (!mAreAccountsInitialized) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700900 Log.d(this, "Enqueueing pre-init request %s", id);
Brad Ebinger0c3541b2016-11-01 14:11:38 -0700901 mPreInitializationConnectionRequests.add(
902 new android.telecom.Logging.Runnable(
903 SESSION_HANDLER + SESSION_CREATE_CONN + ".pICR",
904 null /*lock*/) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700905 @Override
Brad Ebinger0c3541b2016-11-01 14:11:38 -0700906 public void loggedRun() {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700907 createConnection(
908 connectionManagerPhoneAccount,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700909 id,
Ihab Awad5d0410f2014-07-30 10:07:40 -0700910 request,
Yorke Leec3cf9822014-10-02 09:38:39 -0700911 isIncoming,
912 isUnknown);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700913 }
Brad Ebinger0c3541b2016-11-01 14:11:38 -0700914 }.prepare());
Ihab Awad5d0410f2014-07-30 10:07:40 -0700915 } else {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700916 createConnection(
917 connectionManagerPhoneAccount,
918 id,
919 request,
Yorke Leec3cf9822014-10-02 09:38:39 -0700920 isIncoming,
921 isUnknown);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700922 }
Ihab Awadf8b69882014-07-25 15:14:01 -0700923 } finally {
924 args.recycle();
Brad Ebingerb32d4f82016-10-24 16:40:49 -0700925 Log.endSession();
Ihab Awadf8b69882014-07-25 15:14:01 -0700926 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700927 break;
Ihab Awadf8b69882014-07-25 15:14:01 -0700928 }
Tyler Gunn041a1fe2017-05-12 10:04:49 -0700929 case MSG_CREATE_CONNECTION_COMPLETE: {
930 SomeArgs args = (SomeArgs) msg.obj;
931 Log.continueSession((Session) args.arg2,
932 SESSION_HANDLER + SESSION_CREATE_CONN_COMPLETE);
933 try {
934 final String id = (String) args.arg1;
935 if (!mAreAccountsInitialized) {
936 Log.d(this, "Enqueueing pre-init request %s", id);
937 mPreInitializationConnectionRequests.add(
938 new android.telecom.Logging.Runnable(
939 SESSION_HANDLER + SESSION_CREATE_CONN_COMPLETE
940 + ".pICR",
941 null /*lock*/) {
942 @Override
943 public void loggedRun() {
944 notifyCreateConnectionComplete(id);
945 }
946 }.prepare());
947 } else {
948 notifyCreateConnectionComplete(id);
949 }
950 } finally {
951 args.recycle();
952 Log.endSession();
953 }
954 break;
955 }
Tyler Gunn44e01912017-01-31 10:49:05 -0800956 case MSG_CREATE_CONNECTION_FAILED: {
957 SomeArgs args = (SomeArgs) msg.obj;
958 Log.continueSession((Session) args.arg3, SESSION_HANDLER +
959 SESSION_CREATE_CONN_FAILED);
960 try {
961 final String id = (String) args.arg1;
962 final ConnectionRequest request = (ConnectionRequest) args.arg2;
963 final boolean isIncoming = args.argi1 == 1;
Tyler Gunn159f35c2017-03-02 09:28:37 -0800964 final PhoneAccountHandle connectionMgrPhoneAccount =
965 (PhoneAccountHandle) args.arg4;
Tyler Gunn44e01912017-01-31 10:49:05 -0800966 if (!mAreAccountsInitialized) {
967 Log.d(this, "Enqueueing pre-init request %s", id);
968 mPreInitializationConnectionRequests.add(
969 new android.telecom.Logging.Runnable(
970 SESSION_HANDLER + SESSION_CREATE_CONN_FAILED + ".pICR",
971 null /*lock*/) {
972 @Override
973 public void loggedRun() {
Tyler Gunn159f35c2017-03-02 09:28:37 -0800974 createConnectionFailed(connectionMgrPhoneAccount, id,
975 request, isIncoming);
Tyler Gunn44e01912017-01-31 10:49:05 -0800976 }
977 }.prepare());
978 } else {
979 Log.i(this, "createConnectionFailed %s", id);
Tyler Gunn159f35c2017-03-02 09:28:37 -0800980 createConnectionFailed(connectionMgrPhoneAccount, id, request,
981 isIncoming);
Tyler Gunn44e01912017-01-31 10:49:05 -0800982 }
983 } finally {
984 args.recycle();
985 Log.endSession();
986 }
987 break;
988 }
Ravi Paluri80aa2142019-12-02 11:57:37 +0530989 case MSG_CREATE_CONFERENCE: {
990 SomeArgs args = (SomeArgs) msg.obj;
991 Log.continueSession((Session) args.arg4, SESSION_HANDLER + SESSION_CREATE_CONN);
992 try {
993 final PhoneAccountHandle connectionManagerPhoneAccount =
994 (PhoneAccountHandle) args.arg1;
995 final String id = (String) args.arg2;
996 final ConnectionRequest request = (ConnectionRequest) args.arg3;
997 final boolean isIncoming = args.argi1 == 1;
998 final boolean isUnknown = args.argi2 == 1;
999 if (!mAreAccountsInitialized) {
1000 Log.d(this, "Enqueueing pre-initconference request %s", id);
1001 mPreInitializationConnectionRequests.add(
1002 new android.telecom.Logging.Runnable(
1003 SESSION_HANDLER + SESSION_CREATE_CONF + ".pIConfR",
1004 null /*lock*/) {
1005 @Override
1006 public void loggedRun() {
1007 createConference(connectionManagerPhoneAccount,
1008 id,
1009 request,
1010 isIncoming,
1011 isUnknown);
1012 }
1013 }.prepare());
1014 } else {
1015 createConference(connectionManagerPhoneAccount,
1016 id,
1017 request,
1018 isIncoming,
1019 isUnknown);
1020 }
1021 } finally {
1022 args.recycle();
1023 Log.endSession();
1024 }
1025 break;
1026 }
1027 case MSG_CREATE_CONFERENCE_COMPLETE: {
1028 SomeArgs args = (SomeArgs) msg.obj;
1029 Log.continueSession((Session) args.arg2,
1030 SESSION_HANDLER + SESSION_CREATE_CONN_COMPLETE);
1031 try {
1032 final String id = (String) args.arg1;
1033 if (!mAreAccountsInitialized) {
1034 Log.d(this, "Enqueueing pre-init conference request %s", id);
1035 mPreInitializationConnectionRequests.add(
1036 new android.telecom.Logging.Runnable(
1037 SESSION_HANDLER + SESSION_CREATE_CONF_COMPLETE
1038 + ".pIConfR",
1039 null /*lock*/) {
1040 @Override
1041 public void loggedRun() {
1042 notifyCreateConferenceComplete(id);
1043 }
1044 }.prepare());
1045 } else {
1046 notifyCreateConferenceComplete(id);
1047 }
1048 } finally {
1049 args.recycle();
1050 Log.endSession();
1051 }
1052 break;
1053 }
1054 case MSG_CREATE_CONFERENCE_FAILED: {
1055 SomeArgs args = (SomeArgs) msg.obj;
1056 Log.continueSession((Session) args.arg3, SESSION_HANDLER +
1057 SESSION_CREATE_CONN_FAILED);
1058 try {
1059 final String id = (String) args.arg1;
1060 final ConnectionRequest request = (ConnectionRequest) args.arg2;
1061 final boolean isIncoming = args.argi1 == 1;
1062 final PhoneAccountHandle connectionMgrPhoneAccount =
1063 (PhoneAccountHandle) args.arg4;
1064 if (!mAreAccountsInitialized) {
1065 Log.d(this, "Enqueueing pre-init conference request %s", id);
1066 mPreInitializationConnectionRequests.add(
1067 new android.telecom.Logging.Runnable(
1068 SESSION_HANDLER + SESSION_CREATE_CONF_FAILED
1069 + ".pIConfR",
1070 null /*lock*/) {
1071 @Override
1072 public void loggedRun() {
1073 createConferenceFailed(connectionMgrPhoneAccount, id,
1074 request, isIncoming);
1075 }
1076 }.prepare());
1077 } else {
1078 Log.i(this, "createConferenceFailed %s", id);
1079 createConferenceFailed(connectionMgrPhoneAccount, id, request,
1080 isIncoming);
1081 }
1082 } finally {
1083 args.recycle();
1084 Log.endSession();
1085 }
1086 break;
1087 }
1088
Sanket Padawe4cc8ed52017-12-04 16:22:20 -08001089 case MSG_HANDOVER_FAILED: {
1090 SomeArgs args = (SomeArgs) msg.obj;
1091 Log.continueSession((Session) args.arg3, SESSION_HANDLER +
1092 SESSION_HANDOVER_FAILED);
1093 try {
1094 final String id = (String) args.arg1;
1095 final ConnectionRequest request = (ConnectionRequest) args.arg2;
1096 final int reason = (int) args.arg4;
1097 if (!mAreAccountsInitialized) {
1098 Log.d(this, "Enqueueing pre-init request %s", id);
1099 mPreInitializationConnectionRequests.add(
1100 new android.telecom.Logging.Runnable(
1101 SESSION_HANDLER
1102 + SESSION_HANDOVER_FAILED + ".pICR",
1103 null /*lock*/) {
1104 @Override
1105 public void loggedRun() {
1106 handoverFailed(id, request, reason);
1107 }
1108 }.prepare());
1109 } else {
1110 Log.i(this, "createConnectionFailed %s", id);
1111 handoverFailed(id, request, reason);
1112 }
1113 } finally {
1114 args.recycle();
1115 Log.endSession();
1116 }
1117 break;
1118 }
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001119 case MSG_ABORT: {
1120 SomeArgs args = (SomeArgs) msg.obj;
1121 Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_ABORT);
1122 try {
1123 abort((String) args.arg1);
1124 } finally {
1125 args.recycle();
1126 Log.endSession();
1127 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001128 break;
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001129 }
1130 case MSG_ANSWER: {
1131 SomeArgs args = (SomeArgs) msg.obj;
1132 Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_ANSWER);
1133 try {
1134 answer((String) args.arg1);
1135 } finally {
1136 args.recycle();
1137 Log.endSession();
1138 }
Tyler Gunnbe74de02014-08-29 14:51:48 -07001139 break;
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001140 }
Tyler Gunnbe74de02014-08-29 14:51:48 -07001141 case MSG_ANSWER_VIDEO: {
Andrew Lee8da4c3c2014-07-16 10:11:42 -07001142 SomeArgs args = (SomeArgs) msg.obj;
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001143 Log.continueSession((Session) args.arg2,
1144 SESSION_HANDLER + SESSION_ANSWER_VIDEO);
Andrew Lee8da4c3c2014-07-16 10:11:42 -07001145 try {
1146 String callId = (String) args.arg1;
Evan Charltonbf11f982014-07-20 22:06:28 -07001147 int videoState = args.argi1;
Tyler Gunnbe74de02014-08-29 14:51:48 -07001148 answerVideo(callId, videoState);
Andrew Lee8da4c3c2014-07-16 10:11:42 -07001149 } finally {
1150 args.recycle();
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001151 Log.endSession();
Andrew Lee8da4c3c2014-07-16 10:11:42 -07001152 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001153 break;
Andrew Lee8da4c3c2014-07-16 10:11:42 -07001154 }
Pooja Jaind34698d2017-12-28 14:15:31 +05301155 case MSG_DEFLECT: {
1156 SomeArgs args = (SomeArgs) msg.obj;
1157 Log.continueSession((Session) args.arg3, SESSION_HANDLER + SESSION_DEFLECT);
1158 try {
1159 deflect((String) args.arg1, (Uri) args.arg2);
1160 } finally {
1161 args.recycle();
1162 Log.endSession();
1163 }
1164 break;
1165 }
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001166 case MSG_REJECT: {
1167 SomeArgs args = (SomeArgs) msg.obj;
1168 Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_REJECT);
1169 try {
1170 reject((String) args.arg1);
1171 } finally {
1172 args.recycle();
1173 Log.endSession();
1174 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001175 break;
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001176 }
Tyler Gunnfacfdee2020-01-23 13:10:37 -08001177 case MSG_REJECT_WITH_REASON: {
1178 SomeArgs args = (SomeArgs) msg.obj;
1179 Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_REJECT);
1180 try {
1181 reject((String) args.arg1, args.argi1);
1182 } finally {
1183 args.recycle();
1184 Log.endSession();
1185 }
1186 break;
1187 }
Bryce Lee81901682015-08-28 16:38:02 -07001188 case MSG_REJECT_WITH_MESSAGE: {
1189 SomeArgs args = (SomeArgs) msg.obj;
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001190 Log.continueSession((Session) args.arg3,
1191 SESSION_HANDLER + SESSION_REJECT_MESSAGE);
Bryce Lee81901682015-08-28 16:38:02 -07001192 try {
1193 reject((String) args.arg1, (String) args.arg2);
1194 } finally {
1195 args.recycle();
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001196 Log.endSession();
Bryce Lee81901682015-08-28 16:38:02 -07001197 }
1198 break;
1199 }
Ravi Palurif4b38e72020-02-05 12:35:41 +05301200 case MSG_EXPLICIT_CALL_TRANSFER: {
1201 SomeArgs args = (SomeArgs) msg.obj;
1202 Log.continueSession((Session) args.arg3, SESSION_HANDLER + SESSION_TRANSFER);
1203 try {
1204 final boolean isConfirmationRequired = args.argi1 == 1;
1205 transfer((String) args.arg1, (Uri) args.arg2, isConfirmationRequired);
1206 } finally {
1207 args.recycle();
1208 Log.endSession();
1209 }
1210 break;
1211 }
1212 case MSG_EXPLICIT_CALL_TRANSFER_CONSULTATIVE: {
1213 SomeArgs args = (SomeArgs) msg.obj;
1214 Log.continueSession(
1215 (Session) args.arg3, SESSION_HANDLER + SESSION_CONSULTATIVE_TRANSFER);
1216 try {
1217 consultativeTransfer((String) args.arg1, (String) args.arg2);
1218 } finally {
1219 args.recycle();
1220 Log.endSession();
1221 }
1222 break;
1223 }
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001224 case MSG_DISCONNECT: {
1225 SomeArgs args = (SomeArgs) msg.obj;
1226 Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_DISCONNECT);
1227 try {
1228 disconnect((String) args.arg1);
1229 } finally {
1230 args.recycle();
1231 Log.endSession();
1232 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001233 break;
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001234 }
1235 case MSG_SILENCE: {
1236 SomeArgs args = (SomeArgs) msg.obj;
1237 Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_SILENCE);
1238 try {
1239 silence((String) args.arg1);
1240 } finally {
1241 args.recycle();
1242 Log.endSession();
1243 }
Bryce Leecac50772015-11-17 15:13:29 -08001244 break;
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001245 }
1246 case MSG_HOLD: {
1247 SomeArgs args = (SomeArgs) msg.obj;
1248 Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_REJECT);
1249 try {
1250 hold((String) args.arg1);
1251 } finally {
1252 args.recycle();
1253 Log.endSession();
1254 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001255 break;
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001256 }
1257 case MSG_UNHOLD: {
1258 SomeArgs args = (SomeArgs) msg.obj;
1259 Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_UNHOLD);
1260 try {
1261 unhold((String) args.arg1);
1262 } finally {
1263 args.recycle();
1264 Log.endSession();
1265 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001266 break;
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001267 }
Yorke Lee4af59352015-05-13 14:14:54 -07001268 case MSG_ON_CALL_AUDIO_STATE_CHANGED: {
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001269 SomeArgs args = (SomeArgs) msg.obj;
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001270 Log.continueSession((Session) args.arg3,
1271 SESSION_HANDLER + SESSION_CALL_AUDIO_SC);
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001272 try {
1273 String callId = (String) args.arg1;
Yorke Lee4af59352015-05-13 14:14:54 -07001274 CallAudioState audioState = (CallAudioState) args.arg2;
1275 onCallAudioStateChanged(callId, new CallAudioState(audioState));
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001276 } finally {
1277 args.recycle();
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001278 Log.endSession();
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001279 }
1280 break;
1281 }
Grace Jiae99fde92021-01-19 14:58:01 -08001282 case MSG_ON_USING_ALTERNATIVE_UI: {
1283 SomeArgs args = (SomeArgs) msg.obj;
1284 Log.continueSession((Session) args.arg3,
1285 SESSION_HANDLER + SESSION_USING_ALTERNATIVE_UI);
1286 try {
1287 String callId = (String) args.arg1;
1288 boolean isUsingAlternativeUi = (boolean) args.arg2;
1289 onUsingAlternativeUi(callId, isUsingAlternativeUi);
1290 } finally {
1291 args.recycle();
1292 Log.endSession();
1293 }
1294 break;
1295 }
1296 case MSG_ON_TRACKED_BY_NON_UI_SERVICE: {
1297 SomeArgs args = (SomeArgs) msg.obj;
1298 Log.continueSession((Session) args.arg3,
1299 SESSION_HANDLER + SESSION_TRACKED_BY_NON_UI_SERVICE);
1300 try {
1301 String callId = (String) args.arg1;
1302 boolean isTracked = (boolean) args.arg2;
1303 onTrackedByNonUiService(callId, isTracked);
1304 } finally {
1305 args.recycle();
1306 Log.endSession();
1307 }
1308 break;
1309 }
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001310 case MSG_PLAY_DTMF_TONE: {
1311 SomeArgs args = (SomeArgs) msg.obj;
1312 try {
1313 Log.continueSession((Session) args.arg3,
1314 SESSION_HANDLER + SESSION_PLAY_DTMF);
1315 playDtmfTone((String) args.arg2, (char) args.arg1);
1316 } finally {
1317 args.recycle();
1318 Log.endSession();
1319 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001320 break;
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001321 }
1322 case MSG_STOP_DTMF_TONE: {
1323 SomeArgs args = (SomeArgs) msg.obj;
1324 try {
1325 Log.continueSession((Session) args.arg2,
1326 SESSION_HANDLER + SESSION_STOP_DTMF);
1327 stopDtmfTone((String) args.arg1);
1328 } finally {
1329 args.recycle();
1330 Log.endSession();
1331 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001332 break;
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001333 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001334 case MSG_CONFERENCE: {
1335 SomeArgs args = (SomeArgs) msg.obj;
1336 try {
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001337 Log.continueSession((Session) args.arg3,
1338 SESSION_HANDLER + SESSION_CONFERENCE);
Santos Cordon823fd3c2014-08-07 18:35:18 -07001339 String callId1 = (String) args.arg1;
1340 String callId2 = (String) args.arg2;
1341 conference(callId1, callId2);
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001342 } finally {
1343 args.recycle();
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001344 Log.endSession();
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001345 }
1346 break;
1347 }
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001348 case MSG_SPLIT_FROM_CONFERENCE: {
1349 SomeArgs args = (SomeArgs) msg.obj;
1350 try {
1351 Log.continueSession((Session) args.arg2,
1352 SESSION_HANDLER + SESSION_SPLIT_CONFERENCE);
1353 splitFromConference((String) args.arg1);
1354 } finally {
1355 args.recycle();
1356 Log.endSession();
1357 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001358 break;
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001359 }
1360 case MSG_MERGE_CONFERENCE: {
1361 SomeArgs args = (SomeArgs) msg.obj;
1362 try {
1363 Log.continueSession((Session) args.arg2,
1364 SESSION_HANDLER + SESSION_MERGE_CONFERENCE);
1365 mergeConference((String) args.arg1);
1366 } finally {
1367 args.recycle();
1368 Log.endSession();
1369 }
Santos Cordona4868042014-09-04 17:39:22 -07001370 break;
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001371 }
1372 case MSG_SWAP_CONFERENCE: {
1373 SomeArgs args = (SomeArgs) msg.obj;
1374 try {
1375 Log.continueSession((Session) args.arg2,
1376 SESSION_HANDLER + SESSION_SWAP_CONFERENCE);
1377 swapConference((String) args.arg1);
1378 } finally {
1379 args.recycle();
1380 Log.endSession();
1381 }
Santos Cordona4868042014-09-04 17:39:22 -07001382 break;
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001383 }
Ravi Paluri404babb2020-01-23 19:02:44 +05301384 case MSG_ADD_PARTICIPANT: {
1385 SomeArgs args = (SomeArgs) msg.obj;
1386 try {
1387 Log.continueSession((Session) args.arg3,
1388 SESSION_HANDLER + SESSION_ADD_PARTICIPANT);
1389 addConferenceParticipants((String) args.arg1, (List<Uri>)args.arg2);
1390 } finally {
1391 args.recycle();
1392 Log.endSession();
1393 }
1394 break;
1395 }
1396
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001397 case MSG_ON_POST_DIAL_CONTINUE: {
1398 SomeArgs args = (SomeArgs) msg.obj;
1399 try {
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001400 Log.continueSession((Session) args.arg2,
1401 SESSION_HANDLER + SESSION_POST_DIAL_CONT);
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001402 String callId = (String) args.arg1;
1403 boolean proceed = (args.argi1 == 1);
1404 onPostDialContinue(callId, proceed);
1405 } finally {
1406 args.recycle();
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001407 Log.endSession();
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001408 }
1409 break;
1410 }
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001411 case MSG_PULL_EXTERNAL_CALL: {
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001412 SomeArgs args = (SomeArgs) msg.obj;
1413 try {
1414 Log.continueSession((Session) args.arg2,
1415 SESSION_HANDLER + SESSION_PULL_EXTERNAL_CALL);
1416 pullExternalCall((String) args.arg1);
1417 } finally {
1418 args.recycle();
1419 Log.endSession();
1420 }
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001421 break;
1422 }
1423 case MSG_SEND_CALL_EVENT: {
1424 SomeArgs args = (SomeArgs) msg.obj;
1425 try {
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001426 Log.continueSession((Session) args.arg4,
1427 SESSION_HANDLER + SESSION_SEND_CALL_EVENT);
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001428 String callId = (String) args.arg1;
1429 String event = (String) args.arg2;
1430 Bundle extras = (Bundle) args.arg3;
1431 sendCallEvent(callId, event, extras);
1432 } finally {
1433 args.recycle();
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001434 Log.endSession();
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001435 }
1436 break;
1437 }
Hall Liu49cabcc2021-01-15 11:41:48 -08001438 case MSG_ON_CALL_FILTERING_COMPLETED: {
1439 SomeArgs args = (SomeArgs) msg.obj;
1440 try {
Hall Liu73903142021-02-18 18:41:41 -08001441 Log.continueSession((Session) args.arg3,
Hall Liu49cabcc2021-01-15 11:41:48 -08001442 SESSION_HANDLER + SESSION_CALL_FILTERING_COMPLETED);
1443 String callId = (String) args.arg1;
Hall Liu73903142021-02-18 18:41:41 -08001444 Connection.CallFilteringCompletionInfo completionInfo =
1445 (Connection.CallFilteringCompletionInfo) args.arg2;
1446 onCallFilteringCompleted(callId, completionInfo);
Hall Liu49cabcc2021-01-15 11:41:48 -08001447 } finally {
1448 args.recycle();
1449 Log.endSession();
1450 }
1451 break;
1452 }
Tyler Gunn79bc1ec2018-01-22 15:17:54 -08001453 case MSG_HANDOVER_COMPLETE: {
1454 SomeArgs args = (SomeArgs) msg.obj;
1455 try {
1456 Log.continueSession((Session) args.arg2,
1457 SESSION_HANDLER + SESSION_HANDOVER_COMPLETE);
1458 String callId = (String) args.arg1;
1459 notifyHandoverComplete(callId);
1460 } finally {
1461 args.recycle();
1462 Log.endSession();
1463 }
1464 break;
1465 }
Tyler Gunndee56a82016-03-23 16:06:34 -07001466 case MSG_ON_EXTRAS_CHANGED: {
1467 SomeArgs args = (SomeArgs) msg.obj;
1468 try {
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001469 Log.continueSession((Session) args.arg3,
1470 SESSION_HANDLER + SESSION_EXTRAS_CHANGED);
Tyler Gunndee56a82016-03-23 16:06:34 -07001471 String callId = (String) args.arg1;
1472 Bundle extras = (Bundle) args.arg2;
1473 handleExtrasChanged(callId, extras);
1474 } finally {
1475 args.recycle();
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001476 Log.endSession();
Tyler Gunndee56a82016-03-23 16:06:34 -07001477 }
1478 break;
1479 }
Hall Liub64ac4c2017-02-06 10:49:48 -08001480 case MSG_ON_START_RTT: {
1481 SomeArgs args = (SomeArgs) msg.obj;
1482 try {
1483 Log.continueSession((Session) args.arg3,
1484 SESSION_HANDLER + SESSION_START_RTT);
1485 String callId = (String) args.arg1;
1486 Connection.RttTextStream rttTextStream =
1487 (Connection.RttTextStream) args.arg2;
1488 startRtt(callId, rttTextStream);
1489 } finally {
1490 args.recycle();
1491 Log.endSession();
1492 }
1493 break;
1494 }
1495 case MSG_ON_STOP_RTT: {
1496 SomeArgs args = (SomeArgs) msg.obj;
1497 try {
1498 Log.continueSession((Session) args.arg2,
1499 SESSION_HANDLER + SESSION_STOP_RTT);
1500 String callId = (String) args.arg1;
1501 stopRtt(callId);
1502 } finally {
1503 args.recycle();
1504 Log.endSession();
1505 }
1506 break;
1507 }
1508 case MSG_RTT_UPGRADE_RESPONSE: {
1509 SomeArgs args = (SomeArgs) msg.obj;
1510 try {
1511 Log.continueSession((Session) args.arg3,
1512 SESSION_HANDLER + SESSION_RTT_UPGRADE_RESPONSE);
1513 String callId = (String) args.arg1;
1514 Connection.RttTextStream rttTextStream =
1515 (Connection.RttTextStream) args.arg2;
1516 handleRttUpgradeResponse(callId, rttTextStream);
1517 } finally {
1518 args.recycle();
1519 Log.endSession();
1520 }
1521 break;
1522 }
Pengquan Meng731c1a32017-11-21 18:01:13 -08001523 case MSG_CONNECTION_SERVICE_FOCUS_GAINED:
1524 onConnectionServiceFocusGained();
1525 break;
1526 case MSG_CONNECTION_SERVICE_FOCUS_LOST:
1527 onConnectionServiceFocusLost();
1528 break;
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001529 default:
1530 break;
1531 }
1532 }
1533 };
1534
Santos Cordon823fd3c2014-08-07 18:35:18 -07001535 private final Conference.Listener mConferenceListener = new Conference.Listener() {
1536 @Override
1537 public void onStateChanged(Conference conference, int oldState, int newState) {
1538 String id = mIdByConference.get(conference);
1539 switch (newState) {
Ravi Paluri80aa2142019-12-02 11:57:37 +05301540 case Connection.STATE_RINGING:
1541 mAdapter.setRinging(id);
1542 break;
1543 case Connection.STATE_DIALING:
1544 mAdapter.setDialing(id);
1545 break;
Santos Cordon823fd3c2014-08-07 18:35:18 -07001546 case Connection.STATE_ACTIVE:
1547 mAdapter.setActive(id);
1548 break;
1549 case Connection.STATE_HOLDING:
1550 mAdapter.setOnHold(id);
1551 break;
1552 case Connection.STATE_DISCONNECTED:
1553 // handled by onDisconnected
1554 break;
1555 }
1556 }
1557
1558 @Override
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001559 public void onDisconnected(Conference conference, DisconnectCause disconnectCause) {
Santos Cordon823fd3c2014-08-07 18:35:18 -07001560 String id = mIdByConference.get(conference);
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001561 mAdapter.setDisconnected(id, disconnectCause);
Santos Cordon823fd3c2014-08-07 18:35:18 -07001562 }
1563
1564 @Override
1565 public void onConnectionAdded(Conference conference, Connection connection) {
1566 }
1567
1568 @Override
1569 public void onConnectionRemoved(Conference conference, Connection connection) {
1570 }
1571
1572 @Override
Ihab Awad50e35062014-09-30 09:17:03 -07001573 public void onConferenceableConnectionsChanged(
1574 Conference conference, List<Connection> conferenceableConnections) {
1575 mAdapter.setConferenceableConnections(
1576 mIdByConference.get(conference),
1577 createConnectionIdList(conferenceableConnections));
1578 }
1579
1580 @Override
Santos Cordon823fd3c2014-08-07 18:35:18 -07001581 public void onDestroyed(Conference conference) {
1582 removeConference(conference);
1583 }
1584
1585 @Override
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001586 public void onConnectionCapabilitiesChanged(
1587 Conference conference,
1588 int connectionCapabilities) {
Santos Cordon823fd3c2014-08-07 18:35:18 -07001589 String id = mIdByConference.get(conference);
1590 Log.d(this, "call capabilities: conference: %s",
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001591 Connection.capabilitiesToString(connectionCapabilities));
1592 mAdapter.setConnectionCapabilities(id, connectionCapabilities);
Santos Cordon823fd3c2014-08-07 18:35:18 -07001593 }
Rekha Kumar07366812015-03-24 16:42:31 -07001594
1595 @Override
Tyler Gunn720c6642016-03-22 09:02:47 -07001596 public void onConnectionPropertiesChanged(
1597 Conference conference,
1598 int connectionProperties) {
1599 String id = mIdByConference.get(conference);
1600 Log.d(this, "call capabilities: conference: %s",
1601 Connection.propertiesToString(connectionProperties));
1602 mAdapter.setConnectionProperties(id, connectionProperties);
1603 }
1604
1605 @Override
Rekha Kumar07366812015-03-24 16:42:31 -07001606 public void onVideoStateChanged(Conference c, int videoState) {
1607 String id = mIdByConference.get(c);
1608 Log.d(this, "onVideoStateChanged set video state %d", videoState);
1609 mAdapter.setVideoState(id, videoState);
1610 }
1611
1612 @Override
1613 public void onVideoProviderChanged(Conference c, Connection.VideoProvider videoProvider) {
1614 String id = mIdByConference.get(c);
1615 Log.d(this, "onVideoProviderChanged: Connection: %s, VideoProvider: %s", c,
1616 videoProvider);
1617 mAdapter.setVideoProvider(id, videoProvider);
1618 }
Andrew Lee0f51da32015-04-16 13:11:55 -07001619
1620 @Override
Andrew Leeedc625f2015-04-14 13:38:12 -07001621 public void onStatusHintsChanged(Conference conference, StatusHints statusHints) {
1622 String id = mIdByConference.get(conference);
Tyler Gunndee56a82016-03-23 16:06:34 -07001623 if (id != null) {
1624 mAdapter.setStatusHints(id, statusHints);
1625 }
Andrew Leeedc625f2015-04-14 13:38:12 -07001626 }
Santos Cordon6b7f9552015-05-27 17:21:45 -07001627
1628 @Override
Tyler Gunndee56a82016-03-23 16:06:34 -07001629 public void onExtrasChanged(Conference c, Bundle extras) {
1630 String id = mIdByConference.get(c);
1631 if (id != null) {
1632 mAdapter.putExtras(id, extras);
1633 }
1634 }
1635
1636 @Override
1637 public void onExtrasRemoved(Conference c, List<String> keys) {
1638 String id = mIdByConference.get(c);
1639 if (id != null) {
1640 mAdapter.removeExtras(id, keys);
1641 }
Santos Cordon6b7f9552015-05-27 17:21:45 -07001642 }
Tyler Gunn68a73a42018-10-03 15:38:57 -07001643
1644 @Override
1645 public void onConferenceStateChanged(Conference c, boolean isConference) {
1646 String id = mIdByConference.get(c);
1647 if (id != null) {
1648 mAdapter.setConferenceState(id, isConference);
1649 }
1650 }
1651
1652 @Override
Brad Ebingere0c12f42020-04-08 16:25:12 -07001653 public void onCallDirectionChanged(Conference c, int direction) {
1654 String id = mIdByConference.get(c);
1655 if (id != null) {
1656 mAdapter.setCallDirection(id, direction);
1657 }
1658 }
1659
1660 @Override
Tyler Gunn68a73a42018-10-03 15:38:57 -07001661 public void onAddressChanged(Conference c, Uri newAddress, int presentation) {
1662 String id = mIdByConference.get(c);
1663 if (id != null) {
1664 mAdapter.setAddress(id, newAddress, presentation);
1665 }
1666 }
1667
1668 @Override
1669 public void onCallerDisplayNameChanged(Conference c, String callerDisplayName,
1670 int presentation) {
1671 String id = mIdByConference.get(c);
1672 if (id != null) {
1673 mAdapter.setCallerDisplayName(id, callerDisplayName, presentation);
1674 }
1675 }
Hall Liuc9bc1c62019-04-16 14:00:55 -07001676
1677 @Override
1678 public void onConnectionEvent(Conference c, String event, Bundle extras) {
1679 String id = mIdByConference.get(c);
1680 if (id != null) {
1681 mAdapter.onConnectionEvent(id, event, extras);
1682 }
1683 }
Ravi Paluri80aa2142019-12-02 11:57:37 +05301684
1685 @Override
1686 public void onRingbackRequested(Conference c, boolean ringback) {
1687 String id = mIdByConference.get(c);
1688 Log.d(this, "Adapter conference onRingback %b", ringback);
1689 mAdapter.setRingbackRequested(id, ringback);
1690 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07001691 };
1692
Ihab Awad542e0ea2014-05-16 10:22:16 -07001693 private final Connection.Listener mConnectionListener = new Connection.Listener() {
1694 @Override
1695 public void onStateChanged(Connection c, int state) {
1696 String id = mIdByConnection.get(c);
Ihab Awad42b30e12014-05-22 09:49:34 -07001697 Log.d(this, "Adapter set state %s %s", id, Connection.stateToString(state));
Ihab Awad542e0ea2014-05-16 10:22:16 -07001698 switch (state) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001699 case Connection.STATE_ACTIVE:
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001700 mAdapter.setActive(id);
Ihab Awad542e0ea2014-05-16 10:22:16 -07001701 break;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001702 case Connection.STATE_DIALING:
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001703 mAdapter.setDialing(id);
Ihab Awad542e0ea2014-05-16 10:22:16 -07001704 break;
Tyler Gunnc96b5e02016-07-07 22:53:57 -07001705 case Connection.STATE_PULLING_CALL:
1706 mAdapter.setPulling(id);
1707 break;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001708 case Connection.STATE_DISCONNECTED:
Ihab Awad542e0ea2014-05-16 10:22:16 -07001709 // Handled in onDisconnected()
1710 break;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001711 case Connection.STATE_HOLDING:
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001712 mAdapter.setOnHold(id);
Ihab Awad542e0ea2014-05-16 10:22:16 -07001713 break;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001714 case Connection.STATE_NEW:
Tyler Gunnef9f6f92014-09-12 22:16:17 -07001715 // Nothing to tell Telecom
Ihab Awad542e0ea2014-05-16 10:22:16 -07001716 break;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001717 case Connection.STATE_RINGING:
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001718 mAdapter.setRinging(id);
Ihab Awad542e0ea2014-05-16 10:22:16 -07001719 break;
1720 }
1721 }
1722
1723 @Override
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001724 public void onDisconnected(Connection c, DisconnectCause disconnectCause) {
Ihab Awad542e0ea2014-05-16 10:22:16 -07001725 String id = mIdByConnection.get(c);
Andrew Lee26786392014-09-16 18:14:59 -07001726 Log.d(this, "Adapter set disconnected %s", disconnectCause);
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001727 mAdapter.setDisconnected(id, disconnectCause);
Ihab Awad542e0ea2014-05-16 10:22:16 -07001728 }
1729
1730 @Override
Tyler Gunnaa07df82014-07-17 07:50:22 -07001731 public void onVideoStateChanged(Connection c, int videoState) {
1732 String id = mIdByConnection.get(c);
1733 Log.d(this, "Adapter set video state %d", videoState);
1734 mAdapter.setVideoState(id, videoState);
1735 }
1736
1737 @Override
Andrew Lee100e2932014-09-08 15:34:24 -07001738 public void onAddressChanged(Connection c, Uri address, int presentation) {
Sailesh Nepal61203862014-07-11 14:50:13 -07001739 String id = mIdByConnection.get(c);
Andrew Lee100e2932014-09-08 15:34:24 -07001740 mAdapter.setAddress(id, address, presentation);
Sailesh Nepal61203862014-07-11 14:50:13 -07001741 }
1742
1743 @Override
1744 public void onCallerDisplayNameChanged(
1745 Connection c, String callerDisplayName, int presentation) {
1746 String id = mIdByConnection.get(c);
1747 mAdapter.setCallerDisplayName(id, callerDisplayName, presentation);
Ihab Awad542e0ea2014-05-16 10:22:16 -07001748 }
1749
1750 @Override
Ihab Awad542e0ea2014-05-16 10:22:16 -07001751 public void onDestroyed(Connection c) {
1752 removeConnection(c);
1753 }
Ihab Awadf8358972014-05-28 16:46:42 -07001754
1755 @Override
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001756 public void onPostDialWait(Connection c, String remaining) {
Sailesh Nepal091768c2014-06-30 15:15:23 -07001757 String id = mIdByConnection.get(c);
1758 Log.d(this, "Adapter onPostDialWait %s, %s", c, remaining);
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001759 mAdapter.onPostDialWait(id, remaining);
Sailesh Nepal091768c2014-06-30 15:15:23 -07001760 }
1761
1762 @Override
Nancy Chen27d1c2d2014-12-15 16:12:50 -08001763 public void onPostDialChar(Connection c, char nextChar) {
1764 String id = mIdByConnection.get(c);
1765 Log.d(this, "Adapter onPostDialChar %s, %s", c, nextChar);
1766 mAdapter.onPostDialChar(id, nextChar);
1767 }
1768
1769 @Override
Andrew Lee100e2932014-09-08 15:34:24 -07001770 public void onRingbackRequested(Connection c, boolean ringback) {
Ihab Awadf8358972014-05-28 16:46:42 -07001771 String id = mIdByConnection.get(c);
1772 Log.d(this, "Adapter onRingback %b", ringback);
Andrew Lee100e2932014-09-08 15:34:24 -07001773 mAdapter.setRingbackRequested(id, ringback);
Ihab Awadf8358972014-05-28 16:46:42 -07001774 }
Santos Cordonb6939982014-06-04 20:20:58 -07001775
1776 @Override
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001777 public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {
Santos Cordonb6939982014-06-04 20:20:58 -07001778 String id = mIdByConnection.get(c);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001779 Log.d(this, "capabilities: parcelableconnection: %s",
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001780 Connection.capabilitiesToString(capabilities));
1781 mAdapter.setConnectionCapabilities(id, capabilities);
Santos Cordonb6939982014-06-04 20:20:58 -07001782 }
1783
Santos Cordonb6939982014-06-04 20:20:58 -07001784 @Override
Tyler Gunn720c6642016-03-22 09:02:47 -07001785 public void onConnectionPropertiesChanged(Connection c, int properties) {
1786 String id = mIdByConnection.get(c);
1787 Log.d(this, "properties: parcelableconnection: %s",
1788 Connection.propertiesToString(properties));
1789 mAdapter.setConnectionProperties(id, properties);
1790 }
1791
1792 @Override
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001793 public void onVideoProviderChanged(Connection c, Connection.VideoProvider videoProvider) {
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07001794 String id = mIdByConnection.get(c);
Rekha Kumar07366812015-03-24 16:42:31 -07001795 Log.d(this, "onVideoProviderChanged: Connection: %s, VideoProvider: %s", c,
1796 videoProvider);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001797 mAdapter.setVideoProvider(id, videoProvider);
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07001798 }
Sailesh Nepal33aaae42014-07-07 22:49:44 -07001799
1800 @Override
Sailesh Nepal001bbbb2014-07-15 14:40:39 -07001801 public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {
Sailesh Nepal33aaae42014-07-07 22:49:44 -07001802 String id = mIdByConnection.get(c);
Andrew Lee100e2932014-09-08 15:34:24 -07001803 mAdapter.setIsVoipAudioMode(id, isVoip);
Sailesh Nepal33aaae42014-07-07 22:49:44 -07001804 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07001805
1806 @Override
Sailesh Nepal001bbbb2014-07-15 14:40:39 -07001807 public void onStatusHintsChanged(Connection c, StatusHints statusHints) {
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07001808 String id = mIdByConnection.get(c);
1809 mAdapter.setStatusHints(id, statusHints);
1810 }
Sailesh Nepal2ab88cc2014-07-18 14:49:18 -07001811
1812 @Override
Tyler Gunn6d76ca02014-11-17 15:49:51 -08001813 public void onConferenceablesChanged(
Tyler Gunndf2cbc82015-04-20 09:13:01 -07001814 Connection connection, List<Conferenceable> conferenceables) {
Ihab Awadb8e85c72014-08-23 20:34:57 -07001815 mAdapter.setConferenceableConnections(
1816 mIdByConnection.get(connection),
Tyler Gunn6d76ca02014-11-17 15:49:51 -08001817 createIdList(conferenceables));
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07001818 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07001819
1820 @Override
1821 public void onConferenceChanged(Connection connection, Conference conference) {
1822 String id = mIdByConnection.get(connection);
1823 if (id != null) {
1824 String conferenceId = null;
1825 if (conference != null) {
1826 conferenceId = mIdByConference.get(conference);
1827 }
1828 mAdapter.setIsConferenced(id, conferenceId);
1829 }
1830 }
Anthony Lee17455a32015-04-24 15:25:29 -07001831
1832 @Override
1833 public void onConferenceMergeFailed(Connection connection) {
1834 String id = mIdByConnection.get(connection);
1835 if (id != null) {
1836 mAdapter.onConferenceMergeFailed(id);
1837 }
1838 }
Santos Cordon6b7f9552015-05-27 17:21:45 -07001839
1840 @Override
Tyler Gunndee56a82016-03-23 16:06:34 -07001841 public void onExtrasChanged(Connection c, Bundle extras) {
1842 String id = mIdByConnection.get(c);
Santos Cordon6b7f9552015-05-27 17:21:45 -07001843 if (id != null) {
Tyler Gunndee56a82016-03-23 16:06:34 -07001844 mAdapter.putExtras(id, extras);
Santos Cordon6b7f9552015-05-27 17:21:45 -07001845 }
1846 }
Brad Ebingerb32d4f82016-10-24 16:40:49 -07001847
Tyler Gunnf5035432017-01-09 09:43:12 -08001848 @Override
Tyler Gunndee56a82016-03-23 16:06:34 -07001849 public void onExtrasRemoved(Connection c, List<String> keys) {
1850 String id = mIdByConnection.get(c);
1851 if (id != null) {
1852 mAdapter.removeExtras(id, keys);
1853 }
1854 }
1855
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08001856 @Override
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001857 public void onConnectionEvent(Connection connection, String event, Bundle extras) {
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08001858 String id = mIdByConnection.get(connection);
1859 if (id != null) {
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001860 mAdapter.onConnectionEvent(id, event, extras);
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08001861 }
1862 }
Tyler Gunnf5035432017-01-09 09:43:12 -08001863
1864 @Override
Hall Liua98f58b52017-11-07 17:59:28 -08001865 public void onAudioRouteChanged(Connection c, int audioRoute, String bluetoothAddress) {
Tyler Gunnf5035432017-01-09 09:43:12 -08001866 String id = mIdByConnection.get(c);
1867 if (id != null) {
Hall Liua98f58b52017-11-07 17:59:28 -08001868 mAdapter.setAudioRoute(id, audioRoute, bluetoothAddress);
Tyler Gunnf5035432017-01-09 09:43:12 -08001869 }
1870 }
Hall Liub64ac4c2017-02-06 10:49:48 -08001871
1872 @Override
1873 public void onRttInitiationSuccess(Connection c) {
1874 String id = mIdByConnection.get(c);
1875 if (id != null) {
1876 mAdapter.onRttInitiationSuccess(id);
1877 }
1878 }
1879
1880 @Override
1881 public void onRttInitiationFailure(Connection c, int reason) {
1882 String id = mIdByConnection.get(c);
1883 if (id != null) {
1884 mAdapter.onRttInitiationFailure(id, reason);
1885 }
1886 }
1887
1888 @Override
1889 public void onRttSessionRemotelyTerminated(Connection c) {
1890 String id = mIdByConnection.get(c);
1891 if (id != null) {
1892 mAdapter.onRttSessionRemotelyTerminated(id);
1893 }
1894 }
1895
1896 @Override
1897 public void onRemoteRttRequest(Connection c) {
1898 String id = mIdByConnection.get(c);
1899 if (id != null) {
1900 mAdapter.onRemoteRttRequest(id);
1901 }
1902 }
Srikanth Chintalafcb15012017-05-04 20:58:34 +05301903
1904 @Override
1905 public void onPhoneAccountChanged(Connection c, PhoneAccountHandle pHandle) {
1906 String id = mIdByConnection.get(c);
1907 if (id != null) {
1908 mAdapter.onPhoneAccountChanged(id, pHandle);
1909 }
1910 }
Mengjun Leng25707742017-07-04 11:10:37 +08001911
1912 public void onConnectionTimeReset(Connection c) {
1913 String id = mIdByConnection.get(c);
1914 if (id != null) {
1915 mAdapter.resetConnectionTime(id);
1916 }
1917 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07001918 };
1919
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001920 /** {@inheritDoc} */
Ihab Awad542e0ea2014-05-16 10:22:16 -07001921 @Override
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001922 public final IBinder onBind(Intent intent) {
Hall Liueb7c9ea2021-03-09 20:24:50 -08001923 onBindClient(intent);
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001924 return mBinder;
1925 }
1926
Santos Cordon29f2f2e2014-09-11 19:50:24 -07001927 /** {@inheritDoc} */
1928 @Override
1929 public boolean onUnbind(Intent intent) {
1930 endAllConnections();
1931 return super.onUnbind(intent);
1932 }
1933
Hall Liueb7c9ea2021-03-09 20:24:50 -08001934 /**
1935 * Used for testing to let the test suite know when the connection service has been bound.
1936 * @hide
1937 */
1938 @TestApi
1939 public void onBindClient(@Nullable Intent intent) {
1940 }
Ravi Paluri80aa2142019-12-02 11:57:37 +05301941
1942 /**
1943 * This can be used by telecom to either create a new outgoing conference call or attach
1944 * to an existing incoming conference call. In either case, telecom will cycle through a
1945 * set of services and call createConference until a connection service cancels the process
1946 * or completes it successfully.
1947 */
1948 private void createConference(
1949 final PhoneAccountHandle callManagerAccount,
1950 final String callId,
1951 final ConnectionRequest request,
1952 boolean isIncoming,
1953 boolean isUnknown) {
1954
1955 Conference conference = null;
1956 conference = isIncoming ? onCreateIncomingConference(callManagerAccount, request)
1957 : onCreateOutgoingConference(callManagerAccount, request);
1958
1959 Log.d(this, "createConference, conference: %s", conference);
1960 if (conference == null) {
1961 Log.i(this, "createConference, implementation returned null conference.");
1962 conference = Conference.createFailedConference(
1963 new DisconnectCause(DisconnectCause.ERROR, "IMPL_RETURNED_NULL_CONFERENCE"),
1964 request.getAccountHandle());
1965 }
Tyler Gunnc59fd0c2020-04-17 14:03:35 -07001966
1967 Bundle extras = request.getExtras();
1968 Bundle newExtras = new Bundle();
1969 newExtras.putString(Connection.EXTRA_ORIGINAL_CONNECTION_ID, callId);
1970 if (extras != null) {
1971 // If the request originated from a remote connection service, we will add some
1972 // tracking information that Telecom can use to keep informed of which package
1973 // made the remote request, and which remote connection service was used.
1974 if (extras.containsKey(Connection.EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME)) {
1975 newExtras.putString(
1976 Connection.EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME,
1977 extras.getString(
1978 Connection.EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME));
1979 newExtras.putParcelable(Connection.EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE,
1980 request.getAccountHandle());
1981 }
Ravi Paluri80aa2142019-12-02 11:57:37 +05301982 }
Tyler Gunnc59fd0c2020-04-17 14:03:35 -07001983 conference.putExtras(newExtras);
1984
Ravi Paluri80aa2142019-12-02 11:57:37 +05301985 mConferenceById.put(callId, conference);
1986 mIdByConference.put(conference, callId);
Tyler Gunn460360d2020-07-29 10:21:45 -07001987
Ravi Paluri80aa2142019-12-02 11:57:37 +05301988 conference.addListener(mConferenceListener);
Brad Ebinger0ae44ed2020-04-09 15:30:57 -07001989 ParcelableConference parcelableConference = new ParcelableConference.Builder(
1990 request.getAccountHandle(), conference.getState())
1991 .setConnectionCapabilities(conference.getConnectionCapabilities())
1992 .setConnectionProperties(conference.getConnectionProperties())
1993 .setVideoAttributes(conference.getVideoProvider() == null
1994 ? null : conference.getVideoProvider().getInterface(),
1995 conference.getVideoState())
1996 .setConnectTimeMillis(conference.getConnectTimeMillis(),
1997 conference.getConnectionStartElapsedRealtimeMillis())
1998 .setStatusHints(conference.getStatusHints())
1999 .setExtras(conference.getExtras())
2000 .setAddress(conference.getAddress(), conference.getAddressPresentation())
2001 .setCallerDisplayName(conference.getCallerDisplayName(),
2002 conference.getCallerDisplayNamePresentation())
2003 .setDisconnectCause(conference.getDisconnectCause())
2004 .setRingbackRequested(conference.isRingbackRequested())
2005 .build();
Ravi Paluri80aa2142019-12-02 11:57:37 +05302006 if (conference.getState() != Connection.STATE_DISCONNECTED) {
2007 conference.setTelecomCallId(callId);
2008 mAdapter.setVideoProvider(callId, conference.getVideoProvider());
2009 mAdapter.setVideoState(callId, conference.getVideoState());
2010 onConferenceAdded(conference);
2011 }
2012
2013 Log.d(this, "createConference, calling handleCreateConferenceSuccessful %s", callId);
2014 mAdapter.handleCreateConferenceComplete(
2015 callId,
2016 request,
2017 parcelableConference);
2018 }
2019
Sailesh Nepalc5b01572014-07-14 16:29:44 -07002020 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002021 * This can be used by telecom to either create a new outgoing call or attach to an existing
2022 * incoming call. In either case, telecom will cycle through a set of services and call
Sailesh Nepalc5b01572014-07-14 16:29:44 -07002023 * createConnection util a connection service cancels the process or completes it successfully.
2024 */
Ihab Awadf8b69882014-07-25 15:14:01 -07002025 private void createConnection(
2026 final PhoneAccountHandle callManagerAccount,
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002027 final String callId,
Ihab Awadf8b69882014-07-25 15:14:01 -07002028 final ConnectionRequest request,
Yorke Leec3cf9822014-10-02 09:38:39 -07002029 boolean isIncoming,
2030 boolean isUnknown) {
Tyler Gunn79bc1ec2018-01-22 15:17:54 -08002031 boolean isLegacyHandover = request.getExtras() != null &&
2032 request.getExtras().getBoolean(TelecomManager.EXTRA_IS_HANDOVER, false);
2033 boolean isHandover = request.getExtras() != null && request.getExtras().getBoolean(
2034 TelecomManager.EXTRA_IS_HANDOVER_CONNECTION, false);
Grace Jiae99fde92021-01-19 14:58:01 -08002035 boolean addSelfManaged = request.getExtras() != null && request.getExtras().getBoolean(
Grace Jia8b22bb42021-02-02 15:37:32 -08002036 PhoneAccount.EXTRA_ADD_SELF_MANAGED_CALLS_TO_INCALLSERVICE, true);
Grace Jiae99fde92021-01-19 14:58:01 -08002037 Log.i(this, "createConnection, callManagerAccount: %s, callId: %s, request: %s, "
2038 + "isIncoming: %b, isUnknown: %b, isLegacyHandover: %b, isHandover: %b, "
2039 + " addSelfManaged: %b", callManagerAccount, callId, request, isIncoming,
2040 isUnknown, isLegacyHandover, isHandover, addSelfManaged);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002041
Sanket Padawee29a2662017-12-01 13:59:27 -08002042 Connection connection = null;
Tyler Gunn79bc1ec2018-01-22 15:17:54 -08002043 if (isHandover) {
2044 PhoneAccountHandle fromPhoneAccountHandle = request.getExtras() != null
2045 ? (PhoneAccountHandle) request.getExtras().getParcelable(
2046 TelecomManager.EXTRA_HANDOVER_FROM_PHONE_ACCOUNT) : null;
Sanket Padawee29a2662017-12-01 13:59:27 -08002047 if (!isIncoming) {
Tyler Gunn79bc1ec2018-01-22 15:17:54 -08002048 connection = onCreateOutgoingHandoverConnection(fromPhoneAccountHandle, request);
Sanket Padawee29a2662017-12-01 13:59:27 -08002049 } else {
Tyler Gunn79bc1ec2018-01-22 15:17:54 -08002050 connection = onCreateIncomingHandoverConnection(fromPhoneAccountHandle, request);
Sanket Padawee29a2662017-12-01 13:59:27 -08002051 }
2052 } else {
2053 connection = isUnknown ? onCreateUnknownConnection(callManagerAccount, request)
2054 : isIncoming ? onCreateIncomingConnection(callManagerAccount, request)
2055 : onCreateOutgoingConnection(callManagerAccount, request);
2056 }
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002057 Log.d(this, "createConnection, connection: %s", connection);
2058 if (connection == null) {
Tyler Gunnfba1a8e2017-12-19 15:23:59 -08002059 Log.i(this, "createConnection, implementation returned null connection.");
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002060 connection = Connection.createFailedConnection(
Tyler Gunnfba1a8e2017-12-19 15:23:59 -08002061 new DisconnectCause(DisconnectCause.ERROR, "IMPL_RETURNED_NULL_CONNECTION"));
Tyler Gunnc59fd0c2020-04-17 14:03:35 -07002062 } else {
2063 try {
2064 Bundle extras = request.getExtras();
2065 if (extras != null) {
2066 // If the request originated from a remote connection service, we will add some
2067 // tracking information that Telecom can use to keep informed of which package
2068 // made the remote request, and which remote connection service was used.
2069 if (extras.containsKey(
2070 Connection.EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME)) {
2071 Bundle newExtras = new Bundle();
2072 newExtras.putString(
2073 Connection.EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME,
2074 extras.getString(
2075 Connection.EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME
2076 ));
2077 newExtras.putParcelable(Connection.EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE,
2078 request.getAccountHandle());
2079 connection.putExtras(newExtras);
2080 }
2081 }
2082 } catch (UnsupportedOperationException ose) {
2083 // Do nothing; if the ConnectionService reported a failure it will be an instance
2084 // of an immutable Connection which we cannot edit, so we're out of luck.
2085 }
Sailesh Nepalc5b01572014-07-14 16:29:44 -07002086 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002087
Tyler Gunnf2e08b42018-05-24 10:44:44 -07002088 boolean isSelfManaged =
2089 (connection.getConnectionProperties() & Connection.PROPERTY_SELF_MANAGED)
2090 == Connection.PROPERTY_SELF_MANAGED;
2091 // Self-managed Connections should always use voip audio mode; we default here so that the
2092 // local state within the ConnectionService matches the default we assume in Telecom.
2093 if (isSelfManaged) {
2094 connection.setAudioModeIsVoip(true);
2095 }
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002096 connection.setTelecomCallId(callId);
Sungjae7f4137452020-09-16 17:01:54 +09002097 PhoneAccountHandle phoneAccountHandle = connection.getPhoneAccountHandle() == null
2098 ? request.getAccountHandle() : connection.getPhoneAccountHandle();
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002099 if (connection.getState() != Connection.STATE_DISCONNECTED) {
Sungjae7f4137452020-09-16 17:01:54 +09002100 addConnection(phoneAccountHandle, callId, connection);
Ihab Awad6107bab2014-08-18 09:23:25 -07002101 }
2102
Andrew Lee100e2932014-09-08 15:34:24 -07002103 Uri address = connection.getAddress();
2104 String number = address == null ? "null" : address.getSchemeSpecificPart();
Tyler Gunn720c6642016-03-22 09:02:47 -07002105 Log.v(this, "createConnection, number: %s, state: %s, capabilities: %s, properties: %s",
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002106 Connection.toLogSafePhoneNumber(number),
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002107 Connection.stateToString(connection.getState()),
Tyler Gunn720c6642016-03-22 09:02:47 -07002108 Connection.capabilitiesToString(connection.getConnectionCapabilities()),
2109 Connection.propertiesToString(connection.getConnectionProperties()));
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002110
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002111 Log.d(this, "createConnection, calling handleCreateConnectionSuccessful %s", callId);
Ihab Awad6107bab2014-08-18 09:23:25 -07002112 mAdapter.handleCreateConnectionComplete(
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002113 callId,
Evan Charltonbf11f982014-07-20 22:06:28 -07002114 request,
2115 new ParcelableConnection(
Sungjae7f4137452020-09-16 17:01:54 +09002116 phoneAccountHandle,
Evan Charltonbf11f982014-07-20 22:06:28 -07002117 connection.getState(),
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002118 connection.getConnectionCapabilities(),
Tyler Gunn720c6642016-03-22 09:02:47 -07002119 connection.getConnectionProperties(),
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002120 connection.getSupportedAudioRoutes(),
Andrew Lee100e2932014-09-08 15:34:24 -07002121 connection.getAddress(),
2122 connection.getAddressPresentation(),
Evan Charltonbf11f982014-07-20 22:06:28 -07002123 connection.getCallerDisplayName(),
2124 connection.getCallerDisplayNamePresentation(),
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002125 connection.getVideoProvider() == null ?
2126 null : connection.getVideoProvider().getInterface(),
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -07002127 connection.getVideoState(),
Andrew Lee100e2932014-09-08 15:34:24 -07002128 connection.isRingbackRequested(),
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -07002129 connection.getAudioModeIsVoip(),
Roshan Piuse927ec02015-07-15 15:47:21 -07002130 connection.getConnectTimeMillis(),
Tyler Gunnc9503d62020-01-27 10:30:51 -08002131 connection.getConnectionStartElapsedRealtimeMillis(),
Ihab Awad6107bab2014-08-18 09:23:25 -07002132 connection.getStatusHints(),
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002133 connection.getDisconnectCause(),
Santos Cordon6b7f9552015-05-27 17:21:45 -07002134 createIdList(connection.getConferenceables()),
Tyler Gunnd57d76c2019-09-24 14:53:23 -07002135 connection.getExtras(),
2136 connection.getCallerNumberVerificationStatus()));
Tyler Gunnf5035432017-01-09 09:43:12 -08002137
Tyler Gunnf2e08b42018-05-24 10:44:44 -07002138 if (isIncoming && request.shouldShowIncomingCallUi() && isSelfManaged) {
Tyler Gunnf5035432017-01-09 09:43:12 -08002139 // Tell ConnectionService to show its incoming call UX.
2140 connection.onShowIncomingCallUi();
2141 }
Shriram Ganesh6bf35ac2014-12-11 17:53:38 -08002142 if (isUnknown) {
2143 triggerConferenceRecalculate();
2144 }
Evan Charltonbf11f982014-07-20 22:06:28 -07002145 }
2146
Tyler Gunn159f35c2017-03-02 09:28:37 -08002147 private void createConnectionFailed(final PhoneAccountHandle callManagerAccount,
2148 final String callId, final ConnectionRequest request,
2149 boolean isIncoming) {
Tyler Gunn44e01912017-01-31 10:49:05 -08002150
2151 Log.i(this, "createConnectionFailed %s", callId);
2152 if (isIncoming) {
Tyler Gunn159f35c2017-03-02 09:28:37 -08002153 onCreateIncomingConnectionFailed(callManagerAccount, request);
Tyler Gunn44e01912017-01-31 10:49:05 -08002154 } else {
Tyler Gunn159f35c2017-03-02 09:28:37 -08002155 onCreateOutgoingConnectionFailed(callManagerAccount, request);
Tyler Gunn44e01912017-01-31 10:49:05 -08002156 }
2157 }
2158
Ravi Paluri80aa2142019-12-02 11:57:37 +05302159 private void createConferenceFailed(final PhoneAccountHandle callManagerAccount,
2160 final String callId, final ConnectionRequest request,
2161 boolean isIncoming) {
2162
2163 Log.i(this, "createConferenceFailed %s", callId);
2164 if (isIncoming) {
2165 onCreateIncomingConferenceFailed(callManagerAccount, request);
2166 } else {
2167 onCreateOutgoingConferenceFailed(callManagerAccount, request);
2168 }
2169 }
2170
Sanket Padawe4cc8ed52017-12-04 16:22:20 -08002171 private void handoverFailed(final String callId, final ConnectionRequest request,
2172 int reason) {
2173
2174 Log.i(this, "handoverFailed %s", callId);
2175 onHandoverFailed(request, reason);
2176 }
2177
Tyler Gunn041a1fe2017-05-12 10:04:49 -07002178 /**
2179 * Called by Telecom when the creation of a new Connection has completed and it is now added
2180 * to Telecom.
2181 * @param callId The ID of the connection.
2182 */
2183 private void notifyCreateConnectionComplete(final String callId) {
2184 Log.i(this, "notifyCreateConnectionComplete %s", callId);
Tyler Gunn0a88f2e2017-06-16 20:20:34 -07002185 if (callId == null) {
2186 // This could happen if the connection fails quickly and is removed from the
2187 // ConnectionService before Telecom sends the create connection complete callback.
2188 Log.w(this, "notifyCreateConnectionComplete: callId is null.");
2189 return;
2190 }
Tyler Gunn041a1fe2017-05-12 10:04:49 -07002191 onCreateConnectionComplete(findConnectionForAction(callId,
2192 "notifyCreateConnectionComplete"));
2193 }
2194
Ravi Paluri80aa2142019-12-02 11:57:37 +05302195 /**
2196 * Called by Telecom when the creation of a new Conference has completed and it is now added
2197 * to Telecom.
2198 * @param callId The ID of the connection.
2199 */
2200 private void notifyCreateConferenceComplete(final String callId) {
2201 Log.i(this, "notifyCreateConferenceComplete %s", callId);
2202 if (callId == null) {
2203 // This could happen if the conference fails quickly and is removed from the
2204 // ConnectionService before Telecom sends the create conference complete callback.
2205 Log.w(this, "notifyCreateConferenceComplete: callId is null.");
2206 return;
2207 }
2208 onCreateConferenceComplete(findConferenceForAction(callId,
2209 "notifyCreateConferenceComplete"));
2210 }
2211
2212
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002213 private void abort(String callId) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002214 Log.i(this, "abort %s", callId);
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002215 findConnectionForAction(callId, "abort").onAbort();
Ihab Awad542e0ea2014-05-16 10:22:16 -07002216 }
2217
Tyler Gunnbe74de02014-08-29 14:51:48 -07002218 private void answerVideo(String callId, int videoState) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002219 Log.i(this, "answerVideo %s", callId);
Ravi Paluri80aa2142019-12-02 11:57:37 +05302220 if (mConnectionById.containsKey(callId)) {
2221 findConnectionForAction(callId, "answer").onAnswer(videoState);
2222 } else {
2223 findConferenceForAction(callId, "answer").onAnswer(videoState);
2224 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002225 }
2226
Tyler Gunnbe74de02014-08-29 14:51:48 -07002227 private void answer(String callId) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002228 Log.i(this, "answer %s", callId);
Ravi Paluri80aa2142019-12-02 11:57:37 +05302229 if (mConnectionById.containsKey(callId)) {
2230 findConnectionForAction(callId, "answer").onAnswer();
2231 } else {
2232 findConferenceForAction(callId, "answer").onAnswer();
2233 }
Tyler Gunnbe74de02014-08-29 14:51:48 -07002234 }
2235
Pooja Jaind34698d2017-12-28 14:15:31 +05302236 private void deflect(String callId, Uri address) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002237 Log.i(this, "deflect %s", callId);
Pooja Jaind34698d2017-12-28 14:15:31 +05302238 findConnectionForAction(callId, "deflect").onDeflect(address);
2239 }
2240
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002241 private void reject(String callId) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002242 Log.i(this, "reject %s", callId);
Ravi Paluri80aa2142019-12-02 11:57:37 +05302243 if (mConnectionById.containsKey(callId)) {
2244 findConnectionForAction(callId, "reject").onReject();
2245 } else {
2246 findConferenceForAction(callId, "reject").onReject();
2247 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002248 }
2249
Bryce Lee81901682015-08-28 16:38:02 -07002250 private void reject(String callId, String rejectWithMessage) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002251 Log.i(this, "reject %s with message", callId);
Bryce Lee81901682015-08-28 16:38:02 -07002252 findConnectionForAction(callId, "reject").onReject(rejectWithMessage);
2253 }
2254
Tyler Gunnfacfdee2020-01-23 13:10:37 -08002255 private void reject(String callId, @android.telecom.Call.RejectReason int rejectReason) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002256 Log.i(this, "reject %s with reason %d", callId, rejectReason);
Tyler Gunnfacfdee2020-01-23 13:10:37 -08002257 findConnectionForAction(callId, "reject").onReject(rejectReason);
2258 }
2259
Ravi Palurif4b38e72020-02-05 12:35:41 +05302260 private void transfer(String callId, Uri number, boolean isConfirmationRequired) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002261 Log.i(this, "transfer %s", callId);
Ravi Palurif4b38e72020-02-05 12:35:41 +05302262 findConnectionForAction(callId, "transfer").onTransfer(number, isConfirmationRequired);
2263 }
2264
2265 private void consultativeTransfer(String callId, String otherCallId) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002266 Log.i(this, "consultativeTransfer %s", callId);
Ravi Palurif4b38e72020-02-05 12:35:41 +05302267 Connection connection1 = findConnectionForAction(callId, "consultativeTransfer");
2268 Connection connection2 = findConnectionForAction(otherCallId, " consultativeTransfer");
2269 connection1.onTransfer(connection2);
2270 }
2271
Bryce Leecac50772015-11-17 15:13:29 -08002272 private void silence(String callId) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002273 Log.i(this, "silence %s", callId);
Bryce Leecac50772015-11-17 15:13:29 -08002274 findConnectionForAction(callId, "silence").onSilence();
2275 }
2276
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002277 private void disconnect(String callId) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002278 Log.i(this, "disconnect %s", callId);
Santos Cordon0159ac02014-08-21 14:28:11 -07002279 if (mConnectionById.containsKey(callId)) {
2280 findConnectionForAction(callId, "disconnect").onDisconnect();
2281 } else {
2282 findConferenceForAction(callId, "disconnect").onDisconnect();
2283 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002284 }
2285
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002286 private void hold(String callId) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002287 Log.i(this, "hold %s", callId);
Santos Cordon0159ac02014-08-21 14:28:11 -07002288 if (mConnectionById.containsKey(callId)) {
2289 findConnectionForAction(callId, "hold").onHold();
2290 } else {
2291 findConferenceForAction(callId, "hold").onHold();
2292 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002293 }
2294
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002295 private void unhold(String callId) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002296 Log.i(this, "unhold %s", callId);
Santos Cordon0159ac02014-08-21 14:28:11 -07002297 if (mConnectionById.containsKey(callId)) {
2298 findConnectionForAction(callId, "unhold").onUnhold();
2299 } else {
2300 findConferenceForAction(callId, "unhold").onUnhold();
2301 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002302 }
2303
Yorke Lee4af59352015-05-13 14:14:54 -07002304 private void onCallAudioStateChanged(String callId, CallAudioState callAudioState) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002305 Log.i(this, "onAudioStateChanged %s %s", callId, callAudioState);
Yorke Leea0d3ca92014-09-15 19:18:13 -07002306 if (mConnectionById.containsKey(callId)) {
Yorke Lee4af59352015-05-13 14:14:54 -07002307 findConnectionForAction(callId, "onCallAudioStateChanged").setCallAudioState(
2308 callAudioState);
Yorke Leea0d3ca92014-09-15 19:18:13 -07002309 } else {
Yorke Lee4af59352015-05-13 14:14:54 -07002310 findConferenceForAction(callId, "onCallAudioStateChanged").setCallAudioState(
2311 callAudioState);
Yorke Leea0d3ca92014-09-15 19:18:13 -07002312 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002313 }
2314
Grace Jiae99fde92021-01-19 14:58:01 -08002315 private void onUsingAlternativeUi(String callId, boolean isUsingAlternativeUi) {
2316 Log.i(this, "onUsingAlternativeUi %s %s", callId, isUsingAlternativeUi);
2317 if (mConnectionById.containsKey(callId)) {
2318 findConnectionForAction(callId, "onUsingAlternativeUi")
2319 .onUsingAlternativeUi(isUsingAlternativeUi);
2320 }
2321 }
2322
2323 private void onTrackedByNonUiService(String callId, boolean isTracked) {
2324 Log.i(this, "onTrackedByNonUiService %s %s", callId, isTracked);
2325 if (mConnectionById.containsKey(callId)) {
2326 findConnectionForAction(callId, "onTrackedByNonUiService")
2327 .onTrackedByNonUiService(isTracked);
2328 }
2329 }
2330
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002331 private void playDtmfTone(String callId, char digit) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002332 Log.i(this, "playDtmfTone %s %c", callId, digit);
Yorke Leea0d3ca92014-09-15 19:18:13 -07002333 if (mConnectionById.containsKey(callId)) {
2334 findConnectionForAction(callId, "playDtmfTone").onPlayDtmfTone(digit);
2335 } else {
2336 findConferenceForAction(callId, "playDtmfTone").onPlayDtmfTone(digit);
2337 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002338 }
2339
2340 private void stopDtmfTone(String callId) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002341 Log.i(this, "stopDtmfTone %s", callId);
Yorke Leea0d3ca92014-09-15 19:18:13 -07002342 if (mConnectionById.containsKey(callId)) {
2343 findConnectionForAction(callId, "stopDtmfTone").onStopDtmfTone();
2344 } else {
2345 findConferenceForAction(callId, "stopDtmfTone").onStopDtmfTone();
2346 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002347 }
2348
Santos Cordon823fd3c2014-08-07 18:35:18 -07002349 private void conference(String callId1, String callId2) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002350 Log.i(this, "conference %s, %s", callId1, callId2);
Santos Cordon980acb92014-05-31 10:31:19 -07002351
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002352 // Attempt to get second connection or conference.
Santos Cordon823fd3c2014-08-07 18:35:18 -07002353 Connection connection2 = findConnectionForAction(callId2, "conference");
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002354 Conference conference2 = getNullConference();
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002355 if (connection2 == getNullConnection()) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002356 conference2 = findConferenceForAction(callId2, "conference");
2357 if (conference2 == getNullConference()) {
2358 Log.w(this, "Connection2 or Conference2 missing in conference request %s.",
2359 callId2);
2360 return;
2361 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07002362 }
Santos Cordonb6939982014-06-04 20:20:58 -07002363
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002364 // Attempt to get first connection or conference and perform merge.
Ihab Awad50e35062014-09-30 09:17:03 -07002365 Connection connection1 = findConnectionForAction(callId1, "conference");
2366 if (connection1 == getNullConnection()) {
2367 Conference conference1 = findConferenceForAction(callId1, "addConnection");
2368 if (conference1 == getNullConference()) {
2369 Log.w(this,
2370 "Connection1 or Conference1 missing in conference request %s.",
2371 callId1);
2372 } else {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002373 // Call 1 is a conference.
2374 if (connection2 != getNullConnection()) {
2375 // Call 2 is a connection so merge via call 1 (conference).
2376 conference1.onMerge(connection2);
2377 } else {
2378 // Call 2 is ALSO a conference; this should never happen.
2379 Log.wtf(this, "There can only be one conference and an attempt was made to " +
2380 "merge two conferences.");
2381 return;
2382 }
Ihab Awad50e35062014-09-30 09:17:03 -07002383 }
2384 } else {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002385 // Call 1 is a connection.
2386 if (conference2 != getNullConference()) {
2387 // Call 2 is a conference, so merge via call 2.
2388 conference2.onMerge(connection1);
2389 } else {
2390 // Call 2 is a connection, so merge together.
2391 onConference(connection1, connection2);
2392 }
Ihab Awad50e35062014-09-30 09:17:03 -07002393 }
Santos Cordon980acb92014-05-31 10:31:19 -07002394 }
2395
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002396 private void splitFromConference(String callId) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002397 Log.i(this, "splitFromConference(%s)", callId);
Santos Cordon980acb92014-05-31 10:31:19 -07002398
2399 Connection connection = findConnectionForAction(callId, "splitFromConference");
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002400 if (connection == getNullConnection()) {
Santos Cordon980acb92014-05-31 10:31:19 -07002401 Log.w(this, "Connection missing in conference request %s.", callId);
2402 return;
2403 }
2404
Santos Cordon0159ac02014-08-21 14:28:11 -07002405 Conference conference = connection.getConference();
2406 if (conference != null) {
2407 conference.onSeparate(connection);
2408 }
Santos Cordon980acb92014-05-31 10:31:19 -07002409 }
2410
Santos Cordona4868042014-09-04 17:39:22 -07002411 private void mergeConference(String callId) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002412 Log.i(this, "mergeConference(%s)", callId);
Santos Cordona4868042014-09-04 17:39:22 -07002413 Conference conference = findConferenceForAction(callId, "mergeConference");
2414 if (conference != null) {
2415 conference.onMerge();
2416 }
2417 }
2418
2419 private void swapConference(String callId) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002420 Log.i(this, "swapConference(%s)", callId);
Santos Cordona4868042014-09-04 17:39:22 -07002421 Conference conference = findConferenceForAction(callId, "swapConference");
2422 if (conference != null) {
2423 conference.onSwap();
2424 }
2425 }
2426
Ravi Paluri404babb2020-01-23 19:02:44 +05302427 private void addConferenceParticipants(String callId, List<Uri> participants) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002428 Log.i(this, "addConferenceParticipants(%s)", callId);
Ravi Paluri404babb2020-01-23 19:02:44 +05302429 if (mConnectionById.containsKey(callId)) {
2430 findConnectionForAction(callId, "addConferenceParticipants")
2431 .onAddConferenceParticipants(participants);
2432 } else {
2433 findConferenceForAction(callId, "addConferenceParticipants")
2434 .onAddConferenceParticipants(participants);
2435 }
2436 }
2437
Tyler Gunn876dbfb2016-03-14 15:18:07 -07002438 /**
2439 * Notifies a {@link Connection} of a request to pull an external call.
2440 *
2441 * See {@link Call#pullExternalCall()}.
2442 *
2443 * @param callId The ID of the call to pull.
2444 */
2445 private void pullExternalCall(String callId) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002446 Log.i(this, "pullExternalCall(%s)", callId);
Tyler Gunn876dbfb2016-03-14 15:18:07 -07002447 Connection connection = findConnectionForAction(callId, "pullExternalCall");
2448 if (connection != null) {
2449 connection.onPullExternalCall();
2450 }
2451 }
2452
2453 /**
2454 * Notifies a {@link Connection} of a call event.
2455 *
2456 * See {@link Call#sendCallEvent(String, Bundle)}.
2457 *
2458 * @param callId The ID of the call receiving the event.
2459 * @param event The event.
2460 * @param extras Extras associated with the event.
2461 */
2462 private void sendCallEvent(String callId, String event, Bundle extras) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002463 Log.i(this, "sendCallEvent(%s, %s)", callId, event);
Tyler Gunn876dbfb2016-03-14 15:18:07 -07002464 Connection connection = findConnectionForAction(callId, "sendCallEvent");
2465 if (connection != null) {
2466 connection.onCallEvent(event, extras);
2467 }
Tyler Gunn876dbfb2016-03-14 15:18:07 -07002468 }
2469
Hall Liu73903142021-02-18 18:41:41 -08002470 private void onCallFilteringCompleted(String callId, Connection.CallFilteringCompletionInfo
2471 callFilteringCompletionInfo) {
2472 Log.i(this, "onCallFilteringCompleted(%s, %s)", callId, callFilteringCompletionInfo);
Hall Liu49cabcc2021-01-15 11:41:48 -08002473 Connection connection = findConnectionForAction(callId, "onCallFilteringCompleted");
2474 if (connection != null) {
Hall Liu73903142021-02-18 18:41:41 -08002475 connection.onCallFilteringCompleted(callFilteringCompletionInfo);
Hall Liu49cabcc2021-01-15 11:41:48 -08002476 }
2477 }
2478
Tyler Gunndee56a82016-03-23 16:06:34 -07002479 /**
Tyler Gunn79bc1ec2018-01-22 15:17:54 -08002480 * Notifies a {@link Connection} that a handover has completed.
2481 *
2482 * @param callId The ID of the call which completed handover.
2483 */
2484 private void notifyHandoverComplete(String callId) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002485 Log.i(this, "notifyHandoverComplete(%s)", callId);
Tyler Gunn79bc1ec2018-01-22 15:17:54 -08002486 Connection connection = findConnectionForAction(callId, "notifyHandoverComplete");
2487 if (connection != null) {
2488 connection.onHandoverComplete();
2489 }
2490 }
2491
2492 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002493 * Notifies a {@link Connection} or {@link Conference} of a change to the extras from Telecom.
2494 * <p>
2495 * These extra changes can originate from Telecom itself, or from an {@link InCallService} via
2496 * the {@link android.telecom.Call#putExtra(String, boolean)},
2497 * {@link android.telecom.Call#putExtra(String, int)},
2498 * {@link android.telecom.Call#putExtra(String, String)},
2499 * {@link Call#removeExtras(List)}.
2500 *
2501 * @param callId The ID of the call receiving the event.
2502 * @param extras The new extras bundle.
2503 */
2504 private void handleExtrasChanged(String callId, Bundle extras) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002505 Log.i(this, "handleExtrasChanged(%s, %s)", callId, extras);
Tyler Gunndee56a82016-03-23 16:06:34 -07002506 if (mConnectionById.containsKey(callId)) {
2507 findConnectionForAction(callId, "handleExtrasChanged").handleExtrasChanged(extras);
2508 } else if (mConferenceById.containsKey(callId)) {
2509 findConferenceForAction(callId, "handleExtrasChanged").handleExtrasChanged(extras);
2510 }
2511 }
2512
Hall Liub64ac4c2017-02-06 10:49:48 -08002513 private void startRtt(String callId, Connection.RttTextStream rttTextStream) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002514 Log.i(this, "startRtt(%s)", callId);
Hall Liub64ac4c2017-02-06 10:49:48 -08002515 if (mConnectionById.containsKey(callId)) {
2516 findConnectionForAction(callId, "startRtt").onStartRtt(rttTextStream);
2517 } else if (mConferenceById.containsKey(callId)) {
2518 Log.w(this, "startRtt called on a conference.");
2519 }
2520 }
2521
2522 private void stopRtt(String callId) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002523 Log.i(this, "stopRtt(%s)", callId);
Hall Liub64ac4c2017-02-06 10:49:48 -08002524 if (mConnectionById.containsKey(callId)) {
2525 findConnectionForAction(callId, "stopRtt").onStopRtt();
2526 } else if (mConferenceById.containsKey(callId)) {
2527 Log.w(this, "stopRtt called on a conference.");
2528 }
2529 }
2530
2531 private void handleRttUpgradeResponse(String callId, Connection.RttTextStream rttTextStream) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002532 Log.i(this, "handleRttUpgradeResponse(%s, %s)", callId, rttTextStream == null);
Hall Liub64ac4c2017-02-06 10:49:48 -08002533 if (mConnectionById.containsKey(callId)) {
2534 findConnectionForAction(callId, "handleRttUpgradeResponse")
2535 .handleRttUpgradeResponse(rttTextStream);
2536 } else if (mConferenceById.containsKey(callId)) {
2537 Log.w(this, "handleRttUpgradeResponse called on a conference.");
2538 }
2539 }
2540
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002541 private void onPostDialContinue(String callId, boolean proceed) {
Tyler Gunnffbcd892020-05-04 15:01:59 -07002542 Log.i(this, "onPostDialContinue(%s)", callId);
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002543 findConnectionForAction(callId, "stopDtmfTone").onPostDialContinue(proceed);
Evan Charlton6dea4ac2014-06-03 14:07:13 -07002544 }
2545
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002546 private void onAdapterAttached() {
Ihab Awad9c3f1882014-06-30 21:17:13 -07002547 if (mAreAccountsInitialized) {
Santos Cordon52d8a152014-06-17 19:08:45 -07002548 // No need to query again if we already did it.
2549 return;
2550 }
2551
Tyler Gunn4c69fb32019-05-17 10:49:16 -07002552 String callingPackage = getOpPackageName();
2553
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002554 mAdapter.queryRemoteConnectionServices(new RemoteServiceCallback.Stub() {
Santos Cordon52d8a152014-06-17 19:08:45 -07002555 @Override
2556 public void onResult(
2557 final List<ComponentName> componentNames,
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002558 final List<IBinder> services) {
Brad Ebinger0c3541b2016-11-01 14:11:38 -07002559 mHandler.post(new android.telecom.Logging.Runnable("oAA.qRCS.oR", null /*lock*/) {
Ihab Awad6107bab2014-08-18 09:23:25 -07002560 @Override
Brad Ebinger0c3541b2016-11-01 14:11:38 -07002561 public void loggedRun() {
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002562 for (int i = 0; i < componentNames.size() && i < services.size(); i++) {
Santos Cordon52d8a152014-06-17 19:08:45 -07002563 mRemoteConnectionManager.addConnectionService(
2564 componentNames.get(i),
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002565 IConnectionService.Stub.asInterface(services.get(i)));
Santos Cordon52d8a152014-06-17 19:08:45 -07002566 }
Ihab Awad5d0410f2014-07-30 10:07:40 -07002567 onAccountsInitialized();
Sailesh Nepalc5b01572014-07-14 16:29:44 -07002568 Log.d(this, "remote connection services found: " + services);
Santos Cordon52d8a152014-06-17 19:08:45 -07002569 }
Brad Ebinger0c3541b2016-11-01 14:11:38 -07002570 }.prepare());
Santos Cordon52d8a152014-06-17 19:08:45 -07002571 }
2572
2573 @Override
2574 public void onError() {
Brad Ebinger0c3541b2016-11-01 14:11:38 -07002575 mHandler.post(new android.telecom.Logging.Runnable("oAA.qRCS.oE", null /*lock*/) {
Ihab Awad6107bab2014-08-18 09:23:25 -07002576 @Override
Brad Ebinger0c3541b2016-11-01 14:11:38 -07002577 public void loggedRun() {
Ihab Awad9c3f1882014-06-30 21:17:13 -07002578 mAreAccountsInitialized = true;
Santos Cordon52d8a152014-06-17 19:08:45 -07002579 }
Brad Ebinger0c3541b2016-11-01 14:11:38 -07002580 }.prepare());
Santos Cordon52d8a152014-06-17 19:08:45 -07002581 }
Tyler Gunn4c69fb32019-05-17 10:49:16 -07002582 }, callingPackage);
Santos Cordon52d8a152014-06-17 19:08:45 -07002583 }
2584
Ihab Awadf8b69882014-07-25 15:14:01 -07002585 /**
2586 * Ask some other {@code ConnectionService} to create a {@code RemoteConnection} given an
Santos Cordona663f862014-10-29 13:49:58 -07002587 * incoming request. This is used by {@code ConnectionService}s that are registered with
2588 * {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER} and want to be able to manage
2589 * SIM-based incoming calls.
Ihab Awadf8b69882014-07-25 15:14:01 -07002590 *
2591 * @param connectionManagerPhoneAccount See description at
2592 * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
2593 * @param request Details about the incoming call.
2594 * @return The {@code Connection} object to satisfy this call, or {@code null} to
2595 * not handle the call.
2596 */
Grace Jia41895152021-01-19 13:57:51 -08002597 public final @Nullable RemoteConnection createRemoteIncomingConnection(
2598 @NonNull PhoneAccountHandle connectionManagerPhoneAccount,
2599 @NonNull ConnectionRequest request) {
Ihab Awadf8b69882014-07-25 15:14:01 -07002600 return mRemoteConnectionManager.createRemoteConnection(
2601 connectionManagerPhoneAccount, request, true);
Santos Cordon52d8a152014-06-17 19:08:45 -07002602 }
2603
2604 /**
Ihab Awadf8b69882014-07-25 15:14:01 -07002605 * Ask some other {@code ConnectionService} to create a {@code RemoteConnection} given an
Santos Cordona663f862014-10-29 13:49:58 -07002606 * outgoing request. This is used by {@code ConnectionService}s that are registered with
2607 * {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER} and want to be able to use the
2608 * SIM-based {@code ConnectionService} to place its outgoing calls.
Ihab Awadf8b69882014-07-25 15:14:01 -07002609 *
2610 * @param connectionManagerPhoneAccount See description at
2611 * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
Cuihtlauac ALVARADO0b3b2a52016-09-13 14:49:41 +02002612 * @param request Details about the outgoing call.
Ihab Awadf8b69882014-07-25 15:14:01 -07002613 * @return The {@code Connection} object to satisfy this call, or {@code null} to
2614 * not handle the call.
2615 */
Grace Jia41895152021-01-19 13:57:51 -08002616 public final @Nullable RemoteConnection createRemoteOutgoingConnection(
2617 @NonNull PhoneAccountHandle connectionManagerPhoneAccount,
2618 @NonNull ConnectionRequest request) {
Ihab Awadf8b69882014-07-25 15:14:01 -07002619 return mRemoteConnectionManager.createRemoteConnection(
2620 connectionManagerPhoneAccount, request, false);
2621 }
2622
2623 /**
Grace Jia9a09c672020-08-04 12:52:09 -07002624 * Ask some other {@code ConnectionService} to create a {@code RemoteConference} given an
2625 * incoming request. This is used by {@code ConnectionService}s that are registered with
2626 * {@link PhoneAccount#CAPABILITY_ADHOC_CONFERENCE_CALLING}.
2627 *
2628 * @param connectionManagerPhoneAccount See description at
2629 * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
2630 * @param request Details about the incoming conference call.
2631 * @return The {@code RemoteConference} object to satisfy this call, or {@code null} to not
2632 * handle the call.
2633 */
2634 public final @Nullable RemoteConference createRemoteIncomingConference(
2635 @Nullable PhoneAccountHandle connectionManagerPhoneAccount,
2636 @Nullable ConnectionRequest request) {
2637 return mRemoteConnectionManager.createRemoteConference(connectionManagerPhoneAccount,
2638 request, true);
2639 }
2640
2641 /**
2642 * Ask some other {@code ConnectionService} to create a {@code RemoteConference} given an
2643 * outgoing request. This is used by {@code ConnectionService}s that are registered with
2644 * {@link PhoneAccount#CAPABILITY_ADHOC_CONFERENCE_CALLING}.
2645 *
2646 * @param connectionManagerPhoneAccount See description at
2647 * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
2648 * @param request Details about the outgoing conference call.
2649 * @return The {@code RemoteConference} object to satisfy this call, or {@code null} to not
2650 * handle the call.
2651 */
2652 public final @Nullable RemoteConference createRemoteOutgoingConference(
2653 @Nullable PhoneAccountHandle connectionManagerPhoneAccount,
2654 @Nullable ConnectionRequest request) {
2655 return mRemoteConnectionManager.createRemoteConference(connectionManagerPhoneAccount,
2656 request, false);
2657 }
2658
2659 /**
Santos Cordona663f862014-10-29 13:49:58 -07002660 * Indicates to the relevant {@code RemoteConnectionService} that the specified
2661 * {@link RemoteConnection}s should be merged into a conference call.
2662 * <p>
2663 * If the conference request is successful, the method {@link #onRemoteConferenceAdded} will
2664 * be invoked.
2665 *
2666 * @param remoteConnection1 The first of the remote connections to conference.
2667 * @param remoteConnection2 The second of the remote connections to conference.
Ihab Awadb8e85c72014-08-23 20:34:57 -07002668 */
2669 public final void conferenceRemoteConnections(
Santos Cordona663f862014-10-29 13:49:58 -07002670 RemoteConnection remoteConnection1,
2671 RemoteConnection remoteConnection2) {
2672 mRemoteConnectionManager.conferenceRemoteConnections(remoteConnection1, remoteConnection2);
Ihab Awadb8e85c72014-08-23 20:34:57 -07002673 }
2674
2675 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002676 * Adds a new conference call. When a conference call is created either as a result of an
2677 * explicit request via {@link #onConference} or otherwise, the connection service should supply
2678 * an instance of {@link Conference} by invoking this method. A conference call provided by this
2679 * method will persist until {@link Conference#destroy} is invoked on the conference instance.
2680 *
2681 * @param conference The new conference object.
2682 */
2683 public final void addConference(Conference conference) {
Rekha Kumar07366812015-03-24 16:42:31 -07002684 Log.d(this, "addConference: conference=%s", conference);
2685
Santos Cordon823fd3c2014-08-07 18:35:18 -07002686 String id = addConferenceInternal(conference);
2687 if (id != null) {
2688 List<String> connectionIds = new ArrayList<>(2);
2689 for (Connection connection : conference.getConnections()) {
2690 if (mIdByConnection.containsKey(connection)) {
2691 connectionIds.add(mIdByConnection.get(connection));
2692 }
2693 }
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002694 conference.setTelecomCallId(id);
Brad Ebinger0ae44ed2020-04-09 15:30:57 -07002695 ParcelableConference parcelableConference = new ParcelableConference.Builder(
2696 conference.getPhoneAccountHandle(), conference.getState())
2697 .setConnectionCapabilities(conference.getConnectionCapabilities())
2698 .setConnectionProperties(conference.getConnectionProperties())
2699 .setConnectionIds(connectionIds)
2700 .setVideoAttributes(conference.getVideoProvider() == null
2701 ? null : conference.getVideoProvider().getInterface(),
2702 conference.getVideoState())
2703 .setConnectTimeMillis(conference.getConnectTimeMillis(),
2704 conference.getConnectionStartElapsedRealtimeMillis())
2705 .setStatusHints(conference.getStatusHints())
2706 .setExtras(conference.getExtras())
2707 .setAddress(conference.getAddress(), conference.getAddressPresentation())
2708 .setCallerDisplayName(conference.getCallerDisplayName(),
2709 conference.getCallerDisplayNamePresentation())
2710 .setDisconnectCause(conference.getDisconnectCause())
2711 .setRingbackRequested(conference.isRingbackRequested())
2712 .setCallDirection(conference.getCallDirection())
2713 .build();
Andrew Lee0f51da32015-04-16 13:11:55 -07002714
Santos Cordon823fd3c2014-08-07 18:35:18 -07002715 mAdapter.addConferenceCall(id, parcelableConference);
Rekha Kumar07366812015-03-24 16:42:31 -07002716 mAdapter.setVideoProvider(id, conference.getVideoProvider());
2717 mAdapter.setVideoState(id, conference.getVideoState());
Tyler Gunn10362372020-04-08 13:12:30 -07002718 // In some instances a conference can start its life as a standalone call with just a
2719 // single participant; ensure we signal to Telecom in this case.
2720 if (!conference.isMultiparty()) {
2721 mAdapter.setConferenceState(id, conference.isMultiparty());
2722 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07002723
2724 // Go through any child calls and set the parent.
2725 for (Connection connection : conference.getConnections()) {
2726 String connectionId = mIdByConnection.get(connection);
2727 if (connectionId != null) {
2728 mAdapter.setIsConferenced(connectionId, id);
2729 }
2730 }
Pengquan Meng70c9885332017-10-02 18:09:03 -07002731 onConferenceAdded(conference);
Santos Cordon823fd3c2014-08-07 18:35:18 -07002732 }
2733 }
2734
2735 /**
Tyler Gunn4a57b9b2014-10-30 14:27:48 -07002736 * Adds a connection created by the {@link ConnectionService} and informs telecom of the new
2737 * connection.
2738 *
2739 * @param phoneAccountHandle The phone account handle for the connection.
2740 * @param connection The connection to add.
2741 */
2742 public final void addExistingConnection(PhoneAccountHandle phoneAccountHandle,
2743 Connection connection) {
Tyler Gunn78da7812017-05-09 14:34:57 -07002744 addExistingConnection(phoneAccountHandle, connection, null /* conference */);
2745 }
2746
2747 /**
Pengquan Meng731c1a32017-11-21 18:01:13 -08002748 * Call to inform Telecom that your {@link ConnectionService} has released call resources (e.g
2749 * microphone, camera).
2750 *
Pengquan Menge3bf7e22018-02-22 17:30:04 -08002751 * <p>
2752 * The {@link ConnectionService} will be disconnected when it failed to call this method within
2753 * 5 seconds after {@link #onConnectionServiceFocusLost()} is called.
2754 *
Pengquan Meng731c1a32017-11-21 18:01:13 -08002755 * @see ConnectionService#onConnectionServiceFocusLost()
2756 */
2757 public final void connectionServiceFocusReleased() {
2758 mAdapter.onConnectionServiceFocusReleased();
2759 }
2760
2761 /**
Tyler Gunn78da7812017-05-09 14:34:57 -07002762 * Adds a connection created by the {@link ConnectionService} and informs telecom of the new
Tyler Gunn5567d742019-10-31 13:04:37 -07002763 * connection, as well as adding that connection to the specified conference.
2764 * <p>
2765 * Note: This API is intended ONLY for use by the Telephony stack to provide an easy way to add
2766 * IMS conference participants to be added to a conference in a single step; this helps ensure
2767 * UI updates happen atomically, rather than adding the connection and then adding it to
2768 * the conference in another step.
Tyler Gunn78da7812017-05-09 14:34:57 -07002769 *
2770 * @param phoneAccountHandle The phone account handle for the connection.
2771 * @param connection The connection to add.
2772 * @param conference The parent conference of the new connection.
2773 * @hide
2774 */
Tyler Gunn5567d742019-10-31 13:04:37 -07002775 @SystemApi
2776 public final void addExistingConnection(@NonNull PhoneAccountHandle phoneAccountHandle,
2777 @NonNull Connection connection, @NonNull Conference conference) {
Tyler Gunn4a57b9b2014-10-30 14:27:48 -07002778
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002779 String id = addExistingConnectionInternal(phoneAccountHandle, connection);
Tyler Gunn4a57b9b2014-10-30 14:27:48 -07002780 if (id != null) {
2781 List<String> emptyList = new ArrayList<>(0);
Tyler Gunn78da7812017-05-09 14:34:57 -07002782 String conferenceId = null;
2783 if (conference != null) {
2784 conferenceId = mIdByConference.get(conference);
2785 }
Tyler Gunn4a57b9b2014-10-30 14:27:48 -07002786
2787 ParcelableConnection parcelableConnection = new ParcelableConnection(
2788 phoneAccountHandle,
2789 connection.getState(),
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002790 connection.getConnectionCapabilities(),
Tyler Gunn720c6642016-03-22 09:02:47 -07002791 connection.getConnectionProperties(),
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002792 connection.getSupportedAudioRoutes(),
Tyler Gunn4a57b9b2014-10-30 14:27:48 -07002793 connection.getAddress(),
2794 connection.getAddressPresentation(),
2795 connection.getCallerDisplayName(),
2796 connection.getCallerDisplayNamePresentation(),
2797 connection.getVideoProvider() == null ?
2798 null : connection.getVideoProvider().getInterface(),
2799 connection.getVideoState(),
2800 connection.isRingbackRequested(),
2801 connection.getAudioModeIsVoip(),
Roshan Piuse927ec02015-07-15 15:47:21 -07002802 connection.getConnectTimeMillis(),
Tyler Gunnc9503d62020-01-27 10:30:51 -08002803 connection.getConnectionStartElapsedRealtimeMillis(),
Tyler Gunn4a57b9b2014-10-30 14:27:48 -07002804 connection.getStatusHints(),
2805 connection.getDisconnectCause(),
Santos Cordon6b7f9552015-05-27 17:21:45 -07002806 emptyList,
Tyler Gunn78da7812017-05-09 14:34:57 -07002807 connection.getExtras(),
Tyler Gunn6986a632019-06-25 13:45:32 -07002808 conferenceId,
Tyler Gunnd57d76c2019-09-24 14:53:23 -07002809 connection.getCallDirection(),
2810 Connection.VERIFICATION_STATUS_NOT_VERIFIED);
Tyler Gunn4a57b9b2014-10-30 14:27:48 -07002811 mAdapter.addExistingConnection(id, parcelableConnection);
2812 }
2813 }
2814
2815 /**
Ihab Awadf8b69882014-07-25 15:14:01 -07002816 * Returns all the active {@code Connection}s for which this {@code ConnectionService}
2817 * has taken responsibility.
2818 *
2819 * @return A collection of {@code Connection}s created by this {@code ConnectionService}.
Santos Cordonb6939982014-06-04 20:20:58 -07002820 */
Sailesh Nepal091768c2014-06-30 15:15:23 -07002821 public final Collection<Connection> getAllConnections() {
Santos Cordonb6939982014-06-04 20:20:58 -07002822 return mConnectionById.values();
2823 }
2824
2825 /**
Santos Cordona6018b92016-02-16 14:23:12 -08002826 * Returns all the active {@code Conference}s for which this {@code ConnectionService}
2827 * has taken responsibility.
2828 *
2829 * @return A collection of {@code Conference}s created by this {@code ConnectionService}.
2830 */
2831 public final Collection<Conference> getAllConferences() {
2832 return mConferenceById.values();
2833 }
2834
2835 /**
Ihab Awadf8b69882014-07-25 15:14:01 -07002836 * Create a {@code Connection} given an incoming request. This is used to attach to existing
2837 * incoming calls.
Evan Charltonbf11f982014-07-20 22:06:28 -07002838 *
Ihab Awadf8b69882014-07-25 15:14:01 -07002839 * @param connectionManagerPhoneAccount See description at
2840 * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
2841 * @param request Details about the incoming call.
2842 * @return The {@code Connection} object to satisfy this call, or {@code null} to
2843 * not handle the call.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002844 */
Ihab Awadf8b69882014-07-25 15:14:01 -07002845 public Connection onCreateIncomingConnection(
2846 PhoneAccountHandle connectionManagerPhoneAccount,
2847 ConnectionRequest request) {
2848 return null;
2849 }
Ravi Paluri80aa2142019-12-02 11:57:37 +05302850 /**
Grace Jia8587ee52020-07-10 15:42:32 -07002851 * Create a {@code Conference} given an incoming request. This is used to attach to an incoming
2852 * conference call initiated via
2853 * {@link TelecomManager#addNewIncomingConference(PhoneAccountHandle, Bundle)}.
Ravi Paluri80aa2142019-12-02 11:57:37 +05302854 *
2855 * @param connectionManagerPhoneAccount See description at
2856 * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
Grace Jia8587ee52020-07-10 15:42:32 -07002857 * @param request Details about the incoming conference call.
Grace Jia41895152021-01-19 13:57:51 -08002858 * @return The {@code Conference} object to satisfy this call. If the conference attempt is
2859 * failed, the return value will be a result of an invocation of
2860 * {@link Connection#createFailedConnection(DisconnectCause)}.
2861 * Return {@code null} if the {@link ConnectionService} cannot handle the call.
Ravi Paluri80aa2142019-12-02 11:57:37 +05302862 */
2863 public @Nullable Conference onCreateIncomingConference(
Grace Jia41895152021-01-19 13:57:51 -08002864 @NonNull PhoneAccountHandle connectionManagerPhoneAccount,
2865 @NonNull ConnectionRequest request) {
Ravi Paluri80aa2142019-12-02 11:57:37 +05302866 return null;
2867 }
Sailesh Nepalc5b01572014-07-14 16:29:44 -07002868
2869 /**
Tyler Gunn041a1fe2017-05-12 10:04:49 -07002870 * Called after the {@link Connection} returned by
2871 * {@link #onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}
2872 * or {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)} has been
2873 * added to the {@link ConnectionService} and sent to Telecom.
2874 *
2875 * @param connection the {@link Connection}.
2876 * @hide
2877 */
2878 public void onCreateConnectionComplete(Connection connection) {
2879 }
2880
2881 /**
Ravi Paluri80aa2142019-12-02 11:57:37 +05302882 * Called after the {@link Conference} returned by
2883 * {@link #onCreateIncomingConference(PhoneAccountHandle, ConnectionRequest)}
2884 * or {@link #onCreateOutgoingConference(PhoneAccountHandle, ConnectionRequest)} has been
2885 * added to the {@link ConnectionService} and sent to Telecom.
2886 *
2887 * @param conference the {@link Conference}.
2888 * @hide
2889 */
2890 public void onCreateConferenceComplete(Conference conference) {
2891 }
2892
2893
2894 /**
Tyler Gunnf5035432017-01-09 09:43:12 -08002895 * Called by Telecom to inform the {@link ConnectionService} that its request to create a new
2896 * incoming {@link Connection} was denied.
2897 * <p>
2898 * Used when a self-managed {@link ConnectionService} attempts to create a new incoming
2899 * {@link Connection}, but Telecom has determined that the call cannot be allowed at this time.
2900 * The {@link ConnectionService} is responsible for silently rejecting the new incoming
2901 * {@link Connection}.
2902 * <p>
2903 * See {@link TelecomManager#isIncomingCallPermitted(PhoneAccountHandle)} for more information.
2904 *
Tyler Gunn159f35c2017-03-02 09:28:37 -08002905 * @param connectionManagerPhoneAccount See description at
2906 * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
Tyler Gunnf5035432017-01-09 09:43:12 -08002907 * @param request The incoming connection request.
2908 */
Tyler Gunn159f35c2017-03-02 09:28:37 -08002909 public void onCreateIncomingConnectionFailed(PhoneAccountHandle connectionManagerPhoneAccount,
2910 ConnectionRequest request) {
Tyler Gunnf5035432017-01-09 09:43:12 -08002911 }
2912
2913 /**
2914 * Called by Telecom to inform the {@link ConnectionService} that its request to create a new
2915 * outgoing {@link Connection} was denied.
2916 * <p>
2917 * Used when a self-managed {@link ConnectionService} attempts to create a new outgoing
2918 * {@link Connection}, but Telecom has determined that the call cannot be placed at this time.
2919 * The {@link ConnectionService} is responisible for informing the user that the
2920 * {@link Connection} cannot be made at this time.
2921 * <p>
2922 * See {@link TelecomManager#isOutgoingCallPermitted(PhoneAccountHandle)} for more information.
2923 *
Tyler Gunn159f35c2017-03-02 09:28:37 -08002924 * @param connectionManagerPhoneAccount See description at
2925 * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
Tyler Gunnf5035432017-01-09 09:43:12 -08002926 * @param request The outgoing connection request.
2927 */
Tyler Gunn159f35c2017-03-02 09:28:37 -08002928 public void onCreateOutgoingConnectionFailed(PhoneAccountHandle connectionManagerPhoneAccount,
2929 ConnectionRequest request) {
Tyler Gunnf5035432017-01-09 09:43:12 -08002930 }
2931
2932 /**
Ravi Paluri80aa2142019-12-02 11:57:37 +05302933 * Called by Telecom to inform the {@link ConnectionService} that its request to create a new
2934 * incoming {@link Conference} was denied.
2935 * <p>
2936 * Used when a self-managed {@link ConnectionService} attempts to create a new incoming
2937 * {@link Conference}, but Telecom has determined that the call cannot be allowed at this time.
2938 * The {@link ConnectionService} is responsible for silently rejecting the new incoming
2939 * {@link Conference}.
2940 * <p>
2941 * See {@link TelecomManager#isIncomingCallPermitted(PhoneAccountHandle)} for more information.
2942 *
2943 * @param connectionManagerPhoneAccount See description at
2944 * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
2945 * @param request The incoming connection request.
2946 */
2947 public void onCreateIncomingConferenceFailed(
2948 @Nullable PhoneAccountHandle connectionManagerPhoneAccount,
2949 @Nullable ConnectionRequest request) {
2950 }
2951
2952 /**
2953 * Called by Telecom to inform the {@link ConnectionService} that its request to create a new
2954 * outgoing {@link Conference} was denied.
2955 * <p>
2956 * Used when a self-managed {@link ConnectionService} attempts to create a new outgoing
2957 * {@link Conference}, but Telecom has determined that the call cannot be placed at this time.
2958 * The {@link ConnectionService} is responisible for informing the user that the
2959 * {@link Conference} cannot be made at this time.
2960 * <p>
2961 * See {@link TelecomManager#isOutgoingCallPermitted(PhoneAccountHandle)} for more information.
2962 *
2963 * @param connectionManagerPhoneAccount See description at
2964 * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
2965 * @param request The outgoing connection request.
2966 */
2967 public void onCreateOutgoingConferenceFailed(
Grace Jia41895152021-01-19 13:57:51 -08002968 @NonNull PhoneAccountHandle connectionManagerPhoneAccount,
2969 @NonNull ConnectionRequest request) {
Ravi Paluri80aa2142019-12-02 11:57:37 +05302970 }
2971
2972
2973 /**
Shriram Ganesh6bf35ac2014-12-11 17:53:38 -08002974 * Trigger recalculate functinality for conference calls. This is used when a Telephony
2975 * Connection is part of a conference controller but is not yet added to Connection
2976 * Service and hence cannot be added to the conference call.
2977 *
2978 * @hide
2979 */
2980 public void triggerConferenceRecalculate() {
2981 }
2982
2983 /**
Ihab Awadf8b69882014-07-25 15:14:01 -07002984 * Create a {@code Connection} given an outgoing request. This is used to initiate new
2985 * outgoing calls.
Sailesh Nepalc5b01572014-07-14 16:29:44 -07002986 *
Ihab Awadf8b69882014-07-25 15:14:01 -07002987 * @param connectionManagerPhoneAccount The connection manager account to use for managing
2988 * this call.
2989 * <p>
2990 * If this parameter is not {@code null}, it means that this {@code ConnectionService}
2991 * has registered one or more {@code PhoneAccount}s having
2992 * {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER}. This parameter will contain
2993 * one of these {@code PhoneAccount}s, while the {@code request} will contain another
2994 * (usually but not always distinct) {@code PhoneAccount} to be used for actually
2995 * making the connection.
2996 * <p>
2997 * If this parameter is {@code null}, it means that this {@code ConnectionService} is
2998 * being asked to make a direct connection. The
2999 * {@link ConnectionRequest#getAccountHandle()} of parameter {@code request} will be
3000 * a {@code PhoneAccount} registered by this {@code ConnectionService} to use for
3001 * making the connection.
3002 * @param request Details about the outgoing call.
3003 * @return The {@code Connection} object to satisfy this call, or the result of an invocation
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003004 * of {@link Connection#createFailedConnection(DisconnectCause)} to not handle the call.
Sailesh Nepalc5b01572014-07-14 16:29:44 -07003005 */
Ihab Awadf8b69882014-07-25 15:14:01 -07003006 public Connection onCreateOutgoingConnection(
3007 PhoneAccountHandle connectionManagerPhoneAccount,
3008 ConnectionRequest request) {
3009 return null;
3010 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07003011
3012 /**
Ravi Paluri80aa2142019-12-02 11:57:37 +05303013 * Create a {@code Conference} given an outgoing request. This is used to initiate new
Grace Jia8587ee52020-07-10 15:42:32 -07003014 * outgoing conference call requested via
3015 * {@link TelecomManager#startConference(List, Bundle)}.
Ravi Paluri80aa2142019-12-02 11:57:37 +05303016 *
3017 * @param connectionManagerPhoneAccount The connection manager account to use for managing
3018 * this call.
3019 * <p>
3020 * If this parameter is not {@code null}, it means that this {@code ConnectionService}
3021 * has registered one or more {@code PhoneAccount}s having
3022 * {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER}. This parameter will contain
3023 * one of these {@code PhoneAccount}s, while the {@code request} will contain another
3024 * (usually but not always distinct) {@code PhoneAccount} to be used for actually
3025 * making the connection.
3026 * <p>
3027 * If this parameter is {@code null}, it means that this {@code ConnectionService} is
3028 * being asked to make a direct connection. The
3029 * {@link ConnectionRequest#getAccountHandle()} of parameter {@code request} will be
3030 * a {@code PhoneAccount} registered by this {@code ConnectionService} to use for
3031 * making the connection.
3032 * @param request Details about the outgoing call.
Grace Jia41895152021-01-19 13:57:51 -08003033 * @return The {@code Conference} object to satisfy this call. If the conference attempt is
3034 * failed, the return value will be a result of an invocation of
3035 * {@link Connection#createFailedConnection(DisconnectCause)}.
3036 * Return {@code null} if the {@link ConnectionService} cannot handle the call.
Ravi Paluri80aa2142019-12-02 11:57:37 +05303037 */
3038 public @Nullable Conference onCreateOutgoingConference(
Grace Jia41895152021-01-19 13:57:51 -08003039 @NonNull PhoneAccountHandle connectionManagerPhoneAccount,
3040 @NonNull ConnectionRequest request) {
Ravi Paluri80aa2142019-12-02 11:57:37 +05303041 return null;
3042 }
3043
3044
3045 /**
Tyler Gunn9d127732018-03-02 15:45:51 -08003046 * Called by Telecom to request that a {@link ConnectionService} creates an instance of an
3047 * outgoing handover {@link Connection}.
3048 * <p>
3049 * A call handover is the process where an ongoing call is transferred from one app (i.e.
3050 * {@link ConnectionService} to another app. The user could, for example, choose to continue a
3051 * mobile network call in a video calling app. The mobile network call via the Telephony stack
3052 * is referred to as the source of the handover, and the video calling app is referred to as the
3053 * destination.
3054 * <p>
3055 * When considering a handover scenario the <em>initiating</em> device is where a user initiated
3056 * the handover process (e.g. by calling {@link android.telecom.Call#handoverTo(
3057 * PhoneAccountHandle, int, Bundle)}, and the other device is considered the <em>receiving</em>
3058 * device.
3059 * <p>
3060 * This method is called on the destination {@link ConnectionService} on <em>initiating</em>
3061 * device when the user initiates a handover request from one app to another. The user request
3062 * originates in the {@link InCallService} via
3063 * {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int, Bundle)}.
3064 * <p>
3065 * For a full discussion of the handover process and the APIs involved, see
3066 * {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int, Bundle)}.
3067 * <p>
3068 * Implementations of this method should return an instance of {@link Connection} which
3069 * represents the handover. If your app does not wish to accept a handover to it at this time,
3070 * you can return {@code null}. The code below shows an example of how this is done.
3071 * <pre>
3072 * {@code
3073 * public Connection onCreateIncomingHandoverConnection(PhoneAccountHandle
3074 * fromPhoneAccountHandle, ConnectionRequest request) {
3075 * if (!isHandoverAvailable()) {
3076 * return null;
3077 * }
3078 * MyConnection connection = new MyConnection();
3079 * connection.setAddress(request.getAddress(), TelecomManager.PRESENTATION_ALLOWED);
3080 * connection.setVideoState(request.getVideoState());
3081 * return connection;
3082 * }
3083 * }
3084 * </pre>
3085 *
Sanket Padawea8eddd42017-11-03 11:07:35 -07003086 * @param fromPhoneAccountHandle {@link PhoneAccountHandle} associated with the
3087 * ConnectionService which needs to handover the call.
Tyler Gunn9d127732018-03-02 15:45:51 -08003088 * @param request Details about the call to handover.
3089 * @return {@link Connection} instance corresponding to the handover call.
Sanket Padawea8eddd42017-11-03 11:07:35 -07003090 */
3091 public Connection onCreateOutgoingHandoverConnection(PhoneAccountHandle fromPhoneAccountHandle,
3092 ConnectionRequest request) {
3093 return null;
3094 }
3095
3096 /**
Tyler Gunn9d127732018-03-02 15:45:51 -08003097 * Called by Telecom to request that a {@link ConnectionService} creates an instance of an
3098 * incoming handover {@link Connection}.
3099 * <p>
3100 * A call handover is the process where an ongoing call is transferred from one app (i.e.
3101 * {@link ConnectionService} to another app. The user could, for example, choose to continue a
3102 * mobile network call in a video calling app. The mobile network call via the Telephony stack
3103 * is referred to as the source of the handover, and the video calling app is referred to as the
3104 * destination.
3105 * <p>
3106 * When considering a handover scenario the <em>initiating</em> device is where a user initiated
3107 * the handover process (e.g. by calling {@link android.telecom.Call#handoverTo(
3108 * PhoneAccountHandle, int, Bundle)}, and the other device is considered the <em>receiving</em>
3109 * device.
3110 * <p>
3111 * This method is called on the destination app on the <em>receiving</em> device when the
3112 * destination app calls {@link TelecomManager#acceptHandover(Uri, int, PhoneAccountHandle)} to
3113 * accept an incoming handover from the <em>initiating</em> device.
3114 * <p>
3115 * For a full discussion of the handover process and the APIs involved, see
3116 * {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int, Bundle)}.
3117 * <p>
3118 * Implementations of this method should return an instance of {@link Connection} which
3119 * represents the handover. The code below shows an example of how this is done.
3120 * <pre>
3121 * {@code
3122 * public Connection onCreateIncomingHandoverConnection(PhoneAccountHandle
3123 * fromPhoneAccountHandle, ConnectionRequest request) {
3124 * // Given that your app requested to accept the handover, you should not return null here.
3125 * MyConnection connection = new MyConnection();
3126 * connection.setAddress(request.getAddress(), TelecomManager.PRESENTATION_ALLOWED);
3127 * connection.setVideoState(request.getVideoState());
3128 * return connection;
3129 * }
3130 * }
3131 * </pre>
3132 *
Sanket Padawea8eddd42017-11-03 11:07:35 -07003133 * @param fromPhoneAccountHandle {@link PhoneAccountHandle} associated with the
3134 * ConnectionService which needs to handover the call.
3135 * @param request Details about the call which needs to be handover.
Tyler Gunn9d127732018-03-02 15:45:51 -08003136 * @return {@link Connection} instance corresponding to the handover call.
Sanket Padawea8eddd42017-11-03 11:07:35 -07003137 */
3138 public Connection onCreateIncomingHandoverConnection(PhoneAccountHandle fromPhoneAccountHandle,
3139 ConnectionRequest request) {
3140 return null;
3141 }
3142
3143 /**
3144 * Called by Telecom in response to a {@code TelecomManager#acceptHandover()}
3145 * invocation which failed.
Tyler Gunn9d127732018-03-02 15:45:51 -08003146 * <p>
3147 * For a full discussion of the handover process and the APIs involved, see
3148 * {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int, Bundle)}
3149 *
3150 * @param request Details about the call which failed to handover.
3151 * @param error Reason for handover failure. Will be one of the
Sanket Padawea8eddd42017-11-03 11:07:35 -07003152 */
Tyler Gunn9d127732018-03-02 15:45:51 -08003153 public void onHandoverFailed(ConnectionRequest request,
3154 @Call.Callback.HandoverFailureErrors int error) {
Sanket Padawea8eddd42017-11-03 11:07:35 -07003155 return;
3156 }
3157
3158 /**
Yorke Leec3cf9822014-10-02 09:38:39 -07003159 * Create a {@code Connection} for a new unknown call. An unknown call is a call originating
3160 * from the ConnectionService that was neither a user-initiated outgoing call, nor an incoming
3161 * call created using
3162 * {@code TelecomManager#addNewIncomingCall(PhoneAccountHandle, android.os.Bundle)}.
3163 *
Yorke Lee770ed6e2014-10-06 18:58:52 -07003164 * @hide
Yorke Leec3cf9822014-10-02 09:38:39 -07003165 */
3166 public Connection onCreateUnknownConnection(PhoneAccountHandle connectionManagerPhoneAccount,
3167 ConnectionRequest request) {
Brad Ebingerb32d4f82016-10-24 16:40:49 -07003168 return null;
Yorke Leec3cf9822014-10-02 09:38:39 -07003169 }
3170
3171 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07003172 * Conference two specified connections. Invoked when the user has made a request to merge the
3173 * specified connections into a conference call. In response, the connection service should
3174 * create an instance of {@link Conference} and pass it into {@link #addConference}.
Santos Cordonb6939982014-06-04 20:20:58 -07003175 *
Santos Cordon823fd3c2014-08-07 18:35:18 -07003176 * @param connection1 A connection to merge into a conference call.
3177 * @param connection2 A connection to merge into a conference call.
Santos Cordonb6939982014-06-04 20:20:58 -07003178 */
Santos Cordon823fd3c2014-08-07 18:35:18 -07003179 public void onConference(Connection connection1, Connection connection2) {}
Santos Cordonb6939982014-06-04 20:20:58 -07003180
Santos Cordona663f862014-10-29 13:49:58 -07003181 /**
Pengquan Meng70c9885332017-10-02 18:09:03 -07003182 * Called when a connection is added.
3183 * @hide
3184 */
3185 public void onConnectionAdded(Connection connection) {}
3186
3187 /**
3188 * Called when a connection is removed.
3189 * @hide
3190 */
3191 public void onConnectionRemoved(Connection connection) {}
3192
3193 /**
3194 * Called when a conference is added.
3195 * @hide
3196 */
3197 public void onConferenceAdded(Conference conference) {}
3198
3199 /**
3200 * Called when a conference is removed.
3201 * @hide
3202 */
3203 public void onConferenceRemoved(Conference conference) {}
3204
3205 /**
Santos Cordona663f862014-10-29 13:49:58 -07003206 * Indicates that a remote conference has been created for existing {@link RemoteConnection}s.
3207 * When this method is invoked, this {@link ConnectionService} should create its own
3208 * representation of the conference call and send it to telecom using {@link #addConference}.
3209 * <p>
3210 * This is only relevant to {@link ConnectionService}s which are registered with
3211 * {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER}.
3212 *
3213 * @param conference The remote conference call.
3214 */
Ihab Awadb8e85c72014-08-23 20:34:57 -07003215 public void onRemoteConferenceAdded(RemoteConference conference) {}
3216
Santos Cordon823fd3c2014-08-07 18:35:18 -07003217 /**
Tyler Gunn4a57b9b2014-10-30 14:27:48 -07003218 * Called when an existing connection is added remotely.
3219 * @param connection The existing connection which was added.
3220 */
3221 public void onRemoteExistingConnectionAdded(RemoteConnection connection) {}
3222
3223 /**
Pengquan Meng731c1a32017-11-21 18:01:13 -08003224 * Called when the {@link ConnectionService} has lost the call focus.
3225 * The {@link ConnectionService} should release the call resources and invokes
3226 * {@link ConnectionService#connectionServiceFocusReleased()} to inform telecom that it has
3227 * released the call resources.
3228 */
3229 public void onConnectionServiceFocusLost() {}
3230
3231 /**
3232 * Called when the {@link ConnectionService} has gained the call focus. The
3233 * {@link ConnectionService} can acquire the call resources at this time.
3234 */
3235 public void onConnectionServiceFocusGained() {}
3236
3237 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07003238 * @hide
3239 */
3240 public boolean containsConference(Conference conference) {
3241 return mIdByConference.containsKey(conference);
3242 }
3243
Ihab Awadb8e85c72014-08-23 20:34:57 -07003244 /** {@hide} */
3245 void addRemoteConference(RemoteConference remoteConference) {
3246 onRemoteConferenceAdded(remoteConference);
3247 }
3248
Tyler Gunn4a57b9b2014-10-30 14:27:48 -07003249 /** {@hide} */
3250 void addRemoteExistingConnection(RemoteConnection remoteConnection) {
3251 onRemoteExistingConnectionAdded(remoteConnection);
3252 }
3253
Ihab Awad5d0410f2014-07-30 10:07:40 -07003254 private void onAccountsInitialized() {
3255 mAreAccountsInitialized = true;
3256 for (Runnable r : mPreInitializationConnectionRequests) {
3257 r.run();
3258 }
3259 mPreInitializationConnectionRequests.clear();
3260 }
3261
Tyler Gunn4a57b9b2014-10-30 14:27:48 -07003262 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07003263 * Adds an existing connection to the list of connections, identified by a new call ID unique
3264 * to this connection service.
Tyler Gunn4a57b9b2014-10-30 14:27:48 -07003265 *
3266 * @param connection The connection.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07003267 * @return The ID of the connection (e.g. the call-id).
Tyler Gunn4a57b9b2014-10-30 14:27:48 -07003268 */
Tyler Gunnf0500bd2015-09-01 10:59:48 -07003269 private String addExistingConnectionInternal(PhoneAccountHandle handle, Connection connection) {
3270 String id;
Tyler Gunncd6ccfd2016-10-17 15:48:19 -07003271
3272 if (connection.getExtras() != null && connection.getExtras()
3273 .containsKey(Connection.EXTRA_ORIGINAL_CONNECTION_ID)) {
3274 id = connection.getExtras().getString(Connection.EXTRA_ORIGINAL_CONNECTION_ID);
3275 Log.d(this, "addExistingConnectionInternal - conn %s reusing original id %s",
3276 connection.getTelecomCallId(), id);
3277 } else if (handle == null) {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07003278 // If no phone account handle was provided, we cannot be sure the call ID is unique,
3279 // so just use a random UUID.
3280 id = UUID.randomUUID().toString();
3281 } else {
3282 // Phone account handle was provided, so use the ConnectionService class name as a
3283 // prefix for a unique incremental call ID.
3284 id = handle.getComponentName().getClassName() + "@" + getNextCallId();
3285 }
Pengquan Meng70c9885332017-10-02 18:09:03 -07003286 addConnection(handle, id, connection);
Tyler Gunn4a57b9b2014-10-30 14:27:48 -07003287 return id;
3288 }
3289
Pengquan Meng70c9885332017-10-02 18:09:03 -07003290 private void addConnection(PhoneAccountHandle handle, String callId, Connection connection) {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07003291 connection.setTelecomCallId(callId);
Ihab Awad542e0ea2014-05-16 10:22:16 -07003292 mConnectionById.put(callId, connection);
3293 mIdByConnection.put(connection, callId);
3294 connection.addConnectionListener(mConnectionListener);
Santos Cordon823fd3c2014-08-07 18:35:18 -07003295 connection.setConnectionService(this);
Pengquan Meng70c9885332017-10-02 18:09:03 -07003296 connection.setPhoneAccountHandle(handle);
3297 onConnectionAdded(connection);
Ihab Awad542e0ea2014-05-16 10:22:16 -07003298 }
3299
Anthony Lee30e65842014-11-06 16:30:53 -08003300 /** {@hide} */
3301 protected void removeConnection(Connection connection) {
Santos Cordon823fd3c2014-08-07 18:35:18 -07003302 connection.unsetConnectionService(this);
Ihab Awad542e0ea2014-05-16 10:22:16 -07003303 connection.removeConnectionListener(mConnectionListener);
Chenjie Luoe370b532016-05-12 16:59:43 -07003304 String id = mIdByConnection.get(connection);
3305 if (id != null) {
3306 mConnectionById.remove(id);
3307 mIdByConnection.remove(connection);
3308 mAdapter.removeCall(id);
Pengquan Meng70c9885332017-10-02 18:09:03 -07003309 onConnectionRemoved(connection);
Chenjie Luoe370b532016-05-12 16:59:43 -07003310 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07003311 }
3312
Santos Cordon823fd3c2014-08-07 18:35:18 -07003313 private String addConferenceInternal(Conference conference) {
Tyler Gunncd6ccfd2016-10-17 15:48:19 -07003314 String originalId = null;
3315 if (conference.getExtras() != null && conference.getExtras()
3316 .containsKey(Connection.EXTRA_ORIGINAL_CONNECTION_ID)) {
3317 originalId = conference.getExtras().getString(Connection.EXTRA_ORIGINAL_CONNECTION_ID);
3318 Log.d(this, "addConferenceInternal: conf %s reusing original id %s",
3319 conference.getTelecomCallId(),
3320 originalId);
3321 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07003322 if (mIdByConference.containsKey(conference)) {
3323 Log.w(this, "Re-adding an existing conference: %s.", conference);
3324 } else if (conference != null) {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07003325 // Conferences do not (yet) have a PhoneAccountHandle associated with them, so we
3326 // cannot determine a ConnectionService class name to associate with the ID, so use
3327 // a unique UUID (for now).
Tyler Gunncd6ccfd2016-10-17 15:48:19 -07003328 String id = originalId == null ? UUID.randomUUID().toString() : originalId;
Santos Cordon823fd3c2014-08-07 18:35:18 -07003329 mConferenceById.put(id, conference);
3330 mIdByConference.put(conference, id);
3331 conference.addListener(mConferenceListener);
3332 return id;
3333 }
3334
3335 return null;
3336 }
3337
3338 private void removeConference(Conference conference) {
3339 if (mIdByConference.containsKey(conference)) {
3340 conference.removeListener(mConferenceListener);
3341
3342 String id = mIdByConference.get(conference);
3343 mConferenceById.remove(id);
3344 mIdByConference.remove(conference);
3345 mAdapter.removeCall(id);
Pengquan Meng70c9885332017-10-02 18:09:03 -07003346
3347 onConferenceRemoved(conference);
Santos Cordon823fd3c2014-08-07 18:35:18 -07003348 }
3349 }
3350
Ihab Awad542e0ea2014-05-16 10:22:16 -07003351 private Connection findConnectionForAction(String callId, String action) {
Tyler Gunn0a88f2e2017-06-16 20:20:34 -07003352 if (callId != null && mConnectionById.containsKey(callId)) {
Ihab Awad542e0ea2014-05-16 10:22:16 -07003353 return mConnectionById.get(callId);
3354 }
Ihab Awad60ac30b2014-05-20 22:32:12 -07003355 Log.w(this, "%s - Cannot find Connection %s", action, callId);
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07003356 return getNullConnection();
3357 }
3358
3359 static synchronized Connection getNullConnection() {
3360 if (sNullConnection == null) {
3361 sNullConnection = new Connection() {};
3362 }
3363 return sNullConnection;
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003364 }
Santos Cordon0159ac02014-08-21 14:28:11 -07003365
3366 private Conference findConferenceForAction(String conferenceId, String action) {
3367 if (mConferenceById.containsKey(conferenceId)) {
3368 return mConferenceById.get(conferenceId);
3369 }
3370 Log.w(this, "%s - Cannot find conference %s", action, conferenceId);
3371 return getNullConference();
3372 }
3373
Ihab Awadb8e85c72014-08-23 20:34:57 -07003374 private List<String> createConnectionIdList(List<Connection> connections) {
3375 List<String> ids = new ArrayList<>();
3376 for (Connection c : connections) {
3377 if (mIdByConnection.containsKey(c)) {
3378 ids.add(mIdByConnection.get(c));
3379 }
3380 }
3381 Collections.sort(ids);
3382 return ids;
3383 }
3384
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003385 /**
3386 * Builds a list of {@link Connection} and {@link Conference} IDs based on the list of
Tyler Gunndf2cbc82015-04-20 09:13:01 -07003387 * {@link Conferenceable}s passed in.
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003388 *
Tyler Gunndf2cbc82015-04-20 09:13:01 -07003389 * @param conferenceables The {@link Conferenceable} connections and conferences.
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003390 * @return List of string conference and call Ids.
3391 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07003392 private List<String> createIdList(List<Conferenceable> conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003393 List<String> ids = new ArrayList<>();
Tyler Gunndf2cbc82015-04-20 09:13:01 -07003394 for (Conferenceable c : conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003395 // Only allow Connection and Conference conferenceables.
3396 if (c instanceof Connection) {
3397 Connection connection = (Connection) c;
3398 if (mIdByConnection.containsKey(connection)) {
3399 ids.add(mIdByConnection.get(connection));
3400 }
3401 } else if (c instanceof Conference) {
3402 Conference conference = (Conference) c;
3403 if (mIdByConference.containsKey(conference)) {
3404 ids.add(mIdByConference.get(conference));
3405 }
3406 }
3407 }
3408 Collections.sort(ids);
3409 return ids;
3410 }
3411
Santos Cordon0159ac02014-08-21 14:28:11 -07003412 private Conference getNullConference() {
3413 if (sNullConference == null) {
3414 sNullConference = new Conference(null) {};
3415 }
3416 return sNullConference;
3417 }
Santos Cordon29f2f2e2014-09-11 19:50:24 -07003418
3419 private void endAllConnections() {
3420 // Unbound from telecomm. We should end all connections and conferences.
3421 for (Connection connection : mIdByConnection.keySet()) {
3422 // only operate on top-level calls. Conference calls will be removed on their own.
3423 if (connection.getConference() == null) {
3424 connection.onDisconnect();
3425 }
3426 }
3427 for (Conference conference : mIdByConference.keySet()) {
3428 conference.onDisconnect();
3429 }
3430 }
Tyler Gunnf0500bd2015-09-01 10:59:48 -07003431
3432 /**
3433 * Retrieves the next call ID as maintainted by the connection service.
3434 *
3435 * @return The call ID.
3436 */
3437 private int getNextCallId() {
Brad Ebingerb32d4f82016-10-24 16:40:49 -07003438 synchronized (mIdSyncRoot) {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07003439 return ++mId;
3440 }
3441 }
Brad Ebinger99f17ce2019-09-11 18:06:51 -07003442
3443 /**
3444 * Returns this handler, ONLY FOR TESTING.
3445 * @hide
3446 */
3447 @VisibleForTesting
3448 public Handler getHandler() {
3449 return mHandler;
3450 }
Tyler Gunnc7e07b92021-04-06 11:40:57 -07003451
3452 /**
3453 * Sets this {@link ConnectionService} ready for testing purposes.
3454 * @hide
3455 */
3456 @VisibleForTesting
3457 public void setReadyForTest() {
3458 mAreAccountsInitialized = true;
3459 }
Santos Cordon980acb92014-05-31 10:31:19 -07003460}