blob: c8cd3c0486fb7059cdbcacea4635ef30115fc52e [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 /**
146 * Sets a call's state to disconnected.
Santos Cordon37841332013-12-17 13:30:53 -0800147 *
148 * @param callId The unique ID of the call whose state is changing to disconnected.
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700149 * @param disconnectCause The reason for the disconnection, as described by
150 * {@link android.telecomm.DisconnectCause}.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800151 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700152 void setDisconnected(String callId, DisconnectCause disconnectCause) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700153 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700154 try {
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700155 adapter.setDisconnected(callId, disconnectCause);
Santos Cordon52d8a152014-06-17 19:08:45 -0700156 } catch (RemoteException e) {
157 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800158 }
159 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700160
161 /**
162 * Sets a call's state to be on hold.
163 *
164 * @param callId - The unique ID of the call whose state is changing to be on hold.
165 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700166 void setOnHold(String callId) {
167 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700168 try {
169 adapter.setOnHold(callId);
170 } catch (RemoteException e) {
171 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700172 }
173 }
174
Ihab Awadf8358972014-05-28 16:46:42 -0700175 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700176 * Asks Telecom to start or stop a ringback tone for a call.
Ihab Awadf8358972014-05-28 16:46:42 -0700177 *
178 * @param callId The unique ID of the call whose ringback is being changed.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700179 * @param ringback Whether Telecom should start playing a ringback tone.
Ihab Awadf8358972014-05-28 16:46:42 -0700180 */
Andrew Lee100e2932014-09-08 15:34:24 -0700181 void setRingbackRequested(String callId, boolean ringback) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700182 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700183 try {
Andrew Lee100e2932014-09-08 15:34:24 -0700184 adapter.setRingbackRequested(callId, ringback);
Santos Cordon52d8a152014-06-17 19:08:45 -0700185 } catch (RemoteException e) {
186 }
Ihab Awadf8358972014-05-28 16:46:42 -0700187 }
188 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700189
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800190 void setConnectionCapabilities(String callId, int capabilities) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700191 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700192 try {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800193 adapter.setConnectionCapabilities(callId, capabilities);
Santos Cordon52d8a152014-06-17 19:08:45 -0700194 } catch (RemoteException ignored) {
195 }
Santos Cordon980acb92014-05-31 10:31:19 -0700196 }
197 }
198
Tyler Gunn720c6642016-03-22 09:02:47 -0700199 void setConnectionProperties(String callId, int properties) {
200 for (IConnectionServiceAdapter adapter : mAdapters) {
201 try {
202 adapter.setConnectionProperties(callId, properties);
203 } catch (RemoteException ignored) {
204 }
205 }
206 }
207
Santos Cordon980acb92014-05-31 10:31:19 -0700208 /**
209 * Indicates whether or not the specified call is currently conferenced into the specified
210 * conference call.
211 *
Santos Cordon980acb92014-05-31 10:31:19 -0700212 * @param callId The unique ID of the call being conferenced.
Santos Cordonb6939982014-06-04 20:20:58 -0700213 * @param conferenceCallId The unique ID of the conference call. Null if call is not
Santos Cordon52d8a152014-06-17 19:08:45 -0700214 * conferenced.
Santos Cordon980acb92014-05-31 10:31:19 -0700215 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700216 void setIsConferenced(String callId, String conferenceCallId) {
217 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700218 try {
Santos Cordon0159ac02014-08-21 14:28:11 -0700219 Log.d(this, "sending connection %s with conference %s", callId, conferenceCallId);
Santos Cordon52d8a152014-06-17 19:08:45 -0700220 adapter.setIsConferenced(callId, conferenceCallId);
221 } catch (RemoteException ignored) {
222 }
Santos Cordon980acb92014-05-31 10:31:19 -0700223 }
224 }
225
226 /**
Anthony Lee17455a32015-04-24 15:25:29 -0700227 * Indicates that the merge request on this call has failed.
228 *
229 * @param callId The unique ID of the call being conferenced.
230 */
231 void onConferenceMergeFailed(String callId) {
232 for (IConnectionServiceAdapter adapter : mAdapters) {
233 try {
234 Log.d(this, "merge failed for call %s", callId);
235 adapter.setConferenceMergeFailed(callId);
236 } catch (RemoteException ignored) {
237 }
238 }
239 }
240
241 /**
Santos Cordon980acb92014-05-31 10:31:19 -0700242 * Indicates that the call no longer exists. Can be used with either a call or a conference
243 * call.
244 *
245 * @param callId The unique ID of the call.
Santos Cordon980acb92014-05-31 10:31:19 -0700246 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700247 void removeCall(String callId) {
248 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700249 try {
250 adapter.removeCall(callId);
251 } catch (RemoteException ignored) {
252 }
Santos Cordon980acb92014-05-31 10:31:19 -0700253 }
254 }
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700255
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700256 void onPostDialWait(String callId, String remaining) {
257 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700258 try {
259 adapter.onPostDialWait(callId, remaining);
260 } catch (RemoteException ignored) {
261 }
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700262 }
263 }
Sailesh Nepal8b4818d2014-06-06 10:54:07 -0700264
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800265 void onPostDialChar(String callId, char nextChar) {
266 for (IConnectionServiceAdapter adapter : mAdapters) {
267 try {
268 adapter.onPostDialChar(callId, nextChar);
269 } catch (RemoteException ignored) {
270 }
271 }
272 }
273
Sailesh Nepal8b4818d2014-06-06 10:54:07 -0700274 /**
Santos Cordonb6939982014-06-04 20:20:58 -0700275 * Indicates that a new conference call has been created.
276 *
277 * @param callId The unique ID of the conference call.
278 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700279 void addConferenceCall(String callId, ParcelableConference parcelableConference) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700280 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700281 try {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700282 adapter.addConferenceCall(callId, parcelableConference);
Santos Cordon52d8a152014-06-17 19:08:45 -0700283 } catch (RemoteException ignored) {
284 }
285 }
286 }
287
288 /**
289 * Retrieves a list of remote connection services usable to place calls.
Santos Cordon52d8a152014-06-17 19:08:45 -0700290 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700291 void queryRemoteConnectionServices(RemoteServiceCallback callback) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700292 // Only supported when there is only one adapter.
293 if (mAdapters.size() == 1) {
294 try {
295 mAdapters.iterator().next().queryRemoteConnectionServices(callback);
296 } catch (RemoteException e) {
297 Log.e(this, e, "Exception trying to query for remote CSs");
298 }
Santos Cordonb6939982014-06-04 20:20:58 -0700299 }
300 }
Andrew Lee5ffbe8b2014-06-20 16:29:33 -0700301
302 /**
303 * Sets the call video provider for a call.
304 *
305 * @param callId The unique ID of the call to set with the given call video provider.
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700306 * @param videoProvider The call video provider instance to set on the call.
Andrew Lee5ffbe8b2014-06-20 16:29:33 -0700307 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700308 void setVideoProvider(
309 String callId, Connection.VideoProvider videoProvider) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700310 for (IConnectionServiceAdapter adapter : mAdapters) {
Andrew Lee5ffbe8b2014-06-20 16:29:33 -0700311 try {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700312 adapter.setVideoProvider(
Santos Cordone8dc4be2014-07-21 01:28:28 -0700313 callId,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700314 videoProvider == null ? null : videoProvider.getInterface());
Andrew Lee5ffbe8b2014-06-20 16:29:33 -0700315 } catch (RemoteException e) {
316 }
317 }
318 }
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700319
320 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700321 * Requests that the framework use VOIP audio mode for this connection.
322 *
323 * @param callId The unique ID of the call to set with the given call video provider.
324 * @param isVoip True if the audio mode is VOIP.
325 */
Andrew Lee100e2932014-09-08 15:34:24 -0700326 void setIsVoipAudioMode(String callId, boolean isVoip) {
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700327 for (IConnectionServiceAdapter adapter : mAdapters) {
328 try {
Andrew Lee100e2932014-09-08 15:34:24 -0700329 adapter.setIsVoipAudioMode(callId, isVoip);
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700330 } catch (RemoteException e) {
331 }
332 }
333 }
334
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700335 void setStatusHints(String callId, StatusHints statusHints) {
336 for (IConnectionServiceAdapter adapter : mAdapters) {
337 try {
338 adapter.setStatusHints(callId, statusHints);
339 } catch (RemoteException e) {
340 }
341 }
342 }
343
Andrew Lee100e2932014-09-08 15:34:24 -0700344 void setAddress(String callId, Uri address, int presentation) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700345 for (IConnectionServiceAdapter adapter : mAdapters) {
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700346 try {
Andrew Lee100e2932014-09-08 15:34:24 -0700347 adapter.setAddress(callId, address, presentation);
Sailesh Nepal61203862014-07-11 14:50:13 -0700348 } catch (RemoteException e) {
349 }
350 }
351 }
352
353 void setCallerDisplayName(String callId, String callerDisplayName, int presentation) {
354 for (IConnectionServiceAdapter adapter : mAdapters) {
355 try {
356 adapter.setCallerDisplayName(callId, callerDisplayName, presentation);
357 } catch (RemoteException e) {
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700358 }
359 }
360 }
Tyler Gunnaa07df82014-07-17 07:50:22 -0700361
362 /**
363 * Sets the video state associated with a call.
364 *
Tyler Gunn87b73f32015-06-03 10:09:59 -0700365 * Valid values: {@link VideoProfile#STATE_BIDIRECTIONAL},
366 * {@link VideoProfile#STATE_AUDIO_ONLY},
367 * {@link VideoProfile#STATE_TX_ENABLED},
368 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -0700369 *
370 * @param callId The unique ID of the call to set the video state for.
371 * @param videoState The video state.
372 */
373 void setVideoState(String callId, int videoState) {
374 Log.v(this, "setVideoState: %d", videoState);
375 for (IConnectionServiceAdapter adapter : mAdapters) {
376 try {
377 adapter.setVideoState(callId, videoState);
378 } catch (RemoteException ignored) {
379 }
380 }
381 }
Sailesh Nepal2ab88cc2014-07-18 14:49:18 -0700382
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700383 void setConferenceableConnections(String callId, List<String> conferenceableCallIds) {
384 Log.v(this, "setConferenceableConnections: %s, %s", callId, conferenceableCallIds);
385 for (IConnectionServiceAdapter adapter : mAdapters) {
386 try {
387 adapter.setConferenceableConnections(callId, conferenceableCallIds);
388 } catch (RemoteException ignored) {
389 }
390 }
391 }
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700392
393 /**
394 * Informs telecom of an existing connection which was added by the {@link ConnectionService}.
395 *
396 * @param callId The unique ID of the call being added.
397 * @param connection The connection.
398 */
399 void addExistingConnection(String callId, ParcelableConnection connection) {
400 Log.v(this, "addExistingConnection: %s", callId);
401 for (IConnectionServiceAdapter adapter : mAdapters) {
402 try {
403 adapter.addExistingConnection(callId, connection);
404 } catch (RemoteException ignored) {
405 }
406 }
407 }
Santos Cordon6b7f9552015-05-27 17:21:45 -0700408
409 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700410 * Adds some extras associated with a {@code Connection}.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700411 *
412 * @param callId The unique ID of the call.
Tyler Gunndee56a82016-03-23 16:06:34 -0700413 * @param extras The extras to add.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700414 */
Tyler Gunndee56a82016-03-23 16:06:34 -0700415 void putExtras(String callId, Bundle extras) {
416 Log.v(this, "putExtras: %s", callId);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700417 for (IConnectionServiceAdapter adapter : mAdapters) {
418 try {
Tyler Gunndee56a82016-03-23 16:06:34 -0700419 adapter.putExtras(callId, extras);
420 } catch (RemoteException ignored) {
421 }
422 }
423 }
424
425 /**
426 * Adds an extra associated with a {@code Connection}.
427 *
428 * @param callId The unique ID of the call.
429 * @param key The extra key.
430 * @param value The extra value.
431 */
432 void putExtra(String callId, String key, boolean value) {
433 Log.v(this, "putExtra: %s %s=%b", callId, key, value);
434 for (IConnectionServiceAdapter adapter : mAdapters) {
435 try {
436 Bundle bundle = new Bundle();
437 bundle.putBoolean(key, value);
438 adapter.putExtras(callId, bundle);
439 } catch (RemoteException ignored) {
440 }
441 }
442 }
443
444 /**
445 * Adds an extra associated with a {@code Connection}.
446 *
447 * @param callId The unique ID of the call.
448 * @param key The extra key.
449 * @param value The extra value.
450 */
451 void putExtra(String callId, String key, int value) {
452 Log.v(this, "putExtra: %s %s=%d", callId, key, value);
453 for (IConnectionServiceAdapter adapter : mAdapters) {
454 try {
455 Bundle bundle = new Bundle();
456 bundle.putInt(key, value);
457 adapter.putExtras(callId, bundle);
458 } catch (RemoteException ignored) {
459 }
460 }
461 }
462
463 /**
464 * Adds an extra associated with a {@code Connection}.
465 *
466 * @param callId The unique ID of the call.
467 * @param key The extra key.
468 * @param value The extra value.
469 */
470 void putExtra(String callId, String key, String value) {
471 Log.v(this, "putExtra: %s %s=%s", callId, key, value);
472 for (IConnectionServiceAdapter adapter : mAdapters) {
473 try {
474 Bundle bundle = new Bundle();
475 bundle.putString(key, value);
476 adapter.putExtras(callId, bundle);
477 } catch (RemoteException ignored) {
478 }
479 }
480 }
481
482 /**
483 * Removes extras associated with a {@code Connection}.
484 * @param callId The unique ID of the call.
485 * @param keys The extra keys to remove.
486 */
487 void removeExtras(String callId, List<String> keys) {
488 Log.v(this, "removeExtras: %s %s", callId, keys);
489 for (IConnectionServiceAdapter adapter : mAdapters) {
490 try {
491 adapter.removeExtras(callId, keys);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700492 } catch (RemoteException ignored) {
493 }
494 }
495 }
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800496
497 /**
498 * Informs Telecom of a connection level event.
499 *
500 * @param callId The unique ID of the call.
501 * @param event The event.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700502 * @param extras Extras associated with the event.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800503 */
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700504 void onConnectionEvent(String callId, String event, Bundle extras) {
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800505 Log.v(this, "onConnectionEvent: %s", event);
506 for (IConnectionServiceAdapter adapter : mAdapters) {
507 try {
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700508 adapter.onConnectionEvent(callId, event, extras);
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800509 } catch (RemoteException ignored) {
510 }
511 }
512 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800513}