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