Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 1 | /* |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 2 | * Copyright (C) 2014 The Android Open Source Project |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 3 | * |
| 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 Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 17 | package android.telecom; |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 18 | |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 19 | import android.net.Uri; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 20 | import android.os.Bundle; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 21 | import android.os.IBinder.DeathRecipient; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 22 | import android.os.RemoteException; |
| 23 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 24 | import com.android.internal.telecom.IConnectionServiceAdapter; |
| 25 | import com.android.internal.telecom.RemoteServiceCallback; |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 26 | |
Jay Shrauner | b0c0e36 | 2014-08-08 16:31:48 -0700 | [diff] [blame] | 27 | import java.util.Collections; |
Sailesh Nepal | 4dd9df5 | 2014-07-10 18:15:15 -0700 | [diff] [blame] | 28 | import java.util.Iterator; |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 29 | import java.util.List; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 30 | import java.util.Set; |
Jay Shrauner | b0c0e36 | 2014-08-08 16:31:48 -0700 | [diff] [blame] | 31 | import java.util.concurrent.ConcurrentHashMap; |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 32 | |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 33 | /** |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 34 | * Provides methods for IConnectionService implementations to interact with the system phone app. |
Sailesh Nepal | 2bed956 | 2014-07-02 21:26:12 -0700 | [diff] [blame] | 35 | * |
| 36 | * @hide |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 37 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 38 | final class ConnectionServiceAdapter implements DeathRecipient { |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 39 | /** |
| 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 Shrauner | b0c0e36 | 2014-08-08 16:31:48 -0700 | [diff] [blame] | 44 | private final Set<IConnectionServiceAdapter> mAdapters = Collections.newSetFromMap( |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 45 | new ConcurrentHashMap<IConnectionServiceAdapter, Boolean>(8, 0.9f, 1)); |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 46 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 47 | ConnectionServiceAdapter() { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 48 | } |
| 49 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 50 | void addAdapter(IConnectionServiceAdapter adapter) { |
Roshan Pius | 75c36b6 | 2015-07-08 16:52:37 -0700 | [diff] [blame] | 51 | for (IConnectionServiceAdapter it : mAdapters) { |
| 52 | if (it.asBinder() == adapter.asBinder()) { |
| 53 | Log.w(this, "Ignoring duplicate adapter addition."); |
| 54 | return; |
| 55 | } |
| 56 | } |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 57 | 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 Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 66 | void removeAdapter(IConnectionServiceAdapter adapter) { |
Roshan Pius | 75c36b6 | 2015-07-08 16:52:37 -0700 | [diff] [blame] | 67 | 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 Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 74 | } |
| 75 | } |
| 76 | |
| 77 | /** ${inheritDoc} */ |
| 78 | @Override |
| 79 | public void binderDied() { |
Sailesh Nepal | 4dd9df5 | 2014-07-10 18:15:15 -0700 | [diff] [blame] | 80 | Iterator<IConnectionServiceAdapter> it = mAdapters.iterator(); |
| 81 | while (it.hasNext()) { |
| 82 | IConnectionServiceAdapter adapter = it.next(); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 83 | if (!adapter.asBinder().isBinderAlive()) { |
Sailesh Nepal | 4dd9df5 | 2014-07-10 18:15:15 -0700 | [diff] [blame] | 84 | it.remove(); |
| 85 | adapter.asBinder().unlinkToDeath(this, 0); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 86 | } |
| 87 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 88 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 89 | |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 90 | void handleCreateConnectionComplete( |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 91 | String id, |
| 92 | ConnectionRequest request, |
| 93 | ParcelableConnection connection) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 94 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 95 | try { |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 96 | adapter.handleCreateConnectionComplete(id, request, connection); |
Sailesh Nepal | 506e386 | 2014-06-25 13:35:14 -0700 | [diff] [blame] | 97 | } catch (RemoteException e) { |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | /** |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 103 | * Sets a call's state to active (e.g., an ongoing call where two parties can actively |
| 104 | * communicate). |
Santos Cordon | 3784133 | 2013-12-17 13:30:53 -0800 | [diff] [blame] | 105 | * |
| 106 | * @param callId The unique ID of the call whose state is changing to active. |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 107 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 108 | void setActive(String callId) { |
| 109 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 110 | try { |
| 111 | adapter.setActive(callId); |
| 112 | } catch (RemoteException e) { |
| 113 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 114 | } |
| 115 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 116 | |
| 117 | /** |
| 118 | * Sets a call's state to ringing (e.g., an inbound ringing call). |
Santos Cordon | 3784133 | 2013-12-17 13:30:53 -0800 | [diff] [blame] | 119 | * |
| 120 | * @param callId The unique ID of the call whose state is changing to ringing. |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 121 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 122 | void setRinging(String callId) { |
| 123 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 124 | try { |
| 125 | adapter.setRinging(callId); |
| 126 | } catch (RemoteException e) { |
| 127 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 128 | } |
| 129 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 130 | |
| 131 | /** |
| 132 | * Sets a call's state to dialing (e.g., dialing an outbound call). |
Santos Cordon | 3784133 | 2013-12-17 13:30:53 -0800 | [diff] [blame] | 133 | * |
| 134 | * @param callId The unique ID of the call whose state is changing to dialing. |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 135 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 136 | void setDialing(String callId) { |
| 137 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 138 | try { |
| 139 | adapter.setDialing(callId); |
| 140 | } catch (RemoteException e) { |
| 141 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 142 | } |
| 143 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 144 | |
| 145 | /** |
Tyler Gunn | c96b5e0 | 2016-07-07 22:53:57 -0700 | [diff] [blame] | 146 | * 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 Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 161 | * Sets a call's state to disconnected. |
Santos Cordon | 3784133 | 2013-12-17 13:30:53 -0800 | [diff] [blame] | 162 | * |
| 163 | * @param callId The unique ID of the call whose state is changing to disconnected. |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 164 | * @param disconnectCause The reason for the disconnection, as described by |
| 165 | * {@link android.telecomm.DisconnectCause}. |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 166 | */ |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 167 | void setDisconnected(String callId, DisconnectCause disconnectCause) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 168 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 169 | try { |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 170 | adapter.setDisconnected(callId, disconnectCause); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 171 | } catch (RemoteException e) { |
| 172 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 173 | } |
| 174 | } |
Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 175 | |
| 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 Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 181 | void setOnHold(String callId) { |
| 182 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 183 | try { |
| 184 | adapter.setOnHold(callId); |
| 185 | } catch (RemoteException e) { |
| 186 | } |
Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 187 | } |
| 188 | } |
| 189 | |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 190 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 191 | * Asks Telecom to start or stop a ringback tone for a call. |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 192 | * |
| 193 | * @param callId The unique ID of the call whose ringback is being changed. |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 194 | * @param ringback Whether Telecom should start playing a ringback tone. |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 195 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 196 | void setRingbackRequested(String callId, boolean ringback) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 197 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 198 | try { |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 199 | adapter.setRingbackRequested(callId, ringback); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 200 | } catch (RemoteException e) { |
| 201 | } |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 202 | } |
| 203 | } |
Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 204 | |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 205 | void setConnectionCapabilities(String callId, int capabilities) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 206 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 207 | try { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 208 | adapter.setConnectionCapabilities(callId, capabilities); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 209 | } catch (RemoteException ignored) { |
| 210 | } |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 211 | } |
| 212 | } |
| 213 | |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 214 | 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 Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 223 | /** |
| 224 | * Indicates whether or not the specified call is currently conferenced into the specified |
| 225 | * conference call. |
| 226 | * |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 227 | * @param callId The unique ID of the call being conferenced. |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 228 | * @param conferenceCallId The unique ID of the conference call. Null if call is not |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 229 | * conferenced. |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 230 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 231 | void setIsConferenced(String callId, String conferenceCallId) { |
| 232 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 233 | try { |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 234 | Log.d(this, "sending connection %s with conference %s", callId, conferenceCallId); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 235 | adapter.setIsConferenced(callId, conferenceCallId); |
| 236 | } catch (RemoteException ignored) { |
| 237 | } |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 238 | } |
| 239 | } |
| 240 | |
| 241 | /** |
Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 242 | * 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 Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 257 | * 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 Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 261 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 262 | void removeCall(String callId) { |
| 263 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 264 | try { |
| 265 | adapter.removeCall(callId); |
| 266 | } catch (RemoteException ignored) { |
| 267 | } |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 268 | } |
| 269 | } |
Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 270 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 271 | void onPostDialWait(String callId, String remaining) { |
| 272 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 273 | try { |
| 274 | adapter.onPostDialWait(callId, remaining); |
| 275 | } catch (RemoteException ignored) { |
| 276 | } |
Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 277 | } |
| 278 | } |
Sailesh Nepal | 8b4818d | 2014-06-06 10:54:07 -0700 | [diff] [blame] | 279 | |
Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 280 | 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 Nepal | 8b4818d | 2014-06-06 10:54:07 -0700 | [diff] [blame] | 289 | /** |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 290 | * Indicates that a new conference call has been created. |
| 291 | * |
| 292 | * @param callId The unique ID of the conference call. |
| 293 | */ |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 294 | void addConferenceCall(String callId, ParcelableConference parcelableConference) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 295 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 296 | try { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 297 | adapter.addConferenceCall(callId, parcelableConference); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 298 | } catch (RemoteException ignored) { |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * Retrieves a list of remote connection services usable to place calls. |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 305 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 306 | void queryRemoteConnectionServices(RemoteServiceCallback callback) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 307 | // 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 Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 314 | } |
| 315 | } |
Andrew Lee | 5ffbe8b | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 316 | |
| 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 Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 321 | * @param videoProvider The call video provider instance to set on the call. |
Andrew Lee | 5ffbe8b | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 322 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 323 | void setVideoProvider( |
| 324 | String callId, Connection.VideoProvider videoProvider) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 325 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Andrew Lee | 5ffbe8b | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 326 | try { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 327 | adapter.setVideoProvider( |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 328 | callId, |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 329 | videoProvider == null ? null : videoProvider.getInterface()); |
Andrew Lee | 5ffbe8b | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 330 | } catch (RemoteException e) { |
| 331 | } |
| 332 | } |
| 333 | } |
Tyler Gunn | 8d83fa9 | 2014-07-01 11:31:21 -0700 | [diff] [blame] | 334 | |
| 335 | /** |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 336 | * 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 Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 341 | void setIsVoipAudioMode(String callId, boolean isVoip) { |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 342 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 343 | try { |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 344 | adapter.setIsVoipAudioMode(callId, isVoip); |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 345 | } catch (RemoteException e) { |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 350 | 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 Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 359 | void setAddress(String callId, Uri address, int presentation) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 360 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Tyler Gunn | 8d83fa9 | 2014-07-01 11:31:21 -0700 | [diff] [blame] | 361 | try { |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 362 | adapter.setAddress(callId, address, presentation); |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 363 | } 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 Gunn | 8d83fa9 | 2014-07-01 11:31:21 -0700 | [diff] [blame] | 373 | } |
| 374 | } |
| 375 | } |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 376 | |
| 377 | /** |
| 378 | * Sets the video state associated with a call. |
| 379 | * |
Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 380 | * 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 Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 384 | * |
| 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 Nepal | 2ab88cc | 2014-07-18 14:49:18 -0700 | [diff] [blame] | 397 | |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 398 | 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 Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 407 | |
| 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 Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 423 | |
| 424 | /** |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 425 | * Adds some extras associated with a {@code Connection}. |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 426 | * |
| 427 | * @param callId The unique ID of the call. |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 428 | * @param extras The extras to add. |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 429 | */ |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 430 | void putExtras(String callId, Bundle extras) { |
| 431 | Log.v(this, "putExtras: %s", callId); |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 432 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 433 | try { |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 434 | 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 Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 507 | } catch (RemoteException ignored) { |
| 508 | } |
| 509 | } |
| 510 | } |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 511 | |
| 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 Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 517 | * @param extras Extras associated with the event. |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 518 | */ |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 519 | void onConnectionEvent(String callId, String event, Bundle extras) { |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 520 | Log.v(this, "onConnectionEvent: %s", event); |
| 521 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 522 | try { |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 523 | adapter.onConnectionEvent(callId, event, extras); |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 524 | } catch (RemoteException ignored) { |
| 525 | } |
| 526 | } |
| 527 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 528 | } |