blob: dab1c6e7ae77993dfc4bd966463158ba84d96795 [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;
Tyler Gunnb2f875b2017-08-04 09:27:26 -070050 private final long mConnectElapsedTimeMillis;
Ihab Awadb8e85c72014-08-23 20:34:57 -070051 private final StatusHints mStatusHints;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070052 private final DisconnectCause mDisconnectCause;
Ihab Awadb8e85c72014-08-23 20:34:57 -070053 private final List<String> mConferenceableConnectionIds;
Santos Cordon6b7f9552015-05-27 17:21:45 -070054 private final Bundle mExtras;
Tyler Gunn78da7812017-05-09 14:34:57 -070055 private String mParentCallId;
56
57 /** @hide */
58 public ParcelableConnection(
59 PhoneAccountHandle phoneAccount,
60 int state,
61 int capabilities,
62 int properties,
63 int supportedAudioRoutes,
64 Uri address,
65 int addressPresentation,
66 String callerDisplayName,
67 int callerDisplayNamePresentation,
68 IVideoProvider videoProvider,
69 int videoState,
70 boolean ringbackRequested,
71 boolean isVoipAudioMode,
72 long connectTimeMillis,
Tyler Gunnb2f875b2017-08-04 09:27:26 -070073 long connectElapsedTimeMillis,
Tyler Gunn78da7812017-05-09 14:34:57 -070074 StatusHints statusHints,
75 DisconnectCause disconnectCause,
76 List<String> conferenceableConnectionIds,
77 Bundle extras,
78 String parentCallId) {
79 this(phoneAccount, state, capabilities, properties, supportedAudioRoutes, address,
80 addressPresentation, callerDisplayName, callerDisplayNamePresentation,
81 videoProvider, videoState, ringbackRequested, isVoipAudioMode, connectTimeMillis,
Tyler Gunnb2f875b2017-08-04 09:27:26 -070082 connectElapsedTimeMillis, statusHints, disconnectCause, conferenceableConnectionIds,
83 extras);
Tyler Gunn78da7812017-05-09 14:34:57 -070084 mParentCallId = parentCallId;
85 }
Santos Cordone8dc4be2014-07-21 01:28:28 -070086
87 /** @hide */
88 public ParcelableConnection(
89 PhoneAccountHandle phoneAccount,
90 int state,
91 int capabilities,
Tyler Gunn720c6642016-03-22 09:02:47 -070092 int properties,
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -080093 int supportedAudioRoutes,
Andrew Lee100e2932014-09-08 15:34:24 -070094 Uri address,
95 int addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -070096 String callerDisplayName,
97 int callerDisplayNamePresentation,
Ihab Awadb19a0bc2014-08-07 19:46:01 -070098 IVideoProvider videoProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -070099 int videoState,
Andrew Lee100e2932014-09-08 15:34:24 -0700100 boolean ringbackRequested,
101 boolean isVoipAudioMode,
Roshan Piuse927ec02015-07-15 15:47:21 -0700102 long connectTimeMillis,
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700103 long connectElapsedTimeMillis,
Ihab Awad6107bab2014-08-18 09:23:25 -0700104 StatusHints statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700105 DisconnectCause disconnectCause,
Santos Cordon6b7f9552015-05-27 17:21:45 -0700106 List<String> conferenceableConnectionIds,
107 Bundle extras) {
Santos Cordone8dc4be2014-07-21 01:28:28 -0700108 mPhoneAccount = phoneAccount;
109 mState = state;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800110 mConnectionCapabilities = capabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -0700111 mConnectionProperties = properties;
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800112 mSupportedAudioRoutes = supportedAudioRoutes;
Andrew Lee100e2932014-09-08 15:34:24 -0700113 mAddress = address;
114 mAddressPresentation = addressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700115 mCallerDisplayName = callerDisplayName;
116 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700117 mVideoProvider = videoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700118 mVideoState = videoState;
Andrew Lee100e2932014-09-08 15:34:24 -0700119 mRingbackRequested = ringbackRequested;
120 mIsVoipAudioMode = isVoipAudioMode;
Roshan Piuse927ec02015-07-15 15:47:21 -0700121 mConnectTimeMillis = connectTimeMillis;
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700122 mConnectElapsedTimeMillis = connectElapsedTimeMillis;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700123 mStatusHints = statusHints;
Sailesh Nepalcf7020b2014-08-20 10:07:19 -0700124 mDisconnectCause = disconnectCause;
Santos Cordon6b7f9552015-05-27 17:21:45 -0700125 mConferenceableConnectionIds = conferenceableConnectionIds;
126 mExtras = extras;
Tyler Gunn78da7812017-05-09 14:34:57 -0700127 mParentCallId = null;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700128 }
129
130 public PhoneAccountHandle getPhoneAccount() {
131 return mPhoneAccount;
132 }
133
134 public int getState() {
135 return mState;
136 }
137
Tyler Gunn720c6642016-03-22 09:02:47 -0700138 /**
139 * Returns the current connection capabilities bit-mask. Connection capabilities are defined as
140 * {@code CAPABILITY_*} constants in {@link Connection}.
141 *
142 * @return Bit-mask containing capabilities of the connection.
143 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800144 public int getConnectionCapabilities() {
145 return mConnectionCapabilities;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700146 }
147
Tyler Gunn720c6642016-03-22 09:02:47 -0700148 /**
149 * Returns the current connection properties bit-mask. Connection properties are defined as
150 * {@code PROPERTY_*} constants in {@link Connection}.
151 *
152 * @return Bit-mask containing properties of the connection.
153 */
154 public int getConnectionProperties() {
155 return mConnectionProperties;
156 }
157
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800158 public int getSupportedAudioRoutes() {
159 return mSupportedAudioRoutes;
160 }
161
Santos Cordone8dc4be2014-07-21 01:28:28 -0700162 public Uri getHandle() {
Andrew Lee100e2932014-09-08 15:34:24 -0700163 return mAddress;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700164 }
165
166 public int getHandlePresentation() {
Andrew Lee100e2932014-09-08 15:34:24 -0700167 return mAddressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700168 }
169
170 public String getCallerDisplayName() {
171 return mCallerDisplayName;
172 }
173
174 public int getCallerDisplayNamePresentation() {
175 return mCallerDisplayNamePresentation;
176 }
177
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700178 public IVideoProvider getVideoProvider() {
179 return mVideoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700180 }
181
182 public int getVideoState() {
183 return mVideoState;
184 }
185
Andrew Lee100e2932014-09-08 15:34:24 -0700186 public boolean isRingbackRequested() {
187 return mRingbackRequested;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700188 }
189
Andrew Lee100e2932014-09-08 15:34:24 -0700190 public boolean getIsVoipAudioMode() {
191 return mIsVoipAudioMode;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700192 }
193
Roshan Piuse927ec02015-07-15 15:47:21 -0700194 public long getConnectTimeMillis() {
195 return mConnectTimeMillis;
196 }
197
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700198 public long getConnectElapsedTimeMillis() {
199 return mConnectElapsedTimeMillis;
200 }
201
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700202 public final StatusHints getStatusHints() {
203 return mStatusHints;
204 }
205
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700206 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -0700207 return mDisconnectCause;
Ihab Awad6107bab2014-08-18 09:23:25 -0700208 }
209
Ihab Awadb8e85c72014-08-23 20:34:57 -0700210 public final List<String> getConferenceableConnectionIds() {
211 return mConferenceableConnectionIds;
212 }
213
Santos Cordon6b7f9552015-05-27 17:21:45 -0700214 public final Bundle getExtras() {
215 return mExtras;
216 }
217
Tyler Gunn78da7812017-05-09 14:34:57 -0700218 public final String getParentCallId() {
219 return mParentCallId;
220 }
221
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700222 @Override
223 public String toString() {
224 return new StringBuilder()
225 .append("ParcelableConnection [act:")
226 .append(mPhoneAccount)
Santos Cordon6b7f9552015-05-27 17:21:45 -0700227 .append("], state:")
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700228 .append(mState)
229 .append(", capabilities:")
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800230 .append(Connection.capabilitiesToString(mConnectionCapabilities))
Tyler Gunn720c6642016-03-22 09:02:47 -0700231 .append(", properties:")
232 .append(Connection.propertiesToString(mConnectionProperties))
Santos Cordon6b7f9552015-05-27 17:21:45 -0700233 .append(", extras:")
234 .append(mExtras)
Tyler Gunn78da7812017-05-09 14:34:57 -0700235 .append(", parent:")
236 .append(mParentCallId)
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700237 .toString();
238 }
239
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -0700240 public static final @android.annotation.NonNull Parcelable.Creator<ParcelableConnection> CREATOR =
Santos Cordone8dc4be2014-07-21 01:28:28 -0700241 new Parcelable.Creator<ParcelableConnection> () {
242 @Override
243 public ParcelableConnection createFromParcel(Parcel source) {
244 ClassLoader classLoader = ParcelableConnection.class.getClassLoader();
245
246 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
247 int state = source.readInt();
248 int capabilities = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700249 Uri address = source.readParcelable(classLoader);
250 int addressPresentation = source.readInt();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700251 String callerDisplayName = source.readString();
252 int callerDisplayNamePresentation = source.readInt();
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700253 IVideoProvider videoCallProvider =
254 IVideoProvider.Stub.asInterface(source.readStrongBinder());
Santos Cordone8dc4be2014-07-21 01:28:28 -0700255 int videoState = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700256 boolean ringbackRequested = source.readByte() == 1;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700257 boolean audioModeIsVoip = source.readByte() == 1;
Roshan Piuse927ec02015-07-15 15:47:21 -0700258 long connectTimeMillis = source.readLong();
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700259 StatusHints statusHints = source.readParcelable(classLoader);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700260 DisconnectCause disconnectCause = source.readParcelable(classLoader);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700261 List<String> conferenceableConnectionIds = new ArrayList<>();
262 source.readStringList(conferenceableConnectionIds);
Jeff Sharkeyf0ec2e02016-03-21 12:37:54 -0600263 Bundle extras = Bundle.setDefusable(source.readBundle(classLoader), true);
Tyler Gunn720c6642016-03-22 09:02:47 -0700264 int properties = source.readInt();
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800265 int supportedAudioRoutes = source.readInt();
Tyler Gunn78da7812017-05-09 14:34:57 -0700266 String parentCallId = source.readString();
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700267 long connectElapsedTimeMillis = source.readLong();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700268
269 return new ParcelableConnection(
270 phoneAccount,
271 state,
272 capabilities,
Tyler Gunn720c6642016-03-22 09:02:47 -0700273 properties,
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800274 supportedAudioRoutes,
Andrew Lee100e2932014-09-08 15:34:24 -0700275 address,
276 addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -0700277 callerDisplayName,
278 callerDisplayNamePresentation,
Andrew Lee50aca232014-07-22 16:41:54 -0700279 videoCallProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700280 videoState,
Andrew Lee100e2932014-09-08 15:34:24 -0700281 ringbackRequested,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700282 audioModeIsVoip,
Roshan Piuse927ec02015-07-15 15:47:21 -0700283 connectTimeMillis,
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700284 connectElapsedTimeMillis,
Ihab Awad6107bab2014-08-18 09:23:25 -0700285 statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700286 disconnectCause,
Santos Cordon6b7f9552015-05-27 17:21:45 -0700287 conferenceableConnectionIds,
Tyler Gunn78da7812017-05-09 14:34:57 -0700288 extras,
289 parentCallId);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700290 }
291
292 @Override
293 public ParcelableConnection[] newArray(int size) {
294 return new ParcelableConnection[size];
295 }
296 };
297
298 /** {@inheritDoc} */
299 @Override
300 public int describeContents() {
301 return 0;
302 }
303
304 /** Writes ParcelableConnection object into a Parcel. */
305 @Override
306 public void writeToParcel(Parcel destination, int flags) {
307 destination.writeParcelable(mPhoneAccount, 0);
308 destination.writeInt(mState);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800309 destination.writeInt(mConnectionCapabilities);
Andrew Lee100e2932014-09-08 15:34:24 -0700310 destination.writeParcelable(mAddress, 0);
311 destination.writeInt(mAddressPresentation);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700312 destination.writeString(mCallerDisplayName);
313 destination.writeInt(mCallerDisplayNamePresentation);
314 destination.writeStrongBinder(
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700315 mVideoProvider != null ? mVideoProvider.asBinder() : null);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700316 destination.writeInt(mVideoState);
Andrew Lee100e2932014-09-08 15:34:24 -0700317 destination.writeByte((byte) (mRingbackRequested ? 1 : 0));
318 destination.writeByte((byte) (mIsVoipAudioMode ? 1 : 0));
Roshan Piuse927ec02015-07-15 15:47:21 -0700319 destination.writeLong(mConnectTimeMillis);
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700320 destination.writeParcelable(mStatusHints, 0);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700321 destination.writeParcelable(mDisconnectCause, 0);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700322 destination.writeStringList(mConferenceableConnectionIds);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700323 destination.writeBundle(mExtras);
Tyler Gunn720c6642016-03-22 09:02:47 -0700324 destination.writeInt(mConnectionProperties);
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800325 destination.writeInt(mSupportedAudioRoutes);
Tyler Gunn78da7812017-05-09 14:34:57 -0700326 destination.writeString(mParentCallId);
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700327 destination.writeLong(mConnectElapsedTimeMillis);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700328 }
329}