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