Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -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; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 18 | |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 19 | import android.annotation.NonNull; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 20 | import android.annotation.Nullable; |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 21 | import android.annotation.SystemApi; |
Tyler Gunn | 6c14a699 | 2019-02-04 15:12:06 -0800 | [diff] [blame] | 22 | import android.annotation.TestApi; |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 23 | import android.net.Uri; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 24 | import android.os.Bundle; |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 25 | import android.os.SystemClock; |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 26 | import android.telecom.Connection.VideoProvider; |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 27 | import android.util.ArraySet; |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 28 | |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 29 | import java.util.ArrayList; |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 30 | import java.util.Arrays; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 31 | import java.util.Collections; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 32 | import java.util.List; |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 33 | import java.util.Locale; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 34 | import java.util.Set; |
| 35 | import java.util.concurrent.CopyOnWriteArrayList; |
| 36 | import java.util.concurrent.CopyOnWriteArraySet; |
| 37 | |
| 38 | /** |
| 39 | * Represents a conference call which can contain any number of {@link Connection} objects. |
| 40 | */ |
Yorke Lee | abfcfdc | 2015-05-13 18:55:18 -0700 | [diff] [blame] | 41 | public abstract class Conference extends Conferenceable { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 42 | |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 43 | /** |
| 44 | * Used to indicate that the conference connection time is not specified. If not specified, |
| 45 | * Telecom will set the connect time. |
| 46 | */ |
Jay Shrauner | 164a0ac | 2015-04-14 18:16:10 -0700 | [diff] [blame] | 47 | public static final long CONNECT_TIME_NOT_SPECIFIED = 0; |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 48 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 49 | /** @hide */ |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 50 | abstract static class Listener { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 51 | public void onStateChanged(Conference conference, int oldState, int newState) {} |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 52 | public void onDisconnected(Conference conference, DisconnectCause disconnectCause) {} |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 53 | public void onConnectionAdded(Conference conference, Connection connection) {} |
| 54 | public void onConnectionRemoved(Conference conference, Connection connection) {} |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 55 | public void onConferenceableConnectionsChanged( |
| 56 | Conference conference, List<Connection> conferenceableConnections) {} |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 57 | public void onDestroyed(Conference conference) {} |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 58 | public void onConnectionCapabilitiesChanged( |
| 59 | Conference conference, int connectionCapabilities) {} |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 60 | public void onConnectionPropertiesChanged( |
| 61 | Conference conference, int connectionProperties) {} |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 62 | public void onVideoStateChanged(Conference c, int videoState) { } |
| 63 | public void onVideoProviderChanged(Conference c, Connection.VideoProvider videoProvider) {} |
Andrew Lee | edc625f | 2015-04-14 13:38:12 -0700 | [diff] [blame] | 64 | public void onStatusHintsChanged(Conference conference, StatusHints statusHints) {} |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 65 | public void onExtrasChanged(Conference c, Bundle extras) {} |
| 66 | public void onExtrasRemoved(Conference c, List<String> keys) {} |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 67 | public void onConferenceStateChanged(Conference c, boolean isConference) {} |
| 68 | public void onAddressChanged(Conference c, Uri newAddress, int presentation) {} |
Hall Liu | c9bc1c6 | 2019-04-16 14:00:55 -0700 | [diff] [blame] | 69 | public void onConnectionEvent(Conference c, String event, Bundle extras) {} |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 70 | public void onCallerDisplayNameChanged( |
| 71 | Conference c, String callerDisplayName, int presentation) {} |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 72 | public void onRingbackRequested(Conference c, boolean ringback) {} |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | private final Set<Listener> mListeners = new CopyOnWriteArraySet<>(); |
| 76 | private final List<Connection> mChildConnections = new CopyOnWriteArrayList<>(); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 77 | private final List<Connection> mUnmodifiableChildConnections = |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 78 | Collections.unmodifiableList(mChildConnections); |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 79 | private final List<Connection> mConferenceableConnections = new ArrayList<>(); |
| 80 | private final List<Connection> mUnmodifiableConferenceableConnections = |
| 81 | Collections.unmodifiableList(mConferenceableConnections); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 82 | |
Jack Yu | 6714030 | 2015-12-10 12:27:58 -0800 | [diff] [blame] | 83 | private String mTelecomCallId; |
Jay Shrauner | 164a0ac | 2015-04-14 18:16:10 -0700 | [diff] [blame] | 84 | private PhoneAccountHandle mPhoneAccount; |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 85 | private CallAudioState mCallAudioState; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 86 | private int mState = Connection.STATE_NEW; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 87 | private DisconnectCause mDisconnectCause; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 88 | private int mConnectionCapabilities; |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 89 | private int mConnectionProperties; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 90 | private String mDisconnectMessage; |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 91 | private long mConnectTimeMillis = CONNECT_TIME_NOT_SPECIFIED; |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 92 | private long mConnectionStartElapsedRealTime = CONNECT_TIME_NOT_SPECIFIED; |
Andrew Lee | edc625f | 2015-04-14 13:38:12 -0700 | [diff] [blame] | 93 | private StatusHints mStatusHints; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 94 | private Bundle mExtras; |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 95 | private Set<String> mPreviousExtraKeys; |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 96 | private final Object mExtrasLock = new Object(); |
Tyler Gunn | ac60f95 | 2019-05-31 07:23:16 -0700 | [diff] [blame] | 97 | private Uri mAddress; |
| 98 | private int mAddressPresentation; |
| 99 | private String mCallerDisplayName; |
| 100 | private int mCallerDisplayNamePresentation; |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 101 | private boolean mRingbackRequested = false; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 102 | |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 103 | private final Connection.Listener mConnectionDeathListener = new Connection.Listener() { |
| 104 | @Override |
| 105 | public void onDestroyed(Connection c) { |
| 106 | if (mConferenceableConnections.remove(c)) { |
| 107 | fireOnConferenceableConnectionsChanged(); |
| 108 | } |
| 109 | } |
| 110 | }; |
| 111 | |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 112 | /** |
| 113 | * Constructs a new Conference with a mandatory {@link PhoneAccountHandle} |
| 114 | * |
| 115 | * @param phoneAccount The {@code PhoneAccountHandle} associated with the conference. |
| 116 | */ |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 117 | public Conference(PhoneAccountHandle phoneAccount) { |
| 118 | mPhoneAccount = phoneAccount; |
| 119 | } |
| 120 | |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 121 | /** |
Jack Yu | 6714030 | 2015-12-10 12:27:58 -0800 | [diff] [blame] | 122 | * Returns the telecom internal call ID associated with this conference. |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 123 | * <p> |
| 124 | * Note: This is ONLY used for debugging purposes so that the Telephony stack can better |
| 125 | * associate logs in Telephony with those in Telecom. |
| 126 | * The ID returned should not be used for any other purpose. |
Jack Yu | 6714030 | 2015-12-10 12:27:58 -0800 | [diff] [blame] | 127 | * |
| 128 | * @return The telecom call ID. |
| 129 | * @hide |
| 130 | */ |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 131 | @SystemApi |
| 132 | @TestApi |
| 133 | public final @NonNull String getTelecomCallId() { |
Jack Yu | 6714030 | 2015-12-10 12:27:58 -0800 | [diff] [blame] | 134 | return mTelecomCallId; |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Sets the telecom internal call ID associated with this conference. |
| 139 | * |
| 140 | * @param telecomCallId The telecom call ID. |
| 141 | * @hide |
| 142 | */ |
| 143 | public final void setTelecomCallId(String telecomCallId) { |
| 144 | mTelecomCallId = telecomCallId; |
| 145 | } |
| 146 | |
| 147 | /** |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 148 | * Returns the {@link PhoneAccountHandle} the conference call is being placed through. |
| 149 | * |
| 150 | * @return A {@code PhoneAccountHandle} object representing the PhoneAccount of the conference. |
| 151 | */ |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 152 | public final PhoneAccountHandle getPhoneAccountHandle() { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 153 | return mPhoneAccount; |
| 154 | } |
| 155 | |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 156 | /** |
| 157 | * Returns the list of connections currently associated with the conference call. |
| 158 | * |
| 159 | * @return A list of {@code Connection} objects which represent the children of the conference. |
| 160 | */ |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 161 | public final List<Connection> getConnections() { |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 162 | return mUnmodifiableChildConnections; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 163 | } |
| 164 | |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 165 | /** |
| 166 | * Gets the state of the conference call. See {@link Connection} for valid values. |
| 167 | * |
| 168 | * @return A constant representing the state the conference call is currently in. |
| 169 | */ |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 170 | public final int getState() { |
| 171 | return mState; |
| 172 | } |
| 173 | |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 174 | /** |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 175 | * Returns whether this conference is requesting that the system play a ringback tone |
| 176 | * on its behalf. |
| 177 | */ |
| 178 | public final boolean isRingbackRequested() { |
| 179 | return mRingbackRequested; |
| 180 | } |
| 181 | |
| 182 | /** |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 183 | * Returns the capabilities of the conference. See {@code CAPABILITY_*} constants in class |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 184 | * {@link Connection} for valid values. |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 185 | * |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 186 | * @return A bitmask of the capabilities of the conference call. |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 187 | */ |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 188 | public final int getConnectionCapabilities() { |
| 189 | return mConnectionCapabilities; |
| 190 | } |
| 191 | |
| 192 | /** |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 193 | * Returns the properties of the conference. See {@code PROPERTY_*} constants in class |
| 194 | * {@link Connection} for valid values. |
| 195 | * |
| 196 | * @return A bitmask of the properties of the conference call. |
| 197 | */ |
| 198 | public final int getConnectionProperties() { |
| 199 | return mConnectionProperties; |
| 200 | } |
| 201 | |
| 202 | /** |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 203 | * @return The audio state of the conference, describing how its audio is currently |
| 204 | * being routed by the system. This is {@code null} if this Conference |
| 205 | * does not directly know about its audio state. |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 206 | * @deprecated Use {@link #getCallAudioState()} instead. |
| 207 | * @hide |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 208 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 209 | @Deprecated |
| 210 | @SystemApi |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 211 | public final AudioState getAudioState() { |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 212 | return new AudioState(mCallAudioState); |
| 213 | } |
| 214 | |
| 215 | /** |
| 216 | * @return The audio state of the conference, describing how its audio is currently |
| 217 | * being routed by the system. This is {@code null} if this Conference |
| 218 | * does not directly know about its audio state. |
| 219 | */ |
| 220 | public final CallAudioState getCallAudioState() { |
| 221 | return mCallAudioState; |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | /** |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 225 | * Returns VideoProvider of the primary call. This can be null. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 226 | */ |
| 227 | public VideoProvider getVideoProvider() { |
| 228 | return null; |
| 229 | } |
| 230 | |
| 231 | /** |
| 232 | * Returns video state of the primary call. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 233 | */ |
| 234 | public int getVideoState() { |
Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 235 | return VideoProfile.STATE_AUDIO_ONLY; |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 239 | * Notifies the {@link Conference} when the Conference and all it's {@link Connection}s should |
| 240 | * be disconnected. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 241 | */ |
| 242 | public void onDisconnect() {} |
| 243 | |
| 244 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 245 | * Notifies the {@link Conference} when the specified {@link Connection} should be separated |
| 246 | * from the conference call. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 247 | * |
| 248 | * @param connection The connection to separate. |
| 249 | */ |
| 250 | public void onSeparate(Connection connection) {} |
| 251 | |
| 252 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 253 | * Notifies the {@link Conference} when the specified {@link Connection} should merged with the |
| 254 | * conference call. |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 255 | * |
| 256 | * @param connection The {@code Connection} to merge. |
| 257 | */ |
| 258 | public void onMerge(Connection connection) {} |
| 259 | |
| 260 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 261 | * Notifies the {@link Conference} when it should be put on hold. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 262 | */ |
| 263 | public void onHold() {} |
| 264 | |
| 265 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 266 | * Notifies the {@link Conference} when it should be moved from a held to active state. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 267 | */ |
| 268 | public void onUnhold() {} |
| 269 | |
| 270 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 271 | * Notifies the {@link Conference} when the child calls should be merged. Only invoked if the |
| 272 | * conference contains the capability {@link Connection#CAPABILITY_MERGE_CONFERENCE}. |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 273 | */ |
| 274 | public void onMerge() {} |
| 275 | |
| 276 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 277 | * Notifies the {@link Conference} when the child calls should be swapped. Only invoked if the |
| 278 | * conference contains the capability {@link Connection#CAPABILITY_SWAP_CONFERENCE}. |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 279 | */ |
| 280 | public void onSwap() {} |
| 281 | |
| 282 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 283 | * Notifies the {@link Conference} of a request to play a DTMF tone. |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 284 | * |
| 285 | * @param c A DTMF character. |
| 286 | */ |
| 287 | public void onPlayDtmfTone(char c) {} |
| 288 | |
| 289 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 290 | * Notifies the {@link Conference} of a request to stop any currently playing DTMF tones. |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 291 | */ |
| 292 | public void onStopDtmfTone() {} |
| 293 | |
| 294 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 295 | * Notifies the {@link Conference} that the {@link #getAudioState()} property has a new value. |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 296 | * |
| 297 | * @param state The new call audio state. |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 298 | * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead. |
| 299 | * @hide |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 300 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 301 | @SystemApi |
| 302 | @Deprecated |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 303 | public void onAudioStateChanged(AudioState state) {} |
| 304 | |
| 305 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 306 | * Notifies the {@link Conference} that the {@link #getCallAudioState()} property has a new |
| 307 | * value. |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 308 | * |
| 309 | * @param state The new call audio state. |
| 310 | */ |
| 311 | public void onCallAudioStateChanged(CallAudioState state) {} |
| 312 | |
| 313 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 314 | * Notifies the {@link Conference} that a {@link Connection} has been added to it. |
Andrew Lee | 46f7f5d | 2014-11-06 17:00:25 -0800 | [diff] [blame] | 315 | * |
| 316 | * @param connection The newly added connection. |
| 317 | */ |
| 318 | public void onConnectionAdded(Connection connection) {} |
| 319 | |
| 320 | /** |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 321 | * Notifies this Conference, which is in {@code STATE_RINGING}, of |
| 322 | * a request to accept. |
| 323 | * For managed {@link ConnectionService}s, this will be called when the user answers a call via |
| 324 | * the default dialer's {@link InCallService}. |
| 325 | * |
| 326 | * @param videoState The video state in which to answer the connection. |
| 327 | */ |
| 328 | public void onAnswer(int videoState) {} |
| 329 | |
| 330 | /** |
| 331 | * Notifies this Conference, which is in {@code STATE_RINGING}, of |
| 332 | * a request to accept. |
| 333 | * For managed {@link ConnectionService}s, this will be called when the user answers a call via |
| 334 | * the default dialer's {@link InCallService}. |
| 335 | * @hide |
| 336 | */ |
| 337 | public final void onAnswer() { |
| 338 | onAnswer(VideoProfile.STATE_AUDIO_ONLY); |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * Notifies this Conference, which is in {@code STATE_RINGING}, of |
| 343 | * a request to reject. |
| 344 | * For managed {@link ConnectionService}s, this will be called when the user rejects a call via |
| 345 | * the default dialer's {@link InCallService}. |
| 346 | */ |
| 347 | public void onReject() {} |
| 348 | |
| 349 | /** |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 350 | * Sets state to be on hold. |
| 351 | */ |
| 352 | public final void setOnHold() { |
| 353 | setState(Connection.STATE_HOLDING); |
| 354 | } |
| 355 | |
| 356 | /** |
Tyler Gunn | d46595a | 2015-06-01 14:29:11 -0700 | [diff] [blame] | 357 | * Sets state to be dialing. |
| 358 | */ |
| 359 | public final void setDialing() { |
| 360 | setState(Connection.STATE_DIALING); |
| 361 | } |
| 362 | |
| 363 | /** |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 364 | * Sets state to be ringing. |
| 365 | */ |
| 366 | public final void setRinging() { |
| 367 | setState(Connection.STATE_RINGING); |
| 368 | } |
| 369 | |
| 370 | /** |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 371 | * Sets state to be active. |
| 372 | */ |
| 373 | public final void setActive() { |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 374 | setRingbackRequested(false); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 375 | setState(Connection.STATE_ACTIVE); |
| 376 | } |
| 377 | |
| 378 | /** |
| 379 | * Sets state to disconnected. |
| 380 | * |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 381 | * @param disconnectCause The reason for the disconnection, as described by |
| 382 | * {@link android.telecom.DisconnectCause}. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 383 | */ |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 384 | public final void setDisconnected(DisconnectCause disconnectCause) { |
| 385 | mDisconnectCause = disconnectCause;; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 386 | setState(Connection.STATE_DISCONNECTED); |
| 387 | for (Listener l : mListeners) { |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 388 | l.onDisconnected(this, mDisconnectCause); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 389 | } |
| 390 | } |
| 391 | |
| 392 | /** |
mike dooley | 1cf14ac | 2014-11-04 10:59:53 -0800 | [diff] [blame] | 393 | * @return The {@link DisconnectCause} for this connection. |
| 394 | */ |
| 395 | public final DisconnectCause getDisconnectCause() { |
| 396 | return mDisconnectCause; |
| 397 | } |
| 398 | |
| 399 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 400 | * Sets the capabilities of a conference. See {@code CAPABILITY_*} constants of class |
| 401 | * {@link Connection} for valid values. |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 402 | * |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 403 | * @param connectionCapabilities A bitmask of the {@code Capabilities} of the conference call. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 404 | */ |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 405 | public final void setConnectionCapabilities(int connectionCapabilities) { |
| 406 | if (connectionCapabilities != mConnectionCapabilities) { |
| 407 | mConnectionCapabilities = connectionCapabilities; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 408 | |
| 409 | for (Listener l : mListeners) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 410 | l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 411 | } |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | /** |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 416 | * Sets the properties of a conference. See {@code PROPERTY_*} constants of class |
| 417 | * {@link Connection} for valid values. |
| 418 | * |
| 419 | * @param connectionProperties A bitmask of the {@code Properties} of the conference call. |
| 420 | */ |
| 421 | public final void setConnectionProperties(int connectionProperties) { |
| 422 | if (connectionProperties != mConnectionProperties) { |
| 423 | mConnectionProperties = connectionProperties; |
| 424 | |
| 425 | for (Listener l : mListeners) { |
| 426 | l.onConnectionPropertiesChanged(this, mConnectionProperties); |
| 427 | } |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | /** |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 432 | * Adds the specified connection as a child of this conference. |
| 433 | * |
| 434 | * @param connection The connection to add. |
| 435 | * @return True if the connection was successfully added. |
| 436 | */ |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 437 | public final boolean addConnection(Connection connection) { |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 438 | Log.d(this, "Connection=%s, connection=", connection); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 439 | if (connection != null && !mChildConnections.contains(connection)) { |
| 440 | if (connection.setConference(this)) { |
| 441 | mChildConnections.add(connection); |
Andrew Lee | 46f7f5d | 2014-11-06 17:00:25 -0800 | [diff] [blame] | 442 | onConnectionAdded(connection); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 443 | for (Listener l : mListeners) { |
| 444 | l.onConnectionAdded(this, connection); |
| 445 | } |
| 446 | return true; |
| 447 | } |
| 448 | } |
| 449 | return false; |
| 450 | } |
| 451 | |
| 452 | /** |
| 453 | * Removes the specified connection as a child of this conference. |
| 454 | * |
| 455 | * @param connection The connection to remove. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 456 | */ |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 457 | public final void removeConnection(Connection connection) { |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 458 | Log.d(this, "removing %s from %s", connection, mChildConnections); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 459 | if (connection != null && mChildConnections.remove(connection)) { |
| 460 | connection.resetConference(); |
| 461 | for (Listener l : mListeners) { |
| 462 | l.onConnectionRemoved(this, connection); |
| 463 | } |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | /** |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 468 | * Sets the connections with which this connection can be conferenced. |
| 469 | * |
| 470 | * @param conferenceableConnections The set of connections this connection can conference with. |
| 471 | */ |
| 472 | public final void setConferenceableConnections(List<Connection> conferenceableConnections) { |
| 473 | clearConferenceableList(); |
| 474 | for (Connection c : conferenceableConnections) { |
| 475 | // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a |
| 476 | // small amount of items here. |
| 477 | if (!mConferenceableConnections.contains(c)) { |
| 478 | c.addConnectionListener(mConnectionDeathListener); |
| 479 | mConferenceableConnections.add(c); |
| 480 | } |
| 481 | } |
| 482 | fireOnConferenceableConnectionsChanged(); |
| 483 | } |
| 484 | |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 485 | /** |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 486 | * Requests that the framework play a ringback tone. This is to be invoked by implementations |
| 487 | * that do not play a ringback tone themselves in the conference's audio stream. |
| 488 | * |
| 489 | * @param ringback Whether the ringback tone is to be played. |
| 490 | */ |
| 491 | public final void setRingbackRequested(boolean ringback) { |
| 492 | if (mRingbackRequested != ringback) { |
| 493 | mRingbackRequested = ringback; |
| 494 | for (Listener l : mListeners) { |
| 495 | l.onRingbackRequested(this, ringback); |
| 496 | } |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | /** |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 501 | * Set the video state for the conference. |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 502 | * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY}, |
| 503 | * {@link VideoProfile#STATE_BIDIRECTIONAL}, |
| 504 | * {@link VideoProfile#STATE_TX_ENABLED}, |
| 505 | * {@link VideoProfile#STATE_RX_ENABLED}. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 506 | * |
| 507 | * @param videoState The new video state. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 508 | */ |
| 509 | public final void setVideoState(Connection c, int videoState) { |
| 510 | Log.d(this, "setVideoState Conference: %s Connection: %s VideoState: %s", |
| 511 | this, c, videoState); |
| 512 | for (Listener l : mListeners) { |
| 513 | l.onVideoStateChanged(this, videoState); |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | /** |
| 518 | * Sets the video connection provider. |
| 519 | * |
| 520 | * @param videoProvider The video provider. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 521 | */ |
| 522 | public final void setVideoProvider(Connection c, Connection.VideoProvider videoProvider) { |
| 523 | Log.d(this, "setVideoProvider Conference: %s Connection: %s VideoState: %s", |
| 524 | this, c, videoProvider); |
| 525 | for (Listener l : mListeners) { |
| 526 | l.onVideoProviderChanged(this, videoProvider); |
| 527 | } |
| 528 | } |
| 529 | |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 530 | private final void fireOnConferenceableConnectionsChanged() { |
| 531 | for (Listener l : mListeners) { |
| 532 | l.onConferenceableConnectionsChanged(this, getConferenceableConnections()); |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | /** |
| 537 | * Returns the connections with which this connection can be conferenced. |
| 538 | */ |
| 539 | public final List<Connection> getConferenceableConnections() { |
| 540 | return mUnmodifiableConferenceableConnections; |
| 541 | } |
| 542 | |
| 543 | /** |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 544 | * Tears down the conference object and any of its current connections. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 545 | */ |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 546 | public final void destroy() { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 547 | Log.d(this, "destroying conference : %s", this); |
| 548 | // Tear down the children. |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 549 | for (Connection connection : mChildConnections) { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 550 | Log.d(this, "removing connection %s", connection); |
| 551 | removeConnection(connection); |
| 552 | } |
| 553 | |
| 554 | // If not yet disconnected, set the conference call as disconnected first. |
| 555 | if (mState != Connection.STATE_DISCONNECTED) { |
| 556 | Log.d(this, "setting to disconnected"); |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 557 | setDisconnected(new DisconnectCause(DisconnectCause.LOCAL)); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | // ...and notify. |
| 561 | for (Listener l : mListeners) { |
| 562 | l.onDestroyed(this); |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | /** |
| 567 | * Add a listener to be notified of a state change. |
| 568 | * |
| 569 | * @param listener The new listener. |
| 570 | * @return This conference. |
| 571 | * @hide |
| 572 | */ |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 573 | final Conference addListener(Listener listener) { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 574 | mListeners.add(listener); |
| 575 | return this; |
| 576 | } |
| 577 | |
| 578 | /** |
| 579 | * Removes the specified listener. |
| 580 | * |
| 581 | * @param listener The listener to remove. |
| 582 | * @return This conference. |
| 583 | * @hide |
| 584 | */ |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 585 | final Conference removeListener(Listener listener) { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 586 | mListeners.remove(listener); |
| 587 | return this; |
| 588 | } |
| 589 | |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 590 | /** |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 591 | * Retrieves the primary connection associated with the conference. The primary connection is |
| 592 | * the connection from which the conference will retrieve its current state. |
| 593 | * |
| 594 | * @return The primary connection. |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 595 | * @hide |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 596 | */ |
Tyler Gunn | 6c14a699 | 2019-02-04 15:12:06 -0800 | [diff] [blame] | 597 | @TestApi |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 598 | @SystemApi |
Santos Cordon | 4055d64 | 2015-05-12 14:19:24 -0700 | [diff] [blame] | 599 | public Connection getPrimaryConnection() { |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 600 | if (mUnmodifiableChildConnections == null || mUnmodifiableChildConnections.isEmpty()) { |
| 601 | return null; |
| 602 | } |
| 603 | return mUnmodifiableChildConnections.get(0); |
| 604 | } |
| 605 | |
| 606 | /** |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 607 | * @hide |
| 608 | * @deprecated Use {@link #setConnectionTime}. |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 609 | */ |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 610 | @Deprecated |
| 611 | @SystemApi |
| 612 | public final void setConnectTimeMillis(long connectTimeMillis) { |
| 613 | setConnectionTime(connectTimeMillis); |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | /** |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 617 | * Sets the connection start time of the {@code Conference}. This is used in the call log to |
| 618 | * indicate the date and time when the conference took place. |
| 619 | * <p> |
| 620 | * Should be specified in wall-clock time returned by {@link System#currentTimeMillis()}. |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 621 | * <p> |
| 622 | * When setting the connection time, you should always set the connection elapsed time via |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 623 | * {@link #setConnectionStartElapsedRealTime(long)} to ensure the duration is reflected. |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 624 | * |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 625 | * @param connectionTimeMillis The connection time, in milliseconds, as returned by |
| 626 | * {@link System#currentTimeMillis()}. |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 627 | */ |
| 628 | public final void setConnectionTime(long connectionTimeMillis) { |
| 629 | mConnectTimeMillis = connectionTimeMillis; |
| 630 | } |
| 631 | |
| 632 | /** |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 633 | * Sets the start time of the {@link Conference} which is the basis for the determining the |
| 634 | * duration of the {@link Conference}. |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 635 | * <p> |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 636 | * You should use a value returned by {@link SystemClock#elapsedRealtime()} to ensure that time |
| 637 | * zone changes do not impact the conference duration. |
| 638 | * <p> |
| 639 | * When setting this, you should also set the connection time via |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 640 | * {@link #setConnectionTime(long)}. |
| 641 | * |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 642 | * @param connectionStartElapsedRealTime The connection time, as measured by |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 643 | * {@link SystemClock#elapsedRealtime()}. |
| 644 | */ |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 645 | public final void setConnectionStartElapsedRealTime(long connectionStartElapsedRealTime) { |
| 646 | mConnectionStartElapsedRealTime = connectionStartElapsedRealTime; |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | /** |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 650 | * @hide |
| 651 | * @deprecated Use {@link #getConnectionTime}. |
| 652 | */ |
| 653 | @Deprecated |
| 654 | @SystemApi |
| 655 | public final long getConnectTimeMillis() { |
| 656 | return getConnectionTime(); |
| 657 | } |
| 658 | |
| 659 | /** |
| 660 | * Retrieves the connection start time of the {@code Conference}, if specified. A value of |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 661 | * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time |
| 662 | * of the conference. |
| 663 | * |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 664 | * @return The time at which the {@code Conference} was connected. |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 665 | */ |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 666 | public final long getConnectionTime() { |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 667 | return mConnectTimeMillis; |
| 668 | } |
| 669 | |
| 670 | /** |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 671 | * Retrieves the connection start time of the {@link Conference}, if specified. A value of |
| 672 | * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time |
| 673 | * of the conference. |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 674 | * <p> |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 675 | * This is based on the value of {@link SystemClock#elapsedRealtime()} to ensure that it is not |
| 676 | * impacted by wall clock changes (user initiated, network initiated, time zone change, etc). |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 677 | * <p> |
| 678 | * Note: This is only exposed for use by the Telephony framework which needs it to copy |
| 679 | * conference start times among conference participants. It is exposed as a system API since it |
| 680 | * has no general use other than to the Telephony framework. |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 681 | * |
| 682 | * @return The elapsed time at which the {@link Conference} was connected. |
| 683 | * @hide |
| 684 | */ |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 685 | @SystemApi |
| 686 | @TestApi |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 687 | public final long getConnectionStartElapsedRealTime() { |
| 688 | return mConnectionStartElapsedRealTime; |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 689 | } |
| 690 | |
| 691 | /** |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 692 | * Inform this Conference that the state of its audio output has been changed externally. |
| 693 | * |
| 694 | * @param state The new audio state. |
| 695 | * @hide |
| 696 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 697 | final void setCallAudioState(CallAudioState state) { |
| 698 | Log.d(this, "setCallAudioState %s", state); |
| 699 | mCallAudioState = state; |
| 700 | onAudioStateChanged(getAudioState()); |
| 701 | onCallAudioStateChanged(state); |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 702 | } |
| 703 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 704 | private void setState(int newState) { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 705 | if (mState != newState) { |
| 706 | int oldState = mState; |
| 707 | mState = newState; |
| 708 | for (Listener l : mListeners) { |
| 709 | l.onStateChanged(this, oldState, newState); |
| 710 | } |
| 711 | } |
| 712 | } |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 713 | |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 714 | private static class FailureSignalingConference extends Conference { |
| 715 | private boolean mImmutable = false; |
| 716 | public FailureSignalingConference(DisconnectCause disconnectCause, |
| 717 | PhoneAccountHandle phoneAccount) { |
| 718 | super(phoneAccount); |
| 719 | setDisconnected(disconnectCause); |
| 720 | mImmutable = true; |
| 721 | } |
| 722 | public void checkImmutable() { |
| 723 | if (mImmutable) { |
| 724 | throw new UnsupportedOperationException("Conference is immutable"); |
| 725 | } |
| 726 | } |
| 727 | } |
| 728 | |
| 729 | /** |
| 730 | * Return a {@code Conference} which represents a failed conference attempt. The returned |
| 731 | * {@code Conference} will have a {@link android.telecom.DisconnectCause} and as specified, |
| 732 | * and a {@link #getState()} of {@code STATE_DISCONNECTED}. |
| 733 | * <p> |
| 734 | * The returned {@code Conference} can be assumed to {@link #destroy()} itself when appropriate, |
| 735 | * so users of this method need not maintain a reference to its return value to destroy it. |
| 736 | * |
| 737 | * @param disconnectCause The disconnect cause, ({@see android.telecomm.DisconnectCause}). |
| 738 | * @return A {@code Conference} which indicates failure. |
| 739 | */ |
| 740 | public @NonNull static Conference createFailedConference( |
| 741 | @NonNull DisconnectCause disconnectCause, @NonNull PhoneAccountHandle phoneAccount) { |
| 742 | return new FailureSignalingConference(disconnectCause, phoneAccount); |
| 743 | } |
| 744 | |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 745 | private final void clearConferenceableList() { |
| 746 | for (Connection c : mConferenceableConnections) { |
| 747 | c.removeConnectionListener(mConnectionDeathListener); |
| 748 | } |
| 749 | mConferenceableConnections.clear(); |
| 750 | } |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 751 | |
| 752 | @Override |
| 753 | public String toString() { |
| 754 | return String.format(Locale.US, |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 755 | "[State: %s,Capabilites: %s, VideoState: %s, VideoProvider: %s," |
| 756 | + "isRingbackRequested: %s, ThisObject %s]", |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 757 | Connection.stateToString(mState), |
| 758 | Call.Details.capabilitiesToString(mConnectionCapabilities), |
| 759 | getVideoState(), |
| 760 | getVideoProvider(), |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 761 | isRingbackRequested() ? "Y" : "N", |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 762 | super.toString()); |
| 763 | } |
Andrew Lee | 0f51da3 | 2015-04-16 13:11:55 -0700 | [diff] [blame] | 764 | |
Andrew Lee | edc625f | 2015-04-14 13:38:12 -0700 | [diff] [blame] | 765 | /** |
| 766 | * Sets the label and icon status to display in the InCall UI. |
| 767 | * |
| 768 | * @param statusHints The status label and icon to set. |
| 769 | */ |
| 770 | public final void setStatusHints(StatusHints statusHints) { |
| 771 | mStatusHints = statusHints; |
| 772 | for (Listener l : mListeners) { |
| 773 | l.onStatusHintsChanged(this, statusHints); |
| 774 | } |
| 775 | } |
| 776 | |
| 777 | /** |
| 778 | * @return The status hints for this conference. |
| 779 | */ |
| 780 | public final StatusHints getStatusHints() { |
| 781 | return mStatusHints; |
| 782 | } |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 783 | |
| 784 | /** |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 785 | * Replaces all the extras associated with this {@code Conference}. |
| 786 | * <p> |
| 787 | * New or existing keys are replaced in the {@code Conference} extras. Keys which are no longer |
| 788 | * in the new extras, but were present the last time {@code setExtras} was called are removed. |
| 789 | * <p> |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 790 | * Alternatively you may use the {@link #putExtras(Bundle)}, and |
| 791 | * {@link #removeExtras(String...)} methods to modify the extras. |
| 792 | * <p> |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 793 | * No assumptions should be made as to how an In-Call UI or service will handle these extras. |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 794 | * Keys should be fully qualified (e.g., com.example.extras.MY_EXTRA) to avoid conflicts. |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 795 | * |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 796 | * @param extras The extras associated with this {@code Conference}. |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 797 | */ |
| 798 | public final void setExtras(@Nullable Bundle extras) { |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 799 | // Keeping putExtras and removeExtras in the same lock so that this operation happens as a |
| 800 | // block instead of letting other threads put/remove while this method is running. |
| 801 | synchronized (mExtrasLock) { |
| 802 | // Add/replace any new or changed extras values. |
| 803 | putExtras(extras); |
| 804 | // If we have used "setExtras" in the past, compare the key set from the last invocation |
| 805 | // to the current one and remove any keys that went away. |
| 806 | if (mPreviousExtraKeys != null) { |
| 807 | List<String> toRemove = new ArrayList<String>(); |
| 808 | for (String oldKey : mPreviousExtraKeys) { |
| 809 | if (extras == null || !extras.containsKey(oldKey)) { |
| 810 | toRemove.add(oldKey); |
| 811 | } |
| 812 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 813 | |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 814 | if (!toRemove.isEmpty()) { |
| 815 | removeExtras(toRemove); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 816 | } |
| 817 | } |
| 818 | |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 819 | // Track the keys the last time set called setExtras. This way, the next time setExtras |
| 820 | // is called we can see if the caller has removed any extras values. |
| 821 | if (mPreviousExtraKeys == null) { |
| 822 | mPreviousExtraKeys = new ArraySet<String>(); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 823 | } |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 824 | mPreviousExtraKeys.clear(); |
| 825 | if (extras != null) { |
| 826 | mPreviousExtraKeys.addAll(extras.keySet()); |
| 827 | } |
Tyler Gunn | a8fb8ab | 2016-03-29 10:24:22 -0700 | [diff] [blame] | 828 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | /** |
| 832 | * Adds some extras to this {@link Conference}. Existing keys are replaced and new ones are |
| 833 | * added. |
| 834 | * <p> |
| 835 | * No assumptions should be made as to how an In-Call UI or service will handle these extras. |
| 836 | * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts. |
| 837 | * |
| 838 | * @param extras The extras to add. |
| 839 | */ |
| 840 | public final void putExtras(@NonNull Bundle extras) { |
| 841 | if (extras == null) { |
| 842 | return; |
| 843 | } |
| 844 | |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 845 | // Creating a Bundle clone so we don't have to synchronize on mExtrasLock while calling |
| 846 | // onExtrasChanged. |
| 847 | Bundle listenersBundle; |
| 848 | synchronized (mExtrasLock) { |
| 849 | if (mExtras == null) { |
| 850 | mExtras = new Bundle(); |
| 851 | } |
| 852 | mExtras.putAll(extras); |
| 853 | listenersBundle = new Bundle(mExtras); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 854 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 855 | |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 856 | for (Listener l : mListeners) { |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 857 | l.onExtrasChanged(this, new Bundle(listenersBundle)); |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 858 | } |
| 859 | } |
| 860 | |
| 861 | /** |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 862 | * Adds a boolean extra to this {@link Conference}. |
| 863 | * |
| 864 | * @param key The extra key. |
| 865 | * @param value The value. |
| 866 | * @hide |
| 867 | */ |
| 868 | public final void putExtra(String key, boolean value) { |
| 869 | Bundle newExtras = new Bundle(); |
| 870 | newExtras.putBoolean(key, value); |
| 871 | putExtras(newExtras); |
| 872 | } |
| 873 | |
| 874 | /** |
| 875 | * Adds an integer extra to this {@link Conference}. |
| 876 | * |
| 877 | * @param key The extra key. |
| 878 | * @param value The value. |
| 879 | * @hide |
| 880 | */ |
| 881 | public final void putExtra(String key, int value) { |
| 882 | Bundle newExtras = new Bundle(); |
| 883 | newExtras.putInt(key, value); |
| 884 | putExtras(newExtras); |
| 885 | } |
| 886 | |
| 887 | /** |
| 888 | * Adds a string extra to this {@link Conference}. |
| 889 | * |
| 890 | * @param key The extra key. |
| 891 | * @param value The value. |
| 892 | * @hide |
| 893 | */ |
| 894 | public final void putExtra(String key, String value) { |
| 895 | Bundle newExtras = new Bundle(); |
| 896 | newExtras.putString(key, value); |
| 897 | putExtras(newExtras); |
| 898 | } |
| 899 | |
| 900 | /** |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 901 | * Removes extras from this {@link Conference}. |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 902 | * |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 903 | * @param keys The keys of the extras to remove. |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 904 | */ |
| 905 | public final void removeExtras(List<String> keys) { |
| 906 | if (keys == null || keys.isEmpty()) { |
| 907 | return; |
| 908 | } |
| 909 | |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 910 | synchronized (mExtrasLock) { |
| 911 | if (mExtras != null) { |
| 912 | for (String key : keys) { |
| 913 | mExtras.remove(key); |
| 914 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 915 | } |
| 916 | } |
| 917 | |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 918 | List<String> unmodifiableKeys = Collections.unmodifiableList(keys); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 919 | for (Listener l : mListeners) { |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 920 | l.onExtrasRemoved(this, unmodifiableKeys); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 921 | } |
| 922 | } |
| 923 | |
| 924 | /** |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 925 | * Removes extras from this {@link Conference}. |
| 926 | * |
| 927 | * @param keys The keys of the extras to remove. |
| 928 | */ |
| 929 | public final void removeExtras(String ... keys) { |
| 930 | removeExtras(Arrays.asList(keys)); |
| 931 | } |
| 932 | |
| 933 | /** |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 934 | * Returns the extras associated with this conference. |
Tyler Gunn | 2cbe2b5 | 2016-05-04 15:48:10 +0000 | [diff] [blame] | 935 | * <p> |
| 936 | * Extras should be updated using {@link #putExtras(Bundle)} and {@link #removeExtras(List)}. |
| 937 | * <p> |
| 938 | * Telecom or an {@link InCallService} can also update the extras via |
| 939 | * {@link android.telecom.Call#putExtras(Bundle)}, and |
| 940 | * {@link Call#removeExtras(List)}. |
| 941 | * <p> |
| 942 | * The conference is notified of changes to the extras made by Telecom or an |
| 943 | * {@link InCallService} by {@link #onExtrasChanged(Bundle)}. |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 944 | * |
| 945 | * @return The extras associated with this connection. |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 946 | */ |
| 947 | public final Bundle getExtras() { |
| 948 | return mExtras; |
| 949 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 950 | |
| 951 | /** |
| 952 | * Notifies this {@link Conference} of a change to the extras made outside the |
| 953 | * {@link ConnectionService}. |
| 954 | * <p> |
| 955 | * These extras changes can originate from Telecom itself, or from an {@link InCallService} via |
| 956 | * {@link android.telecom.Call#putExtras(Bundle)}, and |
| 957 | * {@link Call#removeExtras(List)}. |
| 958 | * |
| 959 | * @param extras The new extras bundle. |
| 960 | */ |
| 961 | public void onExtrasChanged(Bundle extras) {} |
| 962 | |
| 963 | /** |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 964 | * Set whether Telecom should treat this {@link Conference} as a conference call or if it |
| 965 | * should treat it as a single-party call. |
| 966 | * This method is used as part of a workaround regarding IMS conference calls and user |
| 967 | * expectation. In IMS, once a conference is formed, the UE is connected to an IMS conference |
| 968 | * server. If all participants of the conference drop out of the conference except for one, the |
| 969 | * UE is still connected to the IMS conference server. At this point, the user logically |
| 970 | * assumes they're no longer in a conference, yet the underlying network actually is. |
| 971 | * To help provide a better user experiece, IMS conference calls can pretend to actually be a |
| 972 | * single-party call when the participant count drops to 1. Although the dialer/phone app |
| 973 | * could perform this trickery, it makes sense to do this in Telephony since a fix there will |
| 974 | * ensure that bluetooth head units, auto and wearable apps all behave consistently. |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 975 | * <p> |
| 976 | * This API is intended for use by the platform Telephony stack only. |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 977 | * |
| 978 | * @param isConference {@code true} if this {@link Conference} should be treated like a |
| 979 | * conference call, {@code false} if it should be treated like a single-party call. |
| 980 | * @hide |
| 981 | */ |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 982 | @SystemApi |
| 983 | @TestApi |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 984 | public void setConferenceState(boolean isConference) { |
| 985 | for (Listener l : mListeners) { |
| 986 | l.onConferenceStateChanged(this, isConference); |
| 987 | } |
| 988 | } |
| 989 | |
| 990 | /** |
| 991 | * Sets the address of this {@link Conference}. Used when {@link #setConferenceState(boolean)} |
| 992 | * is called to mark a conference temporarily as NOT a conference. |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 993 | * <p> |
| 994 | * Note: This is a Telephony-specific implementation detail related to IMS conferences. It is |
| 995 | * not intended for use outside of the Telephony stack. |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 996 | * |
| 997 | * @param address The new address. |
| 998 | * @param presentation The presentation requirements for the address. |
| 999 | * See {@link TelecomManager} for valid values. |
| 1000 | * @hide |
| 1001 | */ |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1002 | @SystemApi |
| 1003 | @TestApi |
| 1004 | public final void setAddress(@NonNull Uri address, |
| 1005 | @TelecomManager.Presentation int presentation) { |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 1006 | Log.d(this, "setAddress %s", address); |
Tyler Gunn | ac60f95 | 2019-05-31 07:23:16 -0700 | [diff] [blame] | 1007 | mAddress = address; |
| 1008 | mAddressPresentation = presentation; |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 1009 | for (Listener l : mListeners) { |
| 1010 | l.onAddressChanged(this, address, presentation); |
| 1011 | } |
| 1012 | } |
| 1013 | |
| 1014 | /** |
Tyler Gunn | ac60f95 | 2019-05-31 07:23:16 -0700 | [diff] [blame] | 1015 | * Returns the "address" associated with the conference. This is applicable in two cases: |
| 1016 | * <ol> |
| 1017 | * <li>When {@link #setConferenceState(boolean)} is used to mark a conference as |
| 1018 | * temporarily "not a conference"; we need to present the correct address in the in-call |
| 1019 | * UI.</li> |
| 1020 | * <li>When the conference is not hosted on the current device, we need to know the address |
| 1021 | * information for the purpose of showing the original address to the user, as well as for |
| 1022 | * logging to the call log.</li> |
| 1023 | * </ol> |
| 1024 | * @return The address of the conference, or {@code null} if not applicable. |
| 1025 | * @hide |
| 1026 | */ |
| 1027 | public final Uri getAddress() { |
| 1028 | return mAddress; |
| 1029 | } |
| 1030 | |
| 1031 | /** |
| 1032 | * Returns the address presentation associated with the conference. |
| 1033 | * <p> |
| 1034 | * This is applicable in two cases: |
| 1035 | * <ol> |
| 1036 | * <li>When {@link #setConferenceState(boolean)} is used to mark a conference as |
| 1037 | * temporarily "not a conference"; we need to present the correct address in the in-call |
| 1038 | * UI.</li> |
| 1039 | * <li>When the conference is not hosted on the current device, we need to know the address |
| 1040 | * information for the purpose of showing the original address to the user, as well as for |
| 1041 | * logging to the call log.</li> |
| 1042 | * </ol> |
| 1043 | * @return The address of the conference, or {@code null} if not applicable. |
| 1044 | * @hide |
| 1045 | */ |
| 1046 | public final int getAddressPresentation() { |
| 1047 | return mAddressPresentation; |
| 1048 | } |
| 1049 | |
| 1050 | /** |
| 1051 | * @return The caller display name (CNAP). |
| 1052 | * @hide |
| 1053 | */ |
| 1054 | public final String getCallerDisplayName() { |
| 1055 | return mCallerDisplayName; |
| 1056 | } |
| 1057 | |
| 1058 | /** |
| 1059 | * @return The presentation requirements for the handle. |
| 1060 | * See {@link TelecomManager} for valid values. |
| 1061 | * @hide |
| 1062 | */ |
| 1063 | public final int getCallerDisplayNamePresentation() { |
| 1064 | return mCallerDisplayNamePresentation; |
| 1065 | } |
| 1066 | |
| 1067 | /** |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 1068 | * Sets the caller display name (CNAP) of this {@link Conference}. Used when |
| 1069 | * {@link #setConferenceState(boolean)} is called to mark a conference temporarily as NOT a |
| 1070 | * conference. |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1071 | * <p> |
| 1072 | * Note: This is a Telephony-specific implementation detail related to IMS conferences. It is |
| 1073 | * not intended for use outside of the Telephony stack. |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 1074 | * |
| 1075 | * @param callerDisplayName The new display name. |
| 1076 | * @param presentation The presentation requirements for the handle. |
| 1077 | * See {@link TelecomManager} for valid values. |
| 1078 | * @hide |
| 1079 | */ |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1080 | @SystemApi |
| 1081 | @TestApi |
| 1082 | public final void setCallerDisplayName(@NonNull String callerDisplayName, |
| 1083 | @TelecomManager.Presentation int presentation) { |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 1084 | Log.d(this, "setCallerDisplayName %s", callerDisplayName); |
Tyler Gunn | ac60f95 | 2019-05-31 07:23:16 -0700 | [diff] [blame] | 1085 | mCallerDisplayName = callerDisplayName; |
| 1086 | mCallerDisplayNamePresentation = presentation; |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 1087 | for (Listener l : mListeners) { |
| 1088 | l.onCallerDisplayNameChanged(this, callerDisplayName, presentation); |
| 1089 | } |
| 1090 | } |
| 1091 | |
| 1092 | /** |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1093 | * Handles a change to extras received from Telecom. |
| 1094 | * |
| 1095 | * @param extras The new extras. |
| 1096 | * @hide |
| 1097 | */ |
| 1098 | final void handleExtrasChanged(Bundle extras) { |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 1099 | Bundle b = null; |
| 1100 | synchronized (mExtrasLock) { |
| 1101 | mExtras = extras; |
| 1102 | if (mExtras != null) { |
| 1103 | b = new Bundle(mExtras); |
| 1104 | } |
| 1105 | } |
| 1106 | onExtrasChanged(b); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1107 | } |
Hall Liu | c9bc1c6 | 2019-04-16 14:00:55 -0700 | [diff] [blame] | 1108 | |
| 1109 | /** |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1110 | * Sends an event associated with this {@code Conference} with associated event extras to the |
| 1111 | * {@link InCallService} (note: this is identical in concept to |
| 1112 | * {@link Connection#sendConnectionEvent(String, Bundle)}). |
| 1113 | * @see Connection#sendConnectionEvent(String, Bundle) |
| 1114 | * |
| 1115 | * @param event The connection event. |
| 1116 | * @param extras Optional bundle containing extra information associated with the event. |
Hall Liu | c9bc1c6 | 2019-04-16 14:00:55 -0700 | [diff] [blame] | 1117 | */ |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1118 | public void sendConferenceEvent(@NonNull String event, @Nullable Bundle extras) { |
Hall Liu | c9bc1c6 | 2019-04-16 14:00:55 -0700 | [diff] [blame] | 1119 | for (Listener l : mListeners) { |
| 1120 | l.onConnectionEvent(this, event, extras); |
| 1121 | } |
| 1122 | } |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1123 | } |