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