blob: f691c179af53b79f2de642a3ece630e4d887526e [file] [log] [blame]
Ihab Awad542e0ea2014-05-16 10:22:16 -07001/*
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 Gunnef9f6f92014-09-12 22:16:17 -070017package android.telecom;
Ihab Awad542e0ea2014-05-16 10:22:16 -070018
Tyler Gunn711d876fd2014-09-19 11:17:02 -070019import android.annotation.SystemApi;
Ihab Awad542e0ea2014-05-16 10:22:16 -070020import android.net.Uri;
Sailesh Nepal61203862014-07-11 14:50:13 -070021import android.os.Bundle;
Ihab Awadfbb092f2014-06-03 18:40:45 -070022import android.os.Parcel;
23import android.os.Parcelable;
Ihab Awad542e0ea2014-05-16 10:22:16 -070024
25/**
26 * Simple data container encapsulating a request to some entity to
27 * create a new {@link Connection}.
Tyler Gunn711d876fd2014-09-19 11:17:02 -070028 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -070029 */
Tyler Gunn711d876fd2014-09-19 11:17:02 -070030@SystemApi
Ihab Awadfbb092f2014-06-03 18:40:45 -070031public final class ConnectionRequest implements Parcelable {
Ihab Awad542e0ea2014-05-16 10:22:16 -070032
33 // TODO: Token to limit recursive invocations
Evan Charlton8c8a0622014-07-20 12:31:00 -070034 private final PhoneAccountHandle mAccountHandle;
Nancy Chenea38cca2014-09-05 16:38:49 -070035 private final Uri mAddress;
Ihab Awad542e0ea2014-05-16 10:22:16 -070036 private final Bundle mExtras;
Tyler Gunn12013ad2014-07-08 14:04:58 -070037 private final int mVideoState;
Ihab Awad542e0ea2014-05-16 10:22:16 -070038
Sailesh Nepal61203862014-07-11 14:50:13 -070039 /**
Evan Charlton8c8a0622014-07-20 12:31:00 -070040 * @param accountHandle The accountHandle which should be used to place the call.
Sailesh Nepal61203862014-07-11 14:50:13 -070041 * @param handle The handle (e.g., phone number) to which the {@link Connection} is to connect.
Sailesh Nepal61203862014-07-11 14:50:13 -070042 * @param extras Application-specific extra data.
Tyler Gunnbe74de02014-08-29 14:51:48 -070043 */
44 public ConnectionRequest(
45 PhoneAccountHandle accountHandle,
46 Uri handle,
Tyler Gunnbe74de02014-08-29 14:51:48 -070047 Bundle extras) {
Nancy Chenea38cca2014-09-05 16:38:49 -070048 this(accountHandle, handle, extras, VideoProfile.VideoState.AUDIO_ONLY);
Tyler Gunnbe74de02014-08-29 14:51:48 -070049 }
50
51 /**
52 * @param accountHandle The accountHandle which should be used to place the call.
53 * @param handle The handle (e.g., phone number) to which the {@link Connection} is to connect.
Tyler Gunnbe74de02014-08-29 14:51:48 -070054 * @param extras Application-specific extra data.
Sailesh Nepal61203862014-07-11 14:50:13 -070055 * @param videoState Determines the video state for the connection.
Tyler Gunnbe74de02014-08-29 14:51:48 -070056 * @hide
Sailesh Nepal61203862014-07-11 14:50:13 -070057 */
58 public ConnectionRequest(
Evan Charlton8c8a0622014-07-20 12:31:00 -070059 PhoneAccountHandle accountHandle,
Sailesh Nepal61203862014-07-11 14:50:13 -070060 Uri handle,
Sailesh Nepal61203862014-07-11 14:50:13 -070061 Bundle extras,
Tyler Gunn12013ad2014-07-08 14:04:58 -070062 int videoState) {
Evan Charlton8c8a0622014-07-20 12:31:00 -070063 mAccountHandle = accountHandle;
Nancy Chenea38cca2014-09-05 16:38:49 -070064 mAddress = handle;
Ihab Awadfbb092f2014-06-03 18:40:45 -070065 mExtras = extras;
Tyler Gunn12013ad2014-07-08 14:04:58 -070066 mVideoState = videoState;
Ihab Awadfbb092f2014-06-03 18:40:45 -070067 }
68
Sailesh Nepalc5b01572014-07-14 16:29:44 -070069 private ConnectionRequest(Parcel in) {
Evan Charlton8c8a0622014-07-20 12:31:00 -070070 mAccountHandle = in.readParcelable(getClass().getClassLoader());
Nancy Chenea38cca2014-09-05 16:38:49 -070071 mAddress = in.readParcelable(getClass().getClassLoader());
Sailesh Nepalc5b01572014-07-14 16:29:44 -070072 mExtras = in.readParcelable(getClass().getClassLoader());
73 mVideoState = in.readInt();
74 }
75
Ihab Awadfbb092f2014-06-03 18:40:45 -070076 /**
Ihab Awad9c3f1882014-06-30 21:17:13 -070077 * The account which should be used to place the call.
Santos Cordon52d8a152014-06-17 19:08:45 -070078 */
Evan Charlton8c8a0622014-07-20 12:31:00 -070079 public PhoneAccountHandle getAccountHandle() { return mAccountHandle; }
Santos Cordon52d8a152014-06-17 19:08:45 -070080
81 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -070082 * The handle (e.g., phone number) to which the {@link Connection} is to connect.
83 */
Nancy Chenea38cca2014-09-05 16:38:49 -070084 public Uri getAddress() { return mAddress; }
Sailesh Nepal61203862014-07-11 14:50:13 -070085
86 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -070087 * Application-specific extra data. Used for passing back information from an incoming
88 * call {@code Intent}, and for any proprietary extensions arranged between a client
89 * and servant {@code ConnectionService} which agree on a vocabulary for such data.
90 */
91 public Bundle getExtras() { return mExtras; }
92
Tyler Gunn12013ad2014-07-08 14:04:58 -070093 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -070094 * Describes the video states supported by the client requesting the connection.
95 * Valid values: {@link VideoProfile.VideoState#AUDIO_ONLY},
96 * {@link VideoProfile.VideoState#BIDIRECTIONAL},
97 * {@link VideoProfile.VideoState#TX_ENABLED},
98 * {@link VideoProfile.VideoState#RX_ENABLED}.
Tyler Gunn12013ad2014-07-08 14:04:58 -070099 *
100 * @return The video state for the connection.
Tyler Gunn27d1e252014-08-21 16:38:40 -0700101 * @hide
Tyler Gunn12013ad2014-07-08 14:04:58 -0700102 */
103 public int getVideoState() {
104 return mVideoState;
105 }
106
Evan Charltonbf11f982014-07-20 22:06:28 -0700107 @Override
Ihab Awad542e0ea2014-05-16 10:22:16 -0700108 public String toString() {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700109 return String.format("ConnectionRequest %s %s",
Nancy Chenea38cca2014-09-05 16:38:49 -0700110 mAddress == null
Ihab Awad542e0ea2014-05-16 10:22:16 -0700111 ? Uri.EMPTY
Nancy Chenea38cca2014-09-05 16:38:49 -0700112 : Connection.toLogSafePhoneNumber(mAddress.toString()),
Ihab Awad542e0ea2014-05-16 10:22:16 -0700113 mExtras == null ? "" : mExtras);
114 }
Ihab Awadfbb092f2014-06-03 18:40:45 -0700115
Sailesh Nepalc5b01572014-07-14 16:29:44 -0700116 public static final Creator<ConnectionRequest> CREATOR = new Creator<ConnectionRequest> () {
117 @Override
118 public ConnectionRequest createFromParcel(Parcel source) {
119 return new ConnectionRequest(source);
120 }
Ihab Awadfbb092f2014-06-03 18:40:45 -0700121
Sailesh Nepalc5b01572014-07-14 16:29:44 -0700122 @Override
123 public ConnectionRequest[] newArray(int size) {
124 return new ConnectionRequest[size];
125 }
126 };
Ihab Awadfbb092f2014-06-03 18:40:45 -0700127
128 /**
129 * {@inheritDoc}
130 */
131 @Override
132 public int describeContents() {
133 return 0;
134 }
135
Ihab Awadfbb092f2014-06-03 18:40:45 -0700136 @Override
137 public void writeToParcel(Parcel destination, int flags) {
Evan Charlton8c8a0622014-07-20 12:31:00 -0700138 destination.writeParcelable(mAccountHandle, 0);
Nancy Chenea38cca2014-09-05 16:38:49 -0700139 destination.writeParcelable(mAddress, 0);
Ihab Awadfbb092f2014-06-03 18:40:45 -0700140 destination.writeParcelable(mExtras, 0);
Tyler Gunn12013ad2014-07-08 14:04:58 -0700141 destination.writeInt(mVideoState);
142 }
143}