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 | |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 19 | import android.annotation.NonNull; |
| 20 | import android.annotation.Nullable; |
| 21 | import android.annotation.SystemApi; |
| 22 | import android.annotation.TestApi; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 23 | import android.net.Uri; |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 24 | import android.os.Bundle; |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 25 | import android.os.Parcel; |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 26 | import android.os.ParcelFileDescriptor; |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 27 | import android.os.Parcelable; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 28 | |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame^] | 29 | import java.util.ArrayList; |
| 30 | import java.util.List; |
| 31 | |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 32 | /** |
| 33 | * Simple data container encapsulating a request to some entity to |
| 34 | * create a new {@link Connection}. |
| 35 | */ |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 36 | public final class ConnectionRequest implements Parcelable { |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 37 | |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 38 | /** |
| 39 | * Builder class for {@link ConnectionRequest} |
| 40 | * @hide |
| 41 | */ |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 42 | @TestApi // For convenience in CTS tests |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 43 | public static final class Builder { |
| 44 | private PhoneAccountHandle mAccountHandle; |
| 45 | private Uri mAddress; |
| 46 | private Bundle mExtras; |
| 47 | private int mVideoState = VideoProfile.STATE_AUDIO_ONLY; |
| 48 | private String mTelecomCallId; |
| 49 | private boolean mShouldShowIncomingCallUi = false; |
| 50 | private ParcelFileDescriptor mRttPipeToInCall; |
| 51 | private ParcelFileDescriptor mRttPipeFromInCall; |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame^] | 52 | private List<Uri> mParticipants; |
| 53 | private boolean mIsAdhocConference = false; |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 54 | |
| 55 | public Builder() { } |
| 56 | |
| 57 | /** |
| 58 | * Sets the phone account handle for the resulting {@link ConnectionRequest} |
| 59 | * @param accountHandle The accountHandle which should be used to place the call. |
| 60 | */ |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 61 | public @NonNull Builder setAccountHandle(@NonNull PhoneAccountHandle accountHandle) { |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 62 | this.mAccountHandle = accountHandle; |
| 63 | return this; |
| 64 | } |
| 65 | |
| 66 | /** |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame^] | 67 | * Sets the participants for the resulting {@link ConnectionRequest} |
| 68 | * @param participants The participants to which the {@link Connection} is to connect. |
| 69 | */ |
| 70 | public @NonNull Builder setParticipants(@Nullable List<Uri> participants) { |
| 71 | this.mParticipants = participants; |
| 72 | return this; |
| 73 | } |
| 74 | |
| 75 | /** |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 76 | * Sets the address for the resulting {@link ConnectionRequest} |
| 77 | * @param address The address(e.g., phone number) to which the {@link Connection} is to |
| 78 | * connect. |
| 79 | */ |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 80 | public @NonNull Builder setAddress(@NonNull Uri address) { |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 81 | this.mAddress = address; |
| 82 | return this; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Sets the extras bundle for the resulting {@link ConnectionRequest} |
| 87 | * @param extras Application-specific extra data. |
| 88 | */ |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 89 | public @NonNull Builder setExtras(@NonNull Bundle extras) { |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 90 | this.mExtras = extras; |
| 91 | return this; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Sets the video state for the resulting {@link ConnectionRequest} |
| 96 | * @param videoState Determines the video state for the connection. |
| 97 | */ |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 98 | public @NonNull Builder setVideoState(int videoState) { |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 99 | this.mVideoState = videoState; |
| 100 | return this; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Sets the Telecom call ID for the resulting {@link ConnectionRequest} |
| 105 | * @param telecomCallId The telecom call ID. |
| 106 | */ |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 107 | public @NonNull Builder setTelecomCallId(@NonNull String telecomCallId) { |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 108 | this.mTelecomCallId = telecomCallId; |
| 109 | return this; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Sets shouldShowIncomingUi for the resulting {@link ConnectionRequest} |
| 114 | * @param shouldShowIncomingCallUi For a self-managed {@link ConnectionService}, will be |
| 115 | * {@code true} if the {@link ConnectionService} should show |
| 116 | * its own incoming call UI for an incoming call. When |
| 117 | * {@code false}, Telecom shows the incoming call UI. |
| 118 | */ |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 119 | public @NonNull Builder setShouldShowIncomingCallUi(boolean shouldShowIncomingCallUi) { |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 120 | this.mShouldShowIncomingCallUi = shouldShowIncomingCallUi; |
| 121 | return this; |
| 122 | } |
| 123 | |
| 124 | /** |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame^] | 125 | * Sets isAdhocConference for the resulting {@link ConnectionRequest} |
| 126 | * @param isAdhocConference {@code true} if it is a adhoc conference call |
| 127 | * {@code false}, if not a adhoc conference call |
| 128 | */ |
| 129 | public @NonNull Builder setIsAdhocConferenceCall(boolean isAdhocConference) { |
| 130 | this.mIsAdhocConference = isAdhocConference; |
| 131 | return this; |
| 132 | } |
| 133 | |
| 134 | /** |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 135 | * Sets the RTT pipe for transferring text into the {@link ConnectionService} for the |
| 136 | * resulting {@link ConnectionRequest} |
| 137 | * @param rttPipeFromInCall The data pipe to read from. |
| 138 | */ |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 139 | public @NonNull Builder setRttPipeFromInCall( |
| 140 | @NonNull ParcelFileDescriptor rttPipeFromInCall) { |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 141 | this.mRttPipeFromInCall = rttPipeFromInCall; |
| 142 | return this; |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Sets the RTT pipe for transferring text out of {@link ConnectionService} for the |
| 147 | * resulting {@link ConnectionRequest} |
| 148 | * @param rttPipeToInCall The data pipe to write to. |
| 149 | */ |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 150 | public @NonNull Builder setRttPipeToInCall(@NonNull ParcelFileDescriptor rttPipeToInCall) { |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 151 | this.mRttPipeToInCall = rttPipeToInCall; |
| 152 | return this; |
| 153 | } |
| 154 | |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 155 | /** |
| 156 | * Build the {@link ConnectionRequest} |
| 157 | * @return Result of the builder |
| 158 | */ |
| 159 | public @NonNull ConnectionRequest build() { |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 160 | return new ConnectionRequest( |
| 161 | mAccountHandle, |
| 162 | mAddress, |
| 163 | mExtras, |
| 164 | mVideoState, |
| 165 | mTelecomCallId, |
| 166 | mShouldShowIncomingCallUi, |
| 167 | mRttPipeFromInCall, |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame^] | 168 | mRttPipeToInCall, |
| 169 | mParticipants, |
| 170 | mIsAdhocConference); |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 171 | } |
| 172 | } |
| 173 | |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 174 | private final PhoneAccountHandle mAccountHandle; |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 175 | private final Uri mAddress; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 176 | private final Bundle mExtras; |
Tyler Gunn | 12013ad | 2014-07-08 14:04:58 -0700 | [diff] [blame] | 177 | private final int mVideoState; |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 178 | private final String mTelecomCallId; |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 179 | private final boolean mShouldShowIncomingCallUi; |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 180 | private final ParcelFileDescriptor mRttPipeToInCall; |
| 181 | private final ParcelFileDescriptor mRttPipeFromInCall; |
Hall Liu | e904124 | 2018-02-09 16:40:03 -0800 | [diff] [blame] | 182 | // Cached return value of getRttTextStream -- we don't want to wrap it more than once. |
| 183 | private Connection.RttTextStream mRttTextStream; |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame^] | 184 | private List<Uri> mParticipants; |
| 185 | private final boolean mIsAdhocConference; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 186 | |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 187 | /** |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 188 | * @param accountHandle The accountHandle which should be used to place the call. |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 189 | * @param handle The handle (e.g., phone number) to which the {@link Connection} is to connect. |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 190 | * @param extras Application-specific extra data. |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 191 | */ |
| 192 | public ConnectionRequest( |
| 193 | PhoneAccountHandle accountHandle, |
| 194 | Uri handle, |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 195 | Bundle extras) { |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 196 | this(accountHandle, handle, extras, VideoProfile.STATE_AUDIO_ONLY, null, false, null, null); |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | /** |
| 200 | * @param accountHandle The accountHandle which should be used to place the call. |
| 201 | * @param handle The handle (e.g., phone number) to which the {@link Connection} is to connect. |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 202 | * @param extras Application-specific extra data. |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 203 | * @param videoState Determines the video state for the connection. |
| 204 | */ |
| 205 | public ConnectionRequest( |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 206 | PhoneAccountHandle accountHandle, |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 207 | Uri handle, |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 208 | Bundle extras, |
Tyler Gunn | 12013ad | 2014-07-08 14:04:58 -0700 | [diff] [blame] | 209 | int videoState) { |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 210 | this(accountHandle, handle, extras, videoState, null, false, null, null); |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | /** |
| 214 | * @param accountHandle The accountHandle which should be used to place the call. |
| 215 | * @param handle The handle (e.g., phone number) to which the {@link Connection} is to connect. |
| 216 | * @param extras Application-specific extra data. |
| 217 | * @param videoState Determines the video state for the connection. |
| 218 | * @param telecomCallId The telecom call ID. |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 219 | * @param shouldShowIncomingCallUi For a self-managed {@link ConnectionService}, will be |
| 220 | * {@code true} if the {@link ConnectionService} should show its |
| 221 | * own incoming call UI for an incoming call. When |
| 222 | * {@code false}, Telecom shows the incoming call UI. |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 223 | * @hide |
| 224 | */ |
| 225 | public ConnectionRequest( |
| 226 | PhoneAccountHandle accountHandle, |
| 227 | Uri handle, |
| 228 | Bundle extras, |
| 229 | int videoState, |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 230 | String telecomCallId, |
| 231 | boolean shouldShowIncomingCallUi) { |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 232 | this(accountHandle, handle, extras, videoState, telecomCallId, |
| 233 | shouldShowIncomingCallUi, null, null); |
| 234 | } |
| 235 | |
| 236 | private ConnectionRequest( |
| 237 | PhoneAccountHandle accountHandle, |
| 238 | Uri handle, |
| 239 | Bundle extras, |
| 240 | int videoState, |
| 241 | String telecomCallId, |
| 242 | boolean shouldShowIncomingCallUi, |
| 243 | ParcelFileDescriptor rttPipeFromInCall, |
| 244 | ParcelFileDescriptor rttPipeToInCall) { |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame^] | 245 | this(accountHandle, handle, extras, videoState, telecomCallId, |
| 246 | shouldShowIncomingCallUi, rttPipeFromInCall, rttPipeToInCall, null, false); |
| 247 | } |
| 248 | |
| 249 | private ConnectionRequest( |
| 250 | PhoneAccountHandle accountHandle, |
| 251 | Uri handle, |
| 252 | Bundle extras, |
| 253 | int videoState, |
| 254 | String telecomCallId, |
| 255 | boolean shouldShowIncomingCallUi, |
| 256 | ParcelFileDescriptor rttPipeFromInCall, |
| 257 | ParcelFileDescriptor rttPipeToInCall, |
| 258 | List<Uri> participants, |
| 259 | boolean isAdhocConference) { |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 260 | mAccountHandle = accountHandle; |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 261 | mAddress = handle; |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 262 | mExtras = extras; |
Tyler Gunn | 12013ad | 2014-07-08 14:04:58 -0700 | [diff] [blame] | 263 | mVideoState = videoState; |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 264 | mTelecomCallId = telecomCallId; |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 265 | mShouldShowIncomingCallUi = shouldShowIncomingCallUi; |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 266 | mRttPipeFromInCall = rttPipeFromInCall; |
| 267 | mRttPipeToInCall = rttPipeToInCall; |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame^] | 268 | mParticipants = participants; |
| 269 | mIsAdhocConference = isAdhocConference; |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 270 | } |
| 271 | |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 272 | private ConnectionRequest(Parcel in) { |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 273 | mAccountHandle = in.readParcelable(getClass().getClassLoader()); |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 274 | mAddress = in.readParcelable(getClass().getClassLoader()); |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 275 | mExtras = in.readParcelable(getClass().getClassLoader()); |
| 276 | mVideoState = in.readInt(); |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 277 | mTelecomCallId = in.readString(); |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 278 | mShouldShowIncomingCallUi = in.readInt() == 1; |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 279 | mRttPipeFromInCall = in.readParcelable(getClass().getClassLoader()); |
| 280 | mRttPipeToInCall = in.readParcelable(getClass().getClassLoader()); |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame^] | 281 | |
| 282 | mParticipants = new ArrayList<Uri>(); |
| 283 | in.readList(mParticipants, getClass().getClassLoader()); |
| 284 | |
| 285 | mIsAdhocConference = in.readInt() == 1; |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 286 | } |
| 287 | |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 288 | /** |
Ihab Awad | 9c3f188 | 2014-06-30 21:17:13 -0700 | [diff] [blame] | 289 | * The account which should be used to place the call. |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 290 | */ |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 291 | public PhoneAccountHandle getAccountHandle() { return mAccountHandle; } |
Santos Cordon | 52d8a15 | 2014-06-17 19:08:45 -0700 | [diff] [blame] | 292 | |
| 293 | /** |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 294 | * The handle (e.g., phone number) to which the {@link Connection} is to connect. |
| 295 | */ |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 296 | public Uri getAddress() { return mAddress; } |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 297 | |
| 298 | /** |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame^] | 299 | * The participants to which the {@link Connection} is to connect. |
| 300 | */ |
| 301 | public @Nullable List<Uri> getParticipants() { return mParticipants; } |
| 302 | |
| 303 | /** |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 304 | * Application-specific extra data. Used for passing back information from an incoming |
| 305 | * call {@code Intent}, and for any proprietary extensions arranged between a client |
| 306 | * and servant {@code ConnectionService} which agree on a vocabulary for such data. |
| 307 | */ |
| 308 | public Bundle getExtras() { return mExtras; } |
| 309 | |
Tyler Gunn | 12013ad | 2014-07-08 14:04:58 -0700 | [diff] [blame] | 310 | /** |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 311 | * Describes the video states supported by the client requesting the connection. |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 312 | * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY}, |
| 313 | * {@link VideoProfile#STATE_BIDIRECTIONAL}, |
| 314 | * {@link VideoProfile#STATE_TX_ENABLED}, |
| 315 | * {@link VideoProfile#STATE_RX_ENABLED}. |
Tyler Gunn | 12013ad | 2014-07-08 14:04:58 -0700 | [diff] [blame] | 316 | * |
| 317 | * @return The video state for the connection. |
| 318 | */ |
| 319 | public int getVideoState() { |
| 320 | return mVideoState; |
| 321 | } |
| 322 | |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 323 | /** |
| 324 | * Returns the internal Telecom ID associated with the connection request. |
| 325 | * |
| 326 | * @return The Telecom ID. |
| 327 | * @hide |
| 328 | */ |
Hall Liu | b230624 | 2019-11-15 17:13:05 -0800 | [diff] [blame] | 329 | @SystemApi |
| 330 | @TestApi |
| 331 | public @Nullable String getTelecomCallId() { |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 332 | return mTelecomCallId; |
| 333 | } |
| 334 | |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 335 | /** |
| 336 | * For a self-managed {@link ConnectionService}, indicates for an incoming call whether the |
| 337 | * {@link ConnectionService} should show its own incoming call UI for an incoming call. |
| 338 | * |
| 339 | * @return {@code true} if the {@link ConnectionService} should show its own incoming call UI. |
| 340 | * When {@code false}, Telecom shows the incoming call UI for the call. |
| 341 | * @hide |
| 342 | */ |
| 343 | public boolean shouldShowIncomingCallUi() { |
| 344 | return mShouldShowIncomingCallUi; |
| 345 | } |
| 346 | |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 347 | /** |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame^] | 348 | * @return {@code true} if the call is a adhoc conference call else @return {@code false} |
| 349 | */ |
| 350 | public boolean isAdhocConferenceCall() { |
| 351 | return mIsAdhocConference; |
| 352 | } |
| 353 | |
| 354 | /** |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 355 | * Gets the {@link ParcelFileDescriptor} that is used to send RTT text from the connection |
| 356 | * service to the in-call UI. In order to obtain an |
| 357 | * {@link java.io.InputStream} from this {@link ParcelFileDescriptor}, use |
| 358 | * {@link android.os.ParcelFileDescriptor.AutoCloseInputStream}. |
| 359 | * Only text data encoded using UTF-8 should be written into this {@link ParcelFileDescriptor}. |
| 360 | * @return The {@link ParcelFileDescriptor} that should be used for communication. |
| 361 | * Do not un-hide -- only for use by Telephony |
| 362 | * @hide |
| 363 | */ |
| 364 | public ParcelFileDescriptor getRttPipeToInCall() { |
| 365 | return mRttPipeToInCall; |
| 366 | } |
| 367 | |
| 368 | /** |
| 369 | * Gets the {@link ParcelFileDescriptor} that is used to send RTT text from the in-call UI to |
| 370 | * the connection service. In order to obtain an |
| 371 | * {@link java.io.OutputStream} from this {@link ParcelFileDescriptor}, use |
| 372 | * {@link android.os.ParcelFileDescriptor.AutoCloseOutputStream}. |
| 373 | * The contents of this {@link ParcelFileDescriptor} will consist solely of text encoded in |
| 374 | * UTF-8. |
| 375 | * @return The {@link ParcelFileDescriptor} that should be used for communication |
| 376 | * Do not un-hide -- only for use by Telephony |
| 377 | * @hide |
| 378 | */ |
| 379 | public ParcelFileDescriptor getRttPipeFromInCall() { |
| 380 | return mRttPipeFromInCall; |
| 381 | } |
| 382 | |
| 383 | /** |
| 384 | * Gets the {@link android.telecom.Connection.RttTextStream} object that should be used to |
| 385 | * send and receive RTT text to/from the in-call app. |
| 386 | * @return An instance of {@link android.telecom.Connection.RttTextStream}, or {@code null} |
| 387 | * if this connection request is not requesting an RTT session upon connection establishment. |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 388 | */ |
| 389 | public Connection.RttTextStream getRttTextStream() { |
| 390 | if (isRequestingRtt()) { |
Hall Liu | e904124 | 2018-02-09 16:40:03 -0800 | [diff] [blame] | 391 | if (mRttTextStream == null) { |
| 392 | mRttTextStream = new Connection.RttTextStream(mRttPipeToInCall, mRttPipeFromInCall); |
| 393 | } |
| 394 | return mRttTextStream; |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 395 | } else { |
| 396 | return null; |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | /** |
| 401 | * Convenience method for determining whether the ConnectionRequest is requesting an RTT session |
| 402 | * @return {@code true} if RTT is requested, {@code false} otherwise. |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 403 | */ |
| 404 | public boolean isRequestingRtt() { |
| 405 | return mRttPipeFromInCall != null && mRttPipeToInCall != null; |
| 406 | } |
| 407 | |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 408 | @Override |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 409 | public String toString() { |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame^] | 410 | return String.format("ConnectionRequest %s %s isAdhocConf: %s", |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 411 | mAddress == null |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 412 | ? Uri.EMPTY |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 413 | : Connection.toLogSafePhoneNumber(mAddress.toString()), |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame^] | 414 | bundleToString(mExtras), |
| 415 | isAdhocConferenceCall() ? "Y" : "N"); |
Shi Yuanjie | afea7de | 2018-07-19 20:30:10 +0900 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | private static String bundleToString(Bundle extras){ |
| 419 | if (extras == null) { |
| 420 | return ""; |
| 421 | } |
| 422 | StringBuilder sb = new StringBuilder(); |
| 423 | sb.append("Bundle["); |
| 424 | for (String key : extras.keySet()) { |
| 425 | sb.append(key); |
| 426 | sb.append("="); |
| 427 | switch (key) { |
| 428 | case TelecomManager.EXTRA_INCOMING_CALL_ADDRESS: |
| 429 | case TelecomManager.EXTRA_UNKNOWN_CALL_HANDLE: |
| 430 | sb.append(Log.pii(extras.get(key))); |
| 431 | break; |
| 432 | default: |
| 433 | sb.append(extras.get(key)); |
| 434 | break; |
| 435 | } |
| 436 | sb.append(", "); |
| 437 | } |
| 438 | sb.append("]"); |
| 439 | return sb.toString(); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 440 | } |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 441 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 442 | public static final @android.annotation.NonNull Creator<ConnectionRequest> CREATOR = new Creator<ConnectionRequest> () { |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 443 | @Override |
| 444 | public ConnectionRequest createFromParcel(Parcel source) { |
| 445 | return new ConnectionRequest(source); |
| 446 | } |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 447 | |
Sailesh Nepal | c5b0157 | 2014-07-14 16:29:44 -0700 | [diff] [blame] | 448 | @Override |
| 449 | public ConnectionRequest[] newArray(int size) { |
| 450 | return new ConnectionRequest[size]; |
| 451 | } |
| 452 | }; |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 453 | |
| 454 | /** |
| 455 | * {@inheritDoc} |
| 456 | */ |
| 457 | @Override |
| 458 | public int describeContents() { |
| 459 | return 0; |
| 460 | } |
| 461 | |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 462 | @Override |
| 463 | public void writeToParcel(Parcel destination, int flags) { |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 464 | destination.writeParcelable(mAccountHandle, 0); |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 465 | destination.writeParcelable(mAddress, 0); |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 466 | destination.writeParcelable(mExtras, 0); |
Tyler Gunn | 12013ad | 2014-07-08 14:04:58 -0700 | [diff] [blame] | 467 | destination.writeInt(mVideoState); |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 468 | destination.writeString(mTelecomCallId); |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 469 | destination.writeInt(mShouldShowIncomingCallUi ? 1 : 0); |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 470 | destination.writeParcelable(mRttPipeFromInCall, 0); |
| 471 | destination.writeParcelable(mRttPipeToInCall, 0); |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame^] | 472 | destination.writeList(mParticipants); |
| 473 | destination.writeInt(mIsAdhocConference ? 1 : 0); |
Tyler Gunn | 12013ad | 2014-07-08 14:04:58 -0700 | [diff] [blame] | 474 | } |
| 475 | } |