blob: 78d65e643abc1c1a414e800dccf01bba37985ec4 [file] [log] [blame]
Ihab Awad5d0410f2014-07-30 10:07:40 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
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 R* limitations under the License.
15 */
16
Tyler Gunnef9f6f92014-09-12 22:16:17 -070017package android.telecom;
Ihab Awad5d0410f2014-07-30 10:07:40 -070018
Ihab Awad5d0410f2014-07-30 10:07:40 -070019import android.net.Uri;
Santos Cordon6b7f9552015-05-27 17:21:45 -070020import android.os.Bundle;
Ihab Awad5d0410f2014-07-30 10:07:40 -070021import android.os.Handler;
22import android.os.Message;
23import android.os.RemoteException;
Brad Ebinger4d75bee2016-10-28 12:29:55 -070024import android.telecom.Logging.Session;
Ihab Awad5d0410f2014-07-30 10:07:40 -070025
Santos Cordon7c7bc7f2014-07-28 18:15:48 -070026import com.android.internal.os.SomeArgs;
Tyler Gunnef9f6f92014-09-12 22:16:17 -070027import com.android.internal.telecom.IConnectionServiceAdapter;
28import com.android.internal.telecom.IVideoProvider;
29import com.android.internal.telecom.RemoteServiceCallback;
Santos Cordon7c7bc7f2014-07-28 18:15:48 -070030
31import java.util.List;
32
Ihab Awad5d0410f2014-07-30 10:07:40 -070033/**
34 * A component that provides an RPC servant implementation of {@link IConnectionServiceAdapter},
35 * posting incoming messages on the main thread on a client-supplied delegate object.
36 *
37 * TODO: Generate this and similar classes using a compiler starting from AIDL interfaces.
38 *
39 * @hide
40 */
41final class ConnectionServiceAdapterServant {
Ihab Awad6107bab2014-08-18 09:23:25 -070042 private static final int MSG_HANDLE_CREATE_CONNECTION_COMPLETE = 1;
43 private static final int MSG_SET_ACTIVE = 2;
44 private static final int MSG_SET_RINGING = 3;
45 private static final int MSG_SET_DIALING = 4;
46 private static final int MSG_SET_DISCONNECTED = 5;
47 private static final int MSG_SET_ON_HOLD = 6;
Andrew Lee100e2932014-09-08 15:34:24 -070048 private static final int MSG_SET_RINGBACK_REQUESTED = 7;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080049 private static final int MSG_SET_CONNECTION_CAPABILITIES = 8;
Ihab Awad6107bab2014-08-18 09:23:25 -070050 private static final int MSG_SET_IS_CONFERENCED = 9;
51 private static final int MSG_ADD_CONFERENCE_CALL = 10;
52 private static final int MSG_REMOVE_CALL = 11;
53 private static final int MSG_ON_POST_DIAL_WAIT = 12;
54 private static final int MSG_QUERY_REMOTE_CALL_SERVICES = 13;
55 private static final int MSG_SET_VIDEO_STATE = 14;
56 private static final int MSG_SET_VIDEO_CALL_PROVIDER = 15;
Andrew Lee100e2932014-09-08 15:34:24 -070057 private static final int MSG_SET_IS_VOIP_AUDIO_MODE = 16;
Ihab Awad6107bab2014-08-18 09:23:25 -070058 private static final int MSG_SET_STATUS_HINTS = 17;
Andrew Lee100e2932014-09-08 15:34:24 -070059 private static final int MSG_SET_ADDRESS = 18;
Ihab Awad6107bab2014-08-18 09:23:25 -070060 private static final int MSG_SET_CALLER_DISPLAY_NAME = 19;
Evan Charlton23dc2412014-09-03 10:07:03 -070061 private static final int MSG_SET_CONFERENCEABLE_CONNECTIONS = 20;
Tyler Gunn4a57b9b2014-10-30 14:27:48 -070062 private static final int MSG_ADD_EXISTING_CONNECTION = 21;
Nancy Chen27d1c2d2014-12-15 16:12:50 -080063 private static final int MSG_ON_POST_DIAL_CHAR = 22;
Anthony Lee17455a32015-04-24 15:25:29 -070064 private static final int MSG_SET_CONFERENCE_MERGE_FAILED = 23;
Tyler Gunndee56a82016-03-23 16:06:34 -070065 private static final int MSG_PUT_EXTRAS = 24;
66 private static final int MSG_REMOVE_EXTRAS = 25;
67 private static final int MSG_ON_CONNECTION_EVENT = 26;
Tyler Gunn720c6642016-03-22 09:02:47 -070068 private static final int MSG_SET_CONNECTION_PROPERTIES = 27;
Tyler Gunnc96b5e02016-07-07 22:53:57 -070069 private static final int MSG_SET_PULLING = 28;
Tyler Gunnf5035432017-01-09 09:43:12 -080070 private static final int MSG_SET_AUDIO_ROUTE = 29;
Hall Liu57006aa2017-02-06 10:49:48 -080071 private static final int MSG_ON_RTT_INITIATION_SUCCESS = 30;
72 private static final int MSG_ON_RTT_INITIATION_FAILURE = 31;
73 private static final int MSG_ON_RTT_REMOTELY_TERMINATED = 32;
74 private static final int MSG_ON_RTT_UPGRADE_REQUEST = 33;
Srikanth Chintalafcb15012017-05-04 20:58:34 +053075 private static final int MSG_SET_PHONE_ACCOUNT_CHANGED = 34;
Pengquan Meng63d25a52017-11-21 18:01:13 -080076 private static final int MSG_CONNECTION_SERVICE_FOCUS_RELEASED = 35;
Ihab Awad5d0410f2014-07-30 10:07:40 -070077
78 private final IConnectionServiceAdapter mDelegate;
79
80 private final Handler mHandler = new Handler() {
81 @Override
82 public void handleMessage(Message msg) {
83 try {
84 internalHandleMessage(msg);
85 } catch (RemoteException e) {
86 }
87 }
88
89 // Internal method defined to centralize handling of RemoteException
90 private void internalHandleMessage(Message msg) throws RemoteException {
91 switch (msg.what) {
Ihab Awad6107bab2014-08-18 09:23:25 -070092 case MSG_HANDLE_CREATE_CONNECTION_COMPLETE: {
Ihab Awad5d0410f2014-07-30 10:07:40 -070093 SomeArgs args = (SomeArgs) msg.obj;
94 try {
Ihab Awad6107bab2014-08-18 09:23:25 -070095 mDelegate.handleCreateConnectionComplete(
Ihab Awadb19a0bc2014-08-07 19:46:01 -070096 (String) args.arg1,
97 (ConnectionRequest) args.arg2,
Brad Ebinger4d75bee2016-10-28 12:29:55 -070098 (ParcelableConnection) args.arg3,
99 null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700100 } finally {
101 args.recycle();
102 }
103 break;
104 }
Ihab Awad5d0410f2014-07-30 10:07:40 -0700105 case MSG_SET_ACTIVE:
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700106 mDelegate.setActive((String) msg.obj, null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700107 break;
108 case MSG_SET_RINGING:
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700109 mDelegate.setRinging((String) msg.obj, null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700110 break;
111 case MSG_SET_DIALING:
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700112 mDelegate.setDialing((String) msg.obj, null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700113 break;
Tyler Gunnc96b5e02016-07-07 22:53:57 -0700114 case MSG_SET_PULLING:
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700115 mDelegate.setPulling((String) msg.obj, null /*Session.Info*/);
Tyler Gunnc96b5e02016-07-07 22:53:57 -0700116 break;
Ihab Awad5d0410f2014-07-30 10:07:40 -0700117 case MSG_SET_DISCONNECTED: {
118 SomeArgs args = (SomeArgs) msg.obj;
119 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700120 mDelegate.setDisconnected((String) args.arg1, (DisconnectCause) args.arg2,
121 null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700122 } finally {
123 args.recycle();
124 }
125 break;
126 }
127 case MSG_SET_ON_HOLD:
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700128 mDelegate.setOnHold((String) msg.obj, null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700129 break;
Andrew Lee100e2932014-09-08 15:34:24 -0700130 case MSG_SET_RINGBACK_REQUESTED:
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700131 mDelegate.setRingbackRequested((String) msg.obj, msg.arg1 == 1,
132 null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700133 break;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800134 case MSG_SET_CONNECTION_CAPABILITIES:
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700135 mDelegate.setConnectionCapabilities((String) msg.obj, msg.arg1,
136 null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700137 break;
Tyler Gunn720c6642016-03-22 09:02:47 -0700138 case MSG_SET_CONNECTION_PROPERTIES:
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700139 mDelegate.setConnectionProperties((String) msg.obj, msg.arg1,
140 null /*Session.Info*/);
Tyler Gunn720c6642016-03-22 09:02:47 -0700141 break;
Ihab Awad5d0410f2014-07-30 10:07:40 -0700142 case MSG_SET_IS_CONFERENCED: {
143 SomeArgs args = (SomeArgs) msg.obj;
144 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700145 mDelegate.setIsConferenced((String) args.arg1, (String) args.arg2,
146 null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700147 } finally {
148 args.recycle();
149 }
150 break;
151 }
Santos Cordon823fd3c2014-08-07 18:35:18 -0700152 case MSG_ADD_CONFERENCE_CALL: {
153 SomeArgs args = (SomeArgs) msg.obj;
154 try {
155 mDelegate.addConferenceCall(
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700156 (String) args.arg1, (ParcelableConference) args.arg2,
157 null /*Session.Info*/);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700158 } finally {
159 args.recycle();
160 }
Ihab Awad5d0410f2014-07-30 10:07:40 -0700161 break;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700162 }
Ihab Awad5d0410f2014-07-30 10:07:40 -0700163 case MSG_REMOVE_CALL:
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700164 mDelegate.removeCall((String) msg.obj,
165 null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700166 break;
167 case MSG_ON_POST_DIAL_WAIT: {
168 SomeArgs args = (SomeArgs) msg.obj;
169 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700170 mDelegate.onPostDialWait((String) args.arg1, (String) args.arg2,
171 null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700172 } finally {
173 args.recycle();
174 }
175 break;
176 }
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800177 case MSG_ON_POST_DIAL_CHAR: {
178 SomeArgs args = (SomeArgs) msg.obj;
179 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700180 mDelegate.onPostDialChar((String) args.arg1, (char) args.argi1,
181 null /*Session.Info*/);
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800182 } finally {
183 args.recycle();
184 }
185 break;
186 }
Ihab Awad5d0410f2014-07-30 10:07:40 -0700187 case MSG_QUERY_REMOTE_CALL_SERVICES:
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700188 mDelegate.queryRemoteConnectionServices((RemoteServiceCallback) msg.obj,
189 null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700190 break;
191 case MSG_SET_VIDEO_STATE:
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700192 mDelegate.setVideoState((String) msg.obj, msg.arg1, null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700193 break;
194 case MSG_SET_VIDEO_CALL_PROVIDER: {
195 SomeArgs args = (SomeArgs) msg.obj;
196 try {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700197 mDelegate.setVideoProvider((String) args.arg1,
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700198 (IVideoProvider) args.arg2, null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700199 } finally {
200 args.recycle();
201 }
202 break;
203 }
Andrew Lee100e2932014-09-08 15:34:24 -0700204 case MSG_SET_IS_VOIP_AUDIO_MODE:
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700205 mDelegate.setIsVoipAudioMode((String) msg.obj, msg.arg1 == 1,
206 null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700207 break;
208 case MSG_SET_STATUS_HINTS: {
209 SomeArgs args = (SomeArgs) msg.obj;
210 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700211 mDelegate.setStatusHints((String) args.arg1, (StatusHints) args.arg2,
212 null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700213 } finally {
214 args.recycle();
215 }
216 break;
217 }
Andrew Lee100e2932014-09-08 15:34:24 -0700218 case MSG_SET_ADDRESS: {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700219 SomeArgs args = (SomeArgs) msg.obj;
220 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700221 mDelegate.setAddress((String) args.arg1, (Uri) args.arg2, args.argi1,
222 null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700223 } finally {
224 args.recycle();
225 }
226 break;
227 }
228 case MSG_SET_CALLER_DISPLAY_NAME: {
229 SomeArgs args = (SomeArgs) msg.obj;
230 try {
231 mDelegate.setCallerDisplayName(
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700232 (String) args.arg1, (String) args.arg2, args.argi1,
233 null /*Session.Info*/);
Ihab Awad5d0410f2014-07-30 10:07:40 -0700234 } finally {
235 args.recycle();
236 }
237 break;
238 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700239 case MSG_SET_CONFERENCEABLE_CONNECTIONS: {
240 SomeArgs args = (SomeArgs) msg.obj;
241 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700242 mDelegate.setConferenceableConnections((String) args.arg1,
243 (List<String>) args.arg2, null /*Session.Info*/);
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700244 } finally {
245 args.recycle();
246 }
247 break;
248 }
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700249 case MSG_ADD_EXISTING_CONNECTION: {
250 SomeArgs args = (SomeArgs) msg.obj;
251 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700252 mDelegate.addExistingConnection((String) args.arg1,
253 (ParcelableConnection) args.arg2, null /*Session.Info*/);
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700254 } finally {
255 args.recycle();
256 }
257 break;
258 }
Anthony Lee17455a32015-04-24 15:25:29 -0700259 case MSG_SET_CONFERENCE_MERGE_FAILED: {
260 SomeArgs args = (SomeArgs) msg.obj;
261 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700262 mDelegate.setConferenceMergeFailed((String) args.arg1,
263 null /*Session.Info*/);
Anthony Lee17455a32015-04-24 15:25:29 -0700264 } finally {
265 args.recycle();
266 }
267 break;
268 }
Tyler Gunndee56a82016-03-23 16:06:34 -0700269 case MSG_PUT_EXTRAS: {
Santos Cordon6b7f9552015-05-27 17:21:45 -0700270 SomeArgs args = (SomeArgs) msg.obj;
271 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700272 mDelegate.putExtras((String) args.arg1, (Bundle) args.arg2,
273 null /*Session.Info*/);
Tyler Gunndee56a82016-03-23 16:06:34 -0700274 } finally {
275 args.recycle();
276 }
277 break;
278 }
279 case MSG_REMOVE_EXTRAS: {
280 SomeArgs args = (SomeArgs) msg.obj;
281 try {
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700282 mDelegate.removeExtras((String) args.arg1, (List<String>) args.arg2,
283 null /*Session.Info*/);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700284 } finally {
285 args.recycle();
286 }
Tyler Gunn86c9fb42016-02-24 13:17:21 -0800287 break;
Santos Cordon6b7f9552015-05-27 17:21:45 -0700288 }
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800289 case MSG_ON_CONNECTION_EVENT: {
290 SomeArgs args = (SomeArgs) msg.obj;
291 try {
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700292 mDelegate.onConnectionEvent((String) args.arg1, (String) args.arg2,
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700293 (Bundle) args.arg3, null /*Session.Info*/);
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800294 } finally {
295 args.recycle();
296 }
Tyler Gunn86c9fb42016-02-24 13:17:21 -0800297 break;
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800298 }
Tyler Gunnf5035432017-01-09 09:43:12 -0800299 case MSG_SET_AUDIO_ROUTE: {
300 SomeArgs args = (SomeArgs) msg.obj;
301 try {
Hall Liua98f58b52017-11-07 17:59:28 -0800302 mDelegate.setAudioRoute((String) args.arg1, args.argi1, (String) args.arg2,
303 (Session.Info) args.arg3);
Tyler Gunnf5035432017-01-09 09:43:12 -0800304 } finally {
305 args.recycle();
306 }
307 break;
308 }
Hall Liu57006aa2017-02-06 10:49:48 -0800309 case MSG_ON_RTT_INITIATION_SUCCESS:
310 mDelegate.onRttInitiationSuccess((String) msg.obj, null /*Session.Info*/);
311 break;
312 case MSG_ON_RTT_INITIATION_FAILURE:
313 mDelegate.onRttInitiationFailure((String) msg.obj, msg.arg1,
314 null /*Session.Info*/);
315 break;
316 case MSG_ON_RTT_REMOTELY_TERMINATED:
317 mDelegate.onRttSessionRemotelyTerminated((String) msg.obj,
318 null /*Session.Info*/);
319 break;
320 case MSG_ON_RTT_UPGRADE_REQUEST:
321 mDelegate.onRemoteRttRequest((String) msg.obj, null /*Session.Info*/);
322 break;
Srikanth Chintalafcb15012017-05-04 20:58:34 +0530323 case MSG_SET_PHONE_ACCOUNT_CHANGED: {
324 SomeArgs args = (SomeArgs) msg.obj;
325 try {
326 mDelegate.onPhoneAccountChanged((String) args.arg1,
327 (PhoneAccountHandle) args.arg2, null /*Session.Info*/);
328 } finally {
329 args.recycle();
330 }
331 break;
332 }
Pengquan Meng63d25a52017-11-21 18:01:13 -0800333 case MSG_CONNECTION_SERVICE_FOCUS_RELEASED:
334 mDelegate.onConnectionServiceFocusReleased(null /*Session.Info*/);
335 break;
Ihab Awad5d0410f2014-07-30 10:07:40 -0700336 }
337 }
338 };
339
340 private final IConnectionServiceAdapter mStub = new IConnectionServiceAdapter.Stub() {
341 @Override
Ihab Awad6107bab2014-08-18 09:23:25 -0700342 public void handleCreateConnectionComplete(
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700343 String id,
344 ConnectionRequest request,
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700345 ParcelableConnection connection,
346 Session.Info sessionInfo) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700347 SomeArgs args = SomeArgs.obtain();
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700348 args.arg1 = id;
349 args.arg2 = request;
350 args.arg3 = connection;
Ihab Awad6107bab2014-08-18 09:23:25 -0700351 mHandler.obtainMessage(MSG_HANDLE_CREATE_CONNECTION_COMPLETE, args).sendToTarget();
Ihab Awad5d0410f2014-07-30 10:07:40 -0700352 }
353
354 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700355 public void setActive(String connectionId, Session.Info sessionInfo) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700356 mHandler.obtainMessage(MSG_SET_ACTIVE, connectionId).sendToTarget();
357 }
358
359 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700360 public void setRinging(String connectionId, Session.Info sessionInfo) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700361 mHandler.obtainMessage(MSG_SET_RINGING, connectionId).sendToTarget();
362 }
363
364 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700365 public void setDialing(String connectionId, Session.Info sessionInfo) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700366 mHandler.obtainMessage(MSG_SET_DIALING, connectionId).sendToTarget();
367 }
368
369 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700370 public void setPulling(String connectionId, Session.Info sessionInfo) {
Tyler Gunnc96b5e02016-07-07 22:53:57 -0700371 mHandler.obtainMessage(MSG_SET_PULLING, connectionId).sendToTarget();
372 }
373
374 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700375 public void setDisconnected(String connectionId, DisconnectCause disconnectCause,
376 Session.Info sessionInfo) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700377 SomeArgs args = SomeArgs.obtain();
378 args.arg1 = connectionId;
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700379 args.arg2 = disconnectCause;
Ihab Awad5d0410f2014-07-30 10:07:40 -0700380 mHandler.obtainMessage(MSG_SET_DISCONNECTED, args).sendToTarget();
381 }
382
383 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700384 public void setOnHold(String connectionId, Session.Info sessionInfo) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700385 mHandler.obtainMessage(MSG_SET_ON_HOLD, connectionId).sendToTarget();
386 }
387
388 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700389 public void setRingbackRequested(String connectionId, boolean ringback,
390 Session.Info sessionInfo) {
Andrew Lee100e2932014-09-08 15:34:24 -0700391 mHandler.obtainMessage(MSG_SET_RINGBACK_REQUESTED, ringback ? 1 : 0, 0, connectionId)
Ihab Awad5d0410f2014-07-30 10:07:40 -0700392 .sendToTarget();
393 }
394
395 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700396 public void setConnectionCapabilities(String connectionId, int connectionCapabilities,
397 Session.Info sessionInfo) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800398 mHandler.obtainMessage(
399 MSG_SET_CONNECTION_CAPABILITIES, connectionCapabilities, 0, connectionId)
Ihab Awad5d0410f2014-07-30 10:07:40 -0700400 .sendToTarget();
401 }
402
403 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700404 public void setConnectionProperties(String connectionId, int connectionProperties,
405 Session.Info sessionInfo) {
Tyler Gunn720c6642016-03-22 09:02:47 -0700406 mHandler.obtainMessage(
407 MSG_SET_CONNECTION_PROPERTIES, connectionProperties, 0, connectionId)
408 .sendToTarget();
409 }
410
411 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700412 public void setConferenceMergeFailed(String callId, Session.Info sessionInfo) {
Anthony Lee17455a32015-04-24 15:25:29 -0700413 SomeArgs args = SomeArgs.obtain();
414 args.arg1 = callId;
415 mHandler.obtainMessage(MSG_SET_CONFERENCE_MERGE_FAILED, args).sendToTarget();
416 }
417
418 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700419 public void setIsConferenced(String callId, String conferenceCallId,
420 Session.Info sessionInfo) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700421 SomeArgs args = SomeArgs.obtain();
422 args.arg1 = callId;
423 args.arg2 = conferenceCallId;
424 mHandler.obtainMessage(MSG_SET_IS_CONFERENCED, args).sendToTarget();
425 }
426
427 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700428 public void addConferenceCall(String callId, ParcelableConference parcelableConference,
429 Session.Info sessionInfo) {
Santos Cordon823fd3c2014-08-07 18:35:18 -0700430 SomeArgs args = SomeArgs.obtain();
431 args.arg1 = callId;
432 args.arg2 = parcelableConference;
433 mHandler.obtainMessage(MSG_ADD_CONFERENCE_CALL, args).sendToTarget();
Ihab Awad5d0410f2014-07-30 10:07:40 -0700434 }
435
436 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700437 public void removeCall(String connectionId,
438 Session.Info sessionInfo) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700439 mHandler.obtainMessage(MSG_REMOVE_CALL, connectionId).sendToTarget();
440 }
441
442 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700443 public void onPostDialWait(String connectionId, String remainingDigits,
444 Session.Info sessionInfo) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700445 SomeArgs args = SomeArgs.obtain();
446 args.arg1 = connectionId;
447 args.arg2 = remainingDigits;
448 mHandler.obtainMessage(MSG_ON_POST_DIAL_WAIT, args).sendToTarget();
449 }
450
451 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700452 public void onPostDialChar(String connectionId, char nextChar,
453 Session.Info sessionInfo) {
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800454 SomeArgs args = SomeArgs.obtain();
455 args.arg1 = connectionId;
456 args.argi1 = nextChar;
457 mHandler.obtainMessage(MSG_ON_POST_DIAL_CHAR, args).sendToTarget();
458 }
459
460 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700461 public void queryRemoteConnectionServices(RemoteServiceCallback callback,
462 Session.Info sessionInfo) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700463 mHandler.obtainMessage(MSG_QUERY_REMOTE_CALL_SERVICES, callback).sendToTarget();
464 }
465
466 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700467 public void setVideoState(String connectionId, int videoState,
468 Session.Info sessionInfo) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700469 mHandler.obtainMessage(MSG_SET_VIDEO_STATE, videoState, 0, connectionId).sendToTarget();
470 }
471
472 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700473 public void setVideoProvider(String connectionId, IVideoProvider videoProvider,
474 Session.Info sessionInfo) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700475 SomeArgs args = SomeArgs.obtain();
476 args.arg1 = connectionId;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700477 args.arg2 = videoProvider;
Ihab Awad5d0410f2014-07-30 10:07:40 -0700478 mHandler.obtainMessage(MSG_SET_VIDEO_CALL_PROVIDER, args).sendToTarget();
479 }
480
481 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700482 public final void setIsVoipAudioMode(String connectionId, boolean isVoip,
483 Session.Info sessionInfo) {
Andrew Lee100e2932014-09-08 15:34:24 -0700484 mHandler.obtainMessage(MSG_SET_IS_VOIP_AUDIO_MODE, isVoip ? 1 : 0, 0,
Ihab Awad5d0410f2014-07-30 10:07:40 -0700485 connectionId).sendToTarget();
486 }
487
488 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700489 public final void setStatusHints(String connectionId, StatusHints statusHints,
490 Session.Info sessionInfo) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700491 SomeArgs args = SomeArgs.obtain();
492 args.arg1 = connectionId;
493 args.arg2 = statusHints;
494 mHandler.obtainMessage(MSG_SET_STATUS_HINTS, args).sendToTarget();
495 }
496
497 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700498 public final void setAddress(String connectionId, Uri address, int presentation,
499 Session.Info sessionInfo) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700500 SomeArgs args = SomeArgs.obtain();
501 args.arg1 = connectionId;
Andrew Lee100e2932014-09-08 15:34:24 -0700502 args.arg2 = address;
Ihab Awad5d0410f2014-07-30 10:07:40 -0700503 args.argi1 = presentation;
Andrew Lee100e2932014-09-08 15:34:24 -0700504 mHandler.obtainMessage(MSG_SET_ADDRESS, args).sendToTarget();
Ihab Awad5d0410f2014-07-30 10:07:40 -0700505 }
506
507 @Override
508 public final void setCallerDisplayName(
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700509 String connectionId, String callerDisplayName, int presentation,
510 Session.Info sessionInfo) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700511 SomeArgs args = SomeArgs.obtain();
512 args.arg1 = connectionId;
513 args.arg2 = callerDisplayName;
514 args.argi1 = presentation;
515 mHandler.obtainMessage(MSG_SET_CALLER_DISPLAY_NAME, args).sendToTarget();
516 }
517
518 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700519 public final void setConferenceableConnections(String connectionId,
520 List<String> conferenceableConnectionIds, Session.Info sessionInfo) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700521 SomeArgs args = SomeArgs.obtain();
522 args.arg1 = connectionId;
523 args.arg2 = conferenceableConnectionIds;
524 mHandler.obtainMessage(MSG_SET_CONFERENCEABLE_CONNECTIONS, args).sendToTarget();
525 }
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700526
527 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700528 public final void addExistingConnection(String connectionId,
529 ParcelableConnection connection, Session.Info sessionInfo) {
Tyler Gunn4a57b9b2014-10-30 14:27:48 -0700530 SomeArgs args = SomeArgs.obtain();
531 args.arg1 = connectionId;
532 args.arg2 = connection;
533 mHandler.obtainMessage(MSG_ADD_EXISTING_CONNECTION, args).sendToTarget();
534 }
Santos Cordon6b7f9552015-05-27 17:21:45 -0700535
536 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700537 public final void putExtras(String connectionId, Bundle extras, Session.Info sessionInfo) {
Santos Cordon6b7f9552015-05-27 17:21:45 -0700538 SomeArgs args = SomeArgs.obtain();
539 args.arg1 = connectionId;
540 args.arg2 = extras;
Tyler Gunndee56a82016-03-23 16:06:34 -0700541 mHandler.obtainMessage(MSG_PUT_EXTRAS, args).sendToTarget();
542 }
543
544 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700545 public final void removeExtras(String connectionId, List<String> keys,
546 Session.Info sessionInfo) {
Tyler Gunndee56a82016-03-23 16:06:34 -0700547 SomeArgs args = SomeArgs.obtain();
548 args.arg1 = connectionId;
549 args.arg2 = keys;
550 mHandler.obtainMessage(MSG_REMOVE_EXTRAS, args).sendToTarget();
Santos Cordon6b7f9552015-05-27 17:21:45 -0700551 }
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800552
553 @Override
Tyler Gunnf5035432017-01-09 09:43:12 -0800554 public final void setAudioRoute(String connectionId, int audioRoute,
Hall Liua98f58b52017-11-07 17:59:28 -0800555 String bluetoothAddress, Session.Info sessionInfo) {
Tyler Gunnf5035432017-01-09 09:43:12 -0800556 SomeArgs args = SomeArgs.obtain();
557 args.arg1 = connectionId;
558 args.argi1 = audioRoute;
Hall Liua98f58b52017-11-07 17:59:28 -0800559 args.arg2 = bluetoothAddress;
560 args.arg3 = sessionInfo;
Tyler Gunnf5035432017-01-09 09:43:12 -0800561 mHandler.obtainMessage(MSG_SET_AUDIO_ROUTE, args).sendToTarget();
562 }
563
564 @Override
Brad Ebinger4d75bee2016-10-28 12:29:55 -0700565 public final void onConnectionEvent(String connectionId, String event, Bundle extras,
566 Session.Info sessionInfo) {
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800567 SomeArgs args = SomeArgs.obtain();
568 args.arg1 = connectionId;
569 args.arg2 = event;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700570 args.arg3 = extras;
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800571 mHandler.obtainMessage(MSG_ON_CONNECTION_EVENT, args).sendToTarget();
572 }
Hall Liu57006aa2017-02-06 10:49:48 -0800573
574 @Override
575 public void onRttInitiationSuccess(String connectionId, Session.Info sessionInfo)
576 throws RemoteException {
577 mHandler.obtainMessage(MSG_ON_RTT_INITIATION_SUCCESS, connectionId).sendToTarget();
578 }
579
580 @Override
581 public void onRttInitiationFailure(String connectionId, int reason,
582 Session.Info sessionInfo)
583 throws RemoteException {
584 mHandler.obtainMessage(MSG_ON_RTT_INITIATION_FAILURE, reason, 0, connectionId)
585 .sendToTarget();
586 }
587
588 @Override
589 public void onRttSessionRemotelyTerminated(String connectionId, Session.Info sessionInfo)
590 throws RemoteException {
591 mHandler.obtainMessage(MSG_ON_RTT_REMOTELY_TERMINATED, connectionId).sendToTarget();
592 }
593
594 @Override
595 public void onRemoteRttRequest(String connectionId, Session.Info sessionInfo)
596 throws RemoteException {
597 mHandler.obtainMessage(MSG_ON_RTT_UPGRADE_REQUEST, connectionId).sendToTarget();
598 }
Srikanth Chintalafcb15012017-05-04 20:58:34 +0530599
600 @Override
601 public void onPhoneAccountChanged(String callId, PhoneAccountHandle pHandle,
602 Session.Info sessionInfo) {
603 SomeArgs args = SomeArgs.obtain();
604 args.arg1 = callId;
605 args.arg2 = pHandle;
606 mHandler.obtainMessage(MSG_SET_PHONE_ACCOUNT_CHANGED, args).sendToTarget();
607 }
Pengquan Meng63d25a52017-11-21 18:01:13 -0800608
609 @Override
610 public void onConnectionServiceFocusReleased(Session.Info sessionInfo) {
611 mHandler.obtainMessage(MSG_CONNECTION_SERVICE_FOCUS_RELEASED).sendToTarget();
612 }
Mengjun Leng25707742017-07-04 11:10:37 +0800613
614 @Override
615 public void resetConnectionTime(String callId, Session.Info sessionInfo) {
616 // Do nothing
617 }
Ihab Awad5d0410f2014-07-30 10:07:40 -0700618 };
619
620 public ConnectionServiceAdapterServant(IConnectionServiceAdapter delegate) {
621 mDelegate = delegate;
622 }
623
624 public IConnectionServiceAdapter getStub() {
625 return mStub;
626 }
627}