blob: df7d539d17825ca56f854b1d3daac46ed85752ca [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 {
Ihab Awad6107bab2014-08-18 09:23:25 -070096 adapter.handleCreateConnectionComplete(id, request, connection);
Sailesh Nepal506e3862014-06-25 13:35:14 -070097 } catch (RemoteException e) {
98 }
99 }
100 }
101
102 /**
Ben Giladbb69b0c2013-12-12 18:32:02 -0800103 * Sets a call's state to active (e.g., an ongoing call where two parties can actively
104 * communicate).
Santos Cordon37841332013-12-17 13:30:53 -0800105 *
106 * @param callId The unique ID of the call whose state is changing to active.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800107 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700108 void setActive(String callId) {
109 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700110 try {
111 adapter.setActive(callId);
112 } catch (RemoteException e) {
113 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800114 }
115 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800116
117 /**
118 * Sets a call's state to ringing (e.g., an inbound ringing call).
Santos Cordon37841332013-12-17 13:30:53 -0800119 *
120 * @param callId The unique ID of the call whose state is changing to ringing.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800121 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700122 void setRinging(String callId) {
123 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700124 try {
125 adapter.setRinging(callId);
126 } 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 dialing (e.g., dialing an outbound call).
Santos Cordon37841332013-12-17 13:30:53 -0800133 *
134 * @param callId The unique ID of the call whose state is changing to dialing.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800135 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700136 void setDialing(String callId) {
137 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700138 try {
139 adapter.setDialing(callId);
140 } catch (RemoteException e) {
141 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800142 }
143 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800144
145 /**
Tyler Gunnc96b5e02016-07-07 22:53:57 -0700146 * Sets a call's state to pulling (e.g. a call with {@link Connection#PROPERTY_IS_EXTERNAL_CALL}
147 * is being pulled to the local device.
148 *
149 * @param callId The unique ID of the call whose state is changing to dialing.
150 */
151 void setPulling(String callId) {
152 for (IConnectionServiceAdapter adapter : mAdapters) {
153 try {
154 adapter.setPulling(callId);
155 } catch (RemoteException e) {
156 }
157 }
158 }
159
160 /**
Ben Giladbb69b0c2013-12-12 18:32:02 -0800161 * Sets a call's state to disconnected.
Santos Cordon37841332013-12-17 13:30:53 -0800162 *
163 * @param callId The unique ID of the call whose state is changing to disconnected.
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700164 * @param disconnectCause The reason for the disconnection, as described by
165 * {@link android.telecomm.DisconnectCause}.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800166 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700167 void setDisconnected(String callId, DisconnectCause disconnectCause) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700168 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700169 try {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700170 adapter.setDisconnected(callId, disconnectCause);
Santos Cordon52d8a152014-06-17 19:08:45 -0700171 } catch (RemoteException e) {
172 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800173 }
174 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700175
176 /**
177 * Sets a call's state to be on hold.
178 *
179 * @param callId - The unique ID of the call whose state is changing to be on hold.
180 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700181 void setOnHold(String callId) {
182 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700183 try {
184 adapter.setOnHold(callId);
185 } catch (RemoteException e) {
186 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700187 }
188 }
189
Ihab Awadf8358972014-05-28 16:46:42 -0700190 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700191 * Asks Telecom to start or stop a ringback tone for a call.
Ihab Awadf8358972014-05-28 16:46:42 -0700192 *
193 * @param callId The unique ID of the call whose ringback is being changed.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700194 * @param ringback Whether Telecom should start playing a ringback tone.
Ihab Awadf8358972014-05-28 16:46:42 -0700195 */
Andrew Lee100e2932014-09-08 15:34:24 -0700196 void setRingbackRequested(String callId, boolean ringback) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700197 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700198 try {
Andrew Lee100e2932014-09-08 15:34:24 -0700199 adapter.setRingbackRequested(callId, ringback);
Santos Cordon52d8a152014-06-17 19:08:45 -0700200 } catch (RemoteException e) {
201 }
Ihab Awadf8358972014-05-28 16:46:42 -0700202 }
203 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700204
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800205 void setConnectionCapabilities(String callId, int capabilities) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700206 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700207 try {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800208 adapter.setConnectionCapabilities(callId, capabilities);
Santos Cordon52d8a152014-06-17 19:08:45 -0700209 } catch (RemoteException ignored) {
210 }
Santos Cordon980acb92014-05-31 10:31:19 -0700211 }
212 }
213
Tyler Gunn720c6642016-03-22 09:02:47 -0700214 void setConnectionProperties(String callId, int properties) {
215 for (IConnectionServiceAdapter adapter : mAdapters) {
216 try {
217 adapter.setConnectionProperties(callId, properties);
218 } catch (RemoteException ignored) {
219 }
220 }
221 }
222
Santos Cordon980acb92014-05-31 10:31:19 -0700223 /**
224 * Indicates whether or not the specified call is currently conferenced into the specified
225 * conference call.
226 *
Santos Cordon980acb92014-05-31 10:31:19 -0700227 * @param callId The unique ID of the call being conferenced.
Santos Cordonb6939982014-06-04 20:20:58 -0700228 * @param conferenceCallId The unique ID of the conference call. Null if call is not
Santos Cordon52d8a152014-06-17 19:08:45 -0700229 * conferenced.
Santos Cordon980acb92014-05-31 10:31:19 -0700230 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700231 void setIsConferenced(String callId, String conferenceCallId) {
232 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700233 try {
Santos Cordon0159ac02014-08-21 14:28:11 -0700234 Log.d(this, "sending connection %s with conference %s", callId, conferenceCallId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700235 adapter.setIsConferenced(callId, conferenceCallId);
236 } catch (RemoteException ignored) {
237 }
Santos Cordon980acb92014-05-31 10:31:19 -0700238 }
239 }
240
241 /**
Anthony Lee17455a32015-04-24 15:25:29 -0700242 * Indicates that the merge request on this call has failed.
243 *
244 * @param callId The unique ID of the call being conferenced.
245 */
246 void onConferenceMergeFailed(String callId) {
247 for (IConnectionServiceAdapter adapter : mAdapters) {
248 try {
249 Log.d(this, "merge failed for call %s", callId);
250 adapter.setConferenceMergeFailed(callId);
251 } catch (RemoteException ignored) {
252 }
253 }
254 }
255
256 /**
Santos Cordon980acb92014-05-31 10:31:19 -0700257 * Indicates that the call no longer exists. Can be used with either a call or a conference
258 * call.
259 *
260 * @param callId The unique ID of the call.
Santos Cordon980acb92014-05-31 10:31:19 -0700261 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700262 void removeCall(String callId) {
263 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700264 try {
265 adapter.removeCall(callId);
266 } catch (RemoteException ignored) {
267 }
Santos Cordon980acb92014-05-31 10:31:19 -0700268 }
269 }
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700270
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700271 void onPostDialWait(String callId, String remaining) {
272 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700273 try {
274 adapter.onPostDialWait(callId, remaining);
275 } catch (RemoteException ignored) {
276 }
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700277 }
278 }
Sailesh Nepal8b4818d2014-06-06 10:54:07 -0700279
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800280 void onPostDialChar(String callId, char nextChar) {
281 for (IConnectionServiceAdapter adapter : mAdapters) {
282 try {
283 adapter.onPostDialChar(callId, nextChar);
284 } catch (RemoteException ignored) {
285 }
286 }
287 }
288
Sailesh Nepal8b4818d2014-06-06 10:54:07 -0700289 /**
Santos Cordonb6939982014-06-04 20:20:58 -0700290 * Indicates that a new conference call has been created.
291 *
292 * @param callId The unique ID of the conference call.
293 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700294 void addConferenceCall(String callId, ParcelableConference parcelableConference) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700295 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700296 try {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700297 adapter.addConferenceCall(callId, parcelableConference);
Santos Cordon52d8a152014-06-17 19:08:45 -0700298 } catch (RemoteException ignored) {
299 }
300 }
301 }
302
303 /**
304 * Retrieves a list of remote connection services usable to place calls.
Santos Cordon52d8a152014-06-17 19:08:45 -0700305 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700306 void queryRemoteConnectionServices(RemoteServiceCallback callback) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700307 // Only supported when there is only one adapter.
308 if (mAdapters.size() == 1) {
309 try {
310 mAdapters.iterator().next().queryRemoteConnectionServices(callback);
311 } catch (RemoteException e) {
312 Log.e(this, e, "Exception trying to query for remote CSs");
313 }
Santos Cordonb6939982014-06-04 20:20:58 -0700314 }
315 }
Andrew Lee5ffbe8b2014-06-20 16:29:33 -0700316
317 /**
318 * Sets the call video provider for a call.
319 *
320 * @param callId The unique ID of the call to set with the given call video provider.
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700321 * @param videoProvider The call video provider instance to set on the call.
Andrew Lee5ffbe8b2014-06-20 16:29:33 -0700322 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700323 void setVideoProvider(
324 String callId, Connection.VideoProvider videoProvider) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700325 for (IConnectionServiceAdapter adapter : mAdapters) {
Andrew Lee5ffbe8b2014-06-20 16:29:33 -0700326 try {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700327 adapter.setVideoProvider(
Santos Cordone8dc4be2014-07-21 01:28:28 -0700328 callId,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700329 videoProvider == null ? null : videoProvider.getInterface());
Andrew Lee5ffbe8b2014-06-20 16:29:33 -0700330 } catch (RemoteException e) {
331 }
332 }
333 }
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700334
335 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700336 * Requests that the framework use VOIP audio mode for this connection.
337 *
338 * @param callId The unique ID of the call to set with the given call video provider.
339 * @param isVoip True if the audio mode is VOIP.
340 */
Andrew Lee100e2932014-09-08 15:34:24 -0700341 void setIsVoipAudioMode(String callId, boolean isVoip) {
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700342 for (IConnectionServiceAdapter adapter : mAdapters) {
343 try {
Andrew Lee100e2932014-09-08 15:34:24 -0700344 adapter.setIsVoipAudioMode(callId, isVoip);
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700345 } catch (RemoteException e) {
346 }
347 }
348 }
349
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700350 void setStatusHints(String callId, StatusHints statusHints) {
351 for (IConnectionServiceAdapter adapter : mAdapters) {
352 try {
353 adapter.setStatusHints(callId, statusHints);
354 } catch (RemoteException e) {
355 }
356 }
357 }
358
Andrew Lee100e2932014-09-08 15:34:24 -0700359 void setAddress(String callId, Uri address, int presentation) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700360 for (IConnectionServiceAdapter adapter : mAdapters) {
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700361 try {
Andrew Lee100e2932014-09-08 15:34:24 -0700362 adapter.setAddress(callId, address, presentation);
Sailesh Nepal61203862014-07-11 14:50:13 -0700363 } catch (RemoteException e) {
364 }
365 }
366 }
367
368 void setCallerDisplayName(String callId, String callerDisplayName, int presentation) {
369 for (IConnectionServiceAdapter adapter : mAdapters) {
370 try {
371 adapter.setCallerDisplayName(callId, callerDisplayName, presentation);
372 } catch (RemoteException e) {
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700373 }
374 }
375 }
Tyler Gunnaa07df82014-07-17 07:50:22 -0700376
377 /**
378 * Sets the video state associated with a call.
379 *
Tyler Gunn87b73f32015-06-03 10:09:59 -0700380 * Valid values: {@link VideoProfile#STATE_BIDIRECTIONAL},
381 * {@link VideoProfile#STATE_AUDIO_ONLY},
382 * {@link VideoProfile#STATE_TX_ENABLED},
383 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -0700384 *
385 * @param callId The unique ID of the call to set the video state for.
386 * @param videoState The video state.
387 */
388 void setVideoState(String callId, int videoState) {
389 Log.v(this, "setVideoState: %d", videoState);
390 for (IConnectionServiceAdapter adapter : mAdapters) {
391 try {
392 adapter.setVideoState(callId, videoState);
393 } catch (RemoteException ignored) {
394 }
395 }
396 }
Sailesh Nepal2ab88cc2014-07-18 14:49:18 -0700397
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700398 void setConferenceableConnections(String callId, List<String> conferenceableCallIds) {
399 Log.v(this, "setConferenceableConnections: %s, %s", callId, conferenceableCallIds);
400 for (IConnectionServiceAdapter adapter : mAdapters) {
401 try {
402 adapter.setConferenceableConnections(callId, conferenceableCallIds);
403 } catch (RemoteException ignored) {
404 }
405 }
406 }
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700407
408 /**
409 * Informs telecom of an existing connection which was added by the {@link ConnectionService}.
410 *
411 * @param callId The unique ID of the call being added.
412 * @param connection The connection.
413 */
414 void addExistingConnection(String callId, ParcelableConnection connection) {
415 Log.v(this, "addExistingConnection: %s", callId);
416 for (IConnectionServiceAdapter adapter : mAdapters) {
417 try {
418 adapter.addExistingConnection(callId, connection);
419 } catch (RemoteException ignored) {
420 }
421 }
422 }
Santos Cordon6b7f9552015-05-27 17:21:45 -0700423
424 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700425 * Adds some extras associated with a {@code Connection}.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700426 *
427 * @param callId The unique ID of the call.
Tyler Gunndee56a82016-03-23 16:06:34 -0700428 * @param extras The extras to add.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700429 */
Tyler Gunndee56a82016-03-23 16:06:34 -0700430 void putExtras(String callId, Bundle extras) {
431 Log.v(this, "putExtras: %s", callId);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700432 for (IConnectionServiceAdapter adapter : mAdapters) {
433 try {
Tyler Gunndee56a82016-03-23 16:06:34 -0700434 adapter.putExtras(callId, extras);
435 } catch (RemoteException ignored) {
436 }
437 }
438 }
439
440 /**
441 * Adds an extra associated with a {@code Connection}.
442 *
443 * @param callId The unique ID of the call.
444 * @param key The extra key.
445 * @param value The extra value.
446 */
447 void putExtra(String callId, String key, boolean value) {
448 Log.v(this, "putExtra: %s %s=%b", callId, key, value);
449 for (IConnectionServiceAdapter adapter : mAdapters) {
450 try {
451 Bundle bundle = new Bundle();
452 bundle.putBoolean(key, value);
453 adapter.putExtras(callId, bundle);
454 } catch (RemoteException ignored) {
455 }
456 }
457 }
458
459 /**
460 * Adds an extra associated with a {@code Connection}.
461 *
462 * @param callId The unique ID of the call.
463 * @param key The extra key.
464 * @param value The extra value.
465 */
466 void putExtra(String callId, String key, int value) {
467 Log.v(this, "putExtra: %s %s=%d", callId, key, value);
468 for (IConnectionServiceAdapter adapter : mAdapters) {
469 try {
470 Bundle bundle = new Bundle();
471 bundle.putInt(key, value);
472 adapter.putExtras(callId, bundle);
473 } catch (RemoteException ignored) {
474 }
475 }
476 }
477
478 /**
479 * Adds an extra associated with a {@code Connection}.
480 *
481 * @param callId The unique ID of the call.
482 * @param key The extra key.
483 * @param value The extra value.
484 */
485 void putExtra(String callId, String key, String value) {
486 Log.v(this, "putExtra: %s %s=%s", callId, key, value);
487 for (IConnectionServiceAdapter adapter : mAdapters) {
488 try {
489 Bundle bundle = new Bundle();
490 bundle.putString(key, value);
491 adapter.putExtras(callId, bundle);
492 } catch (RemoteException ignored) {
493 }
494 }
495 }
496
497 /**
498 * Removes extras associated with a {@code Connection}.
499 * @param callId The unique ID of the call.
500 * @param keys The extra keys to remove.
501 */
502 void removeExtras(String callId, List<String> keys) {
503 Log.v(this, "removeExtras: %s %s", callId, keys);
504 for (IConnectionServiceAdapter adapter : mAdapters) {
505 try {
506 adapter.removeExtras(callId, keys);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700507 } catch (RemoteException ignored) {
508 }
509 }
510 }
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800511
512 /**
513 * Informs Telecom of a connection level event.
514 *
515 * @param callId The unique ID of the call.
516 * @param event The event.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700517 * @param extras Extras associated with the event.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800518 */
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700519 void onConnectionEvent(String callId, String event, Bundle extras) {
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800520 Log.v(this, "onConnectionEvent: %s", event);
521 for (IConnectionServiceAdapter adapter : mAdapters) {
522 try {
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700523 adapter.onConnectionEvent(callId, event, extras);
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800524 } catch (RemoteException ignored) {
525 }
526 }
527 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800528}