| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 1 | /* |
| 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 Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 17 | package android.telecom; |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 18 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 19 | import android.net.Uri; |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 20 | import android.os.Bundle; |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 21 | import android.os.Handler; |
| 22 | import android.os.Message; |
| 23 | import android.os.RemoteException; |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 24 | import android.telecom.Logging.Session; |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 25 | |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 26 | import com.android.internal.os.SomeArgs; |
| 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.IVideoProvider; |
| 29 | import com.android.internal.telecom.RemoteServiceCallback; |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 30 | |
| 31 | import java.util.List; |
| 32 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 33 | /** |
| 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 | */ |
| 41 | final class ConnectionServiceAdapterServant { |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 42 | 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 Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 48 | private static final int MSG_SET_RINGBACK_REQUESTED = 7; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 49 | private static final int MSG_SET_CONNECTION_CAPABILITIES = 8; |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 50 | 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 Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 57 | private static final int MSG_SET_IS_VOIP_AUDIO_MODE = 16; |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 58 | private static final int MSG_SET_STATUS_HINTS = 17; |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 59 | private static final int MSG_SET_ADDRESS = 18; |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 60 | private static final int MSG_SET_CALLER_DISPLAY_NAME = 19; |
| Evan Charlton | 23dc241 | 2014-09-03 10:07:03 -0700 | [diff] [blame] | 61 | private static final int MSG_SET_CONFERENCEABLE_CONNECTIONS = 20; |
| Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 62 | private static final int MSG_ADD_EXISTING_CONNECTION = 21; |
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 63 | private static final int MSG_ON_POST_DIAL_CHAR = 22; |
| Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 64 | private static final int MSG_SET_CONFERENCE_MERGE_FAILED = 23; |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 65 | 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 Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 68 | private static final int MSG_SET_CONNECTION_PROPERTIES = 27; |
| Tyler Gunn | c96b5e0 | 2016-07-07 22:53:57 -0700 | [diff] [blame] | 69 | private static final int MSG_SET_PULLING = 28; |
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame^] | 70 | private static final int MSG_SET_AUDIO_ROUTE = 29; |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 71 | |
| 72 | private final IConnectionServiceAdapter mDelegate; |
| 73 | |
| 74 | private final Handler mHandler = new Handler() { |
| 75 | @Override |
| 76 | public void handleMessage(Message msg) { |
| 77 | try { |
| 78 | internalHandleMessage(msg); |
| 79 | } catch (RemoteException e) { |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // Internal method defined to centralize handling of RemoteException |
| 84 | private void internalHandleMessage(Message msg) throws RemoteException { |
| 85 | switch (msg.what) { |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 86 | case MSG_HANDLE_CREATE_CONNECTION_COMPLETE: { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 87 | SomeArgs args = (SomeArgs) msg.obj; |
| 88 | try { |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 89 | mDelegate.handleCreateConnectionComplete( |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 90 | (String) args.arg1, |
| 91 | (ConnectionRequest) args.arg2, |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 92 | (ParcelableConnection) args.arg3, |
| 93 | null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 94 | } finally { |
| 95 | args.recycle(); |
| 96 | } |
| 97 | break; |
| 98 | } |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 99 | case MSG_SET_ACTIVE: |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 100 | mDelegate.setActive((String) msg.obj, null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 101 | break; |
| 102 | case MSG_SET_RINGING: |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 103 | mDelegate.setRinging((String) msg.obj, null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 104 | break; |
| 105 | case MSG_SET_DIALING: |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 106 | mDelegate.setDialing((String) msg.obj, null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 107 | break; |
| Tyler Gunn | c96b5e0 | 2016-07-07 22:53:57 -0700 | [diff] [blame] | 108 | case MSG_SET_PULLING: |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 109 | mDelegate.setPulling((String) msg.obj, null /*Session.Info*/); |
| Tyler Gunn | c96b5e0 | 2016-07-07 22:53:57 -0700 | [diff] [blame] | 110 | break; |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 111 | case MSG_SET_DISCONNECTED: { |
| 112 | SomeArgs args = (SomeArgs) msg.obj; |
| 113 | try { |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 114 | mDelegate.setDisconnected((String) args.arg1, (DisconnectCause) args.arg2, |
| 115 | null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 116 | } finally { |
| 117 | args.recycle(); |
| 118 | } |
| 119 | break; |
| 120 | } |
| 121 | case MSG_SET_ON_HOLD: |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 122 | mDelegate.setOnHold((String) msg.obj, null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 123 | break; |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 124 | case MSG_SET_RINGBACK_REQUESTED: |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 125 | mDelegate.setRingbackRequested((String) msg.obj, msg.arg1 == 1, |
| 126 | null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 127 | break; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 128 | case MSG_SET_CONNECTION_CAPABILITIES: |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 129 | mDelegate.setConnectionCapabilities((String) msg.obj, msg.arg1, |
| 130 | null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 131 | break; |
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 132 | case MSG_SET_CONNECTION_PROPERTIES: |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 133 | mDelegate.setConnectionProperties((String) msg.obj, msg.arg1, |
| 134 | null /*Session.Info*/); |
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 135 | break; |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 136 | case MSG_SET_IS_CONFERENCED: { |
| 137 | SomeArgs args = (SomeArgs) msg.obj; |
| 138 | try { |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 139 | mDelegate.setIsConferenced((String) args.arg1, (String) args.arg2, |
| 140 | null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 141 | } finally { |
| 142 | args.recycle(); |
| 143 | } |
| 144 | break; |
| 145 | } |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 146 | case MSG_ADD_CONFERENCE_CALL: { |
| 147 | SomeArgs args = (SomeArgs) msg.obj; |
| 148 | try { |
| 149 | mDelegate.addConferenceCall( |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 150 | (String) args.arg1, (ParcelableConference) args.arg2, |
| 151 | null /*Session.Info*/); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 152 | } finally { |
| 153 | args.recycle(); |
| 154 | } |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 155 | break; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 156 | } |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 157 | case MSG_REMOVE_CALL: |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 158 | mDelegate.removeCall((String) msg.obj, |
| 159 | null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 160 | break; |
| 161 | case MSG_ON_POST_DIAL_WAIT: { |
| 162 | SomeArgs args = (SomeArgs) msg.obj; |
| 163 | try { |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 164 | mDelegate.onPostDialWait((String) args.arg1, (String) args.arg2, |
| 165 | null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 166 | } finally { |
| 167 | args.recycle(); |
| 168 | } |
| 169 | break; |
| 170 | } |
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 171 | case MSG_ON_POST_DIAL_CHAR: { |
| 172 | SomeArgs args = (SomeArgs) msg.obj; |
| 173 | try { |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 174 | mDelegate.onPostDialChar((String) args.arg1, (char) args.argi1, |
| 175 | null /*Session.Info*/); |
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 176 | } finally { |
| 177 | args.recycle(); |
| 178 | } |
| 179 | break; |
| 180 | } |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 181 | case MSG_QUERY_REMOTE_CALL_SERVICES: |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 182 | mDelegate.queryRemoteConnectionServices((RemoteServiceCallback) msg.obj, |
| 183 | null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 184 | break; |
| 185 | case MSG_SET_VIDEO_STATE: |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 186 | mDelegate.setVideoState((String) msg.obj, msg.arg1, null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 187 | break; |
| 188 | case MSG_SET_VIDEO_CALL_PROVIDER: { |
| 189 | SomeArgs args = (SomeArgs) msg.obj; |
| 190 | try { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 191 | mDelegate.setVideoProvider((String) args.arg1, |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 192 | (IVideoProvider) args.arg2, null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 193 | } finally { |
| 194 | args.recycle(); |
| 195 | } |
| 196 | break; |
| 197 | } |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 198 | case MSG_SET_IS_VOIP_AUDIO_MODE: |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 199 | mDelegate.setIsVoipAudioMode((String) msg.obj, msg.arg1 == 1, |
| 200 | null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 201 | break; |
| 202 | case MSG_SET_STATUS_HINTS: { |
| 203 | SomeArgs args = (SomeArgs) msg.obj; |
| 204 | try { |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 205 | mDelegate.setStatusHints((String) args.arg1, (StatusHints) args.arg2, |
| 206 | null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 207 | } finally { |
| 208 | args.recycle(); |
| 209 | } |
| 210 | break; |
| 211 | } |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 212 | case MSG_SET_ADDRESS: { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 213 | SomeArgs args = (SomeArgs) msg.obj; |
| 214 | try { |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 215 | mDelegate.setAddress((String) args.arg1, (Uri) args.arg2, args.argi1, |
| 216 | null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 217 | } finally { |
| 218 | args.recycle(); |
| 219 | } |
| 220 | break; |
| 221 | } |
| 222 | case MSG_SET_CALLER_DISPLAY_NAME: { |
| 223 | SomeArgs args = (SomeArgs) msg.obj; |
| 224 | try { |
| 225 | mDelegate.setCallerDisplayName( |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 226 | (String) args.arg1, (String) args.arg2, args.argi1, |
| 227 | null /*Session.Info*/); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 228 | } finally { |
| 229 | args.recycle(); |
| 230 | } |
| 231 | break; |
| 232 | } |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 233 | case MSG_SET_CONFERENCEABLE_CONNECTIONS: { |
| 234 | SomeArgs args = (SomeArgs) msg.obj; |
| 235 | try { |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 236 | mDelegate.setConferenceableConnections((String) args.arg1, |
| 237 | (List<String>) args.arg2, null /*Session.Info*/); |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 238 | } finally { |
| 239 | args.recycle(); |
| 240 | } |
| 241 | break; |
| 242 | } |
| Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 243 | case MSG_ADD_EXISTING_CONNECTION: { |
| 244 | SomeArgs args = (SomeArgs) msg.obj; |
| 245 | try { |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 246 | mDelegate.addExistingConnection((String) args.arg1, |
| 247 | (ParcelableConnection) args.arg2, null /*Session.Info*/); |
| Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 248 | } finally { |
| 249 | args.recycle(); |
| 250 | } |
| 251 | break; |
| 252 | } |
| Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 253 | case MSG_SET_CONFERENCE_MERGE_FAILED: { |
| 254 | SomeArgs args = (SomeArgs) msg.obj; |
| 255 | try { |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 256 | mDelegate.setConferenceMergeFailed((String) args.arg1, |
| 257 | null /*Session.Info*/); |
| Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 258 | } finally { |
| 259 | args.recycle(); |
| 260 | } |
| 261 | break; |
| 262 | } |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 263 | case MSG_PUT_EXTRAS: { |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 264 | SomeArgs args = (SomeArgs) msg.obj; |
| 265 | try { |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 266 | mDelegate.putExtras((String) args.arg1, (Bundle) args.arg2, |
| 267 | null /*Session.Info*/); |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 268 | } finally { |
| 269 | args.recycle(); |
| 270 | } |
| 271 | break; |
| 272 | } |
| 273 | case MSG_REMOVE_EXTRAS: { |
| 274 | SomeArgs args = (SomeArgs) msg.obj; |
| 275 | try { |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 276 | mDelegate.removeExtras((String) args.arg1, (List<String>) args.arg2, |
| 277 | null /*Session.Info*/); |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 278 | } finally { |
| 279 | args.recycle(); |
| 280 | } |
| Tyler Gunn | 86c9fb4 | 2016-02-24 13:17:21 -0800 | [diff] [blame] | 281 | break; |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 282 | } |
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 283 | case MSG_ON_CONNECTION_EVENT: { |
| 284 | SomeArgs args = (SomeArgs) msg.obj; |
| 285 | try { |
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 286 | mDelegate.onConnectionEvent((String) args.arg1, (String) args.arg2, |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 287 | (Bundle) args.arg3, null /*Session.Info*/); |
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 288 | } finally { |
| 289 | args.recycle(); |
| 290 | } |
| Tyler Gunn | 86c9fb4 | 2016-02-24 13:17:21 -0800 | [diff] [blame] | 291 | break; |
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 292 | } |
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame^] | 293 | case MSG_SET_AUDIO_ROUTE: { |
| 294 | SomeArgs args = (SomeArgs) msg.obj; |
| 295 | try { |
| 296 | mDelegate.setAudioRoute((String) args.arg1, args.argi1, |
| 297 | (Session.Info) args.arg2); |
| 298 | } finally { |
| 299 | args.recycle(); |
| 300 | } |
| 301 | break; |
| 302 | } |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 303 | } |
| 304 | } |
| 305 | }; |
| 306 | |
| 307 | private final IConnectionServiceAdapter mStub = new IConnectionServiceAdapter.Stub() { |
| 308 | @Override |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 309 | public void handleCreateConnectionComplete( |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 310 | String id, |
| 311 | ConnectionRequest request, |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 312 | ParcelableConnection connection, |
| 313 | Session.Info sessionInfo) { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 314 | SomeArgs args = SomeArgs.obtain(); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 315 | args.arg1 = id; |
| 316 | args.arg2 = request; |
| 317 | args.arg3 = connection; |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 318 | mHandler.obtainMessage(MSG_HANDLE_CREATE_CONNECTION_COMPLETE, args).sendToTarget(); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 322 | public void setActive(String connectionId, Session.Info sessionInfo) { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 323 | mHandler.obtainMessage(MSG_SET_ACTIVE, connectionId).sendToTarget(); |
| 324 | } |
| 325 | |
| 326 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 327 | public void setRinging(String connectionId, Session.Info sessionInfo) { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 328 | mHandler.obtainMessage(MSG_SET_RINGING, connectionId).sendToTarget(); |
| 329 | } |
| 330 | |
| 331 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 332 | public void setDialing(String connectionId, Session.Info sessionInfo) { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 333 | mHandler.obtainMessage(MSG_SET_DIALING, connectionId).sendToTarget(); |
| 334 | } |
| 335 | |
| 336 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 337 | public void setPulling(String connectionId, Session.Info sessionInfo) { |
| Tyler Gunn | c96b5e0 | 2016-07-07 22:53:57 -0700 | [diff] [blame] | 338 | mHandler.obtainMessage(MSG_SET_PULLING, connectionId).sendToTarget(); |
| 339 | } |
| 340 | |
| 341 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 342 | public void setDisconnected(String connectionId, DisconnectCause disconnectCause, |
| 343 | Session.Info sessionInfo) { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 344 | SomeArgs args = SomeArgs.obtain(); |
| 345 | args.arg1 = connectionId; |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 346 | args.arg2 = disconnectCause; |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 347 | mHandler.obtainMessage(MSG_SET_DISCONNECTED, args).sendToTarget(); |
| 348 | } |
| 349 | |
| 350 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 351 | public void setOnHold(String connectionId, Session.Info sessionInfo) { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 352 | mHandler.obtainMessage(MSG_SET_ON_HOLD, connectionId).sendToTarget(); |
| 353 | } |
| 354 | |
| 355 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 356 | public void setRingbackRequested(String connectionId, boolean ringback, |
| 357 | Session.Info sessionInfo) { |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 358 | mHandler.obtainMessage(MSG_SET_RINGBACK_REQUESTED, ringback ? 1 : 0, 0, connectionId) |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 359 | .sendToTarget(); |
| 360 | } |
| 361 | |
| 362 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 363 | public void setConnectionCapabilities(String connectionId, int connectionCapabilities, |
| 364 | Session.Info sessionInfo) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 365 | mHandler.obtainMessage( |
| 366 | MSG_SET_CONNECTION_CAPABILITIES, connectionCapabilities, 0, connectionId) |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 367 | .sendToTarget(); |
| 368 | } |
| 369 | |
| 370 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 371 | public void setConnectionProperties(String connectionId, int connectionProperties, |
| 372 | Session.Info sessionInfo) { |
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 373 | mHandler.obtainMessage( |
| 374 | MSG_SET_CONNECTION_PROPERTIES, connectionProperties, 0, connectionId) |
| 375 | .sendToTarget(); |
| 376 | } |
| 377 | |
| 378 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 379 | public void setConferenceMergeFailed(String callId, Session.Info sessionInfo) { |
| Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 380 | SomeArgs args = SomeArgs.obtain(); |
| 381 | args.arg1 = callId; |
| 382 | mHandler.obtainMessage(MSG_SET_CONFERENCE_MERGE_FAILED, args).sendToTarget(); |
| 383 | } |
| 384 | |
| 385 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 386 | public void setIsConferenced(String callId, String conferenceCallId, |
| 387 | Session.Info sessionInfo) { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 388 | SomeArgs args = SomeArgs.obtain(); |
| 389 | args.arg1 = callId; |
| 390 | args.arg2 = conferenceCallId; |
| 391 | mHandler.obtainMessage(MSG_SET_IS_CONFERENCED, args).sendToTarget(); |
| 392 | } |
| 393 | |
| 394 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 395 | public void addConferenceCall(String callId, ParcelableConference parcelableConference, |
| 396 | Session.Info sessionInfo) { |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 397 | SomeArgs args = SomeArgs.obtain(); |
| 398 | args.arg1 = callId; |
| 399 | args.arg2 = parcelableConference; |
| 400 | mHandler.obtainMessage(MSG_ADD_CONFERENCE_CALL, args).sendToTarget(); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 404 | public void removeCall(String connectionId, |
| 405 | Session.Info sessionInfo) { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 406 | mHandler.obtainMessage(MSG_REMOVE_CALL, connectionId).sendToTarget(); |
| 407 | } |
| 408 | |
| 409 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 410 | public void onPostDialWait(String connectionId, String remainingDigits, |
| 411 | Session.Info sessionInfo) { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 412 | SomeArgs args = SomeArgs.obtain(); |
| 413 | args.arg1 = connectionId; |
| 414 | args.arg2 = remainingDigits; |
| 415 | mHandler.obtainMessage(MSG_ON_POST_DIAL_WAIT, args).sendToTarget(); |
| 416 | } |
| 417 | |
| 418 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 419 | public void onPostDialChar(String connectionId, char nextChar, |
| 420 | Session.Info sessionInfo) { |
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 421 | SomeArgs args = SomeArgs.obtain(); |
| 422 | args.arg1 = connectionId; |
| 423 | args.argi1 = nextChar; |
| 424 | mHandler.obtainMessage(MSG_ON_POST_DIAL_CHAR, args).sendToTarget(); |
| 425 | } |
| 426 | |
| 427 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 428 | public void queryRemoteConnectionServices(RemoteServiceCallback callback, |
| 429 | Session.Info sessionInfo) { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 430 | mHandler.obtainMessage(MSG_QUERY_REMOTE_CALL_SERVICES, callback).sendToTarget(); |
| 431 | } |
| 432 | |
| 433 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 434 | public void setVideoState(String connectionId, int videoState, |
| 435 | Session.Info sessionInfo) { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 436 | mHandler.obtainMessage(MSG_SET_VIDEO_STATE, videoState, 0, connectionId).sendToTarget(); |
| 437 | } |
| 438 | |
| 439 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 440 | public void setVideoProvider(String connectionId, IVideoProvider videoProvider, |
| 441 | Session.Info sessionInfo) { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 442 | SomeArgs args = SomeArgs.obtain(); |
| 443 | args.arg1 = connectionId; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 444 | args.arg2 = videoProvider; |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 445 | mHandler.obtainMessage(MSG_SET_VIDEO_CALL_PROVIDER, args).sendToTarget(); |
| 446 | } |
| 447 | |
| 448 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 449 | public final void setIsVoipAudioMode(String connectionId, boolean isVoip, |
| 450 | Session.Info sessionInfo) { |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 451 | mHandler.obtainMessage(MSG_SET_IS_VOIP_AUDIO_MODE, isVoip ? 1 : 0, 0, |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 452 | connectionId).sendToTarget(); |
| 453 | } |
| 454 | |
| 455 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 456 | public final void setStatusHints(String connectionId, StatusHints statusHints, |
| 457 | Session.Info sessionInfo) { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 458 | SomeArgs args = SomeArgs.obtain(); |
| 459 | args.arg1 = connectionId; |
| 460 | args.arg2 = statusHints; |
| 461 | mHandler.obtainMessage(MSG_SET_STATUS_HINTS, args).sendToTarget(); |
| 462 | } |
| 463 | |
| 464 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 465 | public final void setAddress(String connectionId, Uri address, int presentation, |
| 466 | Session.Info sessionInfo) { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 467 | SomeArgs args = SomeArgs.obtain(); |
| 468 | args.arg1 = connectionId; |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 469 | args.arg2 = address; |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 470 | args.argi1 = presentation; |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 471 | mHandler.obtainMessage(MSG_SET_ADDRESS, args).sendToTarget(); |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | @Override |
| 475 | public final void setCallerDisplayName( |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 476 | String connectionId, String callerDisplayName, int presentation, |
| 477 | Session.Info sessionInfo) { |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 478 | SomeArgs args = SomeArgs.obtain(); |
| 479 | args.arg1 = connectionId; |
| 480 | args.arg2 = callerDisplayName; |
| 481 | args.argi1 = presentation; |
| 482 | mHandler.obtainMessage(MSG_SET_CALLER_DISPLAY_NAME, args).sendToTarget(); |
| 483 | } |
| 484 | |
| 485 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 486 | public final void setConferenceableConnections(String connectionId, |
| 487 | List<String> conferenceableConnectionIds, Session.Info sessionInfo) { |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 488 | SomeArgs args = SomeArgs.obtain(); |
| 489 | args.arg1 = connectionId; |
| 490 | args.arg2 = conferenceableConnectionIds; |
| 491 | mHandler.obtainMessage(MSG_SET_CONFERENCEABLE_CONNECTIONS, args).sendToTarget(); |
| 492 | } |
| Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 493 | |
| 494 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 495 | public final void addExistingConnection(String connectionId, |
| 496 | ParcelableConnection connection, Session.Info sessionInfo) { |
| Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 497 | SomeArgs args = SomeArgs.obtain(); |
| 498 | args.arg1 = connectionId; |
| 499 | args.arg2 = connection; |
| 500 | mHandler.obtainMessage(MSG_ADD_EXISTING_CONNECTION, args).sendToTarget(); |
| 501 | } |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 502 | |
| 503 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 504 | public final void putExtras(String connectionId, Bundle extras, Session.Info sessionInfo) { |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 505 | SomeArgs args = SomeArgs.obtain(); |
| 506 | args.arg1 = connectionId; |
| 507 | args.arg2 = extras; |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 508 | mHandler.obtainMessage(MSG_PUT_EXTRAS, args).sendToTarget(); |
| 509 | } |
| 510 | |
| 511 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 512 | public final void removeExtras(String connectionId, List<String> keys, |
| 513 | Session.Info sessionInfo) { |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 514 | SomeArgs args = SomeArgs.obtain(); |
| 515 | args.arg1 = connectionId; |
| 516 | args.arg2 = keys; |
| 517 | mHandler.obtainMessage(MSG_REMOVE_EXTRAS, args).sendToTarget(); |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 518 | } |
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 519 | |
| 520 | @Override |
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame^] | 521 | public final void setAudioRoute(String connectionId, int audioRoute, |
| 522 | Session.Info sessionInfo) { |
| 523 | |
| 524 | SomeArgs args = SomeArgs.obtain(); |
| 525 | args.arg1 = connectionId; |
| 526 | args.argi1 = audioRoute; |
| 527 | args.arg2 = sessionInfo; |
| 528 | mHandler.obtainMessage(MSG_SET_AUDIO_ROUTE, args).sendToTarget(); |
| 529 | } |
| 530 | |
| 531 | @Override |
| Brad Ebinger | 4d75bee | 2016-10-28 12:29:55 -0700 | [diff] [blame] | 532 | public final void onConnectionEvent(String connectionId, String event, Bundle extras, |
| 533 | Session.Info sessionInfo) { |
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 534 | SomeArgs args = SomeArgs.obtain(); |
| 535 | args.arg1 = connectionId; |
| 536 | args.arg2 = event; |
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 537 | args.arg3 = extras; |
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 538 | mHandler.obtainMessage(MSG_ON_CONNECTION_EVENT, args).sendToTarget(); |
| 539 | } |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 540 | }; |
| 541 | |
| 542 | public ConnectionServiceAdapterServant(IConnectionServiceAdapter delegate) { |
| 543 | mDelegate = delegate; |
| 544 | } |
| 545 | |
| 546 | public IConnectionServiceAdapter getStub() { |
| 547 | return mStub; |
| 548 | } |
| 549 | } |