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