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