Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -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 | * limitations under the License. |
| 15 | */ |
| 16 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 17 | package android.telecom; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 18 | |
Santos Cordon | 5c6fa95 | 2014-07-20 17:47:12 -0700 | [diff] [blame] | 19 | import android.annotation.SdkConstant; |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 20 | import android.app.Service; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 21 | import android.content.ComponentName; |
Santos Cordon | 5c6fa95 | 2014-07-20 17:47:12 -0700 | [diff] [blame] | 22 | import android.content.Intent; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 23 | import android.net.Uri; |
Sanket Padawe | 4cc8ed53 | 2017-12-04 16:22:20 -0800 | [diff] [blame] | 24 | import android.os.Build; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 25 | import android.os.Bundle; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 26 | import android.os.Handler; |
| 27 | import android.os.IBinder; |
| 28 | import android.os.Looper; |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 29 | import android.os.Message; |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 30 | import android.os.ParcelFileDescriptor; |
| 31 | import android.os.RemoteException; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 32 | import android.telecom.Logging.Session; |
Andrew Lee | 1418576 | 2014-07-25 09:41:56 -0700 | [diff] [blame] | 33 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 34 | import com.android.internal.os.SomeArgs; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 35 | import com.android.internal.telecom.IConnectionService; |
| 36 | import com.android.internal.telecom.IConnectionServiceAdapter; |
| 37 | import com.android.internal.telecom.RemoteServiceCallback; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 38 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 39 | import java.util.ArrayList; |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 40 | import java.util.Collection; |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 41 | import java.util.Collections; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 42 | import java.util.List; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 43 | import java.util.Map; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 44 | import java.util.UUID; |
mike dooley | 95e8070 | 2014-09-18 14:07:52 -0700 | [diff] [blame] | 45 | import java.util.concurrent.ConcurrentHashMap; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 46 | |
| 47 | /** |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 48 | * An abstract service that should be implemented by any apps which either: |
| 49 | * <ol> |
| 50 | * <li>Can make phone calls (VoIP or otherwise) and want those calls to be integrated into the |
| 51 | * built-in phone app. Referred to as a <b>system managed</b> {@link ConnectionService}.</li> |
| 52 | * <li>Are a standalone calling app and don't want their calls to be integrated into the |
| 53 | * built-in phone app. Referred to as a <b>self managed</b> {@link ConnectionService}.</li> |
| 54 | * </ol> |
| 55 | * Once implemented, the {@link ConnectionService} needs to take the following steps so that Telecom |
| 56 | * will bind to it: |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 57 | * <p> |
| 58 | * 1. <i>Registration in AndroidManifest.xml</i> |
| 59 | * <br/> |
| 60 | * <pre> |
| 61 | * <service android:name="com.example.package.MyConnectionService" |
| 62 | * android:label="@string/some_label_for_my_connection_service" |
Yorke Lee | 249c12e | 2015-05-13 15:59:29 -0700 | [diff] [blame] | 63 | * android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"> |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 64 | * <intent-filter> |
| 65 | * <action android:name="android.telecom.ConnectionService" /> |
| 66 | * </intent-filter> |
| 67 | * </service> |
| 68 | * </pre> |
| 69 | * <p> |
| 70 | * 2. <i> Registration of {@link PhoneAccount} with {@link TelecomManager}.</i> |
| 71 | * <br/> |
| 72 | * See {@link PhoneAccount} and {@link TelecomManager#registerPhoneAccount} for more information. |
| 73 | * <p> |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 74 | * System managed {@link ConnectionService}s must be enabled by the user in the phone app settings |
| 75 | * before Telecom will bind to them. Self-manged {@link ConnectionService}s must be granted the |
| 76 | * appropriate permission before Telecom will bind to them. |
| 77 | * <p> |
| 78 | * Once registered and enabled by the user in the phone app settings or granted permission, telecom |
| 79 | * will bind to a {@link ConnectionService} implementation when it wants that |
| 80 | * {@link ConnectionService} to place a call or the service has indicated that is has an incoming |
| 81 | * call through {@link TelecomManager#addNewIncomingCall}. The {@link ConnectionService} can then |
| 82 | * expect a call to {@link #onCreateIncomingConnection} or {@link #onCreateOutgoingConnection} |
| 83 | * wherein it should provide a new instance of a {@link Connection} object. It is through this |
| 84 | * {@link Connection} object that telecom receives state updates and the {@link ConnectionService} |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 85 | * receives call-commands such as answer, reject, hold and disconnect. |
| 86 | * <p> |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 87 | * When there are no more live calls, telecom will unbind from the {@link ConnectionService}. |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 88 | */ |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 89 | public abstract class ConnectionService extends Service { |
Santos Cordon | 5c6fa95 | 2014-07-20 17:47:12 -0700 | [diff] [blame] | 90 | /** |
| 91 | * The {@link Intent} that must be declared as handled by the service. |
| 92 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 93 | @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION) |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 94 | public static final String SERVICE_INTERFACE = "android.telecom.ConnectionService"; |
Santos Cordon | 5c6fa95 | 2014-07-20 17:47:12 -0700 | [diff] [blame] | 95 | |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 96 | /** |
| 97 | * Boolean extra used by Telecom to inform a {@link ConnectionService} that the purpose of it |
| 98 | * being asked to create a new outgoing {@link Connection} is to perform a handover of an |
| 99 | * ongoing call on the device from another {@link PhoneAccount}/{@link ConnectionService}. Will |
| 100 | * be specified in the {@link ConnectionRequest#getExtras()} passed by Telecom when |
| 101 | * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)} is called. |
| 102 | * <p> |
Tyler Gunn | 727c6bd | 2017-04-11 09:51:40 -0700 | [diff] [blame] | 103 | * When your {@link ConnectionService} receives this extra, it should communicate the fact that |
| 104 | * this is a handover to the other device's matching {@link ConnectionService}. That |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 105 | * {@link ConnectionService} will continue the handover using |
| 106 | * {@link TelecomManager#addNewIncomingCall(PhoneAccountHandle, Bundle)}, specifying |
Tyler Gunn | 727c6bd | 2017-04-11 09:51:40 -0700 | [diff] [blame] | 107 | * {@link TelecomManager#EXTRA_IS_HANDOVER}. Telecom will match the phone numbers of the |
| 108 | * handover call on the other device with ongoing calls for {@link ConnectionService}s which |
| 109 | * support {@link PhoneAccount#EXTRA_SUPPORTS_HANDOVER_FROM}. |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 110 | * @hide |
| 111 | */ |
| 112 | public static final String EXTRA_IS_HANDOVER = TelecomManager.EXTRA_IS_HANDOVER; |
| 113 | |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 114 | // Flag controlling whether PII is emitted into the logs |
Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 115 | private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 116 | |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 117 | // Session Definitions |
| 118 | private static final String SESSION_HANDLER = "H."; |
| 119 | private static final String SESSION_ADD_CS_ADAPTER = "CS.aCSA"; |
| 120 | private static final String SESSION_REMOVE_CS_ADAPTER = "CS.rCSA"; |
| 121 | private static final String SESSION_CREATE_CONN = "CS.crCo"; |
Tyler Gunn | 041a1fe | 2017-05-12 10:04:49 -0700 | [diff] [blame] | 122 | private static final String SESSION_CREATE_CONN_COMPLETE = "CS.crCoC"; |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 123 | private static final String SESSION_CREATE_CONN_FAILED = "CS.crCoF"; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 124 | private static final String SESSION_ABORT = "CS.ab"; |
| 125 | private static final String SESSION_ANSWER = "CS.an"; |
| 126 | private static final String SESSION_ANSWER_VIDEO = "CS.anV"; |
| 127 | private static final String SESSION_REJECT = "CS.r"; |
| 128 | private static final String SESSION_REJECT_MESSAGE = "CS.rWM"; |
| 129 | private static final String SESSION_SILENCE = "CS.s"; |
| 130 | private static final String SESSION_DISCONNECT = "CS.d"; |
| 131 | private static final String SESSION_HOLD = "CS.h"; |
| 132 | private static final String SESSION_UNHOLD = "CS.u"; |
| 133 | private static final String SESSION_CALL_AUDIO_SC = "CS.cASC"; |
| 134 | private static final String SESSION_PLAY_DTMF = "CS.pDT"; |
| 135 | private static final String SESSION_STOP_DTMF = "CS.sDT"; |
| 136 | private static final String SESSION_CONFERENCE = "CS.c"; |
| 137 | private static final String SESSION_SPLIT_CONFERENCE = "CS.sFC"; |
| 138 | private static final String SESSION_MERGE_CONFERENCE = "CS.mC"; |
| 139 | private static final String SESSION_SWAP_CONFERENCE = "CS.sC"; |
| 140 | private static final String SESSION_POST_DIAL_CONT = "CS.oPDC"; |
| 141 | private static final String SESSION_PULL_EXTERNAL_CALL = "CS.pEC"; |
| 142 | private static final String SESSION_SEND_CALL_EVENT = "CS.sCE"; |
| 143 | private static final String SESSION_EXTRAS_CHANGED = "CS.oEC"; |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 144 | private static final String SESSION_START_RTT = "CS.+RTT"; |
| 145 | private static final String SESSION_STOP_RTT = "CS.-RTT"; |
| 146 | private static final String SESSION_RTT_UPGRADE_RESPONSE = "CS.rTRUR"; |
Pengquan Meng | 731c1a3 | 2017-11-21 18:01:13 -0800 | [diff] [blame] | 147 | private static final String SESSION_CONNECTION_SERVICE_FOCUS_LOST = "CS.cSFL"; |
| 148 | private static final String SESSION_CONNECTION_SERVICE_FOCUS_GAINED = "CS.cSFG"; |
Sanket Padawe | 4cc8ed53 | 2017-12-04 16:22:20 -0800 | [diff] [blame] | 149 | private static final String SESSION_HANDOVER_FAILED = "CS.haF"; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 150 | |
Ihab Awad | 8aecfed | 2014-08-08 17:06:11 -0700 | [diff] [blame] | 151 | private static final int MSG_ADD_CONNECTION_SERVICE_ADAPTER = 1; |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 152 | private static final int MSG_CREATE_CONNECTION = 2; |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 153 | private static final int MSG_ABORT = 3; |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 154 | private static final int MSG_ANSWER = 4; |
| 155 | private static final int MSG_REJECT = 5; |
| 156 | private static final int MSG_DISCONNECT = 6; |
| 157 | private static final int MSG_HOLD = 7; |
| 158 | private static final int MSG_UNHOLD = 8; |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 159 | private static final int MSG_ON_CALL_AUDIO_STATE_CHANGED = 9; |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 160 | private static final int MSG_PLAY_DTMF_TONE = 10; |
| 161 | private static final int MSG_STOP_DTMF_TONE = 11; |
| 162 | private static final int MSG_CONFERENCE = 12; |
| 163 | private static final int MSG_SPLIT_FROM_CONFERENCE = 13; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 164 | private static final int MSG_ON_POST_DIAL_CONTINUE = 14; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 165 | private static final int MSG_REMOVE_CONNECTION_SERVICE_ADAPTER = 16; |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 166 | private static final int MSG_ANSWER_VIDEO = 17; |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 167 | private static final int MSG_MERGE_CONFERENCE = 18; |
| 168 | private static final int MSG_SWAP_CONFERENCE = 19; |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 169 | private static final int MSG_REJECT_WITH_MESSAGE = 20; |
Bryce Lee | cac5077 | 2015-11-17 15:13:29 -0800 | [diff] [blame] | 170 | private static final int MSG_SILENCE = 21; |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 171 | private static final int MSG_PULL_EXTERNAL_CALL = 22; |
| 172 | private static final int MSG_SEND_CALL_EVENT = 23; |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 173 | private static final int MSG_ON_EXTRAS_CHANGED = 24; |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 174 | private static final int MSG_CREATE_CONNECTION_FAILED = 25; |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 175 | private static final int MSG_ON_START_RTT = 26; |
| 176 | private static final int MSG_ON_STOP_RTT = 27; |
| 177 | private static final int MSG_RTT_UPGRADE_RESPONSE = 28; |
Tyler Gunn | 041a1fe | 2017-05-12 10:04:49 -0700 | [diff] [blame] | 178 | private static final int MSG_CREATE_CONNECTION_COMPLETE = 29; |
Pengquan Meng | 731c1a3 | 2017-11-21 18:01:13 -0800 | [diff] [blame] | 179 | private static final int MSG_CONNECTION_SERVICE_FOCUS_LOST = 30; |
| 180 | private static final int MSG_CONNECTION_SERVICE_FOCUS_GAINED = 31; |
Sanket Padawe | 4cc8ed53 | 2017-12-04 16:22:20 -0800 | [diff] [blame] | 181 | private static final int MSG_HANDOVER_FAILED = 32; |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 182 | |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 183 | private static Connection sNullConnection; |
| 184 | |
mike dooley | 95e8070 | 2014-09-18 14:07:52 -0700 | [diff] [blame] | 185 | private final Map<String, Connection> mConnectionById = new ConcurrentHashMap<>(); |
| 186 | private final Map<Connection, String> mIdByConnection = new ConcurrentHashMap<>(); |
| 187 | private final Map<String, Conference> mConferenceById = new ConcurrentHashMap<>(); |
| 188 | private final Map<Conference, String> mIdByConference = new ConcurrentHashMap<>(); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 189 | private final RemoteConnectionManager mRemoteConnectionManager = |
| 190 | new RemoteConnectionManager(this); |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 191 | private final List<Runnable> mPreInitializationConnectionRequests = new ArrayList<>(); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 192 | private final ConnectionServiceAdapter mAdapter = new ConnectionServiceAdapter(); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 193 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 194 | private boolean mAreAccountsInitialized = false; |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 195 | private Conference sNullConference; |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 196 | private Object mIdSyncRoot = new Object(); |
| 197 | private int mId = 0; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 198 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 199 | private final IBinder mBinder = new IConnectionService.Stub() { |
| 200 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 201 | public void addConnectionServiceAdapter(IConnectionServiceAdapter adapter, |
| 202 | Session.Info sessionInfo) { |
| 203 | Log.startSession(sessionInfo, SESSION_ADD_CS_ADAPTER); |
| 204 | try { |
| 205 | SomeArgs args = SomeArgs.obtain(); |
| 206 | args.arg1 = adapter; |
| 207 | args.arg2 = Log.createSubsession(); |
| 208 | mHandler.obtainMessage(MSG_ADD_CONNECTION_SERVICE_ADAPTER, args).sendToTarget(); |
| 209 | } finally { |
| 210 | Log.endSession(); |
| 211 | } |
Ihab Awad | 8aecfed | 2014-08-08 17:06:11 -0700 | [diff] [blame] | 212 | } |
| 213 | |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 214 | public void removeConnectionServiceAdapter(IConnectionServiceAdapter adapter, |
| 215 | Session.Info sessionInfo) { |
| 216 | Log.startSession(sessionInfo, SESSION_REMOVE_CS_ADAPTER); |
| 217 | try { |
| 218 | SomeArgs args = SomeArgs.obtain(); |
| 219 | args.arg1 = adapter; |
| 220 | args.arg2 = Log.createSubsession(); |
| 221 | mHandler.obtainMessage(MSG_REMOVE_CONNECTION_SERVICE_ADAPTER, args).sendToTarget(); |
| 222 | } finally { |
| 223 | Log.endSession(); |
| 224 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | @Override |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 228 | public void createConnection( |
| 229 | PhoneAccountHandle connectionManagerPhoneAccount, |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 230 | String id, |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 231 | ConnectionRequest request, |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 232 | boolean isIncoming, |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 233 | boolean isUnknown, |
| 234 | Session.Info sessionInfo) { |
| 235 | Log.startSession(sessionInfo, SESSION_CREATE_CONN); |
| 236 | try { |
| 237 | SomeArgs args = SomeArgs.obtain(); |
| 238 | args.arg1 = connectionManagerPhoneAccount; |
| 239 | args.arg2 = id; |
| 240 | args.arg3 = request; |
| 241 | args.arg4 = Log.createSubsession(); |
| 242 | args.argi1 = isIncoming ? 1 : 0; |
| 243 | args.argi2 = isUnknown ? 1 : 0; |
| 244 | mHandler.obtainMessage(MSG_CREATE_CONNECTION, args).sendToTarget(); |
| 245 | } finally { |
| 246 | Log.endSession(); |
| 247 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | @Override |
Tyler Gunn | 041a1fe | 2017-05-12 10:04:49 -0700 | [diff] [blame] | 251 | public void createConnectionComplete(String id, Session.Info sessionInfo) { |
| 252 | Log.startSession(sessionInfo, SESSION_CREATE_CONN_COMPLETE); |
| 253 | try { |
| 254 | SomeArgs args = SomeArgs.obtain(); |
| 255 | args.arg1 = id; |
| 256 | args.arg2 = Log.createSubsession(); |
| 257 | mHandler.obtainMessage(MSG_CREATE_CONNECTION_COMPLETE, args).sendToTarget(); |
| 258 | } finally { |
| 259 | Log.endSession(); |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | @Override |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 264 | public void createConnectionFailed( |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 265 | PhoneAccountHandle connectionManagerPhoneAccount, |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 266 | String callId, |
| 267 | ConnectionRequest request, |
| 268 | boolean isIncoming, |
| 269 | Session.Info sessionInfo) { |
| 270 | Log.startSession(sessionInfo, SESSION_CREATE_CONN_FAILED); |
| 271 | try { |
| 272 | SomeArgs args = SomeArgs.obtain(); |
| 273 | args.arg1 = callId; |
| 274 | args.arg2 = request; |
| 275 | args.arg3 = Log.createSubsession(); |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 276 | args.arg4 = connectionManagerPhoneAccount; |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 277 | args.argi1 = isIncoming ? 1 : 0; |
| 278 | mHandler.obtainMessage(MSG_CREATE_CONNECTION_FAILED, args).sendToTarget(); |
| 279 | } finally { |
| 280 | Log.endSession(); |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | @Override |
Sanket Padawe | 4cc8ed53 | 2017-12-04 16:22:20 -0800 | [diff] [blame] | 285 | public void handoverFailed(String callId, ConnectionRequest request, int reason, |
| 286 | Session.Info sessionInfo) { |
| 287 | Log.startSession(sessionInfo, SESSION_HANDOVER_FAILED); |
| 288 | try { |
| 289 | SomeArgs args = SomeArgs.obtain(); |
| 290 | args.arg1 = callId; |
| 291 | args.arg2 = request; |
| 292 | args.arg3 = Log.createSubsession(); |
| 293 | args.arg4 = reason; |
| 294 | mHandler.obtainMessage(MSG_HANDOVER_FAILED, args).sendToTarget(); |
| 295 | } finally { |
| 296 | Log.endSession(); |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 301 | public void abort(String callId, Session.Info sessionInfo) { |
| 302 | Log.startSession(sessionInfo, SESSION_ABORT); |
| 303 | try { |
| 304 | SomeArgs args = SomeArgs.obtain(); |
| 305 | args.arg1 = callId; |
| 306 | args.arg2 = Log.createSubsession(); |
| 307 | mHandler.obtainMessage(MSG_ABORT, args).sendToTarget(); |
| 308 | } finally { |
| 309 | Log.endSession(); |
| 310 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 314 | public void answerVideo(String callId, int videoState, Session.Info sessionInfo) { |
| 315 | Log.startSession(sessionInfo, SESSION_ANSWER_VIDEO); |
| 316 | try { |
| 317 | SomeArgs args = SomeArgs.obtain(); |
| 318 | args.arg1 = callId; |
| 319 | args.arg2 = Log.createSubsession(); |
| 320 | args.argi1 = videoState; |
| 321 | mHandler.obtainMessage(MSG_ANSWER_VIDEO, args).sendToTarget(); |
| 322 | } finally { |
| 323 | Log.endSession(); |
| 324 | } |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 328 | public void answer(String callId, Session.Info sessionInfo) { |
| 329 | Log.startSession(sessionInfo, SESSION_ANSWER); |
| 330 | try { |
| 331 | SomeArgs args = SomeArgs.obtain(); |
| 332 | args.arg1 = callId; |
| 333 | args.arg2 = Log.createSubsession(); |
| 334 | mHandler.obtainMessage(MSG_ANSWER, args).sendToTarget(); |
| 335 | } finally { |
| 336 | Log.endSession(); |
| 337 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 341 | public void reject(String callId, Session.Info sessionInfo) { |
| 342 | Log.startSession(sessionInfo, SESSION_REJECT); |
| 343 | try { |
| 344 | SomeArgs args = SomeArgs.obtain(); |
| 345 | args.arg1 = callId; |
| 346 | args.arg2 = Log.createSubsession(); |
| 347 | mHandler.obtainMessage(MSG_REJECT, args).sendToTarget(); |
| 348 | } finally { |
| 349 | Log.endSession(); |
| 350 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 354 | public void rejectWithMessage(String callId, String message, Session.Info sessionInfo) { |
| 355 | Log.startSession(sessionInfo, SESSION_REJECT_MESSAGE); |
| 356 | try { |
| 357 | SomeArgs args = SomeArgs.obtain(); |
| 358 | args.arg1 = callId; |
| 359 | args.arg2 = message; |
| 360 | args.arg3 = Log.createSubsession(); |
| 361 | mHandler.obtainMessage(MSG_REJECT_WITH_MESSAGE, args).sendToTarget(); |
| 362 | } finally { |
| 363 | Log.endSession(); |
| 364 | } |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 368 | public void silence(String callId, Session.Info sessionInfo) { |
| 369 | Log.startSession(sessionInfo, SESSION_SILENCE); |
| 370 | try { |
| 371 | SomeArgs args = SomeArgs.obtain(); |
| 372 | args.arg1 = callId; |
| 373 | args.arg2 = Log.createSubsession(); |
| 374 | mHandler.obtainMessage(MSG_SILENCE, args).sendToTarget(); |
| 375 | } finally { |
| 376 | Log.endSession(); |
| 377 | } |
Bryce Lee | cac5077 | 2015-11-17 15:13:29 -0800 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 381 | public void disconnect(String callId, Session.Info sessionInfo) { |
| 382 | Log.startSession(sessionInfo, SESSION_DISCONNECT); |
| 383 | try { |
| 384 | SomeArgs args = SomeArgs.obtain(); |
| 385 | args.arg1 = callId; |
| 386 | args.arg2 = Log.createSubsession(); |
| 387 | mHandler.obtainMessage(MSG_DISCONNECT, args).sendToTarget(); |
| 388 | } finally { |
| 389 | Log.endSession(); |
| 390 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 394 | public void hold(String callId, Session.Info sessionInfo) { |
| 395 | Log.startSession(sessionInfo, SESSION_HOLD); |
| 396 | try { |
| 397 | SomeArgs args = SomeArgs.obtain(); |
| 398 | args.arg1 = callId; |
| 399 | args.arg2 = Log.createSubsession(); |
| 400 | mHandler.obtainMessage(MSG_HOLD, args).sendToTarget(); |
| 401 | } finally { |
| 402 | Log.endSession(); |
| 403 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 407 | public void unhold(String callId, Session.Info sessionInfo) { |
| 408 | Log.startSession(sessionInfo, SESSION_UNHOLD); |
| 409 | try { |
| 410 | SomeArgs args = SomeArgs.obtain(); |
| 411 | args.arg1 = callId; |
| 412 | args.arg2 = Log.createSubsession(); |
| 413 | mHandler.obtainMessage(MSG_UNHOLD, args).sendToTarget(); |
| 414 | } finally { |
| 415 | Log.endSession(); |
| 416 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 420 | public void onCallAudioStateChanged(String callId, CallAudioState callAudioState, |
| 421 | Session.Info sessionInfo) { |
| 422 | Log.startSession(sessionInfo, SESSION_CALL_AUDIO_SC); |
| 423 | try { |
| 424 | SomeArgs args = SomeArgs.obtain(); |
| 425 | args.arg1 = callId; |
| 426 | args.arg2 = callAudioState; |
| 427 | args.arg3 = Log.createSubsession(); |
| 428 | mHandler.obtainMessage(MSG_ON_CALL_AUDIO_STATE_CHANGED, args).sendToTarget(); |
| 429 | } finally { |
| 430 | Log.endSession(); |
| 431 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 435 | public void playDtmfTone(String callId, char digit, Session.Info sessionInfo) { |
| 436 | Log.startSession(sessionInfo, SESSION_PLAY_DTMF); |
| 437 | try { |
| 438 | SomeArgs args = SomeArgs.obtain(); |
| 439 | args.arg1 = digit; |
| 440 | args.arg2 = callId; |
| 441 | args.arg3 = Log.createSubsession(); |
| 442 | mHandler.obtainMessage(MSG_PLAY_DTMF_TONE, args).sendToTarget(); |
| 443 | } finally { |
| 444 | Log.endSession(); |
| 445 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 449 | public void stopDtmfTone(String callId, Session.Info sessionInfo) { |
| 450 | Log.startSession(sessionInfo, SESSION_STOP_DTMF); |
| 451 | try { |
| 452 | SomeArgs args = SomeArgs.obtain(); |
| 453 | args.arg1 = callId; |
| 454 | args.arg2 = Log.createSubsession(); |
| 455 | mHandler.obtainMessage(MSG_STOP_DTMF_TONE, args).sendToTarget(); |
| 456 | } finally { |
| 457 | Log.endSession(); |
| 458 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 462 | public void conference(String callId1, String callId2, Session.Info sessionInfo) { |
| 463 | Log.startSession(sessionInfo, SESSION_CONFERENCE); |
| 464 | try { |
| 465 | SomeArgs args = SomeArgs.obtain(); |
| 466 | args.arg1 = callId1; |
| 467 | args.arg2 = callId2; |
| 468 | args.arg3 = Log.createSubsession(); |
| 469 | mHandler.obtainMessage(MSG_CONFERENCE, args).sendToTarget(); |
| 470 | } finally { |
| 471 | Log.endSession(); |
| 472 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 476 | public void splitFromConference(String callId, Session.Info sessionInfo) { |
| 477 | Log.startSession(sessionInfo, SESSION_SPLIT_CONFERENCE); |
| 478 | try { |
| 479 | SomeArgs args = SomeArgs.obtain(); |
| 480 | args.arg1 = callId; |
| 481 | args.arg2 = Log.createSubsession(); |
| 482 | mHandler.obtainMessage(MSG_SPLIT_FROM_CONFERENCE, args).sendToTarget(); |
| 483 | } finally { |
| 484 | Log.endSession(); |
| 485 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 489 | public void mergeConference(String callId, Session.Info sessionInfo) { |
| 490 | Log.startSession(sessionInfo, SESSION_MERGE_CONFERENCE); |
| 491 | try { |
| 492 | SomeArgs args = SomeArgs.obtain(); |
| 493 | args.arg1 = callId; |
| 494 | args.arg2 = Log.createSubsession(); |
| 495 | mHandler.obtainMessage(MSG_MERGE_CONFERENCE, args).sendToTarget(); |
| 496 | } finally { |
| 497 | Log.endSession(); |
| 498 | } |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 502 | public void swapConference(String callId, Session.Info sessionInfo) { |
| 503 | Log.startSession(sessionInfo, SESSION_SWAP_CONFERENCE); |
| 504 | try { |
| 505 | SomeArgs args = SomeArgs.obtain(); |
| 506 | args.arg1 = callId; |
| 507 | args.arg2 = Log.createSubsession(); |
| 508 | mHandler.obtainMessage(MSG_SWAP_CONFERENCE, args).sendToTarget(); |
| 509 | } finally { |
| 510 | Log.endSession(); |
| 511 | } |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 515 | public void onPostDialContinue(String callId, boolean proceed, Session.Info sessionInfo) { |
| 516 | Log.startSession(sessionInfo, SESSION_POST_DIAL_CONT); |
| 517 | try { |
| 518 | SomeArgs args = SomeArgs.obtain(); |
| 519 | args.arg1 = callId; |
| 520 | args.arg2 = Log.createSubsession(); |
| 521 | args.argi1 = proceed ? 1 : 0; |
| 522 | mHandler.obtainMessage(MSG_ON_POST_DIAL_CONTINUE, args).sendToTarget(); |
| 523 | } finally { |
| 524 | Log.endSession(); |
| 525 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 526 | } |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 527 | |
| 528 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 529 | public void pullExternalCall(String callId, Session.Info sessionInfo) { |
| 530 | Log.startSession(sessionInfo, SESSION_PULL_EXTERNAL_CALL); |
| 531 | try { |
| 532 | SomeArgs args = SomeArgs.obtain(); |
| 533 | args.arg1 = callId; |
| 534 | args.arg2 = Log.createSubsession(); |
| 535 | mHandler.obtainMessage(MSG_PULL_EXTERNAL_CALL, args).sendToTarget(); |
| 536 | } finally { |
| 537 | Log.endSession(); |
| 538 | } |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 542 | public void sendCallEvent(String callId, String event, Bundle extras, |
| 543 | Session.Info sessionInfo) { |
| 544 | Log.startSession(sessionInfo, SESSION_SEND_CALL_EVENT); |
| 545 | try { |
| 546 | SomeArgs args = SomeArgs.obtain(); |
| 547 | args.arg1 = callId; |
| 548 | args.arg2 = event; |
| 549 | args.arg3 = extras; |
| 550 | args.arg4 = Log.createSubsession(); |
| 551 | mHandler.obtainMessage(MSG_SEND_CALL_EVENT, args).sendToTarget(); |
| 552 | } finally { |
| 553 | Log.endSession(); |
| 554 | } |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 555 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 556 | |
| 557 | @Override |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 558 | public void onExtrasChanged(String callId, Bundle extras, Session.Info sessionInfo) { |
| 559 | Log.startSession(sessionInfo, SESSION_EXTRAS_CHANGED); |
| 560 | try { |
| 561 | SomeArgs args = SomeArgs.obtain(); |
| 562 | args.arg1 = callId; |
| 563 | args.arg2 = extras; |
| 564 | args.arg3 = Log.createSubsession(); |
| 565 | mHandler.obtainMessage(MSG_ON_EXTRAS_CHANGED, args).sendToTarget(); |
| 566 | } finally { |
| 567 | Log.endSession(); |
| 568 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 569 | } |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 570 | |
| 571 | @Override |
| 572 | public void startRtt(String callId, ParcelFileDescriptor fromInCall, |
| 573 | ParcelFileDescriptor toInCall, Session.Info sessionInfo) throws RemoteException { |
| 574 | Log.startSession(sessionInfo, SESSION_START_RTT); |
| 575 | try { |
| 576 | SomeArgs args = SomeArgs.obtain(); |
| 577 | args.arg1 = callId; |
| 578 | args.arg2 = new Connection.RttTextStream(toInCall, fromInCall); |
| 579 | args.arg3 = Log.createSubsession(); |
| 580 | mHandler.obtainMessage(MSG_ON_START_RTT, args).sendToTarget(); |
| 581 | } finally { |
| 582 | Log.endSession(); |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | @Override |
| 587 | public void stopRtt(String callId, Session.Info sessionInfo) throws RemoteException { |
| 588 | Log.startSession(sessionInfo, SESSION_STOP_RTT); |
| 589 | try { |
| 590 | SomeArgs args = SomeArgs.obtain(); |
| 591 | args.arg1 = callId; |
| 592 | args.arg2 = Log.createSubsession(); |
| 593 | mHandler.obtainMessage(MSG_ON_STOP_RTT, args).sendToTarget(); |
| 594 | } finally { |
| 595 | Log.endSession(); |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | @Override |
| 600 | public void respondToRttUpgradeRequest(String callId, ParcelFileDescriptor fromInCall, |
| 601 | ParcelFileDescriptor toInCall, Session.Info sessionInfo) throws RemoteException { |
| 602 | Log.startSession(sessionInfo, SESSION_RTT_UPGRADE_RESPONSE); |
| 603 | try { |
| 604 | SomeArgs args = SomeArgs.obtain(); |
| 605 | args.arg1 = callId; |
| 606 | if (toInCall == null || fromInCall == null) { |
| 607 | args.arg2 = null; |
| 608 | } else { |
| 609 | args.arg2 = new Connection.RttTextStream(toInCall, fromInCall); |
| 610 | } |
| 611 | args.arg3 = Log.createSubsession(); |
| 612 | mHandler.obtainMessage(MSG_RTT_UPGRADE_RESPONSE, args).sendToTarget(); |
| 613 | } finally { |
| 614 | Log.endSession(); |
| 615 | } |
| 616 | } |
Pengquan Meng | 731c1a3 | 2017-11-21 18:01:13 -0800 | [diff] [blame] | 617 | |
| 618 | @Override |
| 619 | public void connectionServiceFocusLost(Session.Info sessionInfo) throws RemoteException { |
| 620 | Log.startSession(sessionInfo, SESSION_CONNECTION_SERVICE_FOCUS_LOST); |
| 621 | try { |
| 622 | mHandler.obtainMessage(MSG_CONNECTION_SERVICE_FOCUS_LOST).sendToTarget(); |
| 623 | } finally { |
| 624 | Log.endSession(); |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | @Override |
| 629 | public void connectionServiceFocusGained(Session.Info sessionInfo) throws RemoteException { |
| 630 | Log.startSession(sessionInfo, SESSION_CONNECTION_SERVICE_FOCUS_GAINED); |
| 631 | try { |
| 632 | mHandler.obtainMessage(MSG_CONNECTION_SERVICE_FOCUS_GAINED).sendToTarget(); |
| 633 | } finally { |
| 634 | Log.endSession(); |
| 635 | } |
| 636 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 637 | }; |
| 638 | |
| 639 | private final Handler mHandler = new Handler(Looper.getMainLooper()) { |
| 640 | @Override |
| 641 | public void handleMessage(Message msg) { |
| 642 | switch (msg.what) { |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 643 | case MSG_ADD_CONNECTION_SERVICE_ADAPTER: { |
| 644 | SomeArgs args = (SomeArgs) msg.obj; |
| 645 | try { |
| 646 | IConnectionServiceAdapter adapter = (IConnectionServiceAdapter) args.arg1; |
| 647 | Log.continueSession((Session) args.arg2, |
| 648 | SESSION_HANDLER + SESSION_ADD_CS_ADAPTER); |
| 649 | mAdapter.addAdapter(adapter); |
| 650 | onAdapterAttached(); |
| 651 | } finally { |
| 652 | args.recycle(); |
| 653 | Log.endSession(); |
| 654 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 655 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 656 | } |
| 657 | case MSG_REMOVE_CONNECTION_SERVICE_ADAPTER: { |
| 658 | SomeArgs args = (SomeArgs) msg.obj; |
| 659 | try { |
| 660 | Log.continueSession((Session) args.arg2, |
| 661 | SESSION_HANDLER + SESSION_REMOVE_CS_ADAPTER); |
| 662 | mAdapter.removeAdapter((IConnectionServiceAdapter) args.arg1); |
| 663 | } finally { |
| 664 | args.recycle(); |
| 665 | Log.endSession(); |
| 666 | } |
Ihab Awad | 8aecfed | 2014-08-08 17:06:11 -0700 | [diff] [blame] | 667 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 668 | } |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 669 | case MSG_CREATE_CONNECTION: { |
| 670 | SomeArgs args = (SomeArgs) msg.obj; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 671 | Log.continueSession((Session) args.arg4, SESSION_HANDLER + SESSION_CREATE_CONN); |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 672 | try { |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 673 | final PhoneAccountHandle connectionManagerPhoneAccount = |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 674 | (PhoneAccountHandle) args.arg1; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 675 | final String id = (String) args.arg2; |
| 676 | final ConnectionRequest request = (ConnectionRequest) args.arg3; |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 677 | final boolean isIncoming = args.argi1 == 1; |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 678 | final boolean isUnknown = args.argi2 == 1; |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 679 | if (!mAreAccountsInitialized) { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 680 | Log.d(this, "Enqueueing pre-init request %s", id); |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 681 | mPreInitializationConnectionRequests.add( |
| 682 | new android.telecom.Logging.Runnable( |
| 683 | SESSION_HANDLER + SESSION_CREATE_CONN + ".pICR", |
| 684 | null /*lock*/) { |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 685 | @Override |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 686 | public void loggedRun() { |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 687 | createConnection( |
| 688 | connectionManagerPhoneAccount, |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 689 | id, |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 690 | request, |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 691 | isIncoming, |
| 692 | isUnknown); |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 693 | } |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 694 | }.prepare()); |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 695 | } else { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 696 | createConnection( |
| 697 | connectionManagerPhoneAccount, |
| 698 | id, |
| 699 | request, |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 700 | isIncoming, |
| 701 | isUnknown); |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 702 | } |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 703 | } finally { |
| 704 | args.recycle(); |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 705 | Log.endSession(); |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 706 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 707 | break; |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 708 | } |
Tyler Gunn | 041a1fe | 2017-05-12 10:04:49 -0700 | [diff] [blame] | 709 | case MSG_CREATE_CONNECTION_COMPLETE: { |
| 710 | SomeArgs args = (SomeArgs) msg.obj; |
| 711 | Log.continueSession((Session) args.arg2, |
| 712 | SESSION_HANDLER + SESSION_CREATE_CONN_COMPLETE); |
| 713 | try { |
| 714 | final String id = (String) args.arg1; |
| 715 | if (!mAreAccountsInitialized) { |
| 716 | Log.d(this, "Enqueueing pre-init request %s", id); |
| 717 | mPreInitializationConnectionRequests.add( |
| 718 | new android.telecom.Logging.Runnable( |
| 719 | SESSION_HANDLER + SESSION_CREATE_CONN_COMPLETE |
| 720 | + ".pICR", |
| 721 | null /*lock*/) { |
| 722 | @Override |
| 723 | public void loggedRun() { |
| 724 | notifyCreateConnectionComplete(id); |
| 725 | } |
| 726 | }.prepare()); |
| 727 | } else { |
| 728 | notifyCreateConnectionComplete(id); |
| 729 | } |
| 730 | } finally { |
| 731 | args.recycle(); |
| 732 | Log.endSession(); |
| 733 | } |
| 734 | break; |
| 735 | } |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 736 | case MSG_CREATE_CONNECTION_FAILED: { |
| 737 | SomeArgs args = (SomeArgs) msg.obj; |
| 738 | Log.continueSession((Session) args.arg3, SESSION_HANDLER + |
| 739 | SESSION_CREATE_CONN_FAILED); |
| 740 | try { |
| 741 | final String id = (String) args.arg1; |
| 742 | final ConnectionRequest request = (ConnectionRequest) args.arg2; |
| 743 | final boolean isIncoming = args.argi1 == 1; |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 744 | final PhoneAccountHandle connectionMgrPhoneAccount = |
| 745 | (PhoneAccountHandle) args.arg4; |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 746 | if (!mAreAccountsInitialized) { |
| 747 | Log.d(this, "Enqueueing pre-init request %s", id); |
| 748 | mPreInitializationConnectionRequests.add( |
| 749 | new android.telecom.Logging.Runnable( |
| 750 | SESSION_HANDLER + SESSION_CREATE_CONN_FAILED + ".pICR", |
| 751 | null /*lock*/) { |
| 752 | @Override |
| 753 | public void loggedRun() { |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 754 | createConnectionFailed(connectionMgrPhoneAccount, id, |
| 755 | request, isIncoming); |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 756 | } |
| 757 | }.prepare()); |
| 758 | } else { |
| 759 | Log.i(this, "createConnectionFailed %s", id); |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 760 | createConnectionFailed(connectionMgrPhoneAccount, id, request, |
| 761 | isIncoming); |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 762 | } |
| 763 | } finally { |
| 764 | args.recycle(); |
| 765 | Log.endSession(); |
| 766 | } |
| 767 | break; |
| 768 | } |
Sanket Padawe | 4cc8ed53 | 2017-12-04 16:22:20 -0800 | [diff] [blame] | 769 | case MSG_HANDOVER_FAILED: { |
| 770 | SomeArgs args = (SomeArgs) msg.obj; |
| 771 | Log.continueSession((Session) args.arg3, SESSION_HANDLER + |
| 772 | SESSION_HANDOVER_FAILED); |
| 773 | try { |
| 774 | final String id = (String) args.arg1; |
| 775 | final ConnectionRequest request = (ConnectionRequest) args.arg2; |
| 776 | final int reason = (int) args.arg4; |
| 777 | if (!mAreAccountsInitialized) { |
| 778 | Log.d(this, "Enqueueing pre-init request %s", id); |
| 779 | mPreInitializationConnectionRequests.add( |
| 780 | new android.telecom.Logging.Runnable( |
| 781 | SESSION_HANDLER |
| 782 | + SESSION_HANDOVER_FAILED + ".pICR", |
| 783 | null /*lock*/) { |
| 784 | @Override |
| 785 | public void loggedRun() { |
| 786 | handoverFailed(id, request, reason); |
| 787 | } |
| 788 | }.prepare()); |
| 789 | } else { |
| 790 | Log.i(this, "createConnectionFailed %s", id); |
| 791 | handoverFailed(id, request, reason); |
| 792 | } |
| 793 | } finally { |
| 794 | args.recycle(); |
| 795 | Log.endSession(); |
| 796 | } |
| 797 | break; |
| 798 | } |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 799 | case MSG_ABORT: { |
| 800 | SomeArgs args = (SomeArgs) msg.obj; |
| 801 | Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_ABORT); |
| 802 | try { |
| 803 | abort((String) args.arg1); |
| 804 | } finally { |
| 805 | args.recycle(); |
| 806 | Log.endSession(); |
| 807 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 808 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 809 | } |
| 810 | case MSG_ANSWER: { |
| 811 | SomeArgs args = (SomeArgs) msg.obj; |
| 812 | Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_ANSWER); |
| 813 | try { |
| 814 | answer((String) args.arg1); |
| 815 | } finally { |
| 816 | args.recycle(); |
| 817 | Log.endSession(); |
| 818 | } |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 819 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 820 | } |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 821 | case MSG_ANSWER_VIDEO: { |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 822 | SomeArgs args = (SomeArgs) msg.obj; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 823 | Log.continueSession((Session) args.arg2, |
| 824 | SESSION_HANDLER + SESSION_ANSWER_VIDEO); |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 825 | try { |
| 826 | String callId = (String) args.arg1; |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 827 | int videoState = args.argi1; |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 828 | answerVideo(callId, videoState); |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 829 | } finally { |
| 830 | args.recycle(); |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 831 | Log.endSession(); |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 832 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 833 | break; |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 834 | } |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 835 | case MSG_REJECT: { |
| 836 | SomeArgs args = (SomeArgs) msg.obj; |
| 837 | Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_REJECT); |
| 838 | try { |
| 839 | reject((String) args.arg1); |
| 840 | } finally { |
| 841 | args.recycle(); |
| 842 | Log.endSession(); |
| 843 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 844 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 845 | } |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 846 | case MSG_REJECT_WITH_MESSAGE: { |
| 847 | SomeArgs args = (SomeArgs) msg.obj; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 848 | Log.continueSession((Session) args.arg3, |
| 849 | SESSION_HANDLER + SESSION_REJECT_MESSAGE); |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 850 | try { |
| 851 | reject((String) args.arg1, (String) args.arg2); |
| 852 | } finally { |
| 853 | args.recycle(); |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 854 | Log.endSession(); |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 855 | } |
| 856 | break; |
| 857 | } |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 858 | case MSG_DISCONNECT: { |
| 859 | SomeArgs args = (SomeArgs) msg.obj; |
| 860 | Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_DISCONNECT); |
| 861 | try { |
| 862 | disconnect((String) args.arg1); |
| 863 | } finally { |
| 864 | args.recycle(); |
| 865 | Log.endSession(); |
| 866 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 867 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 868 | } |
| 869 | case MSG_SILENCE: { |
| 870 | SomeArgs args = (SomeArgs) msg.obj; |
| 871 | Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_SILENCE); |
| 872 | try { |
| 873 | silence((String) args.arg1); |
| 874 | } finally { |
| 875 | args.recycle(); |
| 876 | Log.endSession(); |
| 877 | } |
Bryce Lee | cac5077 | 2015-11-17 15:13:29 -0800 | [diff] [blame] | 878 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 879 | } |
| 880 | case MSG_HOLD: { |
| 881 | SomeArgs args = (SomeArgs) msg.obj; |
| 882 | Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_REJECT); |
| 883 | try { |
| 884 | hold((String) args.arg1); |
| 885 | } finally { |
| 886 | args.recycle(); |
| 887 | Log.endSession(); |
| 888 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 889 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 890 | } |
| 891 | case MSG_UNHOLD: { |
| 892 | SomeArgs args = (SomeArgs) msg.obj; |
| 893 | Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_UNHOLD); |
| 894 | try { |
| 895 | unhold((String) args.arg1); |
| 896 | } finally { |
| 897 | args.recycle(); |
| 898 | Log.endSession(); |
| 899 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 900 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 901 | } |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 902 | case MSG_ON_CALL_AUDIO_STATE_CHANGED: { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 903 | SomeArgs args = (SomeArgs) msg.obj; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 904 | Log.continueSession((Session) args.arg3, |
| 905 | SESSION_HANDLER + SESSION_CALL_AUDIO_SC); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 906 | try { |
| 907 | String callId = (String) args.arg1; |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 908 | CallAudioState audioState = (CallAudioState) args.arg2; |
| 909 | onCallAudioStateChanged(callId, new CallAudioState(audioState)); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 910 | } finally { |
| 911 | args.recycle(); |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 912 | Log.endSession(); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 913 | } |
| 914 | break; |
| 915 | } |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 916 | case MSG_PLAY_DTMF_TONE: { |
| 917 | SomeArgs args = (SomeArgs) msg.obj; |
| 918 | try { |
| 919 | Log.continueSession((Session) args.arg3, |
| 920 | SESSION_HANDLER + SESSION_PLAY_DTMF); |
| 921 | playDtmfTone((String) args.arg2, (char) args.arg1); |
| 922 | } finally { |
| 923 | args.recycle(); |
| 924 | Log.endSession(); |
| 925 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 926 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 927 | } |
| 928 | case MSG_STOP_DTMF_TONE: { |
| 929 | SomeArgs args = (SomeArgs) msg.obj; |
| 930 | try { |
| 931 | Log.continueSession((Session) args.arg2, |
| 932 | SESSION_HANDLER + SESSION_STOP_DTMF); |
| 933 | stopDtmfTone((String) args.arg1); |
| 934 | } finally { |
| 935 | args.recycle(); |
| 936 | Log.endSession(); |
| 937 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 938 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 939 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 940 | case MSG_CONFERENCE: { |
| 941 | SomeArgs args = (SomeArgs) msg.obj; |
| 942 | try { |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 943 | Log.continueSession((Session) args.arg3, |
| 944 | SESSION_HANDLER + SESSION_CONFERENCE); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 945 | String callId1 = (String) args.arg1; |
| 946 | String callId2 = (String) args.arg2; |
| 947 | conference(callId1, callId2); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 948 | } finally { |
| 949 | args.recycle(); |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 950 | Log.endSession(); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 951 | } |
| 952 | break; |
| 953 | } |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 954 | case MSG_SPLIT_FROM_CONFERENCE: { |
| 955 | SomeArgs args = (SomeArgs) msg.obj; |
| 956 | try { |
| 957 | Log.continueSession((Session) args.arg2, |
| 958 | SESSION_HANDLER + SESSION_SPLIT_CONFERENCE); |
| 959 | splitFromConference((String) args.arg1); |
| 960 | } finally { |
| 961 | args.recycle(); |
| 962 | Log.endSession(); |
| 963 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 964 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 965 | } |
| 966 | case MSG_MERGE_CONFERENCE: { |
| 967 | SomeArgs args = (SomeArgs) msg.obj; |
| 968 | try { |
| 969 | Log.continueSession((Session) args.arg2, |
| 970 | SESSION_HANDLER + SESSION_MERGE_CONFERENCE); |
| 971 | mergeConference((String) args.arg1); |
| 972 | } finally { |
| 973 | args.recycle(); |
| 974 | Log.endSession(); |
| 975 | } |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 976 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 977 | } |
| 978 | case MSG_SWAP_CONFERENCE: { |
| 979 | SomeArgs args = (SomeArgs) msg.obj; |
| 980 | try { |
| 981 | Log.continueSession((Session) args.arg2, |
| 982 | SESSION_HANDLER + SESSION_SWAP_CONFERENCE); |
| 983 | swapConference((String) args.arg1); |
| 984 | } finally { |
| 985 | args.recycle(); |
| 986 | Log.endSession(); |
| 987 | } |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 988 | break; |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 989 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 990 | case MSG_ON_POST_DIAL_CONTINUE: { |
| 991 | SomeArgs args = (SomeArgs) msg.obj; |
| 992 | try { |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 993 | Log.continueSession((Session) args.arg2, |
| 994 | SESSION_HANDLER + SESSION_POST_DIAL_CONT); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 995 | String callId = (String) args.arg1; |
| 996 | boolean proceed = (args.argi1 == 1); |
| 997 | onPostDialContinue(callId, proceed); |
| 998 | } finally { |
| 999 | args.recycle(); |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 1000 | Log.endSession(); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1001 | } |
| 1002 | break; |
| 1003 | } |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1004 | case MSG_PULL_EXTERNAL_CALL: { |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 1005 | SomeArgs args = (SomeArgs) msg.obj; |
| 1006 | try { |
| 1007 | Log.continueSession((Session) args.arg2, |
| 1008 | SESSION_HANDLER + SESSION_PULL_EXTERNAL_CALL); |
| 1009 | pullExternalCall((String) args.arg1); |
| 1010 | } finally { |
| 1011 | args.recycle(); |
| 1012 | Log.endSession(); |
| 1013 | } |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1014 | break; |
| 1015 | } |
| 1016 | case MSG_SEND_CALL_EVENT: { |
| 1017 | SomeArgs args = (SomeArgs) msg.obj; |
| 1018 | try { |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 1019 | Log.continueSession((Session) args.arg4, |
| 1020 | SESSION_HANDLER + SESSION_SEND_CALL_EVENT); |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1021 | String callId = (String) args.arg1; |
| 1022 | String event = (String) args.arg2; |
| 1023 | Bundle extras = (Bundle) args.arg3; |
| 1024 | sendCallEvent(callId, event, extras); |
| 1025 | } finally { |
| 1026 | args.recycle(); |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 1027 | Log.endSession(); |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1028 | } |
| 1029 | break; |
| 1030 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1031 | case MSG_ON_EXTRAS_CHANGED: { |
| 1032 | SomeArgs args = (SomeArgs) msg.obj; |
| 1033 | try { |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 1034 | Log.continueSession((Session) args.arg3, |
| 1035 | SESSION_HANDLER + SESSION_EXTRAS_CHANGED); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1036 | String callId = (String) args.arg1; |
| 1037 | Bundle extras = (Bundle) args.arg2; |
| 1038 | handleExtrasChanged(callId, extras); |
| 1039 | } finally { |
| 1040 | args.recycle(); |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 1041 | Log.endSession(); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1042 | } |
| 1043 | break; |
| 1044 | } |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1045 | case MSG_ON_START_RTT: { |
| 1046 | SomeArgs args = (SomeArgs) msg.obj; |
| 1047 | try { |
| 1048 | Log.continueSession((Session) args.arg3, |
| 1049 | SESSION_HANDLER + SESSION_START_RTT); |
| 1050 | String callId = (String) args.arg1; |
| 1051 | Connection.RttTextStream rttTextStream = |
| 1052 | (Connection.RttTextStream) args.arg2; |
| 1053 | startRtt(callId, rttTextStream); |
| 1054 | } finally { |
| 1055 | args.recycle(); |
| 1056 | Log.endSession(); |
| 1057 | } |
| 1058 | break; |
| 1059 | } |
| 1060 | case MSG_ON_STOP_RTT: { |
| 1061 | SomeArgs args = (SomeArgs) msg.obj; |
| 1062 | try { |
| 1063 | Log.continueSession((Session) args.arg2, |
| 1064 | SESSION_HANDLER + SESSION_STOP_RTT); |
| 1065 | String callId = (String) args.arg1; |
| 1066 | stopRtt(callId); |
| 1067 | } finally { |
| 1068 | args.recycle(); |
| 1069 | Log.endSession(); |
| 1070 | } |
| 1071 | break; |
| 1072 | } |
| 1073 | case MSG_RTT_UPGRADE_RESPONSE: { |
| 1074 | SomeArgs args = (SomeArgs) msg.obj; |
| 1075 | try { |
| 1076 | Log.continueSession((Session) args.arg3, |
| 1077 | SESSION_HANDLER + SESSION_RTT_UPGRADE_RESPONSE); |
| 1078 | String callId = (String) args.arg1; |
| 1079 | Connection.RttTextStream rttTextStream = |
| 1080 | (Connection.RttTextStream) args.arg2; |
| 1081 | handleRttUpgradeResponse(callId, rttTextStream); |
| 1082 | } finally { |
| 1083 | args.recycle(); |
| 1084 | Log.endSession(); |
| 1085 | } |
| 1086 | break; |
| 1087 | } |
Pengquan Meng | 731c1a3 | 2017-11-21 18:01:13 -0800 | [diff] [blame] | 1088 | case MSG_CONNECTION_SERVICE_FOCUS_GAINED: |
| 1089 | onConnectionServiceFocusGained(); |
| 1090 | break; |
| 1091 | case MSG_CONNECTION_SERVICE_FOCUS_LOST: |
| 1092 | onConnectionServiceFocusLost(); |
| 1093 | break; |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1094 | default: |
| 1095 | break; |
| 1096 | } |
| 1097 | } |
| 1098 | }; |
| 1099 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1100 | private final Conference.Listener mConferenceListener = new Conference.Listener() { |
| 1101 | @Override |
| 1102 | public void onStateChanged(Conference conference, int oldState, int newState) { |
| 1103 | String id = mIdByConference.get(conference); |
| 1104 | switch (newState) { |
| 1105 | case Connection.STATE_ACTIVE: |
| 1106 | mAdapter.setActive(id); |
| 1107 | break; |
| 1108 | case Connection.STATE_HOLDING: |
| 1109 | mAdapter.setOnHold(id); |
| 1110 | break; |
| 1111 | case Connection.STATE_DISCONNECTED: |
| 1112 | // handled by onDisconnected |
| 1113 | break; |
| 1114 | } |
| 1115 | } |
| 1116 | |
| 1117 | @Override |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1118 | public void onDisconnected(Conference conference, DisconnectCause disconnectCause) { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1119 | String id = mIdByConference.get(conference); |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1120 | mAdapter.setDisconnected(id, disconnectCause); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1121 | } |
| 1122 | |
| 1123 | @Override |
| 1124 | public void onConnectionAdded(Conference conference, Connection connection) { |
| 1125 | } |
| 1126 | |
| 1127 | @Override |
| 1128 | public void onConnectionRemoved(Conference conference, Connection connection) { |
| 1129 | } |
| 1130 | |
| 1131 | @Override |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 1132 | public void onConferenceableConnectionsChanged( |
| 1133 | Conference conference, List<Connection> conferenceableConnections) { |
| 1134 | mAdapter.setConferenceableConnections( |
| 1135 | mIdByConference.get(conference), |
| 1136 | createConnectionIdList(conferenceableConnections)); |
| 1137 | } |
| 1138 | |
| 1139 | @Override |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1140 | public void onDestroyed(Conference conference) { |
| 1141 | removeConference(conference); |
| 1142 | } |
| 1143 | |
| 1144 | @Override |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1145 | public void onConnectionCapabilitiesChanged( |
| 1146 | Conference conference, |
| 1147 | int connectionCapabilities) { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1148 | String id = mIdByConference.get(conference); |
| 1149 | Log.d(this, "call capabilities: conference: %s", |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1150 | Connection.capabilitiesToString(connectionCapabilities)); |
| 1151 | mAdapter.setConnectionCapabilities(id, connectionCapabilities); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1152 | } |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1153 | |
| 1154 | @Override |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1155 | public void onConnectionPropertiesChanged( |
| 1156 | Conference conference, |
| 1157 | int connectionProperties) { |
| 1158 | String id = mIdByConference.get(conference); |
| 1159 | Log.d(this, "call capabilities: conference: %s", |
| 1160 | Connection.propertiesToString(connectionProperties)); |
| 1161 | mAdapter.setConnectionProperties(id, connectionProperties); |
| 1162 | } |
| 1163 | |
| 1164 | @Override |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1165 | public void onVideoStateChanged(Conference c, int videoState) { |
| 1166 | String id = mIdByConference.get(c); |
| 1167 | Log.d(this, "onVideoStateChanged set video state %d", videoState); |
| 1168 | mAdapter.setVideoState(id, videoState); |
| 1169 | } |
| 1170 | |
| 1171 | @Override |
| 1172 | public void onVideoProviderChanged(Conference c, Connection.VideoProvider videoProvider) { |
| 1173 | String id = mIdByConference.get(c); |
| 1174 | Log.d(this, "onVideoProviderChanged: Connection: %s, VideoProvider: %s", c, |
| 1175 | videoProvider); |
| 1176 | mAdapter.setVideoProvider(id, videoProvider); |
| 1177 | } |
Andrew Lee | 0f51da3 | 2015-04-16 13:11:55 -0700 | [diff] [blame] | 1178 | |
| 1179 | @Override |
Andrew Lee | edc625f | 2015-04-14 13:38:12 -0700 | [diff] [blame] | 1180 | public void onStatusHintsChanged(Conference conference, StatusHints statusHints) { |
| 1181 | String id = mIdByConference.get(conference); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1182 | if (id != null) { |
| 1183 | mAdapter.setStatusHints(id, statusHints); |
| 1184 | } |
Andrew Lee | edc625f | 2015-04-14 13:38:12 -0700 | [diff] [blame] | 1185 | } |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1186 | |
| 1187 | @Override |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1188 | public void onExtrasChanged(Conference c, Bundle extras) { |
| 1189 | String id = mIdByConference.get(c); |
| 1190 | if (id != null) { |
| 1191 | mAdapter.putExtras(id, extras); |
| 1192 | } |
| 1193 | } |
| 1194 | |
| 1195 | @Override |
| 1196 | public void onExtrasRemoved(Conference c, List<String> keys) { |
| 1197 | String id = mIdByConference.get(c); |
| 1198 | if (id != null) { |
| 1199 | mAdapter.removeExtras(id, keys); |
| 1200 | } |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1201 | } |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1202 | }; |
| 1203 | |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1204 | private final Connection.Listener mConnectionListener = new Connection.Listener() { |
| 1205 | @Override |
| 1206 | public void onStateChanged(Connection c, int state) { |
| 1207 | String id = mIdByConnection.get(c); |
Ihab Awad | 42b30e1 | 2014-05-22 09:49:34 -0700 | [diff] [blame] | 1208 | Log.d(this, "Adapter set state %s %s", id, Connection.stateToString(state)); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1209 | switch (state) { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1210 | case Connection.STATE_ACTIVE: |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1211 | mAdapter.setActive(id); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1212 | break; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1213 | case Connection.STATE_DIALING: |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1214 | mAdapter.setDialing(id); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1215 | break; |
Tyler Gunn | c96b5e0 | 2016-07-07 22:53:57 -0700 | [diff] [blame] | 1216 | case Connection.STATE_PULLING_CALL: |
| 1217 | mAdapter.setPulling(id); |
| 1218 | break; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1219 | case Connection.STATE_DISCONNECTED: |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1220 | // Handled in onDisconnected() |
| 1221 | break; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1222 | case Connection.STATE_HOLDING: |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1223 | mAdapter.setOnHold(id); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1224 | break; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1225 | case Connection.STATE_NEW: |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1226 | // Nothing to tell Telecom |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1227 | break; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1228 | case Connection.STATE_RINGING: |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1229 | mAdapter.setRinging(id); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1230 | break; |
| 1231 | } |
| 1232 | } |
| 1233 | |
| 1234 | @Override |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1235 | public void onDisconnected(Connection c, DisconnectCause disconnectCause) { |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1236 | String id = mIdByConnection.get(c); |
Andrew Lee | 2678639 | 2014-09-16 18:14:59 -0700 | [diff] [blame] | 1237 | Log.d(this, "Adapter set disconnected %s", disconnectCause); |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1238 | mAdapter.setDisconnected(id, disconnectCause); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1239 | } |
| 1240 | |
| 1241 | @Override |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1242 | public void onVideoStateChanged(Connection c, int videoState) { |
| 1243 | String id = mIdByConnection.get(c); |
| 1244 | Log.d(this, "Adapter set video state %d", videoState); |
| 1245 | mAdapter.setVideoState(id, videoState); |
| 1246 | } |
| 1247 | |
| 1248 | @Override |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1249 | public void onAddressChanged(Connection c, Uri address, int presentation) { |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1250 | String id = mIdByConnection.get(c); |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1251 | mAdapter.setAddress(id, address, presentation); |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1252 | } |
| 1253 | |
| 1254 | @Override |
| 1255 | public void onCallerDisplayNameChanged( |
| 1256 | Connection c, String callerDisplayName, int presentation) { |
| 1257 | String id = mIdByConnection.get(c); |
| 1258 | mAdapter.setCallerDisplayName(id, callerDisplayName, presentation); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1259 | } |
| 1260 | |
| 1261 | @Override |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1262 | public void onDestroyed(Connection c) { |
| 1263 | removeConnection(c); |
| 1264 | } |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 1265 | |
| 1266 | @Override |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1267 | public void onPostDialWait(Connection c, String remaining) { |
Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 1268 | String id = mIdByConnection.get(c); |
| 1269 | Log.d(this, "Adapter onPostDialWait %s, %s", c, remaining); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1270 | mAdapter.onPostDialWait(id, remaining); |
Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 1271 | } |
| 1272 | |
| 1273 | @Override |
Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 1274 | public void onPostDialChar(Connection c, char nextChar) { |
| 1275 | String id = mIdByConnection.get(c); |
| 1276 | Log.d(this, "Adapter onPostDialChar %s, %s", c, nextChar); |
| 1277 | mAdapter.onPostDialChar(id, nextChar); |
| 1278 | } |
| 1279 | |
| 1280 | @Override |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1281 | public void onRingbackRequested(Connection c, boolean ringback) { |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 1282 | String id = mIdByConnection.get(c); |
| 1283 | Log.d(this, "Adapter onRingback %b", ringback); |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1284 | mAdapter.setRingbackRequested(id, ringback); |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 1285 | } |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1286 | |
| 1287 | @Override |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1288 | public void onConnectionCapabilitiesChanged(Connection c, int capabilities) { |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1289 | String id = mIdByConnection.get(c); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1290 | Log.d(this, "capabilities: parcelableconnection: %s", |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1291 | Connection.capabilitiesToString(capabilities)); |
| 1292 | mAdapter.setConnectionCapabilities(id, capabilities); |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1293 | } |
| 1294 | |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1295 | @Override |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1296 | public void onConnectionPropertiesChanged(Connection c, int properties) { |
| 1297 | String id = mIdByConnection.get(c); |
| 1298 | Log.d(this, "properties: parcelableconnection: %s", |
| 1299 | Connection.propertiesToString(properties)); |
| 1300 | mAdapter.setConnectionProperties(id, properties); |
| 1301 | } |
| 1302 | |
| 1303 | @Override |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1304 | public void onVideoProviderChanged(Connection c, Connection.VideoProvider videoProvider) { |
Andrew Lee | 5ffbe8b | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 1305 | String id = mIdByConnection.get(c); |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1306 | Log.d(this, "onVideoProviderChanged: Connection: %s, VideoProvider: %s", c, |
| 1307 | videoProvider); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1308 | mAdapter.setVideoProvider(id, videoProvider); |
Andrew Lee | 5ffbe8b | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 1309 | } |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 1310 | |
| 1311 | @Override |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 1312 | public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) { |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 1313 | String id = mIdByConnection.get(c); |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1314 | mAdapter.setIsVoipAudioMode(id, isVoip); |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 1315 | } |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1316 | |
| 1317 | @Override |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 1318 | public void onStatusHintsChanged(Connection c, StatusHints statusHints) { |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1319 | String id = mIdByConnection.get(c); |
| 1320 | mAdapter.setStatusHints(id, statusHints); |
| 1321 | } |
Sailesh Nepal | 2ab88cc | 2014-07-18 14:49:18 -0700 | [diff] [blame] | 1322 | |
| 1323 | @Override |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1324 | public void onConferenceablesChanged( |
Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 1325 | Connection connection, List<Conferenceable> conferenceables) { |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 1326 | mAdapter.setConferenceableConnections( |
| 1327 | mIdByConnection.get(connection), |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1328 | createIdList(conferenceables)); |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1329 | } |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1330 | |
| 1331 | @Override |
| 1332 | public void onConferenceChanged(Connection connection, Conference conference) { |
| 1333 | String id = mIdByConnection.get(connection); |
| 1334 | if (id != null) { |
| 1335 | String conferenceId = null; |
| 1336 | if (conference != null) { |
| 1337 | conferenceId = mIdByConference.get(conference); |
| 1338 | } |
| 1339 | mAdapter.setIsConferenced(id, conferenceId); |
| 1340 | } |
| 1341 | } |
Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 1342 | |
| 1343 | @Override |
| 1344 | public void onConferenceMergeFailed(Connection connection) { |
| 1345 | String id = mIdByConnection.get(connection); |
| 1346 | if (id != null) { |
| 1347 | mAdapter.onConferenceMergeFailed(id); |
| 1348 | } |
| 1349 | } |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1350 | |
| 1351 | @Override |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1352 | public void onExtrasChanged(Connection c, Bundle extras) { |
| 1353 | String id = mIdByConnection.get(c); |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1354 | if (id != null) { |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1355 | mAdapter.putExtras(id, extras); |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1356 | } |
| 1357 | } |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 1358 | |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1359 | @Override |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1360 | public void onExtrasRemoved(Connection c, List<String> keys) { |
| 1361 | String id = mIdByConnection.get(c); |
| 1362 | if (id != null) { |
| 1363 | mAdapter.removeExtras(id, keys); |
| 1364 | } |
| 1365 | } |
| 1366 | |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 1367 | @Override |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1368 | public void onConnectionEvent(Connection connection, String event, Bundle extras) { |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 1369 | String id = mIdByConnection.get(connection); |
| 1370 | if (id != null) { |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1371 | mAdapter.onConnectionEvent(id, event, extras); |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 1372 | } |
| 1373 | } |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1374 | |
| 1375 | @Override |
Hall Liu | a98f58b | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 1376 | public void onAudioRouteChanged(Connection c, int audioRoute, String bluetoothAddress) { |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1377 | String id = mIdByConnection.get(c); |
| 1378 | if (id != null) { |
Hall Liu | a98f58b | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 1379 | mAdapter.setAudioRoute(id, audioRoute, bluetoothAddress); |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1380 | } |
| 1381 | } |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1382 | |
| 1383 | @Override |
| 1384 | public void onRttInitiationSuccess(Connection c) { |
| 1385 | String id = mIdByConnection.get(c); |
| 1386 | if (id != null) { |
| 1387 | mAdapter.onRttInitiationSuccess(id); |
| 1388 | } |
| 1389 | } |
| 1390 | |
| 1391 | @Override |
| 1392 | public void onRttInitiationFailure(Connection c, int reason) { |
| 1393 | String id = mIdByConnection.get(c); |
| 1394 | if (id != null) { |
| 1395 | mAdapter.onRttInitiationFailure(id, reason); |
| 1396 | } |
| 1397 | } |
| 1398 | |
| 1399 | @Override |
| 1400 | public void onRttSessionRemotelyTerminated(Connection c) { |
| 1401 | String id = mIdByConnection.get(c); |
| 1402 | if (id != null) { |
| 1403 | mAdapter.onRttSessionRemotelyTerminated(id); |
| 1404 | } |
| 1405 | } |
| 1406 | |
| 1407 | @Override |
| 1408 | public void onRemoteRttRequest(Connection c) { |
| 1409 | String id = mIdByConnection.get(c); |
| 1410 | if (id != null) { |
| 1411 | mAdapter.onRemoteRttRequest(id); |
| 1412 | } |
| 1413 | } |
Srikanth Chintala | fcb1501 | 2017-05-04 20:58:34 +0530 | [diff] [blame] | 1414 | |
| 1415 | @Override |
| 1416 | public void onPhoneAccountChanged(Connection c, PhoneAccountHandle pHandle) { |
| 1417 | String id = mIdByConnection.get(c); |
| 1418 | if (id != null) { |
| 1419 | mAdapter.onPhoneAccountChanged(id, pHandle); |
| 1420 | } |
| 1421 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1422 | }; |
| 1423 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1424 | /** {@inheritDoc} */ |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1425 | @Override |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1426 | public final IBinder onBind(Intent intent) { |
| 1427 | return mBinder; |
| 1428 | } |
| 1429 | |
Santos Cordon | 29f2f2e | 2014-09-11 19:50:24 -0700 | [diff] [blame] | 1430 | /** {@inheritDoc} */ |
| 1431 | @Override |
| 1432 | public boolean onUnbind(Intent intent) { |
| 1433 | endAllConnections(); |
| 1434 | return super.onUnbind(intent); |
| 1435 | } |
| 1436 | |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 1437 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1438 | * This can be used by telecom to either create a new outgoing call or attach to an existing |
| 1439 | * incoming call. In either case, telecom will cycle through a set of services and call |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 1440 | * createConnection util a connection service cancels the process or completes it successfully. |
| 1441 | */ |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1442 | private void createConnection( |
| 1443 | final PhoneAccountHandle callManagerAccount, |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1444 | final String callId, |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1445 | final ConnectionRequest request, |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 1446 | boolean isIncoming, |
| 1447 | boolean isUnknown) { |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1448 | Log.d(this, "createConnection, callManagerAccount: %s, callId: %s, request: %s, " + |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 1449 | "isIncoming: %b, isUnknown: %b", callManagerAccount, callId, request, |
| 1450 | isIncoming, |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 1451 | isUnknown); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1452 | |
Sanket Padawe | e29a266 | 2017-12-01 13:59:27 -0800 | [diff] [blame] | 1453 | Connection connection = null; |
Sanket Padawe | 4cc8ed53 | 2017-12-04 16:22:20 -0800 | [diff] [blame] | 1454 | if (getApplicationContext().getApplicationInfo().targetSdkVersion > |
| 1455 | Build.VERSION_CODES.O_MR1 && request.getExtras() != null && |
| 1456 | request.getExtras().getBoolean(TelecomManager.EXTRA_IS_HANDOVER,false)) { |
Sanket Padawe | e29a266 | 2017-12-01 13:59:27 -0800 | [diff] [blame] | 1457 | if (!isIncoming) { |
| 1458 | connection = onCreateOutgoingHandoverConnection(callManagerAccount, request); |
| 1459 | } else { |
Sanket Padawe | 4cc8ed53 | 2017-12-04 16:22:20 -0800 | [diff] [blame] | 1460 | connection = onCreateIncomingHandoverConnection(callManagerAccount, request); |
Sanket Padawe | e29a266 | 2017-12-01 13:59:27 -0800 | [diff] [blame] | 1461 | } |
| 1462 | } else { |
| 1463 | connection = isUnknown ? onCreateUnknownConnection(callManagerAccount, request) |
| 1464 | : isIncoming ? onCreateIncomingConnection(callManagerAccount, request) |
| 1465 | : onCreateOutgoingConnection(callManagerAccount, request); |
| 1466 | } |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1467 | Log.d(this, "createConnection, connection: %s", connection); |
| 1468 | if (connection == null) { |
Tyler Gunn | fba1a8e | 2017-12-19 15:23:59 -0800 | [diff] [blame] | 1469 | Log.i(this, "createConnection, implementation returned null connection."); |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1470 | connection = Connection.createFailedConnection( |
Tyler Gunn | fba1a8e | 2017-12-19 15:23:59 -0800 | [diff] [blame] | 1471 | new DisconnectCause(DisconnectCause.ERROR, "IMPL_RETURNED_NULL_CONNECTION")); |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 1472 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1473 | |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 1474 | connection.setTelecomCallId(callId); |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1475 | if (connection.getState() != Connection.STATE_DISCONNECTED) { |
Pengquan Meng | 70c988533 | 2017-10-02 18:09:03 -0700 | [diff] [blame] | 1476 | addConnection(request.getAccountHandle(), callId, connection); |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1477 | } |
| 1478 | |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1479 | Uri address = connection.getAddress(); |
| 1480 | String number = address == null ? "null" : address.getSchemeSpecificPart(); |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1481 | Log.v(this, "createConnection, number: %s, state: %s, capabilities: %s, properties: %s", |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1482 | Connection.toLogSafePhoneNumber(number), |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1483 | Connection.stateToString(connection.getState()), |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1484 | Connection.capabilitiesToString(connection.getConnectionCapabilities()), |
| 1485 | Connection.propertiesToString(connection.getConnectionProperties())); |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1486 | |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1487 | Log.d(this, "createConnection, calling handleCreateConnectionSuccessful %s", callId); |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1488 | mAdapter.handleCreateConnectionComplete( |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1489 | callId, |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1490 | request, |
| 1491 | new ParcelableConnection( |
| 1492 | request.getAccountHandle(), |
| 1493 | connection.getState(), |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1494 | connection.getConnectionCapabilities(), |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1495 | connection.getConnectionProperties(), |
Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 1496 | connection.getSupportedAudioRoutes(), |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1497 | connection.getAddress(), |
| 1498 | connection.getAddressPresentation(), |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1499 | connection.getCallerDisplayName(), |
| 1500 | connection.getCallerDisplayNamePresentation(), |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1501 | connection.getVideoProvider() == null ? |
| 1502 | null : connection.getVideoProvider().getInterface(), |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 1503 | connection.getVideoState(), |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1504 | connection.isRingbackRequested(), |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 1505 | connection.getAudioModeIsVoip(), |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 1506 | connection.getConnectTimeMillis(), |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 1507 | connection.getConnectElapsedTimeMillis(), |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1508 | connection.getStatusHints(), |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1509 | connection.getDisconnectCause(), |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1510 | createIdList(connection.getConferenceables()), |
| 1511 | connection.getExtras())); |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1512 | |
| 1513 | if (isIncoming && request.shouldShowIncomingCallUi() && |
| 1514 | (connection.getConnectionProperties() & Connection.PROPERTY_SELF_MANAGED) == |
| 1515 | Connection.PROPERTY_SELF_MANAGED) { |
| 1516 | // Tell ConnectionService to show its incoming call UX. |
| 1517 | connection.onShowIncomingCallUi(); |
| 1518 | } |
Shriram Ganesh | 6bf35ac | 2014-12-11 17:53:38 -0800 | [diff] [blame] | 1519 | if (isUnknown) { |
| 1520 | triggerConferenceRecalculate(); |
| 1521 | } |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1522 | } |
| 1523 | |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 1524 | private void createConnectionFailed(final PhoneAccountHandle callManagerAccount, |
| 1525 | final String callId, final ConnectionRequest request, |
| 1526 | boolean isIncoming) { |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 1527 | |
| 1528 | Log.i(this, "createConnectionFailed %s", callId); |
| 1529 | if (isIncoming) { |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 1530 | onCreateIncomingConnectionFailed(callManagerAccount, request); |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 1531 | } else { |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 1532 | onCreateOutgoingConnectionFailed(callManagerAccount, request); |
Tyler Gunn | 44e0191 | 2017-01-31 10:49:05 -0800 | [diff] [blame] | 1533 | } |
| 1534 | } |
| 1535 | |
Sanket Padawe | 4cc8ed53 | 2017-12-04 16:22:20 -0800 | [diff] [blame] | 1536 | private void handoverFailed(final String callId, final ConnectionRequest request, |
| 1537 | int reason) { |
| 1538 | |
| 1539 | Log.i(this, "handoverFailed %s", callId); |
| 1540 | onHandoverFailed(request, reason); |
| 1541 | } |
| 1542 | |
Tyler Gunn | 041a1fe | 2017-05-12 10:04:49 -0700 | [diff] [blame] | 1543 | /** |
| 1544 | * Called by Telecom when the creation of a new Connection has completed and it is now added |
| 1545 | * to Telecom. |
| 1546 | * @param callId The ID of the connection. |
| 1547 | */ |
| 1548 | private void notifyCreateConnectionComplete(final String callId) { |
| 1549 | Log.i(this, "notifyCreateConnectionComplete %s", callId); |
Tyler Gunn | 0a88f2e | 2017-06-16 20:20:34 -0700 | [diff] [blame] | 1550 | if (callId == null) { |
| 1551 | // This could happen if the connection fails quickly and is removed from the |
| 1552 | // ConnectionService before Telecom sends the create connection complete callback. |
| 1553 | Log.w(this, "notifyCreateConnectionComplete: callId is null."); |
| 1554 | return; |
| 1555 | } |
Tyler Gunn | 041a1fe | 2017-05-12 10:04:49 -0700 | [diff] [blame] | 1556 | onCreateConnectionComplete(findConnectionForAction(callId, |
| 1557 | "notifyCreateConnectionComplete")); |
| 1558 | } |
| 1559 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1560 | private void abort(String callId) { |
Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 1561 | Log.d(this, "abort %s", callId); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1562 | findConnectionForAction(callId, "abort").onAbort(); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1563 | } |
| 1564 | |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 1565 | private void answerVideo(String callId, int videoState) { |
| 1566 | Log.d(this, "answerVideo %s", callId); |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 1567 | findConnectionForAction(callId, "answer").onAnswer(videoState); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1568 | } |
| 1569 | |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 1570 | private void answer(String callId) { |
| 1571 | Log.d(this, "answer %s", callId); |
| 1572 | findConnectionForAction(callId, "answer").onAnswer(); |
| 1573 | } |
| 1574 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1575 | private void reject(String callId) { |
Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 1576 | Log.d(this, "reject %s", callId); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1577 | findConnectionForAction(callId, "reject").onReject(); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1578 | } |
| 1579 | |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 1580 | private void reject(String callId, String rejectWithMessage) { |
| 1581 | Log.d(this, "reject %s with message", callId); |
| 1582 | findConnectionForAction(callId, "reject").onReject(rejectWithMessage); |
| 1583 | } |
| 1584 | |
Bryce Lee | cac5077 | 2015-11-17 15:13:29 -0800 | [diff] [blame] | 1585 | private void silence(String callId) { |
| 1586 | Log.d(this, "silence %s", callId); |
| 1587 | findConnectionForAction(callId, "silence").onSilence(); |
| 1588 | } |
| 1589 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1590 | private void disconnect(String callId) { |
Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 1591 | Log.d(this, "disconnect %s", callId); |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 1592 | if (mConnectionById.containsKey(callId)) { |
| 1593 | findConnectionForAction(callId, "disconnect").onDisconnect(); |
| 1594 | } else { |
| 1595 | findConferenceForAction(callId, "disconnect").onDisconnect(); |
| 1596 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1597 | } |
| 1598 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1599 | private void hold(String callId) { |
Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 1600 | Log.d(this, "hold %s", callId); |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 1601 | if (mConnectionById.containsKey(callId)) { |
| 1602 | findConnectionForAction(callId, "hold").onHold(); |
| 1603 | } else { |
| 1604 | findConferenceForAction(callId, "hold").onHold(); |
| 1605 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1606 | } |
| 1607 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1608 | private void unhold(String callId) { |
Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 1609 | Log.d(this, "unhold %s", callId); |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 1610 | if (mConnectionById.containsKey(callId)) { |
| 1611 | findConnectionForAction(callId, "unhold").onUnhold(); |
| 1612 | } else { |
| 1613 | findConferenceForAction(callId, "unhold").onUnhold(); |
| 1614 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1615 | } |
| 1616 | |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 1617 | private void onCallAudioStateChanged(String callId, CallAudioState callAudioState) { |
| 1618 | Log.d(this, "onAudioStateChanged %s %s", callId, callAudioState); |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 1619 | if (mConnectionById.containsKey(callId)) { |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 1620 | findConnectionForAction(callId, "onCallAudioStateChanged").setCallAudioState( |
| 1621 | callAudioState); |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 1622 | } else { |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 1623 | findConferenceForAction(callId, "onCallAudioStateChanged").setCallAudioState( |
| 1624 | callAudioState); |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 1625 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1626 | } |
| 1627 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1628 | private void playDtmfTone(String callId, char digit) { |
| 1629 | Log.d(this, "playDtmfTone %s %c", callId, digit); |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 1630 | if (mConnectionById.containsKey(callId)) { |
| 1631 | findConnectionForAction(callId, "playDtmfTone").onPlayDtmfTone(digit); |
| 1632 | } else { |
| 1633 | findConferenceForAction(callId, "playDtmfTone").onPlayDtmfTone(digit); |
| 1634 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1635 | } |
| 1636 | |
| 1637 | private void stopDtmfTone(String callId) { |
| 1638 | Log.d(this, "stopDtmfTone %s", callId); |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 1639 | if (mConnectionById.containsKey(callId)) { |
| 1640 | findConnectionForAction(callId, "stopDtmfTone").onStopDtmfTone(); |
| 1641 | } else { |
| 1642 | findConferenceForAction(callId, "stopDtmfTone").onStopDtmfTone(); |
| 1643 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1644 | } |
| 1645 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1646 | private void conference(String callId1, String callId2) { |
| 1647 | Log.d(this, "conference %s, %s", callId1, callId2); |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 1648 | |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1649 | // Attempt to get second connection or conference. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1650 | Connection connection2 = findConnectionForAction(callId2, "conference"); |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1651 | Conference conference2 = getNullConference(); |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1652 | if (connection2 == getNullConnection()) { |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1653 | conference2 = findConferenceForAction(callId2, "conference"); |
| 1654 | if (conference2 == getNullConference()) { |
| 1655 | Log.w(this, "Connection2 or Conference2 missing in conference request %s.", |
| 1656 | callId2); |
| 1657 | return; |
| 1658 | } |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1659 | } |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1660 | |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1661 | // Attempt to get first connection or conference and perform merge. |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 1662 | Connection connection1 = findConnectionForAction(callId1, "conference"); |
| 1663 | if (connection1 == getNullConnection()) { |
| 1664 | Conference conference1 = findConferenceForAction(callId1, "addConnection"); |
| 1665 | if (conference1 == getNullConference()) { |
| 1666 | Log.w(this, |
| 1667 | "Connection1 or Conference1 missing in conference request %s.", |
| 1668 | callId1); |
| 1669 | } else { |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1670 | // Call 1 is a conference. |
| 1671 | if (connection2 != getNullConnection()) { |
| 1672 | // Call 2 is a connection so merge via call 1 (conference). |
| 1673 | conference1.onMerge(connection2); |
| 1674 | } else { |
| 1675 | // Call 2 is ALSO a conference; this should never happen. |
| 1676 | Log.wtf(this, "There can only be one conference and an attempt was made to " + |
| 1677 | "merge two conferences."); |
| 1678 | return; |
| 1679 | } |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 1680 | } |
| 1681 | } else { |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1682 | // Call 1 is a connection. |
| 1683 | if (conference2 != getNullConference()) { |
| 1684 | // Call 2 is a conference, so merge via call 2. |
| 1685 | conference2.onMerge(connection1); |
| 1686 | } else { |
| 1687 | // Call 2 is a connection, so merge together. |
| 1688 | onConference(connection1, connection2); |
| 1689 | } |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 1690 | } |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 1691 | } |
| 1692 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1693 | private void splitFromConference(String callId) { |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1694 | Log.d(this, "splitFromConference(%s)", callId); |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 1695 | |
| 1696 | Connection connection = findConnectionForAction(callId, "splitFromConference"); |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1697 | if (connection == getNullConnection()) { |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 1698 | Log.w(this, "Connection missing in conference request %s.", callId); |
| 1699 | return; |
| 1700 | } |
| 1701 | |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 1702 | Conference conference = connection.getConference(); |
| 1703 | if (conference != null) { |
| 1704 | conference.onSeparate(connection); |
| 1705 | } |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 1706 | } |
| 1707 | |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 1708 | private void mergeConference(String callId) { |
| 1709 | Log.d(this, "mergeConference(%s)", callId); |
| 1710 | Conference conference = findConferenceForAction(callId, "mergeConference"); |
| 1711 | if (conference != null) { |
| 1712 | conference.onMerge(); |
| 1713 | } |
| 1714 | } |
| 1715 | |
| 1716 | private void swapConference(String callId) { |
| 1717 | Log.d(this, "swapConference(%s)", callId); |
| 1718 | Conference conference = findConferenceForAction(callId, "swapConference"); |
| 1719 | if (conference != null) { |
| 1720 | conference.onSwap(); |
| 1721 | } |
| 1722 | } |
| 1723 | |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1724 | /** |
| 1725 | * Notifies a {@link Connection} of a request to pull an external call. |
| 1726 | * |
| 1727 | * See {@link Call#pullExternalCall()}. |
| 1728 | * |
| 1729 | * @param callId The ID of the call to pull. |
| 1730 | */ |
| 1731 | private void pullExternalCall(String callId) { |
| 1732 | Log.d(this, "pullExternalCall(%s)", callId); |
| 1733 | Connection connection = findConnectionForAction(callId, "pullExternalCall"); |
| 1734 | if (connection != null) { |
| 1735 | connection.onPullExternalCall(); |
| 1736 | } |
| 1737 | } |
| 1738 | |
| 1739 | /** |
| 1740 | * Notifies a {@link Connection} of a call event. |
| 1741 | * |
| 1742 | * See {@link Call#sendCallEvent(String, Bundle)}. |
| 1743 | * |
| 1744 | * @param callId The ID of the call receiving the event. |
| 1745 | * @param event The event. |
| 1746 | * @param extras Extras associated with the event. |
| 1747 | */ |
| 1748 | private void sendCallEvent(String callId, String event, Bundle extras) { |
| 1749 | Log.d(this, "sendCallEvent(%s, %s)", callId, event); |
| 1750 | Connection connection = findConnectionForAction(callId, "sendCallEvent"); |
| 1751 | if (connection != null) { |
| 1752 | connection.onCallEvent(event, extras); |
| 1753 | } |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1754 | } |
| 1755 | |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1756 | /** |
| 1757 | * Notifies a {@link Connection} or {@link Conference} of a change to the extras from Telecom. |
| 1758 | * <p> |
| 1759 | * These extra changes can originate from Telecom itself, or from an {@link InCallService} via |
| 1760 | * the {@link android.telecom.Call#putExtra(String, boolean)}, |
| 1761 | * {@link android.telecom.Call#putExtra(String, int)}, |
| 1762 | * {@link android.telecom.Call#putExtra(String, String)}, |
| 1763 | * {@link Call#removeExtras(List)}. |
| 1764 | * |
| 1765 | * @param callId The ID of the call receiving the event. |
| 1766 | * @param extras The new extras bundle. |
| 1767 | */ |
| 1768 | private void handleExtrasChanged(String callId, Bundle extras) { |
| 1769 | Log.d(this, "handleExtrasChanged(%s, %s)", callId, extras); |
| 1770 | if (mConnectionById.containsKey(callId)) { |
| 1771 | findConnectionForAction(callId, "handleExtrasChanged").handleExtrasChanged(extras); |
| 1772 | } else if (mConferenceById.containsKey(callId)) { |
| 1773 | findConferenceForAction(callId, "handleExtrasChanged").handleExtrasChanged(extras); |
| 1774 | } |
| 1775 | } |
| 1776 | |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1777 | private void startRtt(String callId, Connection.RttTextStream rttTextStream) { |
| 1778 | Log.d(this, "startRtt(%s)", callId); |
| 1779 | if (mConnectionById.containsKey(callId)) { |
| 1780 | findConnectionForAction(callId, "startRtt").onStartRtt(rttTextStream); |
| 1781 | } else if (mConferenceById.containsKey(callId)) { |
| 1782 | Log.w(this, "startRtt called on a conference."); |
| 1783 | } |
| 1784 | } |
| 1785 | |
| 1786 | private void stopRtt(String callId) { |
| 1787 | Log.d(this, "stopRtt(%s)", callId); |
| 1788 | if (mConnectionById.containsKey(callId)) { |
| 1789 | findConnectionForAction(callId, "stopRtt").onStopRtt(); |
Hall Liu | ffa4a81 | 2017-03-02 16:11:00 -0800 | [diff] [blame] | 1790 | findConnectionForAction(callId, "stopRtt").unsetRttProperty(); |
Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1791 | } else if (mConferenceById.containsKey(callId)) { |
| 1792 | Log.w(this, "stopRtt called on a conference."); |
| 1793 | } |
| 1794 | } |
| 1795 | |
| 1796 | private void handleRttUpgradeResponse(String callId, Connection.RttTextStream rttTextStream) { |
| 1797 | Log.d(this, "handleRttUpgradeResponse(%s, %s)", callId, rttTextStream == null); |
| 1798 | if (mConnectionById.containsKey(callId)) { |
| 1799 | findConnectionForAction(callId, "handleRttUpgradeResponse") |
| 1800 | .handleRttUpgradeResponse(rttTextStream); |
| 1801 | } else if (mConferenceById.containsKey(callId)) { |
| 1802 | Log.w(this, "handleRttUpgradeResponse called on a conference."); |
| 1803 | } |
| 1804 | } |
| 1805 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1806 | private void onPostDialContinue(String callId, boolean proceed) { |
Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 1807 | Log.d(this, "onPostDialContinue(%s)", callId); |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1808 | findConnectionForAction(callId, "stopDtmfTone").onPostDialContinue(proceed); |
Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 1809 | } |
| 1810 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1811 | private void onAdapterAttached() { |
Ihab Awad | 9c3f188 | 2014-06-30 21:17:13 -0700 | [diff] [blame] | 1812 | if (mAreAccountsInitialized) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1813 | // No need to query again if we already did it. |
| 1814 | return; |
| 1815 | } |
| 1816 | |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1817 | mAdapter.queryRemoteConnectionServices(new RemoteServiceCallback.Stub() { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1818 | @Override |
| 1819 | public void onResult( |
| 1820 | final List<ComponentName> componentNames, |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1821 | final List<IBinder> services) { |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 1822 | mHandler.post(new android.telecom.Logging.Runnable("oAA.qRCS.oR", null /*lock*/) { |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1823 | @Override |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 1824 | public void loggedRun() { |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1825 | for (int i = 0; i < componentNames.size() && i < services.size(); i++) { |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1826 | mRemoteConnectionManager.addConnectionService( |
| 1827 | componentNames.get(i), |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1828 | IConnectionService.Stub.asInterface(services.get(i))); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1829 | } |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 1830 | onAccountsInitialized(); |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 1831 | Log.d(this, "remote connection services found: " + services); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1832 | } |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 1833 | }.prepare()); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1834 | } |
| 1835 | |
| 1836 | @Override |
| 1837 | public void onError() { |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 1838 | mHandler.post(new android.telecom.Logging.Runnable("oAA.qRCS.oE", null /*lock*/) { |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1839 | @Override |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 1840 | public void loggedRun() { |
Ihab Awad | 9c3f188 | 2014-06-30 21:17:13 -0700 | [diff] [blame] | 1841 | mAreAccountsInitialized = true; |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1842 | } |
Brad Ebinger | 0c3541b | 2016-11-01 14:11:38 -0700 | [diff] [blame] | 1843 | }.prepare()); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1844 | } |
| 1845 | }); |
| 1846 | } |
| 1847 | |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1848 | /** |
| 1849 | * Ask some other {@code ConnectionService} to create a {@code RemoteConnection} given an |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 1850 | * incoming request. This is used by {@code ConnectionService}s that are registered with |
| 1851 | * {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER} and want to be able to manage |
| 1852 | * SIM-based incoming calls. |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1853 | * |
| 1854 | * @param connectionManagerPhoneAccount See description at |
| 1855 | * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}. |
| 1856 | * @param request Details about the incoming call. |
| 1857 | * @return The {@code Connection} object to satisfy this call, or {@code null} to |
| 1858 | * not handle the call. |
| 1859 | */ |
| 1860 | public final RemoteConnection createRemoteIncomingConnection( |
| 1861 | PhoneAccountHandle connectionManagerPhoneAccount, |
| 1862 | ConnectionRequest request) { |
| 1863 | return mRemoteConnectionManager.createRemoteConnection( |
| 1864 | connectionManagerPhoneAccount, request, true); |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 1865 | } |
| 1866 | |
| 1867 | /** |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1868 | * Ask some other {@code ConnectionService} to create a {@code RemoteConnection} given an |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 1869 | * outgoing request. This is used by {@code ConnectionService}s that are registered with |
| 1870 | * {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER} and want to be able to use the |
| 1871 | * SIM-based {@code ConnectionService} to place its outgoing calls. |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1872 | * |
| 1873 | * @param connectionManagerPhoneAccount See description at |
| 1874 | * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}. |
Cuihtlauac ALVARADO | 0b3b2a5 | 2016-09-13 14:49:41 +0200 | [diff] [blame] | 1875 | * @param request Details about the outgoing call. |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 1876 | * @return The {@code Connection} object to satisfy this call, or {@code null} to |
| 1877 | * not handle the call. |
| 1878 | */ |
| 1879 | public final RemoteConnection createRemoteOutgoingConnection( |
| 1880 | PhoneAccountHandle connectionManagerPhoneAccount, |
| 1881 | ConnectionRequest request) { |
| 1882 | return mRemoteConnectionManager.createRemoteConnection( |
| 1883 | connectionManagerPhoneAccount, request, false); |
| 1884 | } |
| 1885 | |
| 1886 | /** |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 1887 | * Indicates to the relevant {@code RemoteConnectionService} that the specified |
| 1888 | * {@link RemoteConnection}s should be merged into a conference call. |
| 1889 | * <p> |
| 1890 | * If the conference request is successful, the method {@link #onRemoteConferenceAdded} will |
| 1891 | * be invoked. |
| 1892 | * |
| 1893 | * @param remoteConnection1 The first of the remote connections to conference. |
| 1894 | * @param remoteConnection2 The second of the remote connections to conference. |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 1895 | */ |
| 1896 | public final void conferenceRemoteConnections( |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 1897 | RemoteConnection remoteConnection1, |
| 1898 | RemoteConnection remoteConnection2) { |
| 1899 | mRemoteConnectionManager.conferenceRemoteConnections(remoteConnection1, remoteConnection2); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 1900 | } |
| 1901 | |
| 1902 | /** |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1903 | * Adds a new conference call. When a conference call is created either as a result of an |
| 1904 | * explicit request via {@link #onConference} or otherwise, the connection service should supply |
| 1905 | * an instance of {@link Conference} by invoking this method. A conference call provided by this |
| 1906 | * method will persist until {@link Conference#destroy} is invoked on the conference instance. |
| 1907 | * |
| 1908 | * @param conference The new conference object. |
| 1909 | */ |
| 1910 | public final void addConference(Conference conference) { |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1911 | Log.d(this, "addConference: conference=%s", conference); |
| 1912 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1913 | String id = addConferenceInternal(conference); |
| 1914 | if (id != null) { |
| 1915 | List<String> connectionIds = new ArrayList<>(2); |
| 1916 | for (Connection connection : conference.getConnections()) { |
| 1917 | if (mIdByConnection.containsKey(connection)) { |
| 1918 | connectionIds.add(mIdByConnection.get(connection)); |
| 1919 | } |
| 1920 | } |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 1921 | conference.setTelecomCallId(id); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1922 | ParcelableConference parcelableConference = new ParcelableConference( |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 1923 | conference.getPhoneAccountHandle(), |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1924 | conference.getState(), |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1925 | conference.getConnectionCapabilities(), |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1926 | conference.getConnectionProperties(), |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 1927 | connectionIds, |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1928 | conference.getVideoProvider() == null ? |
| 1929 | null : conference.getVideoProvider().getInterface(), |
| 1930 | conference.getVideoState(), |
Andrew Lee | 3e3e2f2 | 2015-04-16 13:48:43 -0700 | [diff] [blame] | 1931 | conference.getConnectTimeMillis(), |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 1932 | conference.getConnectElapsedTime(), |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1933 | conference.getStatusHints(), |
| 1934 | conference.getExtras()); |
Andrew Lee | 0f51da3 | 2015-04-16 13:11:55 -0700 | [diff] [blame] | 1935 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1936 | mAdapter.addConferenceCall(id, parcelableConference); |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1937 | mAdapter.setVideoProvider(id, conference.getVideoProvider()); |
| 1938 | mAdapter.setVideoState(id, conference.getVideoState()); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1939 | |
| 1940 | // Go through any child calls and set the parent. |
| 1941 | for (Connection connection : conference.getConnections()) { |
| 1942 | String connectionId = mIdByConnection.get(connection); |
| 1943 | if (connectionId != null) { |
| 1944 | mAdapter.setIsConferenced(connectionId, id); |
| 1945 | } |
| 1946 | } |
Pengquan Meng | 70c988533 | 2017-10-02 18:09:03 -0700 | [diff] [blame] | 1947 | onConferenceAdded(conference); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1948 | } |
| 1949 | } |
| 1950 | |
| 1951 | /** |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 1952 | * Adds a connection created by the {@link ConnectionService} and informs telecom of the new |
| 1953 | * connection. |
| 1954 | * |
| 1955 | * @param phoneAccountHandle The phone account handle for the connection. |
| 1956 | * @param connection The connection to add. |
| 1957 | */ |
| 1958 | public final void addExistingConnection(PhoneAccountHandle phoneAccountHandle, |
| 1959 | Connection connection) { |
Tyler Gunn | 78da781 | 2017-05-09 14:34:57 -0700 | [diff] [blame] | 1960 | addExistingConnection(phoneAccountHandle, connection, null /* conference */); |
| 1961 | } |
| 1962 | |
| 1963 | /** |
Pengquan Meng | 731c1a3 | 2017-11-21 18:01:13 -0800 | [diff] [blame] | 1964 | * Call to inform Telecom that your {@link ConnectionService} has released call resources (e.g |
| 1965 | * microphone, camera). |
| 1966 | * |
| 1967 | * @see ConnectionService#onConnectionServiceFocusLost() |
| 1968 | */ |
| 1969 | public final void connectionServiceFocusReleased() { |
| 1970 | mAdapter.onConnectionServiceFocusReleased(); |
| 1971 | } |
| 1972 | |
| 1973 | /** |
Tyler Gunn | 78da781 | 2017-05-09 14:34:57 -0700 | [diff] [blame] | 1974 | * Adds a connection created by the {@link ConnectionService} and informs telecom of the new |
| 1975 | * connection. |
| 1976 | * |
| 1977 | * @param phoneAccountHandle The phone account handle for the connection. |
| 1978 | * @param connection The connection to add. |
| 1979 | * @param conference The parent conference of the new connection. |
| 1980 | * @hide |
| 1981 | */ |
| 1982 | public final void addExistingConnection(PhoneAccountHandle phoneAccountHandle, |
| 1983 | Connection connection, Conference conference) { |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 1984 | |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 1985 | String id = addExistingConnectionInternal(phoneAccountHandle, connection); |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 1986 | if (id != null) { |
| 1987 | List<String> emptyList = new ArrayList<>(0); |
Tyler Gunn | 78da781 | 2017-05-09 14:34:57 -0700 | [diff] [blame] | 1988 | String conferenceId = null; |
| 1989 | if (conference != null) { |
| 1990 | conferenceId = mIdByConference.get(conference); |
| 1991 | } |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 1992 | |
| 1993 | ParcelableConnection parcelableConnection = new ParcelableConnection( |
| 1994 | phoneAccountHandle, |
| 1995 | connection.getState(), |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1996 | connection.getConnectionCapabilities(), |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1997 | connection.getConnectionProperties(), |
Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 1998 | connection.getSupportedAudioRoutes(), |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 1999 | connection.getAddress(), |
| 2000 | connection.getAddressPresentation(), |
| 2001 | connection.getCallerDisplayName(), |
| 2002 | connection.getCallerDisplayNamePresentation(), |
| 2003 | connection.getVideoProvider() == null ? |
| 2004 | null : connection.getVideoProvider().getInterface(), |
| 2005 | connection.getVideoState(), |
| 2006 | connection.isRingbackRequested(), |
| 2007 | connection.getAudioModeIsVoip(), |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 2008 | connection.getConnectTimeMillis(), |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 2009 | connection.getConnectElapsedTimeMillis(), |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 2010 | connection.getStatusHints(), |
| 2011 | connection.getDisconnectCause(), |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 2012 | emptyList, |
Tyler Gunn | 78da781 | 2017-05-09 14:34:57 -0700 | [diff] [blame] | 2013 | connection.getExtras(), |
| 2014 | conferenceId); |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 2015 | mAdapter.addExistingConnection(id, parcelableConnection); |
| 2016 | } |
| 2017 | } |
| 2018 | |
| 2019 | /** |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 2020 | * Returns all the active {@code Connection}s for which this {@code ConnectionService} |
| 2021 | * has taken responsibility. |
| 2022 | * |
| 2023 | * @return A collection of {@code Connection}s created by this {@code ConnectionService}. |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 2024 | */ |
Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 2025 | public final Collection<Connection> getAllConnections() { |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 2026 | return mConnectionById.values(); |
| 2027 | } |
| 2028 | |
| 2029 | /** |
Santos Cordon | a6018b9 | 2016-02-16 14:23:12 -0800 | [diff] [blame] | 2030 | * Returns all the active {@code Conference}s for which this {@code ConnectionService} |
| 2031 | * has taken responsibility. |
| 2032 | * |
| 2033 | * @return A collection of {@code Conference}s created by this {@code ConnectionService}. |
| 2034 | */ |
| 2035 | public final Collection<Conference> getAllConferences() { |
| 2036 | return mConferenceById.values(); |
| 2037 | } |
| 2038 | |
| 2039 | /** |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 2040 | * Create a {@code Connection} given an incoming request. This is used to attach to existing |
| 2041 | * incoming calls. |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 2042 | * |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 2043 | * @param connectionManagerPhoneAccount See description at |
| 2044 | * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}. |
| 2045 | * @param request Details about the incoming call. |
| 2046 | * @return The {@code Connection} object to satisfy this call, or {@code null} to |
| 2047 | * not handle the call. |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2048 | */ |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 2049 | public Connection onCreateIncomingConnection( |
| 2050 | PhoneAccountHandle connectionManagerPhoneAccount, |
| 2051 | ConnectionRequest request) { |
| 2052 | return null; |
| 2053 | } |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 2054 | |
| 2055 | /** |
Tyler Gunn | 041a1fe | 2017-05-12 10:04:49 -0700 | [diff] [blame] | 2056 | * Called after the {@link Connection} returned by |
| 2057 | * {@link #onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)} |
| 2058 | * or {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)} has been |
| 2059 | * added to the {@link ConnectionService} and sent to Telecom. |
| 2060 | * |
| 2061 | * @param connection the {@link Connection}. |
| 2062 | * @hide |
| 2063 | */ |
| 2064 | public void onCreateConnectionComplete(Connection connection) { |
| 2065 | } |
| 2066 | |
| 2067 | /** |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2068 | * Called by Telecom to inform the {@link ConnectionService} that its request to create a new |
| 2069 | * incoming {@link Connection} was denied. |
| 2070 | * <p> |
| 2071 | * Used when a self-managed {@link ConnectionService} attempts to create a new incoming |
| 2072 | * {@link Connection}, but Telecom has determined that the call cannot be allowed at this time. |
| 2073 | * The {@link ConnectionService} is responsible for silently rejecting the new incoming |
| 2074 | * {@link Connection}. |
| 2075 | * <p> |
| 2076 | * See {@link TelecomManager#isIncomingCallPermitted(PhoneAccountHandle)} for more information. |
| 2077 | * |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 2078 | * @param connectionManagerPhoneAccount See description at |
| 2079 | * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}. |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2080 | * @param request The incoming connection request. |
| 2081 | */ |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 2082 | public void onCreateIncomingConnectionFailed(PhoneAccountHandle connectionManagerPhoneAccount, |
| 2083 | ConnectionRequest request) { |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2084 | } |
| 2085 | |
| 2086 | /** |
| 2087 | * Called by Telecom to inform the {@link ConnectionService} that its request to create a new |
| 2088 | * outgoing {@link Connection} was denied. |
| 2089 | * <p> |
| 2090 | * Used when a self-managed {@link ConnectionService} attempts to create a new outgoing |
| 2091 | * {@link Connection}, but Telecom has determined that the call cannot be placed at this time. |
| 2092 | * The {@link ConnectionService} is responisible for informing the user that the |
| 2093 | * {@link Connection} cannot be made at this time. |
| 2094 | * <p> |
| 2095 | * See {@link TelecomManager#isOutgoingCallPermitted(PhoneAccountHandle)} for more information. |
| 2096 | * |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 2097 | * @param connectionManagerPhoneAccount See description at |
| 2098 | * {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}. |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2099 | * @param request The outgoing connection request. |
| 2100 | */ |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 2101 | public void onCreateOutgoingConnectionFailed(PhoneAccountHandle connectionManagerPhoneAccount, |
| 2102 | ConnectionRequest request) { |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2103 | } |
| 2104 | |
| 2105 | /** |
Shriram Ganesh | 6bf35ac | 2014-12-11 17:53:38 -0800 | [diff] [blame] | 2106 | * Trigger recalculate functinality for conference calls. This is used when a Telephony |
| 2107 | * Connection is part of a conference controller but is not yet added to Connection |
| 2108 | * Service and hence cannot be added to the conference call. |
| 2109 | * |
| 2110 | * @hide |
| 2111 | */ |
| 2112 | public void triggerConferenceRecalculate() { |
| 2113 | } |
| 2114 | |
| 2115 | /** |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 2116 | * Create a {@code Connection} given an outgoing request. This is used to initiate new |
| 2117 | * outgoing calls. |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 2118 | * |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 2119 | * @param connectionManagerPhoneAccount The connection manager account to use for managing |
| 2120 | * this call. |
| 2121 | * <p> |
| 2122 | * If this parameter is not {@code null}, it means that this {@code ConnectionService} |
| 2123 | * has registered one or more {@code PhoneAccount}s having |
| 2124 | * {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER}. This parameter will contain |
| 2125 | * one of these {@code PhoneAccount}s, while the {@code request} will contain another |
| 2126 | * (usually but not always distinct) {@code PhoneAccount} to be used for actually |
| 2127 | * making the connection. |
| 2128 | * <p> |
| 2129 | * If this parameter is {@code null}, it means that this {@code ConnectionService} is |
| 2130 | * being asked to make a direct connection. The |
| 2131 | * {@link ConnectionRequest#getAccountHandle()} of parameter {@code request} will be |
| 2132 | * a {@code PhoneAccount} registered by this {@code ConnectionService} to use for |
| 2133 | * making the connection. |
| 2134 | * @param request Details about the outgoing call. |
| 2135 | * @return The {@code Connection} object to satisfy this call, or the result of an invocation |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 2136 | * of {@link Connection#createFailedConnection(DisconnectCause)} to not handle the call. |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 2137 | */ |
Ihab Awad | f8b6988 | 2014-07-25 15:14:01 -0700 | [diff] [blame] | 2138 | public Connection onCreateOutgoingConnection( |
| 2139 | PhoneAccountHandle connectionManagerPhoneAccount, |
| 2140 | ConnectionRequest request) { |
| 2141 | return null; |
| 2142 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2143 | |
| 2144 | /** |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 2145 | * Called by Telecom on the initiating side of the handover to create an instance of a |
| 2146 | * handover connection. |
| 2147 | * @param fromPhoneAccountHandle {@link PhoneAccountHandle} associated with the |
| 2148 | * ConnectionService which needs to handover the call. |
| 2149 | * @param request Details about the call which needs to be handover. |
| 2150 | * @return Connection object corresponding to the handover call. |
| 2151 | */ |
| 2152 | public Connection onCreateOutgoingHandoverConnection(PhoneAccountHandle fromPhoneAccountHandle, |
| 2153 | ConnectionRequest request) { |
| 2154 | return null; |
| 2155 | } |
| 2156 | |
| 2157 | /** |
| 2158 | * Called by Telecom on the receiving side of the handover to request the |
| 2159 | * {@link ConnectionService} to create an instance of a handover connection. |
| 2160 | * @param fromPhoneAccountHandle {@link PhoneAccountHandle} associated with the |
| 2161 | * ConnectionService which needs to handover the call. |
| 2162 | * @param request Details about the call which needs to be handover. |
| 2163 | * @return {@link Connection} object corresponding to the handover call. |
| 2164 | */ |
| 2165 | public Connection onCreateIncomingHandoverConnection(PhoneAccountHandle fromPhoneAccountHandle, |
| 2166 | ConnectionRequest request) { |
| 2167 | return null; |
| 2168 | } |
| 2169 | |
| 2170 | /** |
| 2171 | * Called by Telecom in response to a {@code TelecomManager#acceptHandover()} |
| 2172 | * invocation which failed. |
| 2173 | * @param request Details about the call which needs to be handover. |
| 2174 | * @param error Reason for handover failure as defined in |
| 2175 | * {@link android.telecom.Call.Callback#HANDOVER_FAILURE_DEST_INVALID_PERM} |
| 2176 | */ |
| 2177 | public void onHandoverFailed(ConnectionRequest request, int error) { |
| 2178 | return; |
| 2179 | } |
| 2180 | |
| 2181 | /** |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 2182 | * Create a {@code Connection} for a new unknown call. An unknown call is a call originating |
| 2183 | * from the ConnectionService that was neither a user-initiated outgoing call, nor an incoming |
| 2184 | * call created using |
| 2185 | * {@code TelecomManager#addNewIncomingCall(PhoneAccountHandle, android.os.Bundle)}. |
| 2186 | * |
Yorke Lee | 770ed6e | 2014-10-06 18:58:52 -0700 | [diff] [blame] | 2187 | * @hide |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 2188 | */ |
| 2189 | public Connection onCreateUnknownConnection(PhoneAccountHandle connectionManagerPhoneAccount, |
| 2190 | ConnectionRequest request) { |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 2191 | return null; |
Yorke Lee | c3cf982 | 2014-10-02 09:38:39 -0700 | [diff] [blame] | 2192 | } |
| 2193 | |
| 2194 | /** |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2195 | * Conference two specified connections. Invoked when the user has made a request to merge the |
| 2196 | * specified connections into a conference call. In response, the connection service should |
| 2197 | * create an instance of {@link Conference} and pass it into {@link #addConference}. |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 2198 | * |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2199 | * @param connection1 A connection to merge into a conference call. |
| 2200 | * @param connection2 A connection to merge into a conference call. |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 2201 | */ |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2202 | public void onConference(Connection connection1, Connection connection2) {} |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 2203 | |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 2204 | /** |
Pengquan Meng | 70c988533 | 2017-10-02 18:09:03 -0700 | [diff] [blame] | 2205 | * Called when a connection is added. |
| 2206 | * @hide |
| 2207 | */ |
| 2208 | public void onConnectionAdded(Connection connection) {} |
| 2209 | |
| 2210 | /** |
| 2211 | * Called when a connection is removed. |
| 2212 | * @hide |
| 2213 | */ |
| 2214 | public void onConnectionRemoved(Connection connection) {} |
| 2215 | |
| 2216 | /** |
| 2217 | * Called when a conference is added. |
| 2218 | * @hide |
| 2219 | */ |
| 2220 | public void onConferenceAdded(Conference conference) {} |
| 2221 | |
| 2222 | /** |
| 2223 | * Called when a conference is removed. |
| 2224 | * @hide |
| 2225 | */ |
| 2226 | public void onConferenceRemoved(Conference conference) {} |
| 2227 | |
| 2228 | /** |
Santos Cordon | a663f86 | 2014-10-29 13:49:58 -0700 | [diff] [blame] | 2229 | * Indicates that a remote conference has been created for existing {@link RemoteConnection}s. |
| 2230 | * When this method is invoked, this {@link ConnectionService} should create its own |
| 2231 | * representation of the conference call and send it to telecom using {@link #addConference}. |
| 2232 | * <p> |
| 2233 | * This is only relevant to {@link ConnectionService}s which are registered with |
| 2234 | * {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER}. |
| 2235 | * |
| 2236 | * @param conference The remote conference call. |
| 2237 | */ |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 2238 | public void onRemoteConferenceAdded(RemoteConference conference) {} |
| 2239 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2240 | /** |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 2241 | * Called when an existing connection is added remotely. |
| 2242 | * @param connection The existing connection which was added. |
| 2243 | */ |
| 2244 | public void onRemoteExistingConnectionAdded(RemoteConnection connection) {} |
| 2245 | |
| 2246 | /** |
Pengquan Meng | 731c1a3 | 2017-11-21 18:01:13 -0800 | [diff] [blame] | 2247 | * Called when the {@link ConnectionService} has lost the call focus. |
| 2248 | * The {@link ConnectionService} should release the call resources and invokes |
| 2249 | * {@link ConnectionService#connectionServiceFocusReleased()} to inform telecom that it has |
| 2250 | * released the call resources. |
| 2251 | */ |
| 2252 | public void onConnectionServiceFocusLost() {} |
| 2253 | |
| 2254 | /** |
| 2255 | * Called when the {@link ConnectionService} has gained the call focus. The |
| 2256 | * {@link ConnectionService} can acquire the call resources at this time. |
| 2257 | */ |
| 2258 | public void onConnectionServiceFocusGained() {} |
| 2259 | |
| 2260 | /** |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2261 | * @hide |
| 2262 | */ |
| 2263 | public boolean containsConference(Conference conference) { |
| 2264 | return mIdByConference.containsKey(conference); |
| 2265 | } |
| 2266 | |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 2267 | /** {@hide} */ |
| 2268 | void addRemoteConference(RemoteConference remoteConference) { |
| 2269 | onRemoteConferenceAdded(remoteConference); |
| 2270 | } |
| 2271 | |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 2272 | /** {@hide} */ |
| 2273 | void addRemoteExistingConnection(RemoteConnection remoteConnection) { |
| 2274 | onRemoteExistingConnectionAdded(remoteConnection); |
| 2275 | } |
| 2276 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 2277 | private void onAccountsInitialized() { |
| 2278 | mAreAccountsInitialized = true; |
| 2279 | for (Runnable r : mPreInitializationConnectionRequests) { |
| 2280 | r.run(); |
| 2281 | } |
| 2282 | mPreInitializationConnectionRequests.clear(); |
| 2283 | } |
| 2284 | |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 2285 | /** |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2286 | * Adds an existing connection to the list of connections, identified by a new call ID unique |
| 2287 | * to this connection service. |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 2288 | * |
| 2289 | * @param connection The connection. |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2290 | * @return The ID of the connection (e.g. the call-id). |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 2291 | */ |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2292 | private String addExistingConnectionInternal(PhoneAccountHandle handle, Connection connection) { |
| 2293 | String id; |
Tyler Gunn | cd6ccfd | 2016-10-17 15:48:19 -0700 | [diff] [blame] | 2294 | |
| 2295 | if (connection.getExtras() != null && connection.getExtras() |
| 2296 | .containsKey(Connection.EXTRA_ORIGINAL_CONNECTION_ID)) { |
| 2297 | id = connection.getExtras().getString(Connection.EXTRA_ORIGINAL_CONNECTION_ID); |
| 2298 | Log.d(this, "addExistingConnectionInternal - conn %s reusing original id %s", |
| 2299 | connection.getTelecomCallId(), id); |
| 2300 | } else if (handle == null) { |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2301 | // If no phone account handle was provided, we cannot be sure the call ID is unique, |
| 2302 | // so just use a random UUID. |
| 2303 | id = UUID.randomUUID().toString(); |
| 2304 | } else { |
| 2305 | // Phone account handle was provided, so use the ConnectionService class name as a |
| 2306 | // prefix for a unique incremental call ID. |
| 2307 | id = handle.getComponentName().getClassName() + "@" + getNextCallId(); |
| 2308 | } |
Pengquan Meng | 70c988533 | 2017-10-02 18:09:03 -0700 | [diff] [blame] | 2309 | addConnection(handle, id, connection); |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 2310 | return id; |
| 2311 | } |
| 2312 | |
Pengquan Meng | 70c988533 | 2017-10-02 18:09:03 -0700 | [diff] [blame] | 2313 | private void addConnection(PhoneAccountHandle handle, String callId, Connection connection) { |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2314 | connection.setTelecomCallId(callId); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2315 | mConnectionById.put(callId, connection); |
| 2316 | mIdByConnection.put(connection, callId); |
| 2317 | connection.addConnectionListener(mConnectionListener); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2318 | connection.setConnectionService(this); |
Pengquan Meng | 70c988533 | 2017-10-02 18:09:03 -0700 | [diff] [blame] | 2319 | connection.setPhoneAccountHandle(handle); |
| 2320 | onConnectionAdded(connection); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2321 | } |
| 2322 | |
Anthony Lee | 30e6584 | 2014-11-06 16:30:53 -0800 | [diff] [blame] | 2323 | /** {@hide} */ |
| 2324 | protected void removeConnection(Connection connection) { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2325 | connection.unsetConnectionService(this); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2326 | connection.removeConnectionListener(mConnectionListener); |
Chenjie Luo | e370b53 | 2016-05-12 16:59:43 -0700 | [diff] [blame] | 2327 | String id = mIdByConnection.get(connection); |
| 2328 | if (id != null) { |
| 2329 | mConnectionById.remove(id); |
| 2330 | mIdByConnection.remove(connection); |
| 2331 | mAdapter.removeCall(id); |
Pengquan Meng | 70c988533 | 2017-10-02 18:09:03 -0700 | [diff] [blame] | 2332 | onConnectionRemoved(connection); |
Chenjie Luo | e370b53 | 2016-05-12 16:59:43 -0700 | [diff] [blame] | 2333 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2334 | } |
| 2335 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2336 | private String addConferenceInternal(Conference conference) { |
Tyler Gunn | cd6ccfd | 2016-10-17 15:48:19 -0700 | [diff] [blame] | 2337 | String originalId = null; |
| 2338 | if (conference.getExtras() != null && conference.getExtras() |
| 2339 | .containsKey(Connection.EXTRA_ORIGINAL_CONNECTION_ID)) { |
| 2340 | originalId = conference.getExtras().getString(Connection.EXTRA_ORIGINAL_CONNECTION_ID); |
| 2341 | Log.d(this, "addConferenceInternal: conf %s reusing original id %s", |
| 2342 | conference.getTelecomCallId(), |
| 2343 | originalId); |
| 2344 | } |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2345 | if (mIdByConference.containsKey(conference)) { |
| 2346 | Log.w(this, "Re-adding an existing conference: %s.", conference); |
| 2347 | } else if (conference != null) { |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2348 | // Conferences do not (yet) have a PhoneAccountHandle associated with them, so we |
| 2349 | // cannot determine a ConnectionService class name to associate with the ID, so use |
| 2350 | // a unique UUID (for now). |
Tyler Gunn | cd6ccfd | 2016-10-17 15:48:19 -0700 | [diff] [blame] | 2351 | String id = originalId == null ? UUID.randomUUID().toString() : originalId; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2352 | mConferenceById.put(id, conference); |
| 2353 | mIdByConference.put(conference, id); |
| 2354 | conference.addListener(mConferenceListener); |
| 2355 | return id; |
| 2356 | } |
| 2357 | |
| 2358 | return null; |
| 2359 | } |
| 2360 | |
| 2361 | private void removeConference(Conference conference) { |
| 2362 | if (mIdByConference.containsKey(conference)) { |
| 2363 | conference.removeListener(mConferenceListener); |
| 2364 | |
| 2365 | String id = mIdByConference.get(conference); |
| 2366 | mConferenceById.remove(id); |
| 2367 | mIdByConference.remove(conference); |
| 2368 | mAdapter.removeCall(id); |
Pengquan Meng | 70c988533 | 2017-10-02 18:09:03 -0700 | [diff] [blame] | 2369 | |
| 2370 | onConferenceRemoved(conference); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2371 | } |
| 2372 | } |
| 2373 | |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2374 | private Connection findConnectionForAction(String callId, String action) { |
Tyler Gunn | 0a88f2e | 2017-06-16 20:20:34 -0700 | [diff] [blame] | 2375 | if (callId != null && mConnectionById.containsKey(callId)) { |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2376 | return mConnectionById.get(callId); |
| 2377 | } |
Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 2378 | Log.w(this, "%s - Cannot find Connection %s", action, callId); |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 2379 | return getNullConnection(); |
| 2380 | } |
| 2381 | |
| 2382 | static synchronized Connection getNullConnection() { |
| 2383 | if (sNullConnection == null) { |
| 2384 | sNullConnection = new Connection() {}; |
| 2385 | } |
| 2386 | return sNullConnection; |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2387 | } |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 2388 | |
| 2389 | private Conference findConferenceForAction(String conferenceId, String action) { |
| 2390 | if (mConferenceById.containsKey(conferenceId)) { |
| 2391 | return mConferenceById.get(conferenceId); |
| 2392 | } |
| 2393 | Log.w(this, "%s - Cannot find conference %s", action, conferenceId); |
| 2394 | return getNullConference(); |
| 2395 | } |
| 2396 | |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 2397 | private List<String> createConnectionIdList(List<Connection> connections) { |
| 2398 | List<String> ids = new ArrayList<>(); |
| 2399 | for (Connection c : connections) { |
| 2400 | if (mIdByConnection.containsKey(c)) { |
| 2401 | ids.add(mIdByConnection.get(c)); |
| 2402 | } |
| 2403 | } |
| 2404 | Collections.sort(ids); |
| 2405 | return ids; |
| 2406 | } |
| 2407 | |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2408 | /** |
| 2409 | * Builds a list of {@link Connection} and {@link Conference} IDs based on the list of |
Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 2410 | * {@link Conferenceable}s passed in. |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2411 | * |
Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 2412 | * @param conferenceables The {@link Conferenceable} connections and conferences. |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2413 | * @return List of string conference and call Ids. |
| 2414 | */ |
Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 2415 | private List<String> createIdList(List<Conferenceable> conferenceables) { |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2416 | List<String> ids = new ArrayList<>(); |
Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 2417 | for (Conferenceable c : conferenceables) { |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2418 | // Only allow Connection and Conference conferenceables. |
| 2419 | if (c instanceof Connection) { |
| 2420 | Connection connection = (Connection) c; |
| 2421 | if (mIdByConnection.containsKey(connection)) { |
| 2422 | ids.add(mIdByConnection.get(connection)); |
| 2423 | } |
| 2424 | } else if (c instanceof Conference) { |
| 2425 | Conference conference = (Conference) c; |
| 2426 | if (mIdByConference.containsKey(conference)) { |
| 2427 | ids.add(mIdByConference.get(conference)); |
| 2428 | } |
| 2429 | } |
| 2430 | } |
| 2431 | Collections.sort(ids); |
| 2432 | return ids; |
| 2433 | } |
| 2434 | |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 2435 | private Conference getNullConference() { |
| 2436 | if (sNullConference == null) { |
| 2437 | sNullConference = new Conference(null) {}; |
| 2438 | } |
| 2439 | return sNullConference; |
| 2440 | } |
Santos Cordon | 29f2f2e | 2014-09-11 19:50:24 -0700 | [diff] [blame] | 2441 | |
| 2442 | private void endAllConnections() { |
| 2443 | // Unbound from telecomm. We should end all connections and conferences. |
| 2444 | for (Connection connection : mIdByConnection.keySet()) { |
| 2445 | // only operate on top-level calls. Conference calls will be removed on their own. |
| 2446 | if (connection.getConference() == null) { |
| 2447 | connection.onDisconnect(); |
| 2448 | } |
| 2449 | } |
| 2450 | for (Conference conference : mIdByConference.keySet()) { |
| 2451 | conference.onDisconnect(); |
| 2452 | } |
| 2453 | } |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2454 | |
| 2455 | /** |
| 2456 | * Retrieves the next call ID as maintainted by the connection service. |
| 2457 | * |
| 2458 | * @return The call ID. |
| 2459 | */ |
| 2460 | private int getNextCallId() { |
Brad Ebinger | b32d4f8 | 2016-10-24 16:40:49 -0700 | [diff] [blame] | 2461 | synchronized (mIdSyncRoot) { |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2462 | return ++mId; |
| 2463 | } |
| 2464 | } |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 2465 | } |