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