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) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 51 | if (mAdapters.add(adapter)) { |
| 52 | try { |
| 53 | adapter.asBinder().linkToDeath(this, 0); |
| 54 | } catch (RemoteException e) { |
| 55 | mAdapters.remove(adapter); |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 60 | void removeAdapter(IConnectionServiceAdapter adapter) { |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 61 | if (adapter != null && mAdapters.remove(adapter)) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 62 | adapter.asBinder().unlinkToDeath(this, 0); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | /** ${inheritDoc} */ |
| 67 | @Override |
| 68 | public void binderDied() { |
Sailesh Nepal | 4dd9df5 | 2014-07-10 18:15:15 -0700 | [diff] [blame] | 69 | Iterator<IConnectionServiceAdapter> it = mAdapters.iterator(); |
| 70 | while (it.hasNext()) { |
| 71 | IConnectionServiceAdapter adapter = it.next(); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 72 | if (!adapter.asBinder().isBinderAlive()) { |
Sailesh Nepal | 4dd9df5 | 2014-07-10 18:15:15 -0700 | [diff] [blame] | 73 | it.remove(); |
| 74 | adapter.asBinder().unlinkToDeath(this, 0); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 75 | } |
| 76 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 77 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 78 | |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 79 | void handleCreateConnectionComplete( |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 80 | String id, |
| 81 | ConnectionRequest request, |
| 82 | ParcelableConnection connection) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 83 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 84 | try { |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 85 | adapter.handleCreateConnectionComplete(id, request, connection); |
Sailesh Nepal | 506e386 | 2014-06-25 13:35:14 -0700 | [diff] [blame] | 86 | } catch (RemoteException e) { |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | /** |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 92 | * Sets a call's state to active (e.g., an ongoing call where two parties can actively |
| 93 | * communicate). |
Santos Cordon | 3784133 | 2013-12-17 13:30:53 -0800 | [diff] [blame] | 94 | * |
| 95 | * @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] | 96 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 97 | void setActive(String callId) { |
| 98 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 99 | try { |
| 100 | adapter.setActive(callId); |
| 101 | } catch (RemoteException e) { |
| 102 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 103 | } |
| 104 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | * 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] | 108 | * |
| 109 | * @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] | 110 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 111 | void setRinging(String callId) { |
| 112 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 113 | try { |
| 114 | adapter.setRinging(callId); |
| 115 | } catch (RemoteException e) { |
| 116 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 117 | } |
| 118 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 119 | |
| 120 | /** |
| 121 | * 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] | 122 | * |
| 123 | * @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] | 124 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 125 | void setDialing(String callId) { |
| 126 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 127 | try { |
| 128 | adapter.setDialing(callId); |
| 129 | } catch (RemoteException e) { |
| 130 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 131 | } |
| 132 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 133 | |
| 134 | /** |
| 135 | * Sets a call's state to disconnected. |
Santos Cordon | 3784133 | 2013-12-17 13:30:53 -0800 | [diff] [blame] | 136 | * |
| 137 | * @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] | 138 | * @param disconnectCause The reason for the disconnection, as described by |
| 139 | * {@link android.telecomm.DisconnectCause}. |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 140 | */ |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 141 | void setDisconnected(String callId, DisconnectCause disconnectCause) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 142 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 143 | try { |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 144 | adapter.setDisconnected(callId, disconnectCause); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 145 | } catch (RemoteException e) { |
| 146 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 147 | } |
| 148 | } |
Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 149 | |
| 150 | /** |
| 151 | * Sets a call's state to be on hold. |
| 152 | * |
| 153 | * @param callId - The unique ID of the call whose state is changing to be on hold. |
| 154 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 155 | void setOnHold(String callId) { |
| 156 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 157 | try { |
| 158 | adapter.setOnHold(callId); |
| 159 | } catch (RemoteException e) { |
| 160 | } |
Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 161 | } |
| 162 | } |
| 163 | |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 164 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 165 | * Asks Telecom to start or stop a ringback tone for a call. |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 166 | * |
| 167 | * @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] | 168 | * @param ringback Whether Telecom should start playing a ringback tone. |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 169 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 170 | void setRingbackRequested(String callId, boolean ringback) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 171 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 172 | try { |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 173 | adapter.setRingbackRequested(callId, ringback); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 174 | } catch (RemoteException e) { |
| 175 | } |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 176 | } |
| 177 | } |
Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 178 | |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 179 | void setConnectionCapabilities(String callId, int capabilities) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 180 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 181 | try { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 182 | adapter.setConnectionCapabilities(callId, capabilities); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 183 | } catch (RemoteException ignored) { |
| 184 | } |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 185 | } |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Indicates whether or not the specified call is currently conferenced into the specified |
| 190 | * conference call. |
| 191 | * |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 192 | * @param callId The unique ID of the call being conferenced. |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 193 | * @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] | 194 | * conferenced. |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 195 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 196 | void setIsConferenced(String callId, String conferenceCallId) { |
| 197 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 198 | try { |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 199 | Log.d(this, "sending connection %s with conference %s", callId, conferenceCallId); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 200 | adapter.setIsConferenced(callId, conferenceCallId); |
| 201 | } catch (RemoteException ignored) { |
| 202 | } |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 203 | } |
| 204 | } |
| 205 | |
| 206 | /** |
Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 207 | * Indicates that the merge request on this call has failed. |
| 208 | * |
| 209 | * @param callId The unique ID of the call being conferenced. |
| 210 | */ |
| 211 | void onConferenceMergeFailed(String callId) { |
| 212 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 213 | try { |
| 214 | Log.d(this, "merge failed for call %s", callId); |
| 215 | adapter.setConferenceMergeFailed(callId); |
| 216 | } catch (RemoteException ignored) { |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | /** |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 222 | * Indicates that the call no longer exists. Can be used with either a call or a conference |
| 223 | * call. |
| 224 | * |
| 225 | * @param callId The unique ID of the call. |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 226 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 227 | void removeCall(String callId) { |
| 228 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 229 | try { |
| 230 | adapter.removeCall(callId); |
| 231 | } catch (RemoteException ignored) { |
| 232 | } |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 233 | } |
| 234 | } |
Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 235 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 236 | void onPostDialWait(String callId, String remaining) { |
| 237 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 238 | try { |
| 239 | adapter.onPostDialWait(callId, remaining); |
| 240 | } catch (RemoteException ignored) { |
| 241 | } |
Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 242 | } |
| 243 | } |
Sailesh Nepal | 8b4818d | 2014-06-06 10:54:07 -0700 | [diff] [blame] | 244 | |
Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 245 | void onPostDialChar(String callId, char nextChar) { |
| 246 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 247 | try { |
| 248 | adapter.onPostDialChar(callId, nextChar); |
| 249 | } catch (RemoteException ignored) { |
| 250 | } |
| 251 | } |
| 252 | } |
| 253 | |
Sailesh Nepal | 8b4818d | 2014-06-06 10:54:07 -0700 | [diff] [blame] | 254 | /** |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 255 | * Indicates that a new conference call has been created. |
| 256 | * |
| 257 | * @param callId The unique ID of the conference call. |
| 258 | */ |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 259 | void addConferenceCall(String callId, ParcelableConference parcelableConference) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 260 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 261 | try { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 262 | adapter.addConferenceCall(callId, parcelableConference); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 263 | } catch (RemoteException ignored) { |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * Retrieves a list of remote connection services usable to place calls. |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 270 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 271 | void queryRemoteConnectionServices(RemoteServiceCallback callback) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 272 | // Only supported when there is only one adapter. |
| 273 | if (mAdapters.size() == 1) { |
| 274 | try { |
| 275 | mAdapters.iterator().next().queryRemoteConnectionServices(callback); |
| 276 | } catch (RemoteException e) { |
| 277 | Log.e(this, e, "Exception trying to query for remote CSs"); |
| 278 | } |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 279 | } |
| 280 | } |
Andrew Lee | 5ffbe8b | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 281 | |
| 282 | /** |
| 283 | * Sets the call video provider for a call. |
| 284 | * |
| 285 | * @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] | 286 | * @param videoProvider The call video provider instance to set on the call. |
Andrew Lee | 5ffbe8b | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 287 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 288 | void setVideoProvider( |
| 289 | String callId, Connection.VideoProvider videoProvider) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 290 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Andrew Lee | 5ffbe8b | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 291 | try { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 292 | adapter.setVideoProvider( |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 293 | callId, |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 294 | videoProvider == null ? null : videoProvider.getInterface()); |
Andrew Lee | 5ffbe8b | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 295 | } catch (RemoteException e) { |
| 296 | } |
| 297 | } |
| 298 | } |
Tyler Gunn | 8d83fa9 | 2014-07-01 11:31:21 -0700 | [diff] [blame] | 299 | |
| 300 | /** |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 301 | * Requests that the framework use VOIP audio mode for this connection. |
| 302 | * |
| 303 | * @param callId The unique ID of the call to set with the given call video provider. |
| 304 | * @param isVoip True if the audio mode is VOIP. |
| 305 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 306 | void setIsVoipAudioMode(String callId, boolean isVoip) { |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 307 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 308 | try { |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 309 | adapter.setIsVoipAudioMode(callId, isVoip); |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 310 | } catch (RemoteException e) { |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 315 | void setStatusHints(String callId, StatusHints statusHints) { |
| 316 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 317 | try { |
| 318 | adapter.setStatusHints(callId, statusHints); |
| 319 | } catch (RemoteException e) { |
| 320 | } |
| 321 | } |
| 322 | } |
| 323 | |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 324 | void setAddress(String callId, Uri address, int presentation) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 325 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Tyler Gunn | 8d83fa9 | 2014-07-01 11:31:21 -0700 | [diff] [blame] | 326 | try { |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 327 | adapter.setAddress(callId, address, presentation); |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 328 | } catch (RemoteException e) { |
| 329 | } |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | void setCallerDisplayName(String callId, String callerDisplayName, int presentation) { |
| 334 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 335 | try { |
| 336 | adapter.setCallerDisplayName(callId, callerDisplayName, presentation); |
| 337 | } catch (RemoteException e) { |
Tyler Gunn | 8d83fa9 | 2014-07-01 11:31:21 -0700 | [diff] [blame] | 338 | } |
| 339 | } |
| 340 | } |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 341 | |
| 342 | /** |
| 343 | * Sets the video state associated with a call. |
| 344 | * |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 345 | * Valid values: {@link VideoProfile.VideoState#AUDIO_ONLY}, |
| 346 | * {@link VideoProfile.VideoState#BIDIRECTIONAL}, |
| 347 | * {@link VideoProfile.VideoState#TX_ENABLED}, |
| 348 | * {@link VideoProfile.VideoState#RX_ENABLED}. |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 349 | * |
| 350 | * @param callId The unique ID of the call to set the video state for. |
| 351 | * @param videoState The video state. |
| 352 | */ |
| 353 | void setVideoState(String callId, int videoState) { |
| 354 | Log.v(this, "setVideoState: %d", videoState); |
| 355 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 356 | try { |
| 357 | adapter.setVideoState(callId, videoState); |
| 358 | } catch (RemoteException ignored) { |
| 359 | } |
| 360 | } |
| 361 | } |
Sailesh Nepal | 2ab88cc | 2014-07-18 14:49:18 -0700 | [diff] [blame] | 362 | |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 363 | void setConferenceableConnections(String callId, List<String> conferenceableCallIds) { |
| 364 | Log.v(this, "setConferenceableConnections: %s, %s", callId, conferenceableCallIds); |
| 365 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 366 | try { |
| 367 | adapter.setConferenceableConnections(callId, conferenceableCallIds); |
| 368 | } catch (RemoteException ignored) { |
| 369 | } |
| 370 | } |
| 371 | } |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 372 | |
| 373 | /** |
| 374 | * Informs telecom of an existing connection which was added by the {@link ConnectionService}. |
| 375 | * |
| 376 | * @param callId The unique ID of the call being added. |
| 377 | * @param connection The connection. |
| 378 | */ |
| 379 | void addExistingConnection(String callId, ParcelableConnection connection) { |
| 380 | Log.v(this, "addExistingConnection: %s", callId); |
| 381 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 382 | try { |
| 383 | adapter.addExistingConnection(callId, connection); |
| 384 | } catch (RemoteException ignored) { |
| 385 | } |
| 386 | } |
| 387 | } |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame^] | 388 | |
| 389 | /** |
| 390 | * Sets extras associated with a connection. |
| 391 | * |
| 392 | * @param callId The unique ID of the call. |
| 393 | * @param extras The extras to associate with this call. |
| 394 | */ |
| 395 | void setExtras(String callId, Bundle extras) { |
| 396 | Log.v(this, "setExtras: %s", extras); |
| 397 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 398 | try { |
| 399 | adapter.setExtras(callId, extras); |
| 400 | } catch (RemoteException ignored) { |
| 401 | } |
| 402 | } |
| 403 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 404 | } |