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