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