blob: 71b481b89c771d2c39c7637d4ffaba43428695a8 [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
Ihab Awad542e0ea2014-05-16 10:22:16 -070019import android.net.Uri;
Sailesh Nepal61203862014-07-11 14:50:13 -070020import android.os.Bundle;
Ihab Awadfbb092f2014-06-03 18:40:45 -070021import android.os.Parcel;
22import android.os.Parcelable;
Ihab Awad542e0ea2014-05-16 10:22:16 -070023
24/**
25 * Simple data container encapsulating a request to some entity to
26 * create a new {@link Connection}.
27 */
Ihab Awadfbb092f2014-06-03 18:40:45 -070028public final class ConnectionRequest implements Parcelable {
Ihab Awad542e0ea2014-05-16 10:22:16 -070029
30 // TODO: Token to limit recursive invocations
Evan Charlton8c8a0622014-07-20 12:31:00 -070031 private final PhoneAccountHandle mAccountHandle;
Nancy Chenea38cca2014-09-05 16:38:49 -070032 private final Uri mAddress;
Ihab Awad542e0ea2014-05-16 10:22:16 -070033 private final Bundle mExtras;
Tyler Gunn12013ad2014-07-08 14:04:58 -070034 private final int mVideoState;
Ihab Awad542e0ea2014-05-16 10:22:16 -070035
Sailesh Nepal61203862014-07-11 14:50:13 -070036 /**
Evan Charlton8c8a0622014-07-20 12:31:00 -070037 * @param accountHandle The accountHandle which should be used to place the call.
Sailesh Nepal61203862014-07-11 14:50:13 -070038 * @param handle The handle (e.g., phone number) to which the {@link Connection} is to connect.
Sailesh Nepal61203862014-07-11 14:50:13 -070039 * @param extras Application-specific extra data.
Tyler Gunnbe74de02014-08-29 14:51:48 -070040 */
41 public ConnectionRequest(
42 PhoneAccountHandle accountHandle,
43 Uri handle,
Tyler Gunnbe74de02014-08-29 14:51:48 -070044 Bundle extras) {
Nancy Chenea38cca2014-09-05 16:38:49 -070045 this(accountHandle, handle, extras, VideoProfile.VideoState.AUDIO_ONLY);
Tyler Gunnbe74de02014-08-29 14:51:48 -070046 }
47
48 /**
49 * @param accountHandle The accountHandle which should be used to place the call.
50 * @param handle The handle (e.g., phone number) to which the {@link Connection} is to connect.
Tyler Gunnbe74de02014-08-29 14:51:48 -070051 * @param extras Application-specific extra data.
Sailesh Nepal61203862014-07-11 14:50:13 -070052 * @param videoState Determines the video state for the connection.
Tyler Gunnbe74de02014-08-29 14:51:48 -070053 * @hide
Sailesh Nepal61203862014-07-11 14:50:13 -070054 */
55 public ConnectionRequest(
Evan Charlton8c8a0622014-07-20 12:31:00 -070056 PhoneAccountHandle accountHandle,
Sailesh Nepal61203862014-07-11 14:50:13 -070057 Uri handle,
Sailesh Nepal61203862014-07-11 14:50:13 -070058 Bundle extras,
Tyler Gunn12013ad2014-07-08 14:04:58 -070059 int videoState) {
Evan Charlton8c8a0622014-07-20 12:31:00 -070060 mAccountHandle = accountHandle;
Nancy Chenea38cca2014-09-05 16:38:49 -070061 mAddress = handle;
Ihab Awadfbb092f2014-06-03 18:40:45 -070062 mExtras = extras;
Tyler Gunn12013ad2014-07-08 14:04:58 -070063 mVideoState = videoState;
Ihab Awadfbb092f2014-06-03 18:40:45 -070064 }
65
Sailesh Nepalc5b01572014-07-14 16:29:44 -070066 private ConnectionRequest(Parcel in) {
Evan Charlton8c8a0622014-07-20 12:31:00 -070067 mAccountHandle = in.readParcelable(getClass().getClassLoader());
Nancy Chenea38cca2014-09-05 16:38:49 -070068 mAddress = in.readParcelable(getClass().getClassLoader());
Sailesh Nepalc5b01572014-07-14 16:29:44 -070069 mExtras = in.readParcelable(getClass().getClassLoader());
70 mVideoState = in.readInt();
71 }
72
Ihab Awadfbb092f2014-06-03 18:40:45 -070073 /**
Ihab Awad9c3f1882014-06-30 21:17:13 -070074 * The account which should be used to place the call.
Santos Cordon52d8a152014-06-17 19:08:45 -070075 */
Evan Charlton8c8a0622014-07-20 12:31:00 -070076 public PhoneAccountHandle getAccountHandle() { return mAccountHandle; }
Santos Cordon52d8a152014-06-17 19:08:45 -070077
78 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -070079 * The handle (e.g., phone number) to which the {@link Connection} is to connect.
80 */
Nancy Chenea38cca2014-09-05 16:38:49 -070081 public Uri getAddress() { return mAddress; }
Sailesh Nepal61203862014-07-11 14:50:13 -070082
83 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -070084 * Application-specific extra data. Used for passing back information from an incoming
85 * call {@code Intent}, and for any proprietary extensions arranged between a client
86 * and servant {@code ConnectionService} which agree on a vocabulary for such data.
87 */
88 public Bundle getExtras() { return mExtras; }
89
Tyler Gunn12013ad2014-07-08 14:04:58 -070090 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -070091 * Describes the video states supported by the client requesting the connection.
92 * Valid values: {@link VideoProfile.VideoState#AUDIO_ONLY},
93 * {@link VideoProfile.VideoState#BIDIRECTIONAL},
94 * {@link VideoProfile.VideoState#TX_ENABLED},
95 * {@link VideoProfile.VideoState#RX_ENABLED}.
Tyler Gunn12013ad2014-07-08 14:04:58 -070096 *
97 * @return The video state for the connection.
Tyler Gunn27d1e252014-08-21 16:38:40 -070098 * @hide
Tyler Gunn12013ad2014-07-08 14:04:58 -070099 */
100 public int getVideoState() {
101 return mVideoState;
102 }
103
Evan Charltonbf11f982014-07-20 22:06:28 -0700104 @Override
Ihab Awad542e0ea2014-05-16 10:22:16 -0700105 public String toString() {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700106 return String.format("ConnectionRequest %s %s",
Nancy Chenea38cca2014-09-05 16:38:49 -0700107 mAddress == null
Ihab Awad542e0ea2014-05-16 10:22:16 -0700108 ? Uri.EMPTY
Nancy Chenea38cca2014-09-05 16:38:49 -0700109 : Connection.toLogSafePhoneNumber(mAddress.toString()),
Ihab Awad542e0ea2014-05-16 10:22:16 -0700110 mExtras == null ? "" : mExtras);
111 }
Ihab Awadfbb092f2014-06-03 18:40:45 -0700112
Sailesh Nepalc5b01572014-07-14 16:29:44 -0700113 public static final Creator<ConnectionRequest> CREATOR = new Creator<ConnectionRequest> () {
114 @Override
115 public ConnectionRequest createFromParcel(Parcel source) {
116 return new ConnectionRequest(source);
117 }
Ihab Awadfbb092f2014-06-03 18:40:45 -0700118
Sailesh Nepalc5b01572014-07-14 16:29:44 -0700119 @Override
120 public ConnectionRequest[] newArray(int size) {
121 return new ConnectionRequest[size];
122 }
123 };
Ihab Awadfbb092f2014-06-03 18:40:45 -0700124
125 /**
126 * {@inheritDoc}
127 */
128 @Override
129 public int describeContents() {
130 return 0;
131 }
132
Ihab Awadfbb092f2014-06-03 18:40:45 -0700133 @Override
134 public void writeToParcel(Parcel destination, int flags) {
Evan Charlton8c8a0622014-07-20 12:31:00 -0700135 destination.writeParcelable(mAccountHandle, 0);
Nancy Chenea38cca2014-09-05 16:38:49 -0700136 destination.writeParcelable(mAddress, 0);
Ihab Awadfbb092f2014-06-03 18:40:45 -0700137 destination.writeParcelable(mExtras, 0);
Tyler Gunn12013ad2014-07-08 14:04:58 -0700138 destination.writeInt(mVideoState);
139 }
140}