blob: f8a6cf03934ab728cd003c8bb46e345c648f6ce7 [file] [log] [blame]
Ben Giladbb69b0c2013-12-12 18:32:02 -08001/*
Sailesh Nepalab5d2822014-03-08 18:01:06 -08002 * Copyright (C) 2014 The Android Open Source Project
Ben Giladbb69b0c2013-12-12 18:32:02 -08003 *
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;
Ben Giladbb69b0c2013-12-12 18:32:02 -080018
Sailesh Nepal61203862014-07-11 14:50:13 -070019import android.net.Uri;
Santos Cordon6b7f9552015-05-27 17:21:45 -070020import android.os.Bundle;
Santos Cordon52d8a152014-06-17 19:08:45 -070021import android.os.IBinder.DeathRecipient;
Sailesh Nepalab5d2822014-03-08 18:01:06 -080022import android.os.RemoteException;
23
Tyler Gunnef9f6f92014-09-12 22:16:17 -070024import com.android.internal.telecom.IConnectionServiceAdapter;
25import com.android.internal.telecom.RemoteServiceCallback;
Ben Giladbb69b0c2013-12-12 18:32:02 -080026
Jay Shraunerb0c0e362014-08-08 16:31:48 -070027import java.util.Collections;
Sailesh Nepal4dd9df52014-07-10 18:15:15 -070028import java.util.Iterator;
Santos Cordon980acb92014-05-31 10:31:19 -070029import java.util.List;
Santos Cordon52d8a152014-06-17 19:08:45 -070030import java.util.Set;
Jay Shraunerb0c0e362014-08-08 16:31:48 -070031import java.util.concurrent.ConcurrentHashMap;
Santos Cordon980acb92014-05-31 10:31:19 -070032
Ben Giladbb69b0c2013-12-12 18:32:02 -080033/**
Sailesh Nepal2a46b902014-07-04 17:21:07 -070034 * Provides methods for IConnectionService implementations to interact with the system phone app.
Sailesh Nepal2bed9562014-07-02 21:26:12 -070035 *
36 * @hide
Ben Giladbb69b0c2013-12-12 18:32:02 -080037 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -070038final class ConnectionServiceAdapter implements DeathRecipient {
Jay Shrauner229e3822014-08-15 09:23:07 -070039 /**
40 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
41 * load factor before resizing, 1 means we only expect a single thread to
42 * access the map so make only a single shard
43 */
Jay Shraunerb0c0e362014-08-08 16:31:48 -070044 private final Set<IConnectionServiceAdapter> mAdapters = Collections.newSetFromMap(
Jay Shrauner229e3822014-08-15 09:23:07 -070045 new ConcurrentHashMap<IConnectionServiceAdapter, Boolean>(8, 0.9f, 1));
Sailesh Nepalab5d2822014-03-08 18:01:06 -080046
Sailesh Nepal2a46b902014-07-04 17:21:07 -070047 ConnectionServiceAdapter() {
Santos Cordon52d8a152014-06-17 19:08:45 -070048 }
49
Sailesh Nepal2a46b902014-07-04 17:21:07 -070050 void addAdapter(IConnectionServiceAdapter adapter) {
Roshan Pius75c36b62015-07-08 16:52:37 -070051 for (IConnectionServiceAdapter it : mAdapters) {
52 if (it.asBinder() == adapter.asBinder()) {
53 Log.w(this, "Ignoring duplicate adapter addition.");
54 return;
55 }
56 }
Santos Cordon52d8a152014-06-17 19:08:45 -070057 if (mAdapters.add(adapter)) {
58 try {
59 adapter.asBinder().linkToDeath(this, 0);
60 } catch (RemoteException e) {
61 mAdapters.remove(adapter);
62 }
63 }
64 }
65
Sailesh Nepal2a46b902014-07-04 17:21:07 -070066 void removeAdapter(IConnectionServiceAdapter adapter) {
Roshan Pius75c36b62015-07-08 16:52:37 -070067 if (adapter != null) {
68 for (IConnectionServiceAdapter it : mAdapters) {
69 if (it.asBinder() == adapter.asBinder() && mAdapters.remove(it)) {
70 adapter.asBinder().unlinkToDeath(this, 0);
71 break;
72 }
73 }
Santos Cordon52d8a152014-06-17 19:08:45 -070074 }
75 }
76
77 /** ${inheritDoc} */
78 @Override
79 public void binderDied() {
Sailesh Nepal4dd9df52014-07-10 18:15:15 -070080 Iterator<IConnectionServiceAdapter> it = mAdapters.iterator();
81 while (it.hasNext()) {
82 IConnectionServiceAdapter adapter = it.next();
Santos Cordon52d8a152014-06-17 19:08:45 -070083 if (!adapter.asBinder().isBinderAlive()) {
Sailesh Nepal4dd9df52014-07-10 18:15:15 -070084 it.remove();
85 adapter.asBinder().unlinkToDeath(this, 0);
Santos Cordon52d8a152014-06-17 19:08:45 -070086 }
87 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -080088 }
Ben Giladbb69b0c2013-12-12 18:32:02 -080089
Ihab Awad6107bab2014-08-18 09:23:25 -070090 void handleCreateConnectionComplete(
Ihab Awadb19a0bc2014-08-07 19:46:01 -070091 String id,
92 ConnectionRequest request,
93 ParcelableConnection connection) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -070094 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -070095 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -070096 adapter.handleCreateConnectionComplete(id, request, connection,
97 Log.getExternalSession());
Sailesh Nepal506e3862014-06-25 13:35:14 -070098 } catch (RemoteException e) {
99 }
100 }
101 }
102
Ravi Paluri80aa2142019-12-02 11:57:37 +0530103 void handleCreateConferenceComplete(
104 String id,
105 ConnectionRequest request,
106 ParcelableConference conference) {
107 for (IConnectionServiceAdapter adapter : mAdapters) {
108 try {
109 adapter.handleCreateConferenceComplete(id, request, conference,
110 Log.getExternalSession());
111 } catch (RemoteException e) {
112 }
113 }
114 }
115
Sailesh Nepal506e3862014-06-25 13:35:14 -0700116 /**
Ben Giladbb69b0c2013-12-12 18:32:02 -0800117 * Sets a call's state to active (e.g., an ongoing call where two parties can actively
118 * communicate).
Santos Cordon37841332013-12-17 13:30:53 -0800119 *
120 * @param callId The unique ID of the call whose state is changing to active.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800121 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700122 void setActive(String callId) {
123 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700124 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700125 adapter.setActive(callId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700126 } catch (RemoteException e) {
127 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800128 }
129 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800130
131 /**
132 * Sets a call's state to ringing (e.g., an inbound ringing call).
Santos Cordon37841332013-12-17 13:30:53 -0800133 *
134 * @param callId The unique ID of the call whose state is changing to ringing.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800135 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700136 void setRinging(String callId) {
137 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700138 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700139 adapter.setRinging(callId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700140 } catch (RemoteException e) {
141 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800142 }
143 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800144
145 /**
146 * Sets a call's state to dialing (e.g., dialing an outbound call).
Santos Cordon37841332013-12-17 13:30:53 -0800147 *
148 * @param callId The unique ID of the call whose state is changing to dialing.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800149 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700150 void setDialing(String callId) {
151 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700152 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700153 adapter.setDialing(callId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700154 } catch (RemoteException e) {
155 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800156 }
157 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800158
159 /**
Tyler Gunnc96b5e02016-07-07 22:53:57 -0700160 * Sets a call's state to pulling (e.g. a call with {@link Connection#PROPERTY_IS_EXTERNAL_CALL}
161 * is being pulled to the local device.
162 *
163 * @param callId The unique ID of the call whose state is changing to dialing.
164 */
165 void setPulling(String callId) {
166 for (IConnectionServiceAdapter adapter : mAdapters) {
167 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700168 adapter.setPulling(callId, Log.getExternalSession());
Tyler Gunnc96b5e02016-07-07 22:53:57 -0700169 } catch (RemoteException e) {
170 }
171 }
172 }
173
174 /**
Ben Giladbb69b0c2013-12-12 18:32:02 -0800175 * Sets a call's state to disconnected.
Santos Cordon37841332013-12-17 13:30:53 -0800176 *
177 * @param callId The unique ID of the call whose state is changing to disconnected.
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700178 * @param disconnectCause The reason for the disconnection, as described by
179 * {@link android.telecomm.DisconnectCause}.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800180 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700181 void setDisconnected(String callId, DisconnectCause disconnectCause) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700182 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700183 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700184 adapter.setDisconnected(callId, disconnectCause, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700185 } catch (RemoteException e) {
186 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800187 }
188 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700189
190 /**
191 * Sets a call's state to be on hold.
192 *
193 * @param callId - The unique ID of the call whose state is changing to be on hold.
194 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700195 void setOnHold(String callId) {
196 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700197 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700198 adapter.setOnHold(callId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700199 } catch (RemoteException e) {
200 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700201 }
202 }
203
Ihab Awadf8358972014-05-28 16:46:42 -0700204 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700205 * Asks Telecom to start or stop a ringback tone for a call.
Ihab Awadf8358972014-05-28 16:46:42 -0700206 *
207 * @param callId The unique ID of the call whose ringback is being changed.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700208 * @param ringback Whether Telecom should start playing a ringback tone.
Ihab Awadf8358972014-05-28 16:46:42 -0700209 */
Andrew Lee100e2932014-09-08 15:34:24 -0700210 void setRingbackRequested(String callId, boolean ringback) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700211 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700212 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700213 adapter.setRingbackRequested(callId, ringback, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700214 } catch (RemoteException e) {
215 }
Ihab Awadf8358972014-05-28 16:46:42 -0700216 }
217 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700218
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800219 void setConnectionCapabilities(String callId, int capabilities) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700220 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700221 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700222 adapter.setConnectionCapabilities(callId, capabilities, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700223 } catch (RemoteException ignored) {
224 }
Santos Cordon980acb92014-05-31 10:31:19 -0700225 }
226 }
227
Tyler Gunn720c6642016-03-22 09:02:47 -0700228 void setConnectionProperties(String callId, int properties) {
229 for (IConnectionServiceAdapter adapter : mAdapters) {
230 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700231 adapter.setConnectionProperties(callId, properties, Log.getExternalSession());
Tyler Gunn720c6642016-03-22 09:02:47 -0700232 } catch (RemoteException ignored) {
233 }
234 }
235 }
236
Santos Cordon980acb92014-05-31 10:31:19 -0700237 /**
238 * Indicates whether or not the specified call is currently conferenced into the specified
239 * conference call.
240 *
Santos Cordon980acb92014-05-31 10:31:19 -0700241 * @param callId The unique ID of the call being conferenced.
Santos Cordonb6939982014-06-04 20:20:58 -0700242 * @param conferenceCallId The unique ID of the conference call. Null if call is not
Santos Cordon52d8a152014-06-17 19:08:45 -0700243 * conferenced.
Santos Cordon980acb92014-05-31 10:31:19 -0700244 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700245 void setIsConferenced(String callId, String conferenceCallId) {
246 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700247 try {
Santos Cordon0159ac02014-08-21 14:28:11 -0700248 Log.d(this, "sending connection %s with conference %s", callId, conferenceCallId);
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700249 adapter.setIsConferenced(callId, conferenceCallId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700250 } catch (RemoteException ignored) {
251 }
Santos Cordon980acb92014-05-31 10:31:19 -0700252 }
253 }
254
255 /**
Anthony Lee17455a32015-04-24 15:25:29 -0700256 * Indicates that the merge request on this call has failed.
257 *
258 * @param callId The unique ID of the call being conferenced.
259 */
260 void onConferenceMergeFailed(String callId) {
261 for (IConnectionServiceAdapter adapter : mAdapters) {
262 try {
263 Log.d(this, "merge failed for call %s", callId);
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700264 adapter.setConferenceMergeFailed(callId, Log.getExternalSession());
Anthony Lee17455a32015-04-24 15:25:29 -0700265 } catch (RemoteException ignored) {
266 }
267 }
268 }
269
270 /**
Mengjun Leng25707742017-07-04 11:10:37 +0800271 * Resets the cdma connection time.
272 */
273 void resetConnectionTime(String callId) {
274 for (IConnectionServiceAdapter adapter : mAdapters) {
275 try {
276 adapter.resetConnectionTime(callId, Log.getExternalSession());
277 } catch (RemoteException e) {
278 }
279 }
280 }
281
282 /**
Santos Cordon980acb92014-05-31 10:31:19 -0700283 * Indicates that the call no longer exists. Can be used with either a call or a conference
284 * call.
285 *
286 * @param callId The unique ID of the call.
Santos Cordon980acb92014-05-31 10:31:19 -0700287 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700288 void removeCall(String callId) {
289 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700290 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700291 adapter.removeCall(callId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700292 } catch (RemoteException ignored) {
293 }
Santos Cordon980acb92014-05-31 10:31:19 -0700294 }
295 }
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700296
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700297 void onPostDialWait(String callId, String remaining) {
298 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700299 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700300 adapter.onPostDialWait(callId, remaining, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700301 } catch (RemoteException ignored) {
302 }
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700303 }
304 }
Sailesh Nepal8b4818d2014-06-06 10:54:07 -0700305
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800306 void onPostDialChar(String callId, char nextChar) {
307 for (IConnectionServiceAdapter adapter : mAdapters) {
308 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700309 adapter.onPostDialChar(callId, nextChar, Log.getExternalSession());
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800310 } catch (RemoteException ignored) {
311 }
312 }
313 }
314
Sailesh Nepal8b4818d2014-06-06 10:54:07 -0700315 /**
Santos Cordonb6939982014-06-04 20:20:58 -0700316 * Indicates that a new conference call has been created.
317 *
318 * @param callId The unique ID of the conference call.
319 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700320 void addConferenceCall(String callId, ParcelableConference parcelableConference) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700321 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700322 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700323 adapter.addConferenceCall(callId, parcelableConference, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700324 } catch (RemoteException ignored) {
325 }
326 }
327 }
328
329 /**
330 * Retrieves a list of remote connection services usable to place calls.
Santos Cordon52d8a152014-06-17 19:08:45 -0700331 */
Tyler Gunn4c69fb32019-05-17 10:49:16 -0700332 void queryRemoteConnectionServices(RemoteServiceCallback callback, String callingPackage) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700333 // Only supported when there is only one adapter.
334 if (mAdapters.size() == 1) {
335 try {
Tyler Gunn4c69fb32019-05-17 10:49:16 -0700336 mAdapters.iterator().next().queryRemoteConnectionServices(callback, callingPackage,
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700337 Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700338 } catch (RemoteException e) {
339 Log.e(this, e, "Exception trying to query for remote CSs");
340 }
Tyler Gunn156a33b2019-05-30 16:52:28 -0700341 } else {
342 try {
343 // This is not an error condition, so just pass back an empty list.
344 // This happens when querying from a remote connection service, not the connection
345 // manager itself.
346 callback.onResult(Collections.EMPTY_LIST, Collections.EMPTY_LIST);
347 } catch (RemoteException e) {
348 Log.e(this, e, "Exception trying to query for remote CSs");
349 }
Santos Cordonb6939982014-06-04 20:20:58 -0700350 }
351 }
Andrew Lee5ffbe8b82014-06-20 16:29:33 -0700352
353 /**
354 * Sets the call video provider for a call.
355 *
356 * @param callId The unique ID of the call to set with the given call video provider.
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700357 * @param videoProvider The call video provider instance to set on the call.
Andrew Lee5ffbe8b82014-06-20 16:29:33 -0700358 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700359 void setVideoProvider(
360 String callId, Connection.VideoProvider videoProvider) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700361 for (IConnectionServiceAdapter adapter : mAdapters) {
Andrew Lee5ffbe8b82014-06-20 16:29:33 -0700362 try {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700363 adapter.setVideoProvider(
Santos Cordone8dc4be2014-07-21 01:28:28 -0700364 callId,
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700365 videoProvider == null ? null : videoProvider.getInterface(),
366 Log.getExternalSession());
Andrew Lee5ffbe8b82014-06-20 16:29:33 -0700367 } catch (RemoteException e) {
368 }
369 }
370 }
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700371
372 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700373 * Requests that the framework use VOIP audio mode for this connection.
374 *
375 * @param callId The unique ID of the call to set with the given call video provider.
376 * @param isVoip True if the audio mode is VOIP.
377 */
Andrew Lee100e2932014-09-08 15:34:24 -0700378 void setIsVoipAudioMode(String callId, boolean isVoip) {
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700379 for (IConnectionServiceAdapter adapter : mAdapters) {
380 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700381 adapter.setIsVoipAudioMode(callId, isVoip, Log.getExternalSession());
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700382 } catch (RemoteException e) {
383 }
384 }
385 }
386
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700387 void setStatusHints(String callId, StatusHints statusHints) {
388 for (IConnectionServiceAdapter adapter : mAdapters) {
389 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700390 adapter.setStatusHints(callId, statusHints, Log.getExternalSession());
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700391 } catch (RemoteException e) {
392 }
393 }
394 }
395
Andrew Lee100e2932014-09-08 15:34:24 -0700396 void setAddress(String callId, Uri address, int presentation) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700397 for (IConnectionServiceAdapter adapter : mAdapters) {
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700398 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700399 adapter.setAddress(callId, address, presentation, Log.getExternalSession());
Sailesh Nepal61203862014-07-11 14:50:13 -0700400 } catch (RemoteException e) {
401 }
402 }
403 }
404
405 void setCallerDisplayName(String callId, String callerDisplayName, int presentation) {
406 for (IConnectionServiceAdapter adapter : mAdapters) {
407 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700408 adapter.setCallerDisplayName(callId, callerDisplayName, presentation,
409 Log.getExternalSession());
Sailesh Nepal61203862014-07-11 14:50:13 -0700410 } catch (RemoteException e) {
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700411 }
412 }
413 }
Tyler Gunnaa07df82014-07-17 07:50:22 -0700414
415 /**
416 * Sets the video state associated with a call.
417 *
Tyler Gunn87b73f32015-06-03 10:09:59 -0700418 * Valid values: {@link VideoProfile#STATE_BIDIRECTIONAL},
419 * {@link VideoProfile#STATE_AUDIO_ONLY},
420 * {@link VideoProfile#STATE_TX_ENABLED},
421 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -0700422 *
423 * @param callId The unique ID of the call to set the video state for.
424 * @param videoState The video state.
425 */
426 void setVideoState(String callId, int videoState) {
427 Log.v(this, "setVideoState: %d", videoState);
428 for (IConnectionServiceAdapter adapter : mAdapters) {
429 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700430 adapter.setVideoState(callId, videoState, Log.getExternalSession());
Tyler Gunnaa07df82014-07-17 07:50:22 -0700431 } catch (RemoteException ignored) {
432 }
433 }
434 }
Sailesh Nepal2ab88cc2014-07-18 14:49:18 -0700435
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700436 void setConferenceableConnections(String callId, List<String> conferenceableCallIds) {
437 Log.v(this, "setConferenceableConnections: %s, %s", callId, conferenceableCallIds);
438 for (IConnectionServiceAdapter adapter : mAdapters) {
439 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700440 adapter.setConferenceableConnections(callId, conferenceableCallIds,
441 Log.getExternalSession());
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700442 } catch (RemoteException ignored) {
443 }
444 }
445 }
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700446
447 /**
448 * Informs telecom of an existing connection which was added by the {@link ConnectionService}.
449 *
450 * @param callId The unique ID of the call being added.
451 * @param connection The connection.
452 */
453 void addExistingConnection(String callId, ParcelableConnection connection) {
454 Log.v(this, "addExistingConnection: %s", callId);
455 for (IConnectionServiceAdapter adapter : mAdapters) {
456 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700457 adapter.addExistingConnection(callId, connection, Log.getExternalSession());
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700458 } catch (RemoteException ignored) {
459 }
460 }
461 }
Santos Cordon6b7f9552015-05-27 17:21:45 -0700462
463 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700464 * Adds some extras associated with a {@code Connection}.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700465 *
466 * @param callId The unique ID of the call.
Tyler Gunndee56a82016-03-23 16:06:34 -0700467 * @param extras The extras to add.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700468 */
Tyler Gunndee56a82016-03-23 16:06:34 -0700469 void putExtras(String callId, Bundle extras) {
470 Log.v(this, "putExtras: %s", callId);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700471 for (IConnectionServiceAdapter adapter : mAdapters) {
472 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700473 adapter.putExtras(callId, extras, Log.getExternalSession());
Tyler Gunndee56a82016-03-23 16:06:34 -0700474 } catch (RemoteException ignored) {
475 }
476 }
477 }
478
479 /**
480 * Adds an extra associated with a {@code Connection}.
481 *
482 * @param callId The unique ID of the call.
483 * @param key The extra key.
484 * @param value The extra value.
485 */
486 void putExtra(String callId, String key, boolean value) {
487 Log.v(this, "putExtra: %s %s=%b", callId, key, value);
488 for (IConnectionServiceAdapter adapter : mAdapters) {
489 try {
490 Bundle bundle = new Bundle();
491 bundle.putBoolean(key, value);
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700492 adapter.putExtras(callId, bundle, Log.getExternalSession());
Tyler Gunndee56a82016-03-23 16:06:34 -0700493 } catch (RemoteException ignored) {
494 }
495 }
496 }
497
498 /**
499 * Adds an extra associated with a {@code Connection}.
500 *
501 * @param callId The unique ID of the call.
502 * @param key The extra key.
503 * @param value The extra value.
504 */
505 void putExtra(String callId, String key, int value) {
506 Log.v(this, "putExtra: %s %s=%d", callId, key, value);
507 for (IConnectionServiceAdapter adapter : mAdapters) {
508 try {
509 Bundle bundle = new Bundle();
510 bundle.putInt(key, value);
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700511 adapter.putExtras(callId, bundle, Log.getExternalSession());
Tyler Gunndee56a82016-03-23 16:06:34 -0700512 } catch (RemoteException ignored) {
513 }
514 }
515 }
516
517 /**
518 * Adds an extra associated with a {@code Connection}.
519 *
520 * @param callId The unique ID of the call.
521 * @param key The extra key.
522 * @param value The extra value.
523 */
524 void putExtra(String callId, String key, String value) {
525 Log.v(this, "putExtra: %s %s=%s", callId, key, value);
526 for (IConnectionServiceAdapter adapter : mAdapters) {
527 try {
528 Bundle bundle = new Bundle();
529 bundle.putString(key, value);
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700530 adapter.putExtras(callId, bundle, Log.getExternalSession());
Tyler Gunndee56a82016-03-23 16:06:34 -0700531 } catch (RemoteException ignored) {
532 }
533 }
534 }
535
536 /**
537 * Removes extras associated with a {@code Connection}.
538 * @param callId The unique ID of the call.
539 * @param keys The extra keys to remove.
540 */
541 void removeExtras(String callId, List<String> keys) {
542 Log.v(this, "removeExtras: %s %s", callId, keys);
543 for (IConnectionServiceAdapter adapter : mAdapters) {
544 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700545 adapter.removeExtras(callId, keys, Log.getExternalSession());
Santos Cordon6b7f9552015-05-27 17:21:45 -0700546 } catch (RemoteException ignored) {
547 }
548 }
549 }
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800550
551 /**
Tyler Gunnf5035432017-01-09 09:43:12 -0800552 * Sets the audio route associated with a {@link Connection}.
553 *
554 * @param callId The unique ID of the call.
555 * @param audioRoute The new audio route (see {@code CallAudioState#ROUTE_*}).
556 */
Hall Liua98f58b52017-11-07 17:59:28 -0800557 void setAudioRoute(String callId, int audioRoute, String bluetoothAddress) {
558 Log.v(this, "setAudioRoute: %s %s %s", callId,
559 CallAudioState.audioRouteToString(audioRoute),
560 bluetoothAddress);
Tyler Gunnf5035432017-01-09 09:43:12 -0800561 for (IConnectionServiceAdapter adapter : mAdapters) {
562 try {
Hall Liua98f58b52017-11-07 17:59:28 -0800563 adapter.setAudioRoute(callId, audioRoute,
564 bluetoothAddress, Log.getExternalSession());
Tyler Gunnf5035432017-01-09 09:43:12 -0800565 } catch (RemoteException ignored) {
566 }
567 }
568 }
569
570
571 /**
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800572 * Informs Telecom of a connection level event.
573 *
574 * @param callId The unique ID of the call.
575 * @param event The event.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700576 * @param extras Extras associated with the event.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800577 */
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700578 void onConnectionEvent(String callId, String event, Bundle extras) {
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800579 Log.v(this, "onConnectionEvent: %s", event);
580 for (IConnectionServiceAdapter adapter : mAdapters) {
581 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700582 adapter.onConnectionEvent(callId, event, extras, Log.getExternalSession());
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800583 } catch (RemoteException ignored) {
584 }
585 }
586 }
Hall Liu57006aa2017-02-06 10:49:48 -0800587
588 /**
589 * Notifies Telecom that an RTT session was successfully established.
590 *
591 * @param callId The unique ID of the call.
592 */
593 void onRttInitiationSuccess(String callId) {
594 Log.v(this, "onRttInitiationSuccess: %s", callId);
595 for (IConnectionServiceAdapter adapter : mAdapters) {
596 try {
597 adapter.onRttInitiationSuccess(callId, Log.getExternalSession());
598 } catch (RemoteException ignored) {
599 }
600 }
601 }
602
603 /**
604 * Notifies Telecom that a requested RTT session failed to be established.
605 *
606 * @param callId The unique ID of the call.
607 */
608 void onRttInitiationFailure(String callId, int reason) {
609 Log.v(this, "onRttInitiationFailure: %s", callId);
610 for (IConnectionServiceAdapter adapter : mAdapters) {
611 try {
612 adapter.onRttInitiationFailure(callId, reason, Log.getExternalSession());
613 } catch (RemoteException ignored) {
614 }
615 }
616 }
617
618 /**
619 * Notifies Telecom that an established RTT session was terminated by the remote user on
620 * the call.
621 *
622 * @param callId The unique ID of the call.
623 */
624 void onRttSessionRemotelyTerminated(String callId) {
625 Log.v(this, "onRttSessionRemotelyTerminated: %s", callId);
626 for (IConnectionServiceAdapter adapter : mAdapters) {
627 try {
628 adapter.onRttSessionRemotelyTerminated(callId, Log.getExternalSession());
629 } catch (RemoteException ignored) {
630 }
631 }
632 }
633
634 /**
635 * Notifies Telecom that the remote user on the call has requested an upgrade to an RTT
636 * session for this call.
637 *
638 * @param callId The unique ID of the call.
639 */
640 void onRemoteRttRequest(String callId) {
641 Log.v(this, "onRemoteRttRequest: %s", callId);
642 for (IConnectionServiceAdapter adapter : mAdapters) {
643 try {
644 adapter.onRemoteRttRequest(callId, Log.getExternalSession());
645 } catch (RemoteException ignored) {
646 }
647 }
648 }
Srikanth Chintalafcb15012017-05-04 20:58:34 +0530649
650 /**
651 * Notifies Telecom that a call's PhoneAccountHandle has changed.
652 *
653 * @param callId The unique ID of the call.
654 * @param pHandle The new PhoneAccountHandle associated with the call.
655 */
656 void onPhoneAccountChanged(String callId, PhoneAccountHandle pHandle) {
657 for (IConnectionServiceAdapter adapter : mAdapters) {
658 try {
659 Log.d(this, "onPhoneAccountChanged %s", callId);
660 adapter.onPhoneAccountChanged(callId, pHandle, Log.getExternalSession());
661 } catch (RemoteException ignored) {
662 }
663 }
664 }
Pengquan Meng63d25a52017-11-21 18:01:13 -0800665
666 /**
667 * Notifies Telecom that the {@link ConnectionService} has released the call resource.
668 */
669 void onConnectionServiceFocusReleased() {
670 for (IConnectionServiceAdapter adapter : mAdapters) {
671 try {
672 Log.d(this, "onConnectionServiceFocusReleased");
673 adapter.onConnectionServiceFocusReleased(Log.getExternalSession());
674 } catch (RemoteException ignored) {
675 }
676 }
677 }
Tyler Gunn68a73a42018-10-03 15:38:57 -0700678
679 /**
680 * Sets whether a conference is treated as a conference or a single party call.
681 * See {@link Conference#setConferenceState(boolean)} for more information.
682 *
683 * @param callId The ID of the telecom call.
684 * @param isConference {@code true} if this call should be treated as a conference,
685 * {@code false} otherwise.
686 */
687 void setConferenceState(String callId, boolean isConference) {
688 Log.v(this, "setConferenceState: %s %b", callId, isConference);
689 for (IConnectionServiceAdapter adapter : mAdapters) {
690 try {
691 adapter.setConferenceState(callId, isConference, Log.getExternalSession());
692 } catch (RemoteException ignored) {
693 }
694 }
695 }
Brad Ebinger31774ae2020-04-08 16:25:12 -0700696
697 /**
698 * Sets the direction of a call. Setting a new direction of an existing call is usually only
699 * applicable during single caller emulation during conferencing, see
700 * {@link Conference#setConferenceState(boolean)} for more information.
701 * @param callId The identifier of the call.
702 * @param direction The new direction of the call.
703 */
704 void setCallDirection(String callId, @Call.Details.CallDirection int direction) {
705 for (IConnectionServiceAdapter a : mAdapters) {
706 try {
707 a.setCallDirection(callId, direction, Log.getExternalSession());
708 } catch (RemoteException e) {
709 }
710 }
711 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800712}