blob: 39928ef526afd7e717f5c5e818d849a3cb9f1404 [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;
Junhoedf3d822022-11-24 09:26:37 +000020import android.os.Binder;
Santos Cordon6b7f9552015-05-27 17:21:45 -070021import android.os.Bundle;
Santos Cordon52d8a152014-06-17 19:08:45 -070022import android.os.IBinder.DeathRecipient;
Junhoedf3d822022-11-24 09:26:37 +000023import android.os.OutcomeReceiver;
Sailesh Nepalab5d2822014-03-08 18:01:06 -080024import android.os.RemoteException;
Junhoedf3d822022-11-24 09:26:37 +000025import android.os.ResultReceiver;
Sailesh Nepalab5d2822014-03-08 18:01:06 -080026
Tyler Gunnef9f6f92014-09-12 22:16:17 -070027import com.android.internal.telecom.IConnectionServiceAdapter;
28import com.android.internal.telecom.RemoteServiceCallback;
Ben Giladbb69b0c2013-12-12 18:32:02 -080029
Jay Shraunerb0c0e362014-08-08 16:31:48 -070030import java.util.Collections;
Sailesh Nepal4dd9df52014-07-10 18:15:15 -070031import java.util.Iterator;
Santos Cordon980acb92014-05-31 10:31:19 -070032import java.util.List;
Santos Cordon52d8a152014-06-17 19:08:45 -070033import java.util.Set;
Jay Shraunerb0c0e362014-08-08 16:31:48 -070034import java.util.concurrent.ConcurrentHashMap;
Junhoedf3d822022-11-24 09:26:37 +000035import java.util.concurrent.Executor;
Santos Cordon980acb92014-05-31 10:31:19 -070036
Ben Giladbb69b0c2013-12-12 18:32:02 -080037/**
Sailesh Nepal2a46b902014-07-04 17:21:07 -070038 * Provides methods for IConnectionService implementations to interact with the system phone app.
Sailesh Nepal2bed9562014-07-02 21:26:12 -070039 *
40 * @hide
Ben Giladbb69b0c2013-12-12 18:32:02 -080041 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -070042final class ConnectionServiceAdapter implements DeathRecipient {
Jay Shrauner229e3822014-08-15 09:23:07 -070043 /**
44 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
45 * load factor before resizing, 1 means we only expect a single thread to
46 * access the map so make only a single shard
47 */
Jay Shraunerb0c0e362014-08-08 16:31:48 -070048 private final Set<IConnectionServiceAdapter> mAdapters = Collections.newSetFromMap(
Jay Shrauner229e3822014-08-15 09:23:07 -070049 new ConcurrentHashMap<IConnectionServiceAdapter, Boolean>(8, 0.9f, 1));
Sailesh Nepalab5d2822014-03-08 18:01:06 -080050
Sailesh Nepal2a46b902014-07-04 17:21:07 -070051 ConnectionServiceAdapter() {
Santos Cordon52d8a152014-06-17 19:08:45 -070052 }
53
Sailesh Nepal2a46b902014-07-04 17:21:07 -070054 void addAdapter(IConnectionServiceAdapter adapter) {
Roshan Pius75c36b62015-07-08 16:52:37 -070055 for (IConnectionServiceAdapter it : mAdapters) {
56 if (it.asBinder() == adapter.asBinder()) {
57 Log.w(this, "Ignoring duplicate adapter addition.");
58 return;
59 }
60 }
Santos Cordon52d8a152014-06-17 19:08:45 -070061 if (mAdapters.add(adapter)) {
62 try {
63 adapter.asBinder().linkToDeath(this, 0);
64 } catch (RemoteException e) {
65 mAdapters.remove(adapter);
66 }
67 }
68 }
69
Sailesh Nepal2a46b902014-07-04 17:21:07 -070070 void removeAdapter(IConnectionServiceAdapter adapter) {
Roshan Pius75c36b62015-07-08 16:52:37 -070071 if (adapter != null) {
72 for (IConnectionServiceAdapter it : mAdapters) {
73 if (it.asBinder() == adapter.asBinder() && mAdapters.remove(it)) {
74 adapter.asBinder().unlinkToDeath(this, 0);
75 break;
76 }
77 }
Santos Cordon52d8a152014-06-17 19:08:45 -070078 }
79 }
80
81 /** ${inheritDoc} */
82 @Override
83 public void binderDied() {
Sailesh Nepal4dd9df52014-07-10 18:15:15 -070084 Iterator<IConnectionServiceAdapter> it = mAdapters.iterator();
85 while (it.hasNext()) {
86 IConnectionServiceAdapter adapter = it.next();
Santos Cordon52d8a152014-06-17 19:08:45 -070087 if (!adapter.asBinder().isBinderAlive()) {
Sailesh Nepal4dd9df52014-07-10 18:15:15 -070088 it.remove();
89 adapter.asBinder().unlinkToDeath(this, 0);
Santos Cordon52d8a152014-06-17 19:08:45 -070090 }
91 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -080092 }
Ben Giladbb69b0c2013-12-12 18:32:02 -080093
Ihab Awad6107bab2014-08-18 09:23:25 -070094 void handleCreateConnectionComplete(
Ihab Awadb19a0bc2014-08-07 19:46:01 -070095 String id,
96 ConnectionRequest request,
97 ParcelableConnection connection) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -070098 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -070099 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700100 adapter.handleCreateConnectionComplete(id, request, connection,
101 Log.getExternalSession());
Sailesh Nepal506e3862014-06-25 13:35:14 -0700102 } catch (RemoteException e) {
103 }
104 }
105 }
106
Ravi Paluri80aa2142019-12-02 11:57:37 +0530107 void handleCreateConferenceComplete(
108 String id,
109 ConnectionRequest request,
110 ParcelableConference conference) {
111 for (IConnectionServiceAdapter adapter : mAdapters) {
112 try {
113 adapter.handleCreateConferenceComplete(id, request, conference,
114 Log.getExternalSession());
115 } catch (RemoteException e) {
116 }
117 }
118 }
119
Sailesh Nepal506e3862014-06-25 13:35:14 -0700120 /**
Ben Giladbb69b0c2013-12-12 18:32:02 -0800121 * Sets a call's state to active (e.g., an ongoing call where two parties can actively
122 * communicate).
Santos Cordon37841332013-12-17 13:30:53 -0800123 *
124 * @param callId The unique ID of the call whose state is changing to active.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800125 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700126 void setActive(String callId) {
127 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700128 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700129 adapter.setActive(callId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700130 } catch (RemoteException e) {
131 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800132 }
133 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800134
135 /**
136 * Sets a call's state to ringing (e.g., an inbound ringing call).
Santos Cordon37841332013-12-17 13:30:53 -0800137 *
138 * @param callId The unique ID of the call whose state is changing to ringing.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800139 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700140 void setRinging(String callId) {
141 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700142 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700143 adapter.setRinging(callId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700144 } catch (RemoteException e) {
145 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800146 }
147 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800148
149 /**
150 * Sets a call's state to dialing (e.g., dialing an outbound call).
Santos Cordon37841332013-12-17 13:30:53 -0800151 *
152 * @param callId The unique ID of the call whose state is changing to dialing.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800153 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700154 void setDialing(String callId) {
155 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700156 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700157 adapter.setDialing(callId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700158 } catch (RemoteException e) {
159 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800160 }
161 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800162
163 /**
Tyler Gunnc96b5e02016-07-07 22:53:57 -0700164 * Sets a call's state to pulling (e.g. a call with {@link Connection#PROPERTY_IS_EXTERNAL_CALL}
165 * is being pulled to the local device.
166 *
167 * @param callId The unique ID of the call whose state is changing to dialing.
168 */
169 void setPulling(String callId) {
170 for (IConnectionServiceAdapter adapter : mAdapters) {
171 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700172 adapter.setPulling(callId, Log.getExternalSession());
Tyler Gunnc96b5e02016-07-07 22:53:57 -0700173 } catch (RemoteException e) {
174 }
175 }
176 }
177
178 /**
Ben Giladbb69b0c2013-12-12 18:32:02 -0800179 * Sets a call's state to disconnected.
Santos Cordon37841332013-12-17 13:30:53 -0800180 *
181 * @param callId The unique ID of the call whose state is changing to disconnected.
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700182 * @param disconnectCause The reason for the disconnection, as described by
183 * {@link android.telecomm.DisconnectCause}.
Ben Giladbb69b0c2013-12-12 18:32:02 -0800184 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700185 void setDisconnected(String callId, DisconnectCause disconnectCause) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700186 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700187 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700188 adapter.setDisconnected(callId, disconnectCause, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700189 } catch (RemoteException e) {
190 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800191 }
192 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700193
194 /**
195 * Sets a call's state to be on hold.
196 *
197 * @param callId - The unique ID of the call whose state is changing to be on hold.
198 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700199 void setOnHold(String callId) {
200 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700201 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700202 adapter.setOnHold(callId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700203 } catch (RemoteException e) {
204 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700205 }
206 }
207
Ihab Awadf8358972014-05-28 16:46:42 -0700208 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700209 * Asks Telecom to start or stop a ringback tone for a call.
Ihab Awadf8358972014-05-28 16:46:42 -0700210 *
211 * @param callId The unique ID of the call whose ringback is being changed.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700212 * @param ringback Whether Telecom should start playing a ringback tone.
Ihab Awadf8358972014-05-28 16:46:42 -0700213 */
Andrew Lee100e2932014-09-08 15:34:24 -0700214 void setRingbackRequested(String callId, boolean ringback) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700215 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700216 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700217 adapter.setRingbackRequested(callId, ringback, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700218 } catch (RemoteException e) {
219 }
Ihab Awadf8358972014-05-28 16:46:42 -0700220 }
221 }
Yorke Lee81ccaaa2014-03-12 18:33:19 -0700222
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800223 void setConnectionCapabilities(String callId, int capabilities) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700224 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700225 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700226 adapter.setConnectionCapabilities(callId, capabilities, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700227 } catch (RemoteException ignored) {
228 }
Santos Cordon980acb92014-05-31 10:31:19 -0700229 }
230 }
231
Tyler Gunn720c6642016-03-22 09:02:47 -0700232 void setConnectionProperties(String callId, int properties) {
233 for (IConnectionServiceAdapter adapter : mAdapters) {
234 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700235 adapter.setConnectionProperties(callId, properties, Log.getExternalSession());
Tyler Gunn720c6642016-03-22 09:02:47 -0700236 } catch (RemoteException ignored) {
237 }
238 }
239 }
240
Santos Cordon980acb92014-05-31 10:31:19 -0700241 /**
242 * Indicates whether or not the specified call is currently conferenced into the specified
243 * conference call.
244 *
Santos Cordon980acb92014-05-31 10:31:19 -0700245 * @param callId The unique ID of the call being conferenced.
Santos Cordonb6939982014-06-04 20:20:58 -0700246 * @param conferenceCallId The unique ID of the conference call. Null if call is not
Santos Cordon52d8a152014-06-17 19:08:45 -0700247 * conferenced.
Santos Cordon980acb92014-05-31 10:31:19 -0700248 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700249 void setIsConferenced(String callId, String conferenceCallId) {
250 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700251 try {
Santos Cordon0159ac02014-08-21 14:28:11 -0700252 Log.d(this, "sending connection %s with conference %s", callId, conferenceCallId);
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700253 adapter.setIsConferenced(callId, conferenceCallId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700254 } catch (RemoteException ignored) {
255 }
Santos Cordon980acb92014-05-31 10:31:19 -0700256 }
257 }
258
259 /**
Anthony Lee17455a32015-04-24 15:25:29 -0700260 * Indicates that the merge request on this call has failed.
261 *
262 * @param callId The unique ID of the call being conferenced.
263 */
264 void onConferenceMergeFailed(String callId) {
265 for (IConnectionServiceAdapter adapter : mAdapters) {
266 try {
267 Log.d(this, "merge failed for call %s", callId);
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700268 adapter.setConferenceMergeFailed(callId, Log.getExternalSession());
Anthony Lee17455a32015-04-24 15:25:29 -0700269 } catch (RemoteException ignored) {
270 }
271 }
272 }
273
274 /**
Mengjun Leng25707742017-07-04 11:10:37 +0800275 * Resets the cdma connection time.
276 */
277 void resetConnectionTime(String callId) {
278 for (IConnectionServiceAdapter adapter : mAdapters) {
279 try {
280 adapter.resetConnectionTime(callId, Log.getExternalSession());
281 } catch (RemoteException e) {
282 }
283 }
284 }
285
286 /**
Santos Cordon980acb92014-05-31 10:31:19 -0700287 * Indicates that the call no longer exists. Can be used with either a call or a conference
288 * call.
289 *
290 * @param callId The unique ID of the call.
Santos Cordon980acb92014-05-31 10:31:19 -0700291 */
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700292 void removeCall(String callId) {
293 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700294 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700295 adapter.removeCall(callId, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700296 } catch (RemoteException ignored) {
297 }
Santos Cordon980acb92014-05-31 10:31:19 -0700298 }
299 }
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700300
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700301 void onPostDialWait(String callId, String remaining) {
302 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700303 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700304 adapter.onPostDialWait(callId, remaining, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700305 } catch (RemoteException ignored) {
306 }
Evan Charlton6dea4ac2014-06-03 14:07:13 -0700307 }
308 }
Sailesh Nepal8b4818d2014-06-06 10:54:07 -0700309
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800310 void onPostDialChar(String callId, char nextChar) {
311 for (IConnectionServiceAdapter adapter : mAdapters) {
312 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700313 adapter.onPostDialChar(callId, nextChar, Log.getExternalSession());
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800314 } catch (RemoteException ignored) {
315 }
316 }
317 }
318
Sailesh Nepal8b4818d2014-06-06 10:54:07 -0700319 /**
Santos Cordonb6939982014-06-04 20:20:58 -0700320 * Indicates that a new conference call has been created.
321 *
322 * @param callId The unique ID of the conference call.
323 */
Santos Cordon823fd3c2014-08-07 18:35:18 -0700324 void addConferenceCall(String callId, ParcelableConference parcelableConference) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700325 for (IConnectionServiceAdapter adapter : mAdapters) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700326 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700327 adapter.addConferenceCall(callId, parcelableConference, Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700328 } catch (RemoteException ignored) {
329 }
330 }
331 }
332
333 /**
334 * Retrieves a list of remote connection services usable to place calls.
Santos Cordon52d8a152014-06-17 19:08:45 -0700335 */
Tyler Gunn4c69fb32019-05-17 10:49:16 -0700336 void queryRemoteConnectionServices(RemoteServiceCallback callback, String callingPackage) {
Santos Cordon52d8a152014-06-17 19:08:45 -0700337 // Only supported when there is only one adapter.
338 if (mAdapters.size() == 1) {
339 try {
Tyler Gunn4c69fb32019-05-17 10:49:16 -0700340 mAdapters.iterator().next().queryRemoteConnectionServices(callback, callingPackage,
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700341 Log.getExternalSession());
Santos Cordon52d8a152014-06-17 19:08:45 -0700342 } catch (RemoteException e) {
343 Log.e(this, e, "Exception trying to query for remote CSs");
344 }
Tyler Gunn156a33b2019-05-30 16:52:28 -0700345 } else {
346 try {
347 // This is not an error condition, so just pass back an empty list.
348 // This happens when querying from a remote connection service, not the connection
349 // manager itself.
350 callback.onResult(Collections.EMPTY_LIST, Collections.EMPTY_LIST);
351 } catch (RemoteException e) {
352 Log.e(this, e, "Exception trying to query for remote CSs");
353 }
Santos Cordonb6939982014-06-04 20:20:58 -0700354 }
355 }
Andrew Lee5ffbe8b82014-06-20 16:29:33 -0700356
357 /**
358 * Sets the call video provider for a call.
359 *
360 * @param callId The unique ID of the call to set with the given call video provider.
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700361 * @param videoProvider The call video provider instance to set on the call.
Andrew Lee5ffbe8b82014-06-20 16:29:33 -0700362 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700363 void setVideoProvider(
364 String callId, Connection.VideoProvider videoProvider) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700365 for (IConnectionServiceAdapter adapter : mAdapters) {
Andrew Lee5ffbe8b82014-06-20 16:29:33 -0700366 try {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700367 adapter.setVideoProvider(
Santos Cordone8dc4be2014-07-21 01:28:28 -0700368 callId,
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700369 videoProvider == null ? null : videoProvider.getInterface(),
370 Log.getExternalSession());
Andrew Lee5ffbe8b82014-06-20 16:29:33 -0700371 } catch (RemoteException e) {
372 }
373 }
374 }
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700375
376 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700377 * Requests that the framework use VOIP audio mode for this connection.
378 *
379 * @param callId The unique ID of the call to set with the given call video provider.
380 * @param isVoip True if the audio mode is VOIP.
381 */
Andrew Lee100e2932014-09-08 15:34:24 -0700382 void setIsVoipAudioMode(String callId, boolean isVoip) {
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700383 for (IConnectionServiceAdapter adapter : mAdapters) {
384 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700385 adapter.setIsVoipAudioMode(callId, isVoip, Log.getExternalSession());
Sailesh Nepal33aaae42014-07-07 22:49:44 -0700386 } catch (RemoteException e) {
387 }
388 }
389 }
390
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700391 void setStatusHints(String callId, StatusHints statusHints) {
392 for (IConnectionServiceAdapter adapter : mAdapters) {
393 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700394 adapter.setStatusHints(callId, statusHints, Log.getExternalSession());
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700395 } catch (RemoteException e) {
396 }
397 }
398 }
399
Andrew Lee100e2932014-09-08 15:34:24 -0700400 void setAddress(String callId, Uri address, int presentation) {
Sailesh Nepal2a46b902014-07-04 17:21:07 -0700401 for (IConnectionServiceAdapter adapter : mAdapters) {
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700402 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700403 adapter.setAddress(callId, address, presentation, Log.getExternalSession());
Sailesh Nepal61203862014-07-11 14:50:13 -0700404 } catch (RemoteException e) {
405 }
406 }
407 }
408
409 void setCallerDisplayName(String callId, String callerDisplayName, int presentation) {
410 for (IConnectionServiceAdapter adapter : mAdapters) {
411 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700412 adapter.setCallerDisplayName(callId, callerDisplayName, presentation,
413 Log.getExternalSession());
Sailesh Nepal61203862014-07-11 14:50:13 -0700414 } catch (RemoteException e) {
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700415 }
416 }
417 }
Tyler Gunnaa07df82014-07-17 07:50:22 -0700418
419 /**
420 * Sets the video state associated with a call.
421 *
Tyler Gunn87b73f32015-06-03 10:09:59 -0700422 * Valid values: {@link VideoProfile#STATE_BIDIRECTIONAL},
423 * {@link VideoProfile#STATE_AUDIO_ONLY},
424 * {@link VideoProfile#STATE_TX_ENABLED},
425 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -0700426 *
427 * @param callId The unique ID of the call to set the video state for.
428 * @param videoState The video state.
429 */
430 void setVideoState(String callId, int videoState) {
431 Log.v(this, "setVideoState: %d", videoState);
432 for (IConnectionServiceAdapter adapter : mAdapters) {
433 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700434 adapter.setVideoState(callId, videoState, Log.getExternalSession());
Tyler Gunnaa07df82014-07-17 07:50:22 -0700435 } catch (RemoteException ignored) {
436 }
437 }
438 }
Sailesh Nepal2ab88cc2014-07-18 14:49:18 -0700439
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700440 void setConferenceableConnections(String callId, List<String> conferenceableCallIds) {
441 Log.v(this, "setConferenceableConnections: %s, %s", callId, conferenceableCallIds);
442 for (IConnectionServiceAdapter adapter : mAdapters) {
443 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700444 adapter.setConferenceableConnections(callId, conferenceableCallIds,
445 Log.getExternalSession());
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700446 } catch (RemoteException ignored) {
447 }
448 }
449 }
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700450
451 /**
452 * Informs telecom of an existing connection which was added by the {@link ConnectionService}.
453 *
454 * @param callId The unique ID of the call being added.
455 * @param connection The connection.
456 */
457 void addExistingConnection(String callId, ParcelableConnection connection) {
458 Log.v(this, "addExistingConnection: %s", callId);
459 for (IConnectionServiceAdapter adapter : mAdapters) {
460 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700461 adapter.addExistingConnection(callId, connection, Log.getExternalSession());
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700462 } catch (RemoteException ignored) {
463 }
464 }
465 }
Santos Cordon6b7f9552015-05-27 17:21:45 -0700466
467 /**
Tyler Gunndee56a82016-03-23 16:06:34 -0700468 * Adds some extras associated with a {@code Connection}.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700469 *
470 * @param callId The unique ID of the call.
Tyler Gunndee56a82016-03-23 16:06:34 -0700471 * @param extras The extras to add.
Santos Cordon6b7f9552015-05-27 17:21:45 -0700472 */
Tyler Gunndee56a82016-03-23 16:06:34 -0700473 void putExtras(String callId, Bundle extras) {
474 Log.v(this, "putExtras: %s", callId);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700475 for (IConnectionServiceAdapter adapter : mAdapters) {
476 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700477 adapter.putExtras(callId, extras, 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, boolean value) {
491 Log.v(this, "putExtra: %s %s=%b", callId, key, value);
492 for (IConnectionServiceAdapter adapter : mAdapters) {
493 try {
494 Bundle bundle = new Bundle();
495 bundle.putBoolean(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 * Adds an extra associated with a {@code Connection}.
504 *
505 * @param callId The unique ID of the call.
506 * @param key The extra key.
507 * @param value The extra value.
508 */
509 void putExtra(String callId, String key, int value) {
510 Log.v(this, "putExtra: %s %s=%d", callId, key, value);
511 for (IConnectionServiceAdapter adapter : mAdapters) {
512 try {
513 Bundle bundle = new Bundle();
514 bundle.putInt(key, value);
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700515 adapter.putExtras(callId, bundle, Log.getExternalSession());
Tyler Gunndee56a82016-03-23 16:06:34 -0700516 } catch (RemoteException ignored) {
517 }
518 }
519 }
520
521 /**
522 * Adds an extra associated with a {@code Connection}.
523 *
524 * @param callId The unique ID of the call.
525 * @param key The extra key.
526 * @param value The extra value.
527 */
528 void putExtra(String callId, String key, String value) {
529 Log.v(this, "putExtra: %s %s=%s", callId, key, value);
530 for (IConnectionServiceAdapter adapter : mAdapters) {
531 try {
532 Bundle bundle = new Bundle();
533 bundle.putString(key, value);
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700534 adapter.putExtras(callId, bundle, Log.getExternalSession());
Tyler Gunndee56a82016-03-23 16:06:34 -0700535 } catch (RemoteException ignored) {
536 }
537 }
538 }
539
540 /**
541 * Removes extras associated with a {@code Connection}.
542 * @param callId The unique ID of the call.
543 * @param keys The extra keys to remove.
544 */
545 void removeExtras(String callId, List<String> keys) {
546 Log.v(this, "removeExtras: %s %s", callId, keys);
547 for (IConnectionServiceAdapter adapter : mAdapters) {
548 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700549 adapter.removeExtras(callId, keys, Log.getExternalSession());
Santos Cordon6b7f9552015-05-27 17:21:45 -0700550 } catch (RemoteException ignored) {
551 }
552 }
553 }
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800554
555 /**
Tyler Gunnf5035432017-01-09 09:43:12 -0800556 * Sets the audio route associated with a {@link Connection}.
557 *
558 * @param callId The unique ID of the call.
559 * @param audioRoute The new audio route (see {@code CallAudioState#ROUTE_*}).
560 */
Hall Liua98f58b52017-11-07 17:59:28 -0800561 void setAudioRoute(String callId, int audioRoute, String bluetoothAddress) {
562 Log.v(this, "setAudioRoute: %s %s %s", callId,
563 CallAudioState.audioRouteToString(audioRoute),
564 bluetoothAddress);
Tyler Gunnf5035432017-01-09 09:43:12 -0800565 for (IConnectionServiceAdapter adapter : mAdapters) {
566 try {
Hall Liua98f58b52017-11-07 17:59:28 -0800567 adapter.setAudioRoute(callId, audioRoute,
568 bluetoothAddress, Log.getExternalSession());
Tyler Gunnf5035432017-01-09 09:43:12 -0800569 } catch (RemoteException ignored) {
570 }
571 }
572 }
573
Junhoedf3d822022-11-24 09:26:37 +0000574 /**
575 * Sets the call endpoint associated with a {@link Connection}.
576 *
577 * @param callId The unique ID of the call.
578 * @param endpoint The new call endpoint (see {@link CallEndpoint}).
579 * @param executor The executor of where the callback will execute.
580 * @param callback The callback to notify the result of the endpoint change.
581 */
582 void requestCallEndpointChange(String callId, CallEndpoint endpoint, Executor executor,
583 OutcomeReceiver<Void, CallEndpointException> callback) {
584 Log.v(this, "requestCallEndpointChange");
585 for (IConnectionServiceAdapter adapter : mAdapters) {
586 try {
587 adapter.requestCallEndpointChange(callId, endpoint, new ResultReceiver(null) {
588 @Override
589 protected void onReceiveResult(int resultCode, Bundle result) {
590 super.onReceiveResult(resultCode, result);
591 final long identity = Binder.clearCallingIdentity();
592 try {
593 if (resultCode == CallEndpoint.ENDPOINT_OPERATION_SUCCESS) {
594 executor.execute(() -> callback.onResult(null));
595 } else {
596 executor.execute(() -> callback.onError(result.getParcelable(
597 CallEndpointException.CHANGE_ERROR,
598 CallEndpointException.class)));
599 }
600 } finally {
601 Binder.restoreCallingIdentity(identity);
602 }
603 }}, Log.getExternalSession());
604 } catch (RemoteException ignored) {
605 Log.d(this, "Remote exception calling requestCallEndpointChange");
606 }
607 }
608 }
Tyler Gunnf5035432017-01-09 09:43:12 -0800609
610 /**
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800611 * Informs Telecom of a connection level event.
612 *
613 * @param callId The unique ID of the call.
614 * @param event The event.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700615 * @param extras Extras associated with the event.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800616 */
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700617 void onConnectionEvent(String callId, String event, Bundle extras) {
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800618 Log.v(this, "onConnectionEvent: %s", event);
619 for (IConnectionServiceAdapter adapter : mAdapters) {
620 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700621 adapter.onConnectionEvent(callId, event, extras, Log.getExternalSession());
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800622 } catch (RemoteException ignored) {
623 }
624 }
625 }
Hall Liu57006aa2017-02-06 10:49:48 -0800626
627 /**
628 * Notifies Telecom that an RTT session was successfully established.
629 *
630 * @param callId The unique ID of the call.
631 */
632 void onRttInitiationSuccess(String callId) {
633 Log.v(this, "onRttInitiationSuccess: %s", callId);
634 for (IConnectionServiceAdapter adapter : mAdapters) {
635 try {
636 adapter.onRttInitiationSuccess(callId, Log.getExternalSession());
637 } catch (RemoteException ignored) {
638 }
639 }
640 }
641
642 /**
643 * Notifies Telecom that a requested RTT session failed to be established.
644 *
645 * @param callId The unique ID of the call.
646 */
647 void onRttInitiationFailure(String callId, int reason) {
648 Log.v(this, "onRttInitiationFailure: %s", callId);
649 for (IConnectionServiceAdapter adapter : mAdapters) {
650 try {
651 adapter.onRttInitiationFailure(callId, reason, Log.getExternalSession());
652 } catch (RemoteException ignored) {
653 }
654 }
655 }
656
657 /**
658 * Notifies Telecom that an established RTT session was terminated by the remote user on
659 * the call.
660 *
661 * @param callId The unique ID of the call.
662 */
663 void onRttSessionRemotelyTerminated(String callId) {
664 Log.v(this, "onRttSessionRemotelyTerminated: %s", callId);
665 for (IConnectionServiceAdapter adapter : mAdapters) {
666 try {
667 adapter.onRttSessionRemotelyTerminated(callId, Log.getExternalSession());
668 } catch (RemoteException ignored) {
669 }
670 }
671 }
672
673 /**
674 * Notifies Telecom that the remote user on the call has requested an upgrade to an RTT
675 * session for this call.
676 *
677 * @param callId The unique ID of the call.
678 */
679 void onRemoteRttRequest(String callId) {
680 Log.v(this, "onRemoteRttRequest: %s", callId);
681 for (IConnectionServiceAdapter adapter : mAdapters) {
682 try {
683 adapter.onRemoteRttRequest(callId, Log.getExternalSession());
684 } catch (RemoteException ignored) {
685 }
686 }
687 }
Srikanth Chintalafcb15012017-05-04 20:58:34 +0530688
689 /**
690 * Notifies Telecom that a call's PhoneAccountHandle has changed.
691 *
692 * @param callId The unique ID of the call.
693 * @param pHandle The new PhoneAccountHandle associated with the call.
694 */
695 void onPhoneAccountChanged(String callId, PhoneAccountHandle pHandle) {
696 for (IConnectionServiceAdapter adapter : mAdapters) {
697 try {
698 Log.d(this, "onPhoneAccountChanged %s", callId);
699 adapter.onPhoneAccountChanged(callId, pHandle, Log.getExternalSession());
700 } catch (RemoteException ignored) {
701 }
702 }
703 }
Pengquan Meng63d25a52017-11-21 18:01:13 -0800704
705 /**
706 * Notifies Telecom that the {@link ConnectionService} has released the call resource.
707 */
708 void onConnectionServiceFocusReleased() {
709 for (IConnectionServiceAdapter adapter : mAdapters) {
710 try {
711 Log.d(this, "onConnectionServiceFocusReleased");
712 adapter.onConnectionServiceFocusReleased(Log.getExternalSession());
713 } catch (RemoteException ignored) {
714 }
715 }
716 }
Tyler Gunn68a73a42018-10-03 15:38:57 -0700717
718 /**
719 * Sets whether a conference is treated as a conference or a single party call.
720 * See {@link Conference#setConferenceState(boolean)} for more information.
721 *
722 * @param callId The ID of the telecom call.
723 * @param isConference {@code true} if this call should be treated as a conference,
724 * {@code false} otherwise.
725 */
726 void setConferenceState(String callId, boolean isConference) {
727 Log.v(this, "setConferenceState: %s %b", callId, isConference);
728 for (IConnectionServiceAdapter adapter : mAdapters) {
729 try {
730 adapter.setConferenceState(callId, isConference, Log.getExternalSession());
731 } catch (RemoteException ignored) {
732 }
733 }
734 }
Brad Ebinger31774ae2020-04-08 16:25:12 -0700735
736 /**
737 * Sets the direction of a call. Setting a new direction of an existing call is usually only
738 * applicable during single caller emulation during conferencing, see
739 * {@link Conference#setConferenceState(boolean)} for more information.
740 * @param callId The identifier of the call.
741 * @param direction The new direction of the call.
742 */
743 void setCallDirection(String callId, @Call.Details.CallDirection int direction) {
744 for (IConnectionServiceAdapter a : mAdapters) {
745 try {
746 a.setCallDirection(callId, direction, Log.getExternalSession());
747 } catch (RemoteException e) {
748 }
749 }
750 }
Ben Giladbb69b0c2013-12-12 18:32:02 -0800751}