blob: 434abf53624cfa7775e1910bde64d08f8f7ec071 [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;
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -080040 private final int mSupportedAudioRoutes;
Andrew Lee100e2932014-09-08 15:34:24 -070041 private final Uri mAddress;
42 private final int mAddressPresentation;
Ihab Awadb8e85c72014-08-23 20:34:57 -070043 private final String mCallerDisplayName;
44 private final int mCallerDisplayNamePresentation;
45 private final IVideoProvider mVideoProvider;
46 private final int mVideoState;
Andrew Lee100e2932014-09-08 15:34:24 -070047 private final boolean mRingbackRequested;
48 private final boolean mIsVoipAudioMode;
Roshan Piuse927ec02015-07-15 15:47:21 -070049 private final long mConnectTimeMillis;
Ihab Awadb8e85c72014-08-23 20:34:57 -070050 private final StatusHints mStatusHints;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070051 private final DisconnectCause mDisconnectCause;
Ihab Awadb8e85c72014-08-23 20:34:57 -070052 private final List<String> mConferenceableConnectionIds;
Santos Cordon6b7f9552015-05-27 17:21:45 -070053 private final Bundle mExtras;
Tyler Gunn78da7812017-05-09 14:34:57 -070054 private String mParentCallId;
55
56 /** @hide */
57 public ParcelableConnection(
58 PhoneAccountHandle phoneAccount,
59 int state,
60 int capabilities,
61 int properties,
62 int supportedAudioRoutes,
63 Uri address,
64 int addressPresentation,
65 String callerDisplayName,
66 int callerDisplayNamePresentation,
67 IVideoProvider videoProvider,
68 int videoState,
69 boolean ringbackRequested,
70 boolean isVoipAudioMode,
71 long connectTimeMillis,
72 StatusHints statusHints,
73 DisconnectCause disconnectCause,
74 List<String> conferenceableConnectionIds,
75 Bundle extras,
76 String parentCallId) {
77 this(phoneAccount, state, capabilities, properties, supportedAudioRoutes, address,
78 addressPresentation, callerDisplayName, callerDisplayNamePresentation,
79 videoProvider, videoState, ringbackRequested, isVoipAudioMode, connectTimeMillis,
80 statusHints, disconnectCause, conferenceableConnectionIds, extras);
81 mParentCallId = parentCallId;
82 }
Santos Cordone8dc4be2014-07-21 01:28:28 -070083
84 /** @hide */
85 public ParcelableConnection(
86 PhoneAccountHandle phoneAccount,
87 int state,
88 int capabilities,
Tyler Gunn720c6642016-03-22 09:02:47 -070089 int properties,
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -080090 int supportedAudioRoutes,
Andrew Lee100e2932014-09-08 15:34:24 -070091 Uri address,
92 int addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -070093 String callerDisplayName,
94 int callerDisplayNamePresentation,
Ihab Awadb19a0bc2014-08-07 19:46:01 -070095 IVideoProvider videoProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -070096 int videoState,
Andrew Lee100e2932014-09-08 15:34:24 -070097 boolean ringbackRequested,
98 boolean isVoipAudioMode,
Roshan Piuse927ec02015-07-15 15:47:21 -070099 long connectTimeMillis,
Ihab Awad6107bab2014-08-18 09:23:25 -0700100 StatusHints statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700101 DisconnectCause disconnectCause,
Santos Cordon6b7f9552015-05-27 17:21:45 -0700102 List<String> conferenceableConnectionIds,
103 Bundle extras) {
Santos Cordone8dc4be2014-07-21 01:28:28 -0700104 mPhoneAccount = phoneAccount;
105 mState = state;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800106 mConnectionCapabilities = capabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -0700107 mConnectionProperties = properties;
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800108 mSupportedAudioRoutes = supportedAudioRoutes;
Andrew Lee100e2932014-09-08 15:34:24 -0700109 mAddress = address;
110 mAddressPresentation = addressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700111 mCallerDisplayName = callerDisplayName;
112 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700113 mVideoProvider = videoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700114 mVideoState = videoState;
Andrew Lee100e2932014-09-08 15:34:24 -0700115 mRingbackRequested = ringbackRequested;
116 mIsVoipAudioMode = isVoipAudioMode;
Roshan Piuse927ec02015-07-15 15:47:21 -0700117 mConnectTimeMillis = connectTimeMillis;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700118 mStatusHints = statusHints;
Sailesh Nepalcf7020b2014-08-20 10:07:19 -0700119 mDisconnectCause = disconnectCause;
Santos Cordon6b7f9552015-05-27 17:21:45 -0700120 mConferenceableConnectionIds = conferenceableConnectionIds;
121 mExtras = extras;
Tyler Gunn78da7812017-05-09 14:34:57 -0700122 mParentCallId = null;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700123 }
124
125 public PhoneAccountHandle getPhoneAccount() {
126 return mPhoneAccount;
127 }
128
129 public int getState() {
130 return mState;
131 }
132
Tyler Gunn720c6642016-03-22 09:02:47 -0700133 /**
134 * Returns the current connection capabilities bit-mask. Connection capabilities are defined as
135 * {@code CAPABILITY_*} constants in {@link Connection}.
136 *
137 * @return Bit-mask containing capabilities of the connection.
138 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800139 public int getConnectionCapabilities() {
140 return mConnectionCapabilities;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700141 }
142
Tyler Gunn720c6642016-03-22 09:02:47 -0700143 /**
144 * Returns the current connection properties bit-mask. Connection properties are defined as
145 * {@code PROPERTY_*} constants in {@link Connection}.
146 *
147 * @return Bit-mask containing properties of the connection.
148 */
149 public int getConnectionProperties() {
150 return mConnectionProperties;
151 }
152
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800153 public int getSupportedAudioRoutes() {
154 return mSupportedAudioRoutes;
155 }
156
Santos Cordone8dc4be2014-07-21 01:28:28 -0700157 public Uri getHandle() {
Andrew Lee100e2932014-09-08 15:34:24 -0700158 return mAddress;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700159 }
160
161 public int getHandlePresentation() {
Andrew Lee100e2932014-09-08 15:34:24 -0700162 return mAddressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700163 }
164
165 public String getCallerDisplayName() {
166 return mCallerDisplayName;
167 }
168
169 public int getCallerDisplayNamePresentation() {
170 return mCallerDisplayNamePresentation;
171 }
172
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700173 public IVideoProvider getVideoProvider() {
174 return mVideoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700175 }
176
177 public int getVideoState() {
178 return mVideoState;
179 }
180
Andrew Lee100e2932014-09-08 15:34:24 -0700181 public boolean isRingbackRequested() {
182 return mRingbackRequested;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700183 }
184
Andrew Lee100e2932014-09-08 15:34:24 -0700185 public boolean getIsVoipAudioMode() {
186 return mIsVoipAudioMode;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700187 }
188
Roshan Piuse927ec02015-07-15 15:47:21 -0700189 public long getConnectTimeMillis() {
190 return mConnectTimeMillis;
191 }
192
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700193 public final StatusHints getStatusHints() {
194 return mStatusHints;
195 }
196
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700197 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -0700198 return mDisconnectCause;
Ihab Awad6107bab2014-08-18 09:23:25 -0700199 }
200
Ihab Awadb8e85c72014-08-23 20:34:57 -0700201 public final List<String> getConferenceableConnectionIds() {
202 return mConferenceableConnectionIds;
203 }
204
Santos Cordon6b7f9552015-05-27 17:21:45 -0700205 public final Bundle getExtras() {
206 return mExtras;
207 }
208
Tyler Gunn78da7812017-05-09 14:34:57 -0700209 public final String getParentCallId() {
210 return mParentCallId;
211 }
212
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700213 @Override
214 public String toString() {
215 return new StringBuilder()
216 .append("ParcelableConnection [act:")
217 .append(mPhoneAccount)
Santos Cordon6b7f9552015-05-27 17:21:45 -0700218 .append("], state:")
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700219 .append(mState)
220 .append(", capabilities:")
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800221 .append(Connection.capabilitiesToString(mConnectionCapabilities))
Tyler Gunn720c6642016-03-22 09:02:47 -0700222 .append(", properties:")
223 .append(Connection.propertiesToString(mConnectionProperties))
Santos Cordon6b7f9552015-05-27 17:21:45 -0700224 .append(", extras:")
225 .append(mExtras)
Tyler Gunn78da7812017-05-09 14:34:57 -0700226 .append(", parent:")
227 .append(mParentCallId)
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700228 .toString();
229 }
230
Santos Cordone8dc4be2014-07-21 01:28:28 -0700231 public static final Parcelable.Creator<ParcelableConnection> CREATOR =
232 new Parcelable.Creator<ParcelableConnection> () {
233 @Override
234 public ParcelableConnection createFromParcel(Parcel source) {
235 ClassLoader classLoader = ParcelableConnection.class.getClassLoader();
236
237 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
238 int state = source.readInt();
239 int capabilities = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700240 Uri address = source.readParcelable(classLoader);
241 int addressPresentation = source.readInt();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700242 String callerDisplayName = source.readString();
243 int callerDisplayNamePresentation = source.readInt();
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700244 IVideoProvider videoCallProvider =
245 IVideoProvider.Stub.asInterface(source.readStrongBinder());
Santos Cordone8dc4be2014-07-21 01:28:28 -0700246 int videoState = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700247 boolean ringbackRequested = source.readByte() == 1;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700248 boolean audioModeIsVoip = source.readByte() == 1;
Roshan Piuse927ec02015-07-15 15:47:21 -0700249 long connectTimeMillis = source.readLong();
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700250 StatusHints statusHints = source.readParcelable(classLoader);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700251 DisconnectCause disconnectCause = source.readParcelable(classLoader);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700252 List<String> conferenceableConnectionIds = new ArrayList<>();
253 source.readStringList(conferenceableConnectionIds);
Jeff Sharkeyf0ec2e02016-03-21 12:37:54 -0600254 Bundle extras = Bundle.setDefusable(source.readBundle(classLoader), true);
Tyler Gunn720c6642016-03-22 09:02:47 -0700255 int properties = source.readInt();
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800256 int supportedAudioRoutes = source.readInt();
Tyler Gunn78da7812017-05-09 14:34:57 -0700257 String parentCallId = source.readString();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700258
259 return new ParcelableConnection(
260 phoneAccount,
261 state,
262 capabilities,
Tyler Gunn720c6642016-03-22 09:02:47 -0700263 properties,
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800264 supportedAudioRoutes,
Andrew Lee100e2932014-09-08 15:34:24 -0700265 address,
266 addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -0700267 callerDisplayName,
268 callerDisplayNamePresentation,
Andrew Lee50aca232014-07-22 16:41:54 -0700269 videoCallProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700270 videoState,
Andrew Lee100e2932014-09-08 15:34:24 -0700271 ringbackRequested,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700272 audioModeIsVoip,
Roshan Piuse927ec02015-07-15 15:47:21 -0700273 connectTimeMillis,
Ihab Awad6107bab2014-08-18 09:23:25 -0700274 statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700275 disconnectCause,
Santos Cordon6b7f9552015-05-27 17:21:45 -0700276 conferenceableConnectionIds,
Tyler Gunn78da7812017-05-09 14:34:57 -0700277 extras,
278 parentCallId);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700279 }
280
281 @Override
282 public ParcelableConnection[] newArray(int size) {
283 return new ParcelableConnection[size];
284 }
285 };
286
287 /** {@inheritDoc} */
288 @Override
289 public int describeContents() {
290 return 0;
291 }
292
293 /** Writes ParcelableConnection object into a Parcel. */
294 @Override
295 public void writeToParcel(Parcel destination, int flags) {
296 destination.writeParcelable(mPhoneAccount, 0);
297 destination.writeInt(mState);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800298 destination.writeInt(mConnectionCapabilities);
Andrew Lee100e2932014-09-08 15:34:24 -0700299 destination.writeParcelable(mAddress, 0);
300 destination.writeInt(mAddressPresentation);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700301 destination.writeString(mCallerDisplayName);
302 destination.writeInt(mCallerDisplayNamePresentation);
303 destination.writeStrongBinder(
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700304 mVideoProvider != null ? mVideoProvider.asBinder() : null);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700305 destination.writeInt(mVideoState);
Andrew Lee100e2932014-09-08 15:34:24 -0700306 destination.writeByte((byte) (mRingbackRequested ? 1 : 0));
307 destination.writeByte((byte) (mIsVoipAudioMode ? 1 : 0));
Roshan Piuse927ec02015-07-15 15:47:21 -0700308 destination.writeLong(mConnectTimeMillis);
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700309 destination.writeParcelable(mStatusHints, 0);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700310 destination.writeParcelable(mDisconnectCause, 0);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700311 destination.writeStringList(mConferenceableConnectionIds);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700312 destination.writeBundle(mExtras);
Tyler Gunn720c6642016-03-22 09:02:47 -0700313 destination.writeInt(mConnectionProperties);
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800314 destination.writeInt(mSupportedAudioRoutes);
Tyler Gunn78da7812017-05-09 14:34:57 -0700315 destination.writeString(mParentCallId);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700316 }
317}