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; |
Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame^] | 20 | import android.os.Binder; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 21 | import android.os.Bundle; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 22 | import android.os.IBinder.DeathRecipient; |
Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame^] | 23 | import android.os.OutcomeReceiver; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 24 | import android.os.RemoteException; |
Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame^] | 25 | import android.os.ResultReceiver; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 26 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 27 | import com.android.internal.telecom.IConnectionServiceAdapter; |
| 28 | import com.android.internal.telecom.RemoteServiceCallback; |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 29 | |
Jay Shrauner | b0c0e36 | 2014-08-08 16:31:48 -0700 | [diff] [blame] | 30 | import java.util.Collections; |
Sailesh Nepal | 4dd9df5 | 2014-07-10 18:15:15 -0700 | [diff] [blame] | 31 | import java.util.Iterator; |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 32 | import java.util.List; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 33 | import java.util.Set; |
Jay Shrauner | b0c0e36 | 2014-08-08 16:31:48 -0700 | [diff] [blame] | 34 | import java.util.concurrent.ConcurrentHashMap; |
Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame^] | 35 | import java.util.concurrent.Executor; |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 36 | |
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 | * Provides methods for IConnectionService implementations to interact with the system phone app. |
Sailesh Nepal | 2bed956 | 2014-07-02 21:26:12 -0700 | [diff] [blame] | 39 | * |
| 40 | * @hide |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 41 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 42 | final class ConnectionServiceAdapter implements DeathRecipient { |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 43 | /** |
| 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 Shrauner | b0c0e36 | 2014-08-08 16:31:48 -0700 | [diff] [blame] | 48 | private final Set<IConnectionServiceAdapter> mAdapters = Collections.newSetFromMap( |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 49 | new ConcurrentHashMap<IConnectionServiceAdapter, Boolean>(8, 0.9f, 1)); |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 50 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 51 | ConnectionServiceAdapter() { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 52 | } |
| 53 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 54 | void addAdapter(IConnectionServiceAdapter adapter) { |
Roshan Pius | 75c36b6 | 2015-07-08 16:52:37 -0700 | [diff] [blame] | 55 | for (IConnectionServiceAdapter it : mAdapters) { |
| 56 | if (it.asBinder() == adapter.asBinder()) { |
| 57 | Log.w(this, "Ignoring duplicate adapter addition."); |
| 58 | return; |
| 59 | } |
| 60 | } |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 61 | 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 Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 70 | void removeAdapter(IConnectionServiceAdapter adapter) { |
Roshan Pius | 75c36b6 | 2015-07-08 16:52:37 -0700 | [diff] [blame] | 71 | 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 Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 78 | } |
| 79 | } |
| 80 | |
| 81 | /** ${inheritDoc} */ |
| 82 | @Override |
| 83 | public void binderDied() { |
Sailesh Nepal | 4dd9df5 | 2014-07-10 18:15:15 -0700 | [diff] [blame] | 84 | Iterator<IConnectionServiceAdapter> it = mAdapters.iterator(); |
| 85 | while (it.hasNext()) { |
| 86 | IConnectionServiceAdapter adapter = it.next(); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 87 | if (!adapter.asBinder().isBinderAlive()) { |
Sailesh Nepal | 4dd9df5 | 2014-07-10 18:15:15 -0700 | [diff] [blame] | 88 | it.remove(); |
| 89 | adapter.asBinder().unlinkToDeath(this, 0); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 90 | } |
| 91 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 92 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 93 | |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 94 | void handleCreateConnectionComplete( |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 95 | String id, |
| 96 | ConnectionRequest request, |
| 97 | ParcelableConnection connection) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 98 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 99 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 100 | adapter.handleCreateConnectionComplete(id, request, connection, |
| 101 | Log.getExternalSession()); |
Sailesh Nepal | 506e386 | 2014-06-25 13:35:14 -0700 | [diff] [blame] | 102 | } catch (RemoteException e) { |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 107 | 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 Nepal | 506e386 | 2014-06-25 13:35:14 -0700 | [diff] [blame] | 120 | /** |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 121 | * Sets a call's state to active (e.g., an ongoing call where two parties can actively |
| 122 | * communicate). |
Santos Cordon | 3784133 | 2013-12-17 13:30:53 -0800 | [diff] [blame] | 123 | * |
| 124 | * @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] | 125 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 126 | void setActive(String callId) { |
| 127 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 128 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 129 | adapter.setActive(callId, Log.getExternalSession()); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 130 | } catch (RemoteException e) { |
| 131 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 132 | } |
| 133 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 134 | |
| 135 | /** |
| 136 | * 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] | 137 | * |
| 138 | * @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] | 139 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 140 | void setRinging(String callId) { |
| 141 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 142 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 143 | adapter.setRinging(callId, Log.getExternalSession()); |
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 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 148 | |
| 149 | /** |
| 150 | * 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] | 151 | * |
| 152 | * @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] | 153 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 154 | void setDialing(String callId) { |
| 155 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 156 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 157 | adapter.setDialing(callId, Log.getExternalSession()); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 158 | } catch (RemoteException e) { |
| 159 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 160 | } |
| 161 | } |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 162 | |
| 163 | /** |
Tyler Gunn | c96b5e0 | 2016-07-07 22:53:57 -0700 | [diff] [blame] | 164 | * 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 Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 172 | adapter.setPulling(callId, Log.getExternalSession()); |
Tyler Gunn | c96b5e0 | 2016-07-07 22:53:57 -0700 | [diff] [blame] | 173 | } catch (RemoteException e) { |
| 174 | } |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | /** |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 179 | * Sets a call's state to disconnected. |
Santos Cordon | 3784133 | 2013-12-17 13:30:53 -0800 | [diff] [blame] | 180 | * |
| 181 | * @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] | 182 | * @param disconnectCause The reason for the disconnection, as described by |
| 183 | * {@link android.telecomm.DisconnectCause}. |
Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 184 | */ |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 185 | void setDisconnected(String callId, DisconnectCause disconnectCause) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 186 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 187 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 188 | adapter.setDisconnected(callId, disconnectCause, Log.getExternalSession()); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 189 | } catch (RemoteException e) { |
| 190 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 191 | } |
| 192 | } |
Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 193 | |
| 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 Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 199 | void setOnHold(String callId) { |
| 200 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 201 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 202 | adapter.setOnHold(callId, Log.getExternalSession()); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 203 | } catch (RemoteException e) { |
| 204 | } |
Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 205 | } |
| 206 | } |
| 207 | |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 208 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 209 | * Asks Telecom to start or stop a ringback tone for a call. |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 210 | * |
| 211 | * @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] | 212 | * @param ringback Whether Telecom should start playing a ringback tone. |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 213 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 214 | void setRingbackRequested(String callId, boolean ringback) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 215 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 216 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 217 | adapter.setRingbackRequested(callId, ringback, Log.getExternalSession()); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 218 | } catch (RemoteException e) { |
| 219 | } |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 220 | } |
| 221 | } |
Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 222 | |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 223 | void setConnectionCapabilities(String callId, int capabilities) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 224 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 225 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 226 | adapter.setConnectionCapabilities(callId, capabilities, Log.getExternalSession()); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 227 | } catch (RemoteException ignored) { |
| 228 | } |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 229 | } |
| 230 | } |
| 231 | |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 232 | void setConnectionProperties(String callId, int properties) { |
| 233 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 234 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 235 | adapter.setConnectionProperties(callId, properties, Log.getExternalSession()); |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 236 | } catch (RemoteException ignored) { |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 241 | /** |
| 242 | * Indicates whether or not the specified call is currently conferenced into the specified |
| 243 | * conference call. |
| 244 | * |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 245 | * @param callId The unique ID of the call being conferenced. |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 246 | * @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] | 247 | * conferenced. |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 248 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 249 | void setIsConferenced(String callId, String conferenceCallId) { |
| 250 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 251 | try { |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 252 | Log.d(this, "sending connection %s with conference %s", callId, conferenceCallId); |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 253 | adapter.setIsConferenced(callId, conferenceCallId, Log.getExternalSession()); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 254 | } catch (RemoteException ignored) { |
| 255 | } |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 256 | } |
| 257 | } |
| 258 | |
| 259 | /** |
Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 260 | * 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 Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 268 | adapter.setConferenceMergeFailed(callId, Log.getExternalSession()); |
Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 269 | } catch (RemoteException ignored) { |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | /** |
Mengjun Leng | 2570774 | 2017-07-04 11:10:37 +0800 | [diff] [blame] | 275 | * 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 Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 287 | * 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 Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 291 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 292 | void removeCall(String callId) { |
| 293 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 294 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 295 | adapter.removeCall(callId, Log.getExternalSession()); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 296 | } catch (RemoteException ignored) { |
| 297 | } |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 298 | } |
| 299 | } |
Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 300 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 301 | void onPostDialWait(String callId, String remaining) { |
| 302 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 303 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 304 | adapter.onPostDialWait(callId, remaining, Log.getExternalSession()); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 305 | } catch (RemoteException ignored) { |
| 306 | } |
Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 307 | } |
| 308 | } |
Sailesh Nepal | 8b4818d | 2014-06-06 10:54:07 -0700 | [diff] [blame] | 309 | |
Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 310 | void onPostDialChar(String callId, char nextChar) { |
| 311 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 312 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 313 | adapter.onPostDialChar(callId, nextChar, Log.getExternalSession()); |
Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 314 | } catch (RemoteException ignored) { |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | |
Sailesh Nepal | 8b4818d | 2014-06-06 10:54:07 -0700 | [diff] [blame] | 319 | /** |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 320 | * Indicates that a new conference call has been created. |
| 321 | * |
| 322 | * @param callId The unique ID of the conference call. |
| 323 | */ |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 324 | void addConferenceCall(String callId, ParcelableConference parcelableConference) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 325 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 326 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 327 | adapter.addConferenceCall(callId, parcelableConference, Log.getExternalSession()); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 328 | } catch (RemoteException ignored) { |
| 329 | } |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | /** |
| 334 | * Retrieves a list of remote connection services usable to place calls. |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 335 | */ |
Tyler Gunn | 4c69fb3 | 2019-05-17 10:49:16 -0700 | [diff] [blame] | 336 | void queryRemoteConnectionServices(RemoteServiceCallback callback, String callingPackage) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 337 | // Only supported when there is only one adapter. |
| 338 | if (mAdapters.size() == 1) { |
| 339 | try { |
Tyler Gunn | 4c69fb3 | 2019-05-17 10:49:16 -0700 | [diff] [blame] | 340 | mAdapters.iterator().next().queryRemoteConnectionServices(callback, callingPackage, |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 341 | Log.getExternalSession()); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 342 | } catch (RemoteException e) { |
| 343 | Log.e(this, e, "Exception trying to query for remote CSs"); |
| 344 | } |
Tyler Gunn | 156a33b | 2019-05-30 16:52:28 -0700 | [diff] [blame] | 345 | } 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 Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 354 | } |
| 355 | } |
Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 356 | |
| 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 Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 361 | * @param videoProvider The call video provider instance to set on the call. |
Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 362 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 363 | void setVideoProvider( |
| 364 | String callId, Connection.VideoProvider videoProvider) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 365 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 366 | try { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 367 | adapter.setVideoProvider( |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 368 | callId, |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 369 | videoProvider == null ? null : videoProvider.getInterface(), |
| 370 | Log.getExternalSession()); |
Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 371 | } catch (RemoteException e) { |
| 372 | } |
| 373 | } |
| 374 | } |
Tyler Gunn | 8d83fa9 | 2014-07-01 11:31:21 -0700 | [diff] [blame] | 375 | |
| 376 | /** |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 377 | * 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 Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 382 | void setIsVoipAudioMode(String callId, boolean isVoip) { |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 383 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 384 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 385 | adapter.setIsVoipAudioMode(callId, isVoip, Log.getExternalSession()); |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 386 | } catch (RemoteException e) { |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 | |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 391 | void setStatusHints(String callId, StatusHints statusHints) { |
| 392 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 393 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 394 | adapter.setStatusHints(callId, statusHints, Log.getExternalSession()); |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 395 | } catch (RemoteException e) { |
| 396 | } |
| 397 | } |
| 398 | } |
| 399 | |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 400 | void setAddress(String callId, Uri address, int presentation) { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 401 | for (IConnectionServiceAdapter adapter : mAdapters) { |
Tyler Gunn | 8d83fa9 | 2014-07-01 11:31:21 -0700 | [diff] [blame] | 402 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 403 | adapter.setAddress(callId, address, presentation, Log.getExternalSession()); |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 404 | } catch (RemoteException e) { |
| 405 | } |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | void setCallerDisplayName(String callId, String callerDisplayName, int presentation) { |
| 410 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 411 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 412 | adapter.setCallerDisplayName(callId, callerDisplayName, presentation, |
| 413 | Log.getExternalSession()); |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 414 | } catch (RemoteException e) { |
Tyler Gunn | 8d83fa9 | 2014-07-01 11:31:21 -0700 | [diff] [blame] | 415 | } |
| 416 | } |
| 417 | } |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 418 | |
| 419 | /** |
| 420 | * Sets the video state associated with a call. |
| 421 | * |
Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 422 | * 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 Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 426 | * |
| 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 Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 434 | adapter.setVideoState(callId, videoState, Log.getExternalSession()); |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 435 | } catch (RemoteException ignored) { |
| 436 | } |
| 437 | } |
| 438 | } |
Sailesh Nepal | 2ab88cc | 2014-07-18 14:49:18 -0700 | [diff] [blame] | 439 | |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 440 | void setConferenceableConnections(String callId, List<String> conferenceableCallIds) { |
| 441 | Log.v(this, "setConferenceableConnections: %s, %s", callId, conferenceableCallIds); |
| 442 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 443 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 444 | adapter.setConferenceableConnections(callId, conferenceableCallIds, |
| 445 | Log.getExternalSession()); |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 446 | } catch (RemoteException ignored) { |
| 447 | } |
| 448 | } |
| 449 | } |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 450 | |
| 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 Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 461 | adapter.addExistingConnection(callId, connection, Log.getExternalSession()); |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 462 | } catch (RemoteException ignored) { |
| 463 | } |
| 464 | } |
| 465 | } |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 466 | |
| 467 | /** |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 468 | * Adds some extras associated with a {@code Connection}. |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 469 | * |
| 470 | * @param callId The unique ID of the call. |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 471 | * @param extras The extras to add. |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 472 | */ |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 473 | void putExtras(String callId, Bundle extras) { |
| 474 | Log.v(this, "putExtras: %s", callId); |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 475 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 476 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 477 | adapter.putExtras(callId, extras, Log.getExternalSession()); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 478 | } 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 Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 496 | adapter.putExtras(callId, bundle, Log.getExternalSession()); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 497 | } 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 Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 515 | adapter.putExtras(callId, bundle, Log.getExternalSession()); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 516 | } 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 Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 534 | adapter.putExtras(callId, bundle, Log.getExternalSession()); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 535 | } 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 Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 549 | adapter.removeExtras(callId, keys, Log.getExternalSession()); |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 550 | } catch (RemoteException ignored) { |
| 551 | } |
| 552 | } |
| 553 | } |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 554 | |
| 555 | /** |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 556 | * 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 Liu | a98f58b5 | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 561 | void setAudioRoute(String callId, int audioRoute, String bluetoothAddress) { |
| 562 | Log.v(this, "setAudioRoute: %s %s %s", callId, |
| 563 | CallAudioState.audioRouteToString(audioRoute), |
| 564 | bluetoothAddress); |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 565 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 566 | try { |
Hall Liu | a98f58b5 | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 567 | adapter.setAudioRoute(callId, audioRoute, |
| 568 | bluetoothAddress, Log.getExternalSession()); |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 569 | } catch (RemoteException ignored) { |
| 570 | } |
| 571 | } |
| 572 | } |
| 573 | |
Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame^] | 574 | /** |
| 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 Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 609 | |
| 610 | /** |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 611 | * Informs Telecom of a connection level event. |
| 612 | * |
| 613 | * @param callId The unique ID of the call. |
| 614 | * @param event The event. |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 615 | * @param extras Extras associated with the event. |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 616 | */ |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 617 | void onConnectionEvent(String callId, String event, Bundle extras) { |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 618 | Log.v(this, "onConnectionEvent: %s", event); |
| 619 | for (IConnectionServiceAdapter adapter : mAdapters) { |
| 620 | try { |
Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 621 | adapter.onConnectionEvent(callId, event, extras, Log.getExternalSession()); |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 622 | } catch (RemoteException ignored) { |
| 623 | } |
| 624 | } |
| 625 | } |
Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 626 | |
| 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 Chintala | fcb1501 | 2017-05-04 20:58:34 +0530 | [diff] [blame] | 688 | |
| 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 Meng | 63d25a5 | 2017-11-21 18:01:13 -0800 | [diff] [blame] | 704 | |
| 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 Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 717 | |
| 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 Ebinger | 31774ae | 2020-04-08 16:25:12 -0700 | [diff] [blame] | 735 | |
| 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 Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 751 | } |