| 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 |  | 
| yongnamcha | 8ec5624 | 2022-11-28 06:23:02 +0000 | [diff] [blame] | 19 | import android.annotation.CallbackExecutor; | 
 | 20 | import android.annotation.NonNull; | 
 | 21 | import android.location.Location; | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 22 | import android.net.Uri; | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 23 | import android.os.Binder; | 
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 24 | import android.os.Bundle; | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 25 | import android.os.IBinder.DeathRecipient; | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 26 | import android.os.OutcomeReceiver; | 
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 27 | import android.os.RemoteException; | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 28 | import android.os.ResultReceiver; | 
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 29 |  | 
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 30 | import com.android.internal.telecom.IConnectionServiceAdapter; | 
 | 31 | import com.android.internal.telecom.RemoteServiceCallback; | 
| Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 32 |  | 
| Jay Shrauner | b0c0e36 | 2014-08-08 16:31:48 -0700 | [diff] [blame] | 33 | import java.util.Collections; | 
| Sailesh Nepal | 4dd9df5 | 2014-07-10 18:15:15 -0700 | [diff] [blame] | 34 | import java.util.Iterator; | 
| Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 35 | import java.util.List; | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 36 | import java.util.Set; | 
| Jay Shrauner | b0c0e36 | 2014-08-08 16:31:48 -0700 | [diff] [blame] | 37 | import java.util.concurrent.ConcurrentHashMap; | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 38 | import java.util.concurrent.Executor; | 
| Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 39 |  | 
| Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 40 | /** | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 41 |  * Provides methods for IConnectionService implementations to interact with the system phone app. | 
| Sailesh Nepal | 2bed956 | 2014-07-02 21:26:12 -0700 | [diff] [blame] | 42 |  * | 
 | 43 |  * @hide | 
| Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 44 |  */ | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 45 | final class ConnectionServiceAdapter implements DeathRecipient { | 
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 46 |     /** | 
 | 47 |      * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is | 
 | 48 |      * load factor before resizing, 1 means we only expect a single thread to | 
 | 49 |      * access the map so make only a single shard | 
 | 50 |      */ | 
| Jay Shrauner | b0c0e36 | 2014-08-08 16:31:48 -0700 | [diff] [blame] | 51 |     private final Set<IConnectionServiceAdapter> mAdapters = Collections.newSetFromMap( | 
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 52 |             new ConcurrentHashMap<IConnectionServiceAdapter, Boolean>(8, 0.9f, 1)); | 
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 53 |  | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 54 |     ConnectionServiceAdapter() { | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 55 |     } | 
 | 56 |  | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 57 |     void addAdapter(IConnectionServiceAdapter adapter) { | 
| Roshan Pius | 75c36b6 | 2015-07-08 16:52:37 -0700 | [diff] [blame] | 58 |         for (IConnectionServiceAdapter it : mAdapters) { | 
 | 59 |             if (it.asBinder() == adapter.asBinder()) { | 
 | 60 |                 Log.w(this, "Ignoring duplicate adapter addition."); | 
 | 61 |                 return; | 
 | 62 |             } | 
 | 63 |         } | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 64 |         if (mAdapters.add(adapter)) { | 
 | 65 |             try { | 
 | 66 |                 adapter.asBinder().linkToDeath(this, 0); | 
 | 67 |             } catch (RemoteException e) { | 
 | 68 |                 mAdapters.remove(adapter); | 
 | 69 |             } | 
 | 70 |         } | 
 | 71 |     } | 
 | 72 |  | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 73 |     void removeAdapter(IConnectionServiceAdapter adapter) { | 
| Roshan Pius | 75c36b6 | 2015-07-08 16:52:37 -0700 | [diff] [blame] | 74 |         if (adapter != null) { | 
 | 75 |             for (IConnectionServiceAdapter it : mAdapters) { | 
 | 76 |                 if (it.asBinder() == adapter.asBinder() && mAdapters.remove(it)) { | 
 | 77 |                     adapter.asBinder().unlinkToDeath(this, 0); | 
 | 78 |                     break; | 
 | 79 |                 } | 
 | 80 |             } | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 81 |         } | 
 | 82 |     } | 
 | 83 |  | 
 | 84 |     /** ${inheritDoc} */ | 
 | 85 |     @Override | 
 | 86 |     public void binderDied() { | 
| Sailesh Nepal | 4dd9df5 | 2014-07-10 18:15:15 -0700 | [diff] [blame] | 87 |         Iterator<IConnectionServiceAdapter> it = mAdapters.iterator(); | 
 | 88 |         while (it.hasNext()) { | 
 | 89 |             IConnectionServiceAdapter adapter = it.next(); | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 90 |             if (!adapter.asBinder().isBinderAlive()) { | 
| Sailesh Nepal | 4dd9df5 | 2014-07-10 18:15:15 -0700 | [diff] [blame] | 91 |                 it.remove(); | 
 | 92 |                 adapter.asBinder().unlinkToDeath(this, 0); | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 93 |             } | 
 | 94 |         } | 
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 95 |     } | 
| Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 96 |  | 
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 97 |     void handleCreateConnectionComplete( | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 98 |             String id, | 
 | 99 |             ConnectionRequest request, | 
 | 100 |             ParcelableConnection connection) { | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 101 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 102 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 103 |                 adapter.handleCreateConnectionComplete(id, request, connection, | 
 | 104 |                         Log.getExternalSession()); | 
| Sailesh Nepal | 506e386 | 2014-06-25 13:35:14 -0700 | [diff] [blame] | 105 |             } catch (RemoteException e) { | 
 | 106 |             } | 
 | 107 |         } | 
 | 108 |     } | 
 | 109 |  | 
| Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 110 |     void handleCreateConferenceComplete( | 
 | 111 |             String id, | 
 | 112 |             ConnectionRequest request, | 
 | 113 |             ParcelableConference conference) { | 
 | 114 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 115 |             try { | 
 | 116 |                 adapter.handleCreateConferenceComplete(id, request, conference, | 
 | 117 |                         Log.getExternalSession()); | 
 | 118 |             } catch (RemoteException e) { | 
 | 119 |             } | 
 | 120 |         } | 
 | 121 |     } | 
 | 122 |  | 
| Sailesh Nepal | 506e386 | 2014-06-25 13:35:14 -0700 | [diff] [blame] | 123 |     /** | 
| Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 124 |      * Sets a call's state to active (e.g., an ongoing call where two parties can actively | 
 | 125 |      * communicate). | 
| Santos Cordon | 3784133 | 2013-12-17 13:30:53 -0800 | [diff] [blame] | 126 |      * | 
 | 127 |      * @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] | 128 |      */ | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 129 |     void setActive(String callId) { | 
 | 130 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 131 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 132 |                 adapter.setActive(callId, Log.getExternalSession()); | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 133 |             } catch (RemoteException e) { | 
 | 134 |             } | 
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 135 |         } | 
 | 136 |     } | 
| Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 137 |  | 
 | 138 |     /** | 
 | 139 |      * 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] | 140 |      * | 
 | 141 |      * @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] | 142 |      */ | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 143 |     void setRinging(String callId) { | 
 | 144 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 145 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 146 |                 adapter.setRinging(callId, Log.getExternalSession()); | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 147 |             } catch (RemoteException e) { | 
 | 148 |             } | 
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 149 |         } | 
 | 150 |     } | 
| Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 151 |  | 
 | 152 |     /** | 
 | 153 |      * 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] | 154 |      * | 
 | 155 |      * @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] | 156 |      */ | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 157 |     void setDialing(String callId) { | 
 | 158 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 159 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 160 |                 adapter.setDialing(callId, Log.getExternalSession()); | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 161 |             } catch (RemoteException e) { | 
 | 162 |             } | 
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 163 |         } | 
 | 164 |     } | 
| Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 165 |  | 
 | 166 |     /** | 
| Tyler Gunn | c96b5e0 | 2016-07-07 22:53:57 -0700 | [diff] [blame] | 167 |      * Sets a call's state to pulling (e.g. a call with {@link Connection#PROPERTY_IS_EXTERNAL_CALL} | 
 | 168 |      * is being pulled to the local device. | 
 | 169 |      * | 
 | 170 |      * @param callId The unique ID of the call whose state is changing to dialing. | 
 | 171 |      */ | 
 | 172 |     void setPulling(String callId) { | 
 | 173 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 174 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 175 |                 adapter.setPulling(callId, Log.getExternalSession()); | 
| Tyler Gunn | c96b5e0 | 2016-07-07 22:53:57 -0700 | [diff] [blame] | 176 |             } catch (RemoteException e) { | 
 | 177 |             } | 
 | 178 |         } | 
 | 179 |     } | 
 | 180 |  | 
 | 181 |     /** | 
| Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 182 |      * Sets a call's state to disconnected. | 
| Santos Cordon | 3784133 | 2013-12-17 13:30:53 -0800 | [diff] [blame] | 183 |      * | 
 | 184 |      * @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] | 185 |      * @param disconnectCause The reason for the disconnection, as described by | 
 | 186 |      *            {@link android.telecomm.DisconnectCause}. | 
| Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 187 |      */ | 
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 188 |     void setDisconnected(String callId, DisconnectCause disconnectCause) { | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 189 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 190 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 191 |                 adapter.setDisconnected(callId, disconnectCause, Log.getExternalSession()); | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 192 |             } catch (RemoteException e) { | 
 | 193 |             } | 
| Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 194 |         } | 
 | 195 |     } | 
| Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 196 |  | 
 | 197 |     /** | 
 | 198 |      * Sets a call's state to be on hold. | 
 | 199 |      * | 
 | 200 |      * @param callId - The unique ID of the call whose state is changing to be on hold. | 
 | 201 |      */ | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 202 |     void setOnHold(String callId) { | 
 | 203 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 204 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 205 |                 adapter.setOnHold(callId, Log.getExternalSession()); | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 206 |             } catch (RemoteException e) { | 
 | 207 |             } | 
| Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 208 |         } | 
 | 209 |     } | 
 | 210 |  | 
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 211 |     /** | 
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 212 |      * Asks Telecom to start or stop a ringback tone for a call. | 
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 213 |      * | 
 | 214 |      * @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] | 215 |      * @param ringback Whether Telecom should start playing a ringback tone. | 
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 216 |      */ | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 217 |     void setRingbackRequested(String callId, boolean ringback) { | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 218 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 219 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 220 |                 adapter.setRingbackRequested(callId, ringback, Log.getExternalSession()); | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 221 |             } catch (RemoteException e) { | 
 | 222 |             } | 
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 223 |         } | 
 | 224 |     } | 
| Yorke Lee | 81ccaaa | 2014-03-12 18:33:19 -0700 | [diff] [blame] | 225 |  | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 226 |     void setConnectionCapabilities(String callId, int capabilities) { | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 227 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 228 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 229 |                 adapter.setConnectionCapabilities(callId, capabilities, Log.getExternalSession()); | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 230 |             } catch (RemoteException ignored) { | 
 | 231 |             } | 
| Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 232 |         } | 
 | 233 |     } | 
 | 234 |  | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 235 |     void setConnectionProperties(String callId, int properties) { | 
 | 236 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 237 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 238 |                 adapter.setConnectionProperties(callId, properties, Log.getExternalSession()); | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 239 |             } catch (RemoteException ignored) { | 
 | 240 |             } | 
 | 241 |         } | 
 | 242 |     } | 
 | 243 |  | 
| Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 244 |     /** | 
 | 245 |      * Indicates whether or not the specified call is currently conferenced into the specified | 
 | 246 |      * conference call. | 
 | 247 |      * | 
| Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 248 |      * @param callId The unique ID of the call being conferenced. | 
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 249 |      * @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] | 250 |      *            conferenced. | 
| Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 251 |      */ | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 252 |     void setIsConferenced(String callId, String conferenceCallId) { | 
 | 253 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 254 |             try { | 
| Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 255 |                 Log.d(this, "sending connection %s with conference %s", callId, conferenceCallId); | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 256 |                 adapter.setIsConferenced(callId, conferenceCallId, Log.getExternalSession()); | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 257 |             } catch (RemoteException ignored) { | 
 | 258 |             } | 
| Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 259 |         } | 
 | 260 |     } | 
 | 261 |  | 
 | 262 |     /** | 
| Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 263 |      * Indicates that the merge request on this call has failed. | 
 | 264 |      * | 
 | 265 |      * @param callId The unique ID of the call being conferenced. | 
 | 266 |      */ | 
 | 267 |     void onConferenceMergeFailed(String callId) { | 
 | 268 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 269 |             try { | 
 | 270 |                 Log.d(this, "merge failed for call %s", callId); | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 271 |                 adapter.setConferenceMergeFailed(callId, Log.getExternalSession()); | 
| Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 272 |             } catch (RemoteException ignored) { | 
 | 273 |             } | 
 | 274 |         } | 
 | 275 |     } | 
 | 276 |  | 
 | 277 |     /** | 
| Mengjun Leng | 2570774 | 2017-07-04 11:10:37 +0800 | [diff] [blame] | 278 |         * Resets the cdma connection time. | 
 | 279 |         */ | 
 | 280 |     void resetConnectionTime(String callId) { | 
 | 281 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 282 |             try { | 
 | 283 |                 adapter.resetConnectionTime(callId, Log.getExternalSession()); | 
 | 284 |             } catch (RemoteException e) { | 
 | 285 |             } | 
 | 286 |         } | 
 | 287 |     } | 
 | 288 |  | 
 | 289 |     /** | 
| Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 290 |      * Indicates that the call no longer exists. Can be used with either a call or a conference | 
 | 291 |      * call. | 
 | 292 |      * | 
 | 293 |      * @param callId The unique ID of the call. | 
| Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 294 |      */ | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 295 |     void removeCall(String callId) { | 
 | 296 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 297 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 298 |                 adapter.removeCall(callId, Log.getExternalSession()); | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 299 |             } catch (RemoteException ignored) { | 
 | 300 |             } | 
| Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 301 |         } | 
 | 302 |     } | 
| Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 303 |  | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 304 |     void onPostDialWait(String callId, String remaining) { | 
 | 305 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 306 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 307 |                 adapter.onPostDialWait(callId, remaining, Log.getExternalSession()); | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 308 |             } catch (RemoteException ignored) { | 
 | 309 |             } | 
| Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 310 |         } | 
 | 311 |     } | 
| Sailesh Nepal | 8b4818d | 2014-06-06 10:54:07 -0700 | [diff] [blame] | 312 |  | 
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 313 |     void onPostDialChar(String callId, char nextChar) { | 
 | 314 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 315 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 316 |                 adapter.onPostDialChar(callId, nextChar, Log.getExternalSession()); | 
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 317 |             } catch (RemoteException ignored) { | 
 | 318 |             } | 
 | 319 |         } | 
 | 320 |     } | 
 | 321 |  | 
| Sailesh Nepal | 8b4818d | 2014-06-06 10:54:07 -0700 | [diff] [blame] | 322 |     /** | 
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 323 |      * Indicates that a new conference call has been created. | 
 | 324 |      * | 
 | 325 |      * @param callId The unique ID of the conference call. | 
 | 326 |      */ | 
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 327 |     void addConferenceCall(String callId, ParcelableConference parcelableConference) { | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 328 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 329 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 330 |                 adapter.addConferenceCall(callId, parcelableConference, Log.getExternalSession()); | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 331 |             } catch (RemoteException ignored) { | 
 | 332 |             } | 
 | 333 |         } | 
 | 334 |     } | 
 | 335 |  | 
 | 336 |     /** | 
 | 337 |      * Retrieves a list of remote connection services usable to place calls. | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 338 |      */ | 
| Tyler Gunn | 4c69fb3 | 2019-05-17 10:49:16 -0700 | [diff] [blame] | 339 |     void queryRemoteConnectionServices(RemoteServiceCallback callback, String callingPackage) { | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 340 |         // Only supported when there is only one adapter. | 
 | 341 |         if (mAdapters.size() == 1) { | 
 | 342 |             try { | 
| Tyler Gunn | 4c69fb3 | 2019-05-17 10:49:16 -0700 | [diff] [blame] | 343 |                 mAdapters.iterator().next().queryRemoteConnectionServices(callback, callingPackage, | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 344 |                         Log.getExternalSession()); | 
| Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 345 |             } catch (RemoteException e) { | 
 | 346 |                 Log.e(this, e, "Exception trying to query for remote CSs"); | 
 | 347 |             } | 
| Tyler Gunn | 156a33b | 2019-05-30 16:52:28 -0700 | [diff] [blame] | 348 |         } else { | 
 | 349 |             try { | 
 | 350 |                 // This is not an error condition, so just pass back an empty list. | 
 | 351 |                 // This happens when querying from a remote connection service, not the connection | 
 | 352 |                 // manager itself. | 
 | 353 |                 callback.onResult(Collections.EMPTY_LIST, Collections.EMPTY_LIST); | 
 | 354 |             } catch (RemoteException e) { | 
 | 355 |                 Log.e(this, e, "Exception trying to query for remote CSs"); | 
 | 356 |             } | 
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 357 |         } | 
 | 358 |     } | 
| Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 359 |  | 
 | 360 |     /** | 
 | 361 |      * Sets the call video provider for a call. | 
 | 362 |      * | 
 | 363 |      * @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] | 364 |      * @param videoProvider The call video provider instance to set on the call. | 
| Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 365 |      */ | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 366 |     void setVideoProvider( | 
 | 367 |             String callId, Connection.VideoProvider videoProvider) { | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 368 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
| Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 369 |             try { | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 370 |                 adapter.setVideoProvider( | 
| Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 371 |                         callId, | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 372 |                         videoProvider == null ? null : videoProvider.getInterface(), | 
 | 373 |                         Log.getExternalSession()); | 
| Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 374 |             } catch (RemoteException e) { | 
 | 375 |             } | 
 | 376 |         } | 
 | 377 |     } | 
| Tyler Gunn | 8d83fa9 | 2014-07-01 11:31:21 -0700 | [diff] [blame] | 378 |  | 
 | 379 |     /** | 
| Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 380 |      * Requests that the framework use VOIP audio mode for this connection. | 
 | 381 |      * | 
 | 382 |      * @param callId The unique ID of the call to set with the given call video provider. | 
 | 383 |      * @param isVoip True if the audio mode is VOIP. | 
 | 384 |      */ | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 385 |     void setIsVoipAudioMode(String callId, boolean isVoip) { | 
| Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 386 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 387 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 388 |                 adapter.setIsVoipAudioMode(callId, isVoip, Log.getExternalSession()); | 
| Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 389 |             } catch (RemoteException e) { | 
 | 390 |             } | 
 | 391 |         } | 
 | 392 |     } | 
 | 393 |  | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 394 |     void setStatusHints(String callId, StatusHints statusHints) { | 
 | 395 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 396 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 397 |                 adapter.setStatusHints(callId, statusHints, Log.getExternalSession()); | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 398 |             } catch (RemoteException e) { | 
 | 399 |             } | 
 | 400 |         } | 
 | 401 |     } | 
 | 402 |  | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 403 |     void setAddress(String callId, Uri address, int presentation) { | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 404 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
| Tyler Gunn | 8d83fa9 | 2014-07-01 11:31:21 -0700 | [diff] [blame] | 405 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 406 |                 adapter.setAddress(callId, address, presentation, Log.getExternalSession()); | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 407 |             } catch (RemoteException e) { | 
 | 408 |             } | 
 | 409 |         } | 
 | 410 |     } | 
 | 411 |  | 
 | 412 |     void setCallerDisplayName(String callId, String callerDisplayName, int presentation) { | 
 | 413 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 414 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 415 |                 adapter.setCallerDisplayName(callId, callerDisplayName, presentation, | 
 | 416 |                         Log.getExternalSession()); | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 417 |             } catch (RemoteException e) { | 
| Tyler Gunn | 8d83fa9 | 2014-07-01 11:31:21 -0700 | [diff] [blame] | 418 |             } | 
 | 419 |         } | 
 | 420 |     } | 
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 421 |  | 
 | 422 |     /** | 
 | 423 |      * Sets the video state associated with a call. | 
 | 424 |      * | 
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 425 |      * Valid values: {@link VideoProfile#STATE_BIDIRECTIONAL}, | 
 | 426 |      * {@link VideoProfile#STATE_AUDIO_ONLY}, | 
 | 427 |      * {@link VideoProfile#STATE_TX_ENABLED}, | 
 | 428 |      * {@link VideoProfile#STATE_RX_ENABLED}. | 
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 429 |      * | 
 | 430 |      * @param callId The unique ID of the call to set the video state for. | 
 | 431 |      * @param videoState The video state. | 
 | 432 |      */ | 
 | 433 |     void setVideoState(String callId, int videoState) { | 
 | 434 |         Log.v(this, "setVideoState: %d", videoState); | 
 | 435 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 436 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 437 |                 adapter.setVideoState(callId, videoState, Log.getExternalSession()); | 
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 438 |             } catch (RemoteException ignored) { | 
 | 439 |             } | 
 | 440 |         } | 
 | 441 |     } | 
| Sailesh Nepal | 2ab88cc | 2014-07-18 14:49:18 -0700 | [diff] [blame] | 442 |  | 
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 443 |     void setConferenceableConnections(String callId, List<String> conferenceableCallIds) { | 
 | 444 |         Log.v(this, "setConferenceableConnections: %s, %s", callId, conferenceableCallIds); | 
 | 445 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 446 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 447 |                 adapter.setConferenceableConnections(callId, conferenceableCallIds, | 
 | 448 |                         Log.getExternalSession()); | 
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 449 |             } catch (RemoteException ignored) { | 
 | 450 |             } | 
 | 451 |         } | 
 | 452 |     } | 
| Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 453 |  | 
 | 454 |     /** | 
 | 455 |      * Informs telecom of an existing connection which was added by the {@link ConnectionService}. | 
 | 456 |      * | 
 | 457 |      * @param callId The unique ID of the call being added. | 
 | 458 |      * @param connection The connection. | 
 | 459 |      */ | 
 | 460 |     void addExistingConnection(String callId, ParcelableConnection connection) { | 
 | 461 |         Log.v(this, "addExistingConnection: %s", callId); | 
 | 462 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 463 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 464 |                 adapter.addExistingConnection(callId, connection, Log.getExternalSession()); | 
| Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 465 |             } catch (RemoteException ignored) { | 
 | 466 |             } | 
 | 467 |         } | 
 | 468 |     } | 
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 469 |  | 
 | 470 |     /** | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 471 |      * Adds some extras associated with a {@code Connection}. | 
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 472 |      * | 
 | 473 |      * @param callId The unique ID of the call. | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 474 |      * @param extras The extras to add. | 
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 475 |      */ | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 476 |     void putExtras(String callId, Bundle extras) { | 
 | 477 |         Log.v(this, "putExtras: %s", callId); | 
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 478 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 479 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 480 |                 adapter.putExtras(callId, extras, Log.getExternalSession()); | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 481 |             } catch (RemoteException ignored) { | 
 | 482 |             } | 
 | 483 |         } | 
 | 484 |     } | 
 | 485 |  | 
 | 486 |     /** | 
 | 487 |      * Adds an extra associated with a {@code Connection}. | 
 | 488 |      * | 
 | 489 |      * @param callId The unique ID of the call. | 
 | 490 |      * @param key The extra key. | 
 | 491 |      * @param value The extra value. | 
 | 492 |      */ | 
 | 493 |     void putExtra(String callId, String key, boolean value) { | 
 | 494 |         Log.v(this, "putExtra: %s %s=%b", callId, key, value); | 
 | 495 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 496 |             try { | 
 | 497 |                 Bundle bundle = new Bundle(); | 
 | 498 |                 bundle.putBoolean(key, value); | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 499 |                 adapter.putExtras(callId, bundle, Log.getExternalSession()); | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 500 |             } catch (RemoteException ignored) { | 
 | 501 |             } | 
 | 502 |         } | 
 | 503 |     } | 
 | 504 |  | 
 | 505 |     /** | 
 | 506 |      * Adds an extra associated with a {@code Connection}. | 
 | 507 |      * | 
 | 508 |      * @param callId The unique ID of the call. | 
 | 509 |      * @param key The extra key. | 
 | 510 |      * @param value The extra value. | 
 | 511 |      */ | 
 | 512 |     void putExtra(String callId, String key, int value) { | 
 | 513 |         Log.v(this, "putExtra: %s %s=%d", callId, key, value); | 
 | 514 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 515 |             try { | 
 | 516 |                 Bundle bundle = new Bundle(); | 
 | 517 |                 bundle.putInt(key, value); | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 518 |                 adapter.putExtras(callId, bundle, Log.getExternalSession()); | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 519 |             } catch (RemoteException ignored) { | 
 | 520 |             } | 
 | 521 |         } | 
 | 522 |     } | 
 | 523 |  | 
 | 524 |     /** | 
 | 525 |      * Adds an extra associated with a {@code Connection}. | 
 | 526 |      * | 
 | 527 |      * @param callId The unique ID of the call. | 
 | 528 |      * @param key The extra key. | 
 | 529 |      * @param value The extra value. | 
 | 530 |      */ | 
 | 531 |     void putExtra(String callId, String key, String value) { | 
 | 532 |         Log.v(this, "putExtra: %s %s=%s", callId, key, value); | 
 | 533 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 534 |             try { | 
 | 535 |                 Bundle bundle = new Bundle(); | 
 | 536 |                 bundle.putString(key, value); | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 537 |                 adapter.putExtras(callId, bundle, Log.getExternalSession()); | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 538 |             } catch (RemoteException ignored) { | 
 | 539 |             } | 
 | 540 |         } | 
 | 541 |     } | 
 | 542 |  | 
 | 543 |     /** | 
 | 544 |      * Removes extras associated with a {@code Connection}. | 
 | 545 |      *  @param callId The unique ID of the call. | 
 | 546 |      * @param keys The extra keys to remove. | 
 | 547 |      */ | 
 | 548 |     void removeExtras(String callId, List<String> keys) { | 
 | 549 |         Log.v(this, "removeExtras: %s %s", callId, keys); | 
 | 550 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 551 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 552 |                 adapter.removeExtras(callId, keys, Log.getExternalSession()); | 
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 553 |             } catch (RemoteException ignored) { | 
 | 554 |             } | 
 | 555 |         } | 
 | 556 |     } | 
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 557 |  | 
 | 558 |     /** | 
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 559 |      * Sets the audio route associated with a {@link Connection}. | 
 | 560 |      * | 
 | 561 |      * @param callId The unique ID of the call. | 
 | 562 |      * @param audioRoute The new audio route (see {@code CallAudioState#ROUTE_*}). | 
 | 563 |      */ | 
| Hall Liu | a98f58b5 | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 564 |     void setAudioRoute(String callId, int audioRoute, String bluetoothAddress) { | 
 | 565 |         Log.v(this, "setAudioRoute: %s %s %s", callId, | 
 | 566 |                 CallAudioState.audioRouteToString(audioRoute), | 
 | 567 |                 bluetoothAddress); | 
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 568 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 569 |             try { | 
| Hall Liu | a98f58b5 | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 570 |                 adapter.setAudioRoute(callId, audioRoute, | 
 | 571 |                         bluetoothAddress, Log.getExternalSession()); | 
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 572 |             } catch (RemoteException ignored) { | 
 | 573 |             } | 
 | 574 |         } | 
 | 575 |     } | 
 | 576 |  | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 577 |     /** | 
 | 578 |      * Sets the call endpoint associated with a {@link Connection}. | 
 | 579 |      * | 
 | 580 |      * @param callId The unique ID of the call. | 
 | 581 |      * @param endpoint The new call endpoint (see {@link CallEndpoint}). | 
 | 582 |      * @param executor The executor of where the callback will execute. | 
 | 583 |      * @param callback The callback to notify the result of the endpoint change. | 
 | 584 |      */ | 
 | 585 |     void requestCallEndpointChange(String callId, CallEndpoint endpoint, Executor executor, | 
 | 586 |             OutcomeReceiver<Void, CallEndpointException> callback) { | 
 | 587 |         Log.v(this, "requestCallEndpointChange"); | 
 | 588 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 589 |             try { | 
 | 590 |                 adapter.requestCallEndpointChange(callId, endpoint, new ResultReceiver(null) { | 
 | 591 |                     @Override | 
 | 592 |                     protected void onReceiveResult(int resultCode, Bundle result) { | 
 | 593 |                         super.onReceiveResult(resultCode, result); | 
 | 594 |                         final long identity = Binder.clearCallingIdentity(); | 
 | 595 |                         try { | 
 | 596 |                             if (resultCode == CallEndpoint.ENDPOINT_OPERATION_SUCCESS) { | 
 | 597 |                                 executor.execute(() -> callback.onResult(null)); | 
 | 598 |                             } else { | 
 | 599 |                                 executor.execute(() -> callback.onError(result.getParcelable( | 
 | 600 |                                         CallEndpointException.CHANGE_ERROR, | 
 | 601 |                                         CallEndpointException.class))); | 
 | 602 |                             } | 
 | 603 |                         } finally { | 
 | 604 |                             Binder.restoreCallingIdentity(identity); | 
 | 605 |                         } | 
 | 606 |                     }}, Log.getExternalSession()); | 
 | 607 |             } catch (RemoteException ignored) { | 
 | 608 |                 Log.d(this, "Remote exception calling requestCallEndpointChange"); | 
 | 609 |             } | 
 | 610 |         } | 
 | 611 |     } | 
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 612 |  | 
 | 613 |     /** | 
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 614 |      * Informs Telecom of a connection level event. | 
 | 615 |      * | 
 | 616 |      * @param callId The unique ID of the call. | 
 | 617 |      * @param event The event. | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 618 |      * @param extras Extras associated with the event. | 
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 619 |      */ | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 620 |     void onConnectionEvent(String callId, String event, Bundle extras) { | 
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 621 |         Log.v(this, "onConnectionEvent: %s", event); | 
 | 622 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 623 |             try { | 
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 624 |                 adapter.onConnectionEvent(callId, event, extras, Log.getExternalSession()); | 
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 625 |             } catch (RemoteException ignored) { | 
 | 626 |             } | 
 | 627 |         } | 
 | 628 |     } | 
| Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 629 |  | 
 | 630 |     /** | 
 | 631 |      * Notifies Telecom that an RTT session was successfully established. | 
 | 632 |      * | 
 | 633 |      * @param callId The unique ID of the call. | 
 | 634 |      */ | 
 | 635 |     void onRttInitiationSuccess(String callId) { | 
 | 636 |         Log.v(this, "onRttInitiationSuccess: %s", callId); | 
 | 637 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 638 |             try { | 
 | 639 |                 adapter.onRttInitiationSuccess(callId, Log.getExternalSession()); | 
 | 640 |             } catch (RemoteException ignored) { | 
 | 641 |             } | 
 | 642 |         } | 
 | 643 |     } | 
 | 644 |  | 
 | 645 |     /** | 
 | 646 |      * Notifies Telecom that a requested RTT session failed to be established. | 
 | 647 |      * | 
 | 648 |      * @param callId The unique ID of the call. | 
 | 649 |      */ | 
 | 650 |     void onRttInitiationFailure(String callId, int reason) { | 
 | 651 |         Log.v(this, "onRttInitiationFailure: %s", callId); | 
 | 652 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 653 |             try { | 
 | 654 |                 adapter.onRttInitiationFailure(callId, reason, Log.getExternalSession()); | 
 | 655 |             } catch (RemoteException ignored) { | 
 | 656 |             } | 
 | 657 |         } | 
 | 658 |     } | 
 | 659 |  | 
 | 660 |     /** | 
 | 661 |      * Notifies Telecom that an established RTT session was terminated by the remote user on | 
 | 662 |      * the call. | 
 | 663 |      * | 
 | 664 |      * @param callId The unique ID of the call. | 
 | 665 |      */ | 
 | 666 |     void onRttSessionRemotelyTerminated(String callId) { | 
 | 667 |         Log.v(this, "onRttSessionRemotelyTerminated: %s", callId); | 
 | 668 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 669 |             try { | 
 | 670 |                 adapter.onRttSessionRemotelyTerminated(callId, Log.getExternalSession()); | 
 | 671 |             } catch (RemoteException ignored) { | 
 | 672 |             } | 
 | 673 |         } | 
 | 674 |     } | 
 | 675 |  | 
 | 676 |     /** | 
 | 677 |      * Notifies Telecom that the remote user on the call has requested an upgrade to an RTT | 
 | 678 |      * session for this call. | 
 | 679 |      * | 
 | 680 |      * @param callId The unique ID of the call. | 
 | 681 |      */ | 
 | 682 |     void onRemoteRttRequest(String callId) { | 
 | 683 |         Log.v(this, "onRemoteRttRequest: %s", callId); | 
 | 684 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 685 |             try { | 
 | 686 |                 adapter.onRemoteRttRequest(callId, Log.getExternalSession()); | 
 | 687 |             } catch (RemoteException ignored) { | 
 | 688 |             } | 
 | 689 |         } | 
 | 690 |     } | 
| Srikanth Chintala | fcb1501 | 2017-05-04 20:58:34 +0530 | [diff] [blame] | 691 |  | 
 | 692 |     /** | 
 | 693 |      * Notifies Telecom that a call's PhoneAccountHandle has changed. | 
 | 694 |      * | 
 | 695 |      * @param callId The unique ID of the call. | 
 | 696 |      * @param pHandle The new PhoneAccountHandle associated with the call. | 
 | 697 |      */ | 
 | 698 |     void onPhoneAccountChanged(String callId, PhoneAccountHandle pHandle) { | 
 | 699 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 700 |             try { | 
 | 701 |                 Log.d(this, "onPhoneAccountChanged %s", callId); | 
 | 702 |                 adapter.onPhoneAccountChanged(callId, pHandle, Log.getExternalSession()); | 
 | 703 |             } catch (RemoteException ignored) { | 
 | 704 |             } | 
 | 705 |         } | 
 | 706 |     } | 
| Pengquan Meng | 63d25a5 | 2017-11-21 18:01:13 -0800 | [diff] [blame] | 707 |  | 
 | 708 |     /** | 
 | 709 |      * Notifies Telecom that the {@link ConnectionService} has released the call resource. | 
 | 710 |      */ | 
 | 711 |     void onConnectionServiceFocusReleased() { | 
 | 712 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 713 |             try { | 
 | 714 |                 Log.d(this, "onConnectionServiceFocusReleased"); | 
 | 715 |                 adapter.onConnectionServiceFocusReleased(Log.getExternalSession()); | 
 | 716 |             } catch (RemoteException ignored) { | 
 | 717 |             } | 
 | 718 |         } | 
 | 719 |     } | 
| Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 720 |  | 
 | 721 |     /** | 
 | 722 |      * Sets whether a conference is treated as a conference or a single party call. | 
 | 723 |      * See {@link Conference#setConferenceState(boolean)} for more information. | 
 | 724 |      * | 
 | 725 |      * @param callId The ID of the telecom call. | 
 | 726 |      * @param isConference {@code true} if this call should be treated as a conference, | 
 | 727 |      * {@code false} otherwise. | 
 | 728 |      */ | 
 | 729 |     void setConferenceState(String callId, boolean isConference) { | 
 | 730 |         Log.v(this, "setConferenceState: %s %b", callId, isConference); | 
 | 731 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 732 |             try { | 
 | 733 |                 adapter.setConferenceState(callId, isConference, Log.getExternalSession()); | 
 | 734 |             } catch (RemoteException ignored) { | 
 | 735 |             } | 
 | 736 |         } | 
 | 737 |     } | 
| Brad Ebinger | 31774ae | 2020-04-08 16:25:12 -0700 | [diff] [blame] | 738 |  | 
 | 739 |     /** | 
 | 740 |      * Sets the direction of a call. Setting a new direction of an existing call is usually only | 
 | 741 |      * applicable during single caller emulation during conferencing, see | 
 | 742 |      * {@link Conference#setConferenceState(boolean)} for more information. | 
 | 743 |      * @param callId The identifier of the call. | 
 | 744 |      * @param direction The new direction of the call. | 
 | 745 |      */ | 
 | 746 |     void setCallDirection(String callId, @Call.Details.CallDirection int direction) { | 
 | 747 |         for (IConnectionServiceAdapter a : mAdapters) { | 
 | 748 |             try { | 
 | 749 |                 a.setCallDirection(callId, direction, Log.getExternalSession()); | 
 | 750 |             } catch (RemoteException e) { | 
 | 751 |             } | 
 | 752 |         } | 
 | 753 |     } | 
| yongnamcha | 8ec5624 | 2022-11-28 06:23:02 +0000 | [diff] [blame] | 754 |  | 
 | 755 |     /** | 
 | 756 |      * Query location information. | 
 | 757 |      * Only SIM call managers can call this method for Connections representing Emergency calls. | 
 | 758 |      * If the previous request is not completed, the new request will be rejected. | 
 | 759 |      * | 
 | 760 |      * @param timeoutMillis long: Timeout in millis waiting for query response. | 
 | 761 |      * @param provider String: the location provider name, This value cannot be null. | 
 | 762 |      * @param executor The executor of where the callback will execute. | 
 | 763 |      * @param callback The callback to notify the result of queryLocation. | 
 | 764 |      */ | 
 | 765 |     void queryLocation(String callId, long timeoutMillis, @NonNull String provider, | 
 | 766 |             @NonNull @CallbackExecutor Executor executor, | 
 | 767 |             @NonNull OutcomeReceiver<Location, QueryLocationException> callback) { | 
 | 768 |         Log.v(this, "queryLocation: %s %d", callId, timeoutMillis); | 
 | 769 |         for (IConnectionServiceAdapter adapter : mAdapters) { | 
 | 770 |             try { | 
 | 771 |                 adapter.queryLocation(callId, timeoutMillis, provider, | 
 | 772 |                         new ResultReceiver(null) { | 
 | 773 |                             @Override | 
 | 774 |                             protected void onReceiveResult(int resultCode, Bundle result) { | 
 | 775 |                                 super.onReceiveResult(resultCode, result); | 
 | 776 |  | 
 | 777 |                                 if (resultCode == 1 /* success */) { | 
 | 778 |                                     executor.execute(() -> callback.onResult(result.getParcelable( | 
 | 779 |                                             Connection.EXTRA_KEY_QUERY_LOCATION, Location.class))); | 
 | 780 |                                 } else { | 
 | 781 |                                     executor.execute(() -> callback.onError(result.getParcelable( | 
 | 782 |                                             QueryLocationException.QUERY_LOCATION_ERROR, | 
 | 783 |                                             QueryLocationException.class))); | 
 | 784 |                                 } | 
 | 785 |                             } | 
 | 786 |                         }, | 
 | 787 |                         Log.getExternalSession()); | 
 | 788 |             } catch (RemoteException e) { | 
 | 789 |                 Log.d(this, "queryLocation: Exception e : " + e); | 
 | 790 |                 executor.execute(() -> callback.onError(new QueryLocationException( | 
 | 791 |                         e.getMessage(), QueryLocationException.ERROR_SERVICE_UNAVAILABLE))); | 
 | 792 |             } | 
 | 793 |         } | 
 | 794 |     } | 
| Ben Gilad | bb69b0c | 2013-12-12 18:32:02 -0800 | [diff] [blame] | 795 | } |