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