blob: f3fada99c2929a95c2ab0486f3beca79d9f6b008 [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
103 /**
Ben Giladbb69b0c2013-12-12 18:32:02 -0800104 * Sets a call's state to active (e.g., an ongoing call where two parties can actively
105 * communicate).
Santos Cordon37841332013-12-17 13:30:53 -0800106 *
107 * @param callId The unique ID of the call whose state is changing to active.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800108 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700109 void setActive(String callId) {
110 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700111 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700112 adapter.setActive(callId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700113 } catch (RemoteException e) {
114 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800115 }
116 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800117
118 /**
119 * Sets a call's state to ringing (e.g., an inbound ringing call).
Santos Cordon37841332013-12-17 13:30:53 -0800120 *
121 * @param callId The unique ID of the call whose state is changing to ringing.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800122 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700123 void setRinging(String callId) {
124 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700125 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700126 adapter.setRinging(callId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700127 } catch (RemoteException e) {
128 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800129 }
130 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800131
132 /**
133 * Sets a call's state to dialing (e.g., dialing an outbound call).
Santos Cordon37841332013-12-17 13:30:53 -0800134 *
135 * @param callId The unique ID of the call whose state is changing to dialing.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800136 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700137 void setDialing(String callId) {
138 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700139 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700140 adapter.setDialing(callId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700141 } catch (RemoteException e) {
142 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800143 }
144 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800145
146 /**
Tyler Gunnc96b5e02016-07-07 22:53:57 -0700147 * Sets a call's state to pulling (e.g. a call with {@link Connection#PROPERTY_IS_EXTERNAL_CALL}
148 * is being pulled to the local device.
149 *
150 * @param callId The unique ID of the call whose state is changing to dialing.
151 */
152 void setPulling(String callId) {
153 for (IConnectionServiceAdapter adapter : mAdapters) {
154 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700155 adapter.setPulling(callId, Log.getExternalSession());
Tyler Gunnc96b5e02016-07-07 22:53:57 -0700156 } catch (RemoteException e) {
157 }
158 }
159 }
160
161 /**
Ben Giladbb69b0c2013-12-12 18:32:02 -0800162 * Sets a call's state to disconnected.
Santos Cordon37841332013-12-17 13:30:53 -0800163 *
164 * @param callId The unique ID of the call whose state is changing to disconnected.
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700165 * @param disconnectCause The reason for the disconnection, as described by
166 * {@link android.telecomm.DisconnectCause}.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800167 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700168 void setDisconnected(String callId, DisconnectCause disconnectCause) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700169 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700170 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700171 adapter.setDisconnected(callId, disconnectCause, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700172 } catch (RemoteException e) {
173 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800174 }
175 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700176
177 /**
178 * Sets a call's state to be on hold.
179 *
180 * @param callId - The unique ID of the call whose state is changing to be on hold.
181 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700182 void setOnHold(String callId) {
183 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700184 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700185 adapter.setOnHold(callId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700186 } catch (RemoteException e) {
187 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700188 }
189 }
190
Ihab Awadf8358972014-05-28 16:46:42 -0700191 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700192 * Asks Telecom to start or stop a ringback tone for a call.
Ihab Awadf8358972014-05-28 16:46:42 -0700193 *
194 * @param callId The unique ID of the call whose ringback is being changed.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700195 * @param ringback Whether Telecom should start playing a ringback tone.
Ihab Awadf8358972014-05-28 16:46:42 -0700196 */
Andrew Lee100e2932014-09-08 15:34:24 -0700197 void setRingbackRequested(String callId, boolean ringback) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700198 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700199 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700200 adapter.setRingbackRequested(callId, ringback, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700201 } catch (RemoteException e) {
202 }
Ihab Awadf8358972014-05-28 16:46:42 -0700203 }
204 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700205
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800206 void setConnectionCapabilities(String callId, int capabilities) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700207 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700208 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700209 adapter.setConnectionCapabilities(callId, capabilities, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700210 } catch (RemoteException ignored) {
211 }
Santos Cordon980acb92014-05-31 10:31:19 -0700212 }
213 }
214
Tyler Gunn720c6642016-03-22 09:02:47 -0700215 void setConnectionProperties(String callId, int properties) {
216 for (IConnectionServiceAdapter adapter : mAdapters) {
217 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700218 adapter.setConnectionProperties(callId, properties, Log.getExternalSession());
Tyler Gunn720c6642016-03-22 09:02:47 -0700219 } catch (RemoteException ignored) {
220 }
221 }
222 }
223
Santos Cordon980acb92014-05-31 10:31:19 -0700224 /**
225 * Indicates whether or not the specified call is currently conferenced into the specified
226 * conference call.
227 *
Santos Cordon980acb92014-05-31 10:31:19 -0700228 * @param callId The unique ID of the call being conferenced.
Santos Cordonb6939982014-06-04 20:20:58 -0700229 * @param conferenceCallId The unique ID of the conference call. Null if call is not
Santos Cordon52d8a152014-06-17 19:08:45 -0700230 * conferenced.
Santos Cordon980acb92014-05-31 10:31:19 -0700231 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700232 void setIsConferenced(String callId, String conferenceCallId) {
233 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700234 try {
Santos Cordon0159ac02014-08-21 14:28:11 -0700235 Log.d(this, "sending connection %s with conference %s", callId, conferenceCallId);
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700236 adapter.setIsConferenced(callId, conferenceCallId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700237 } catch (RemoteException ignored) {
238 }
Santos Cordon980acb92014-05-31 10:31:19 -0700239 }
240 }
241
242 /**
Anthony Lee17455a32015-04-24 15:25:29 -0700243 * Indicates that the merge request on this call has failed.
244 *
245 * @param callId The unique ID of the call being conferenced.
246 */
247 void onConferenceMergeFailed(String callId) {
248 for (IConnectionServiceAdapter adapter : mAdapters) {
249 try {
250 Log.d(this, "merge failed for call %s", callId);
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700251 adapter.setConferenceMergeFailed(callId, Log.getExternalSession());
Anthony Lee17455a32015-04-24 15:25:29 -0700252 } catch (RemoteException ignored) {
253 }
254 }
255 }
256
257 /**
Santos Cordon980acb92014-05-31 10:31:19 -0700258 * Indicates that the call no longer exists. Can be used with either a call or a conference
259 * call.
260 *
261 * @param callId The unique ID of the call.
Santos Cordon980acb92014-05-31 10:31:19 -0700262 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700263 void removeCall(String callId) {
264 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700265 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700266 adapter.removeCall(callId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700267 } catch (RemoteException ignored) {
268 }
Santos Cordon980acb92014-05-31 10:31:19 -0700269 }
270 }
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700271
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700272 void onPostDialWait(String callId, String remaining) {
273 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700274 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700275 adapter.onPostDialWait(callId, remaining, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700276 } catch (RemoteException ignored) {
277 }
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700278 }
279 }
Sailesh Nepal8b4818d2014-06-06 10:54:07 -0700280
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800281 void onPostDialChar(String callId, char nextChar) {
282 for (IConnectionServiceAdapter adapter : mAdapters) {
283 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700284 adapter.onPostDialChar(callId, nextChar, Log.getExternalSession());
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800285 } catch (RemoteException ignored) {
286 }
287 }
288 }
289
Sailesh Nepal8b4818d2014-06-06 10:54:07 -0700290 /**
Santos Cordonb6939982014-06-04 20:20:58 -0700291 * Indicates that a new conference call has been created.
292 *
293 * @param callId The unique ID of the conference call.
294 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700295 void addConferenceCall(String callId, ParcelableConference parcelableConference) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700296 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700297 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700298 adapter.addConferenceCall(callId, parcelableConference, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700299 } catch (RemoteException ignored) {
300 }
301 }
302 }
303
304 /**
305 * Retrieves a list of remote connection services usable to place calls.
Santos Cordon52d8a152014-06-17 19:08:45 -0700306 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700307 void queryRemoteConnectionServices(RemoteServiceCallback callback) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700308 // Only supported when there is only one adapter.
309 if (mAdapters.size() == 1) {
310 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700311 mAdapters.iterator().next().queryRemoteConnectionServices(callback,
312 Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700313 } catch (RemoteException e) {
314 Log.e(this, e, "Exception trying to query for remote CSs");
315 }
Santos Cordonb6939982014-06-04 20:20:58 -0700316 }
317 }
Andrew Lee5ffbe8b2014-06-20 16:29:33 -0700318
319 /**
320 * Sets the call video provider for a call.
321 *
322 * @param callId The unique ID of the call to set with the given call video provider.
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700323 * @param videoProvider The call video provider instance to set on the call.
Andrew Lee5ffbe8b2014-06-20 16:29:33 -0700324 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700325 void setVideoProvider(
326 String callId, Connection.VideoProvider videoProvider) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700327 for (IConnectionServiceAdapter adapter : mAdapters) {
Andrew Lee5ffbe8b2014-06-20 16:29:33 -0700328 try {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700329 adapter.setVideoProvider(
Santos Cordone8dc4be2014-07-21 01:28:28 -0700330 callId,
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700331 videoProvider == null ? null : videoProvider.getInterface(),
332 Log.getExternalSession());
Andrew Lee5ffbe8b2014-06-20 16:29:33 -0700333 } catch (RemoteException e) {
334 }
335 }
336 }
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700337
338 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700339 * Requests that the framework use VOIP audio mode for this connection.
340 *
341 * @param callId The unique ID of the call to set with the given call video provider.
342 * @param isVoip True if the audio mode is VOIP.
343 */
Andrew Lee100e2932014-09-08 15:34:24 -0700344 void setIsVoipAudioMode(String callId, boolean isVoip) {
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700345 for (IConnectionServiceAdapter adapter : mAdapters) {
346 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700347 adapter.setIsVoipAudioMode(callId, isVoip, Log.getExternalSession());
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700348 } catch (RemoteException e) {
349 }
350 }
351 }
352
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700353 void setStatusHints(String callId, StatusHints statusHints) {
354 for (IConnectionServiceAdapter adapter : mAdapters) {
355 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700356 adapter.setStatusHints(callId, statusHints, Log.getExternalSession());
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700357 } catch (RemoteException e) {
358 }
359 }
360 }
361
Andrew Lee100e2932014-09-08 15:34:24 -0700362 void setAddress(String callId, Uri address, int presentation) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700363 for (IConnectionServiceAdapter adapter : mAdapters) {
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700364 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700365 adapter.setAddress(callId, address, presentation, Log.getExternalSession());
Sailesh Nepal61203862014-07-11 14:50:13 -0700366 } catch (RemoteException e) {
367 }
368 }
369 }
370
371 void setCallerDisplayName(String callId, String callerDisplayName, int presentation) {
372 for (IConnectionServiceAdapter adapter : mAdapters) {
373 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700374 adapter.setCallerDisplayName(callId, callerDisplayName, presentation,
375 Log.getExternalSession());
Sailesh Nepal61203862014-07-11 14:50:13 -0700376 } catch (RemoteException e) {
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700377 }
378 }
379 }
Tyler Gunnaa07df82014-07-17 07:50:22 -0700380
381 /**
382 * Sets the video state associated with a call.
383 *
Tyler Gunn87b73f32015-06-03 10:09:59 -0700384 * Valid values: {@link VideoProfile#STATE_BIDIRECTIONAL},
385 * {@link VideoProfile#STATE_AUDIO_ONLY},
386 * {@link VideoProfile#STATE_TX_ENABLED},
387 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -0700388 *
389 * @param callId The unique ID of the call to set the video state for.
390 * @param videoState The video state.
391 */
392 void setVideoState(String callId, int videoState) {
393 Log.v(this, "setVideoState: %d", videoState);
394 for (IConnectionServiceAdapter adapter : mAdapters) {
395 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700396 adapter.setVideoState(callId, videoState, Log.getExternalSession());
Tyler Gunnaa07df82014-07-17 07:50:22 -0700397 } catch (RemoteException ignored) {
398 }
399 }
400 }
Sailesh Nepal2ab88cc2014-07-18 14:49:18 -0700401
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700402 void setConferenceableConnections(String callId, List<String> conferenceableCallIds) {
403 Log.v(this, "setConferenceableConnections: %s, %s", callId, conferenceableCallIds);
404 for (IConnectionServiceAdapter adapter : mAdapters) {
405 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700406 adapter.setConferenceableConnections(callId, conferenceableCallIds,
407 Log.getExternalSession());
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700408 } catch (RemoteException ignored) {
409 }
410 }
411 }
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700412
413 /**
414 * Informs telecom of an existing connection which was added by the {@link ConnectionService}.
415 *
416 * @param callId The unique ID of the call being added.
417 * @param connection The connection.
418 */
419 void addExistingConnection(String callId, ParcelableConnection connection) {
420 Log.v(this, "addExistingConnection: %s", callId);
421 for (IConnectionServiceAdapter adapter : mAdapters) {
422 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700423 adapter.addExistingConnection(callId, connection, Log.getExternalSession());
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700424 } catch (RemoteException ignored) {
425 }
426 }
427 }
Santos Cordon6b7f9552015-05-27 17:21:45 -0700428
429 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700430 * Adds some extras associated with a {@code Connection}.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700431 *
432 * @param callId The unique ID of the call.
Tyler Gunndee56a82016-03-23 16:06:34 -0700433 * @param extras The extras to add.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700434 */
Tyler Gunndee56a82016-03-23 16:06:34 -0700435 void putExtras(String callId, Bundle extras) {
436 Log.v(this, "putExtras: %s", callId);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700437 for (IConnectionServiceAdapter adapter : mAdapters) {
438 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700439 adapter.putExtras(callId, extras, Log.getExternalSession());
Tyler Gunndee56a82016-03-23 16:06:34 -0700440 } catch (RemoteException ignored) {
441 }
442 }
443 }
444
445 /**
446 * Adds an extra associated with a {@code Connection}.
447 *
448 * @param callId The unique ID of the call.
449 * @param key The extra key.
450 * @param value The extra value.
451 */
452 void putExtra(String callId, String key, boolean value) {
453 Log.v(this, "putExtra: %s %s=%b", callId, key, value);
454 for (IConnectionServiceAdapter adapter : mAdapters) {
455 try {
456 Bundle bundle = new Bundle();
457 bundle.putBoolean(key, value);
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700458 adapter.putExtras(callId, bundle, Log.getExternalSession());
Tyler Gunndee56a82016-03-23 16:06:34 -0700459 } catch (RemoteException ignored) {
460 }
461 }
462 }
463
464 /**
465 * Adds an extra associated with a {@code Connection}.
466 *
467 * @param callId The unique ID of the call.
468 * @param key The extra key.
469 * @param value The extra value.
470 */
471 void putExtra(String callId, String key, int value) {
472 Log.v(this, "putExtra: %s %s=%d", callId, key, value);
473 for (IConnectionServiceAdapter adapter : mAdapters) {
474 try {
475 Bundle bundle = new Bundle();
476 bundle.putInt(key, value);
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700477 adapter.putExtras(callId, bundle, Log.getExternalSession());
Tyler Gunndee56a82016-03-23 16:06:34 -0700478 } catch (RemoteException ignored) {
479 }
480 }
481 }
482
483 /**
484 * Adds an extra associated with a {@code Connection}.
485 *
486 * @param callId The unique ID of the call.
487 * @param key The extra key.
488 * @param value The extra value.
489 */
490 void putExtra(String callId, String key, String value) {
491 Log.v(this, "putExtra: %s %s=%s", callId, key, value);
492 for (IConnectionServiceAdapter adapter : mAdapters) {
493 try {
494 Bundle bundle = new Bundle();
495 bundle.putString(key, value);
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700496 adapter.putExtras(callId, bundle, Log.getExternalSession());
Tyler Gunndee56a82016-03-23 16:06:34 -0700497 } catch (RemoteException ignored) {
498 }
499 }
500 }
501
502 /**
503 * Removes extras associated with a {@code Connection}.
504 * @param callId The unique ID of the call.
505 * @param keys The extra keys to remove.
506 */
507 void removeExtras(String callId, List<String> keys) {
508 Log.v(this, "removeExtras: %s %s", callId, keys);
509 for (IConnectionServiceAdapter adapter : mAdapters) {
510 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700511 adapter.removeExtras(callId, keys, Log.getExternalSession());
Santos Cordon6b7f9552015-05-27 17:21:45 -0700512 } catch (RemoteException ignored) {
513 }
514 }
515 }
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800516
517 /**
518 * Informs Telecom of a connection level event.
519 *
520 * @param callId The unique ID of the call.
521 * @param event The event.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700522 * @param extras Extras associated with the event.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800523 */
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700524 void onConnectionEvent(String callId, String event, Bundle extras) {
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800525 Log.v(this, "onConnectionEvent: %s", event);
526 for (IConnectionServiceAdapter adapter : mAdapters) {
527 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700528 adapter.onConnectionEvent(callId, event, extras, Log.getExternalSession());
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800529 } catch (RemoteException ignored) {
530 }
531 }
532 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800533}