blob: 540f388384bbbb960d018e1d6d2f560f36fa11b5 [file] [log] [blame]
Santos Cordone8dc4be2014-07-21 01:28:28 -07001/*
2 * Copyright 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;
Santos Cordone8dc4be2014-07-21 01:28:28 -070018
19import android.net.Uri;
Santos Cordon6b7f9552015-05-27 17:21:45 -070020import android.os.Bundle;
Santos Cordone8dc4be2014-07-21 01:28:28 -070021import android.os.Parcel;
22import android.os.Parcelable;
23
Tyler Gunnef9f6f92014-09-12 22:16:17 -070024import com.android.internal.telecom.IVideoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -070025
Ihab Awadb8e85c72014-08-23 20:34:57 -070026import java.util.ArrayList;
27import java.util.List;
28
Santos Cordone8dc4be2014-07-21 01:28:28 -070029/**
Tyler Gunnef9f6f92014-09-12 22:16:17 -070030 * Information about a connection that is used between Telecom and the ConnectionService.
31 * This is used to send initial Connection information to Telecom when the connection is
Santos Cordone8dc4be2014-07-21 01:28:28 -070032 * first created.
33 * @hide
34 */
35public final class ParcelableConnection implements Parcelable {
Ihab Awadb8e85c72014-08-23 20:34:57 -070036 private final PhoneAccountHandle mPhoneAccount;
37 private final int mState;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080038 private final int mConnectionCapabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -070039 private final int mConnectionProperties;
Andrew Lee100e2932014-09-08 15:34:24 -070040 private final Uri mAddress;
41 private final int mAddressPresentation;
Ihab Awadb8e85c72014-08-23 20:34:57 -070042 private final String mCallerDisplayName;
43 private final int mCallerDisplayNamePresentation;
44 private final IVideoProvider mVideoProvider;
45 private final int mVideoState;
Andrew Lee100e2932014-09-08 15:34:24 -070046 private final boolean mRingbackRequested;
47 private final boolean mIsVoipAudioMode;
Roshan Piuse927ec02015-07-15 15:47:21 -070048 private final long mConnectTimeMillis;
Ihab Awadb8e85c72014-08-23 20:34:57 -070049 private final StatusHints mStatusHints;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070050 private final DisconnectCause mDisconnectCause;
Ihab Awadb8e85c72014-08-23 20:34:57 -070051 private final List<String> mConferenceableConnectionIds;
Santos Cordon6b7f9552015-05-27 17:21:45 -070052 private final Bundle mExtras;
Santos Cordone8dc4be2014-07-21 01:28:28 -070053
54 /** @hide */
55 public ParcelableConnection(
56 PhoneAccountHandle phoneAccount,
57 int state,
58 int capabilities,
Tyler Gunn720c6642016-03-22 09:02:47 -070059 int properties,
Andrew Lee100e2932014-09-08 15:34:24 -070060 Uri address,
61 int addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -070062 String callerDisplayName,
63 int callerDisplayNamePresentation,
Ihab Awadb19a0bc2014-08-07 19:46:01 -070064 IVideoProvider videoProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -070065 int videoState,
Andrew Lee100e2932014-09-08 15:34:24 -070066 boolean ringbackRequested,
67 boolean isVoipAudioMode,
Roshan Piuse927ec02015-07-15 15:47:21 -070068 long connectTimeMillis,
Ihab Awad6107bab2014-08-18 09:23:25 -070069 StatusHints statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -070070 DisconnectCause disconnectCause,
Santos Cordon6b7f9552015-05-27 17:21:45 -070071 List<String> conferenceableConnectionIds,
72 Bundle extras) {
Santos Cordone8dc4be2014-07-21 01:28:28 -070073 mPhoneAccount = phoneAccount;
74 mState = state;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080075 mConnectionCapabilities = capabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -070076 mConnectionProperties = properties;
Andrew Lee100e2932014-09-08 15:34:24 -070077 mAddress = address;
78 mAddressPresentation = addressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -070079 mCallerDisplayName = callerDisplayName;
80 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070081 mVideoProvider = videoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -070082 mVideoState = videoState;
Andrew Lee100e2932014-09-08 15:34:24 -070083 mRingbackRequested = ringbackRequested;
84 mIsVoipAudioMode = isVoipAudioMode;
Roshan Piuse927ec02015-07-15 15:47:21 -070085 mConnectTimeMillis = connectTimeMillis;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -070086 mStatusHints = statusHints;
Sailesh Nepalcf7020b2014-08-20 10:07:19 -070087 mDisconnectCause = disconnectCause;
Santos Cordon6b7f9552015-05-27 17:21:45 -070088 mConferenceableConnectionIds = conferenceableConnectionIds;
89 mExtras = extras;
Santos Cordone8dc4be2014-07-21 01:28:28 -070090 }
91
92 public PhoneAccountHandle getPhoneAccount() {
93 return mPhoneAccount;
94 }
95
96 public int getState() {
97 return mState;
98 }
99
Tyler Gunn720c6642016-03-22 09:02:47 -0700100 /**
101 * Returns the current connection capabilities bit-mask. Connection capabilities are defined as
102 * {@code CAPABILITY_*} constants in {@link Connection}.
103 *
104 * @return Bit-mask containing capabilities of the connection.
105 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800106 public int getConnectionCapabilities() {
107 return mConnectionCapabilities;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700108 }
109
Tyler Gunn720c6642016-03-22 09:02:47 -0700110 /**
111 * Returns the current connection properties bit-mask. Connection properties are defined as
112 * {@code PROPERTY_*} constants in {@link Connection}.
113 *
114 * @return Bit-mask containing properties of the connection.
115 */
116 public int getConnectionProperties() {
117 return mConnectionProperties;
118 }
119
Santos Cordone8dc4be2014-07-21 01:28:28 -0700120 public Uri getHandle() {
Andrew Lee100e2932014-09-08 15:34:24 -0700121 return mAddress;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700122 }
123
124 public int getHandlePresentation() {
Andrew Lee100e2932014-09-08 15:34:24 -0700125 return mAddressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700126 }
127
128 public String getCallerDisplayName() {
129 return mCallerDisplayName;
130 }
131
132 public int getCallerDisplayNamePresentation() {
133 return mCallerDisplayNamePresentation;
134 }
135
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700136 public IVideoProvider getVideoProvider() {
137 return mVideoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700138 }
139
140 public int getVideoState() {
141 return mVideoState;
142 }
143
Andrew Lee100e2932014-09-08 15:34:24 -0700144 public boolean isRingbackRequested() {
145 return mRingbackRequested;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700146 }
147
Andrew Lee100e2932014-09-08 15:34:24 -0700148 public boolean getIsVoipAudioMode() {
149 return mIsVoipAudioMode;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700150 }
151
Roshan Piuse927ec02015-07-15 15:47:21 -0700152 public long getConnectTimeMillis() {
153 return mConnectTimeMillis;
154 }
155
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700156 public final StatusHints getStatusHints() {
157 return mStatusHints;
158 }
159
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700160 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -0700161 return mDisconnectCause;
Ihab Awad6107bab2014-08-18 09:23:25 -0700162 }
163
Ihab Awadb8e85c72014-08-23 20:34:57 -0700164 public final List<String> getConferenceableConnectionIds() {
165 return mConferenceableConnectionIds;
166 }
167
Santos Cordon6b7f9552015-05-27 17:21:45 -0700168 public final Bundle getExtras() {
169 return mExtras;
170 }
171
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700172 @Override
173 public String toString() {
174 return new StringBuilder()
175 .append("ParcelableConnection [act:")
176 .append(mPhoneAccount)
Santos Cordon6b7f9552015-05-27 17:21:45 -0700177 .append("], state:")
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700178 .append(mState)
179 .append(", capabilities:")
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800180 .append(Connection.capabilitiesToString(mConnectionCapabilities))
Tyler Gunn720c6642016-03-22 09:02:47 -0700181 .append(", properties:")
182 .append(Connection.propertiesToString(mConnectionProperties))
Santos Cordon6b7f9552015-05-27 17:21:45 -0700183 .append(", extras:")
184 .append(mExtras)
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700185 .toString();
186 }
187
Santos Cordone8dc4be2014-07-21 01:28:28 -0700188 public static final Parcelable.Creator<ParcelableConnection> CREATOR =
189 new Parcelable.Creator<ParcelableConnection> () {
190 @Override
191 public ParcelableConnection createFromParcel(Parcel source) {
192 ClassLoader classLoader = ParcelableConnection.class.getClassLoader();
193
194 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
195 int state = source.readInt();
196 int capabilities = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700197 Uri address = source.readParcelable(classLoader);
198 int addressPresentation = source.readInt();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700199 String callerDisplayName = source.readString();
200 int callerDisplayNamePresentation = source.readInt();
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700201 IVideoProvider videoCallProvider =
202 IVideoProvider.Stub.asInterface(source.readStrongBinder());
Santos Cordone8dc4be2014-07-21 01:28:28 -0700203 int videoState = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700204 boolean ringbackRequested = source.readByte() == 1;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700205 boolean audioModeIsVoip = source.readByte() == 1;
Roshan Piuse927ec02015-07-15 15:47:21 -0700206 long connectTimeMillis = source.readLong();
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700207 StatusHints statusHints = source.readParcelable(classLoader);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700208 DisconnectCause disconnectCause = source.readParcelable(classLoader);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700209 List<String> conferenceableConnectionIds = new ArrayList<>();
210 source.readStringList(conferenceableConnectionIds);
Jeff Sharkeyf0ec2e02016-03-21 12:37:54 -0600211 Bundle extras = Bundle.setDefusable(source.readBundle(classLoader), true);
Tyler Gunn720c6642016-03-22 09:02:47 -0700212 int properties = source.readInt();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700213
214 return new ParcelableConnection(
215 phoneAccount,
216 state,
217 capabilities,
Tyler Gunn720c6642016-03-22 09:02:47 -0700218 properties,
Andrew Lee100e2932014-09-08 15:34:24 -0700219 address,
220 addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -0700221 callerDisplayName,
222 callerDisplayNamePresentation,
Andrew Lee50aca232014-07-22 16:41:54 -0700223 videoCallProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700224 videoState,
Andrew Lee100e2932014-09-08 15:34:24 -0700225 ringbackRequested,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700226 audioModeIsVoip,
Roshan Piuse927ec02015-07-15 15:47:21 -0700227 connectTimeMillis,
Ihab Awad6107bab2014-08-18 09:23:25 -0700228 statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700229 disconnectCause,
Santos Cordon6b7f9552015-05-27 17:21:45 -0700230 conferenceableConnectionIds,
231 extras);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700232 }
233
234 @Override
235 public ParcelableConnection[] newArray(int size) {
236 return new ParcelableConnection[size];
237 }
238 };
239
240 /** {@inheritDoc} */
241 @Override
242 public int describeContents() {
243 return 0;
244 }
245
246 /** Writes ParcelableConnection object into a Parcel. */
247 @Override
248 public void writeToParcel(Parcel destination, int flags) {
249 destination.writeParcelable(mPhoneAccount, 0);
250 destination.writeInt(mState);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800251 destination.writeInt(mConnectionCapabilities);
Andrew Lee100e2932014-09-08 15:34:24 -0700252 destination.writeParcelable(mAddress, 0);
253 destination.writeInt(mAddressPresentation);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700254 destination.writeString(mCallerDisplayName);
255 destination.writeInt(mCallerDisplayNamePresentation);
256 destination.writeStrongBinder(
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700257 mVideoProvider != null ? mVideoProvider.asBinder() : null);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700258 destination.writeInt(mVideoState);
Andrew Lee100e2932014-09-08 15:34:24 -0700259 destination.writeByte((byte) (mRingbackRequested ? 1 : 0));
260 destination.writeByte((byte) (mIsVoipAudioMode ? 1 : 0));
Roshan Piuse927ec02015-07-15 15:47:21 -0700261 destination.writeLong(mConnectTimeMillis);
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700262 destination.writeParcelable(mStatusHints, 0);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700263 destination.writeParcelable(mDisconnectCause, 0);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700264 destination.writeStringList(mConferenceableConnectionIds);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700265 destination.writeBundle(mExtras);
Tyler Gunn720c6642016-03-22 09:02:47 -0700266 destination.writeInt(mConnectionProperties);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700267 }
268}