blob: 4734af6371d4b04d4992f483beafdb4b560e18bc [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;
Tyler Gunn6986a632019-06-25 13:45:32 -070056 private @Call.Details.CallDirection int mCallDirection;
Tyler Gunn78da7812017-05-09 14:34:57 -070057
58 /** @hide */
59 public ParcelableConnection(
60 PhoneAccountHandle phoneAccount,
61 int state,
62 int capabilities,
63 int properties,
64 int supportedAudioRoutes,
65 Uri address,
66 int addressPresentation,
67 String callerDisplayName,
68 int callerDisplayNamePresentation,
69 IVideoProvider videoProvider,
70 int videoState,
71 boolean ringbackRequested,
72 boolean isVoipAudioMode,
73 long connectTimeMillis,
Tyler Gunnb2f875b2017-08-04 09:27:26 -070074 long connectElapsedTimeMillis,
Tyler Gunn78da7812017-05-09 14:34:57 -070075 StatusHints statusHints,
76 DisconnectCause disconnectCause,
77 List<String> conferenceableConnectionIds,
78 Bundle extras,
Tyler Gunn6986a632019-06-25 13:45:32 -070079 String parentCallId,
80 @Call.Details.CallDirection int callDirection) {
Tyler Gunn78da7812017-05-09 14:34:57 -070081 this(phoneAccount, state, capabilities, properties, supportedAudioRoutes, address,
82 addressPresentation, callerDisplayName, callerDisplayNamePresentation,
83 videoProvider, videoState, ringbackRequested, isVoipAudioMode, connectTimeMillis,
Tyler Gunnb2f875b2017-08-04 09:27:26 -070084 connectElapsedTimeMillis, statusHints, disconnectCause, conferenceableConnectionIds,
85 extras);
Tyler Gunn78da7812017-05-09 14:34:57 -070086 mParentCallId = parentCallId;
Tyler Gunn6986a632019-06-25 13:45:32 -070087 mCallDirection = callDirection;
Tyler Gunn78da7812017-05-09 14:34:57 -070088 }
Santos Cordone8dc4be2014-07-21 01:28:28 -070089
90 /** @hide */
91 public ParcelableConnection(
92 PhoneAccountHandle phoneAccount,
93 int state,
94 int capabilities,
Tyler Gunn720c6642016-03-22 09:02:47 -070095 int properties,
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -080096 int supportedAudioRoutes,
Andrew Lee100e2932014-09-08 15:34:24 -070097 Uri address,
98 int addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -070099 String callerDisplayName,
100 int callerDisplayNamePresentation,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700101 IVideoProvider videoProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700102 int videoState,
Andrew Lee100e2932014-09-08 15:34:24 -0700103 boolean ringbackRequested,
104 boolean isVoipAudioMode,
Roshan Piuse927ec02015-07-15 15:47:21 -0700105 long connectTimeMillis,
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700106 long connectElapsedTimeMillis,
Ihab Awad6107bab2014-08-18 09:23:25 -0700107 StatusHints statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700108 DisconnectCause disconnectCause,
Santos Cordon6b7f9552015-05-27 17:21:45 -0700109 List<String> conferenceableConnectionIds,
110 Bundle extras) {
Santos Cordone8dc4be2014-07-21 01:28:28 -0700111 mPhoneAccount = phoneAccount;
112 mState = state;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800113 mConnectionCapabilities = capabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -0700114 mConnectionProperties = properties;
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800115 mSupportedAudioRoutes = supportedAudioRoutes;
Andrew Lee100e2932014-09-08 15:34:24 -0700116 mAddress = address;
117 mAddressPresentation = addressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700118 mCallerDisplayName = callerDisplayName;
119 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700120 mVideoProvider = videoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700121 mVideoState = videoState;
Andrew Lee100e2932014-09-08 15:34:24 -0700122 mRingbackRequested = ringbackRequested;
123 mIsVoipAudioMode = isVoipAudioMode;
Roshan Piuse927ec02015-07-15 15:47:21 -0700124 mConnectTimeMillis = connectTimeMillis;
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700125 mConnectElapsedTimeMillis = connectElapsedTimeMillis;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700126 mStatusHints = statusHints;
Sailesh Nepalcf7020b2014-08-20 10:07:19 -0700127 mDisconnectCause = disconnectCause;
Santos Cordon6b7f9552015-05-27 17:21:45 -0700128 mConferenceableConnectionIds = conferenceableConnectionIds;
129 mExtras = extras;
Tyler Gunn78da7812017-05-09 14:34:57 -0700130 mParentCallId = null;
Tyler Gunn6986a632019-06-25 13:45:32 -0700131 mCallDirection = Call.Details.DIRECTION_UNKNOWN;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700132 }
133
134 public PhoneAccountHandle getPhoneAccount() {
135 return mPhoneAccount;
136 }
137
138 public int getState() {
139 return mState;
140 }
141
Tyler Gunn720c6642016-03-22 09:02:47 -0700142 /**
143 * Returns the current connection capabilities bit-mask. Connection capabilities are defined as
144 * {@code CAPABILITY_*} constants in {@link Connection}.
145 *
146 * @return Bit-mask containing capabilities of the connection.
147 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800148 public int getConnectionCapabilities() {
149 return mConnectionCapabilities;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700150 }
151
Tyler Gunn720c6642016-03-22 09:02:47 -0700152 /**
153 * Returns the current connection properties bit-mask. Connection properties are defined as
154 * {@code PROPERTY_*} constants in {@link Connection}.
155 *
156 * @return Bit-mask containing properties of the connection.
157 */
158 public int getConnectionProperties() {
159 return mConnectionProperties;
160 }
161
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800162 public int getSupportedAudioRoutes() {
163 return mSupportedAudioRoutes;
164 }
165
Santos Cordone8dc4be2014-07-21 01:28:28 -0700166 public Uri getHandle() {
Andrew Lee100e2932014-09-08 15:34:24 -0700167 return mAddress;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700168 }
169
170 public int getHandlePresentation() {
Andrew Lee100e2932014-09-08 15:34:24 -0700171 return mAddressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700172 }
173
174 public String getCallerDisplayName() {
175 return mCallerDisplayName;
176 }
177
178 public int getCallerDisplayNamePresentation() {
179 return mCallerDisplayNamePresentation;
180 }
181
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700182 public IVideoProvider getVideoProvider() {
183 return mVideoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700184 }
185
186 public int getVideoState() {
187 return mVideoState;
188 }
189
Andrew Lee100e2932014-09-08 15:34:24 -0700190 public boolean isRingbackRequested() {
191 return mRingbackRequested;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700192 }
193
Andrew Lee100e2932014-09-08 15:34:24 -0700194 public boolean getIsVoipAudioMode() {
195 return mIsVoipAudioMode;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700196 }
197
Roshan Piuse927ec02015-07-15 15:47:21 -0700198 public long getConnectTimeMillis() {
199 return mConnectTimeMillis;
200 }
201
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700202 public long getConnectElapsedTimeMillis() {
203 return mConnectElapsedTimeMillis;
204 }
205
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700206 public final StatusHints getStatusHints() {
207 return mStatusHints;
208 }
209
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700210 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -0700211 return mDisconnectCause;
Ihab Awad6107bab2014-08-18 09:23:25 -0700212 }
213
Ihab Awadb8e85c72014-08-23 20:34:57 -0700214 public final List<String> getConferenceableConnectionIds() {
215 return mConferenceableConnectionIds;
216 }
217
Santos Cordon6b7f9552015-05-27 17:21:45 -0700218 public final Bundle getExtras() {
219 return mExtras;
220 }
221
Tyler Gunn78da7812017-05-09 14:34:57 -0700222 public final String getParentCallId() {
223 return mParentCallId;
224 }
225
Tyler Gunn6986a632019-06-25 13:45:32 -0700226 public @Call.Details.CallDirection int getCallDirection() {
227 return mCallDirection;
228 }
229
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700230 @Override
231 public String toString() {
232 return new StringBuilder()
233 .append("ParcelableConnection [act:")
234 .append(mPhoneAccount)
Santos Cordon6b7f9552015-05-27 17:21:45 -0700235 .append("], state:")
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700236 .append(mState)
237 .append(", capabilities:")
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800238 .append(Connection.capabilitiesToString(mConnectionCapabilities))
Tyler Gunn720c6642016-03-22 09:02:47 -0700239 .append(", properties:")
240 .append(Connection.propertiesToString(mConnectionProperties))
Santos Cordon6b7f9552015-05-27 17:21:45 -0700241 .append(", extras:")
242 .append(mExtras)
Tyler Gunn78da7812017-05-09 14:34:57 -0700243 .append(", parent:")
244 .append(mParentCallId)
Tyler Gunn6986a632019-06-25 13:45:32 -0700245 .append(", callDirection:")
246 .append(mCallDirection)
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700247 .toString();
248 }
249
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -0700250 public static final @android.annotation.NonNull Parcelable.Creator<ParcelableConnection> CREATOR =
Santos Cordone8dc4be2014-07-21 01:28:28 -0700251 new Parcelable.Creator<ParcelableConnection> () {
252 @Override
253 public ParcelableConnection createFromParcel(Parcel source) {
254 ClassLoader classLoader = ParcelableConnection.class.getClassLoader();
255
256 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
257 int state = source.readInt();
258 int capabilities = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700259 Uri address = source.readParcelable(classLoader);
260 int addressPresentation = source.readInt();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700261 String callerDisplayName = source.readString();
262 int callerDisplayNamePresentation = source.readInt();
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700263 IVideoProvider videoCallProvider =
264 IVideoProvider.Stub.asInterface(source.readStrongBinder());
Santos Cordone8dc4be2014-07-21 01:28:28 -0700265 int videoState = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700266 boolean ringbackRequested = source.readByte() == 1;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700267 boolean audioModeIsVoip = source.readByte() == 1;
Roshan Piuse927ec02015-07-15 15:47:21 -0700268 long connectTimeMillis = source.readLong();
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700269 StatusHints statusHints = source.readParcelable(classLoader);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700270 DisconnectCause disconnectCause = source.readParcelable(classLoader);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700271 List<String> conferenceableConnectionIds = new ArrayList<>();
272 source.readStringList(conferenceableConnectionIds);
Jeff Sharkeyf0ec2e02016-03-21 12:37:54 -0600273 Bundle extras = Bundle.setDefusable(source.readBundle(classLoader), true);
Tyler Gunn720c6642016-03-22 09:02:47 -0700274 int properties = source.readInt();
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800275 int supportedAudioRoutes = source.readInt();
Tyler Gunn78da7812017-05-09 14:34:57 -0700276 String parentCallId = source.readString();
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700277 long connectElapsedTimeMillis = source.readLong();
Tyler Gunn6986a632019-06-25 13:45:32 -0700278 int callDirection = source.readInt();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700279
280 return new ParcelableConnection(
281 phoneAccount,
282 state,
283 capabilities,
Tyler Gunn720c6642016-03-22 09:02:47 -0700284 properties,
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800285 supportedAudioRoutes,
Andrew Lee100e2932014-09-08 15:34:24 -0700286 address,
287 addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -0700288 callerDisplayName,
289 callerDisplayNamePresentation,
Andrew Lee50aca232014-07-22 16:41:54 -0700290 videoCallProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700291 videoState,
Andrew Lee100e2932014-09-08 15:34:24 -0700292 ringbackRequested,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700293 audioModeIsVoip,
Roshan Piuse927ec02015-07-15 15:47:21 -0700294 connectTimeMillis,
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700295 connectElapsedTimeMillis,
Ihab Awad6107bab2014-08-18 09:23:25 -0700296 statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700297 disconnectCause,
Santos Cordon6b7f9552015-05-27 17:21:45 -0700298 conferenceableConnectionIds,
Tyler Gunn78da7812017-05-09 14:34:57 -0700299 extras,
Tyler Gunn6986a632019-06-25 13:45:32 -0700300 parentCallId,
301 callDirection);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700302 }
303
304 @Override
305 public ParcelableConnection[] newArray(int size) {
306 return new ParcelableConnection[size];
307 }
308 };
309
310 /** {@inheritDoc} */
311 @Override
312 public int describeContents() {
313 return 0;
314 }
315
316 /** Writes ParcelableConnection object into a Parcel. */
317 @Override
318 public void writeToParcel(Parcel destination, int flags) {
319 destination.writeParcelable(mPhoneAccount, 0);
320 destination.writeInt(mState);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800321 destination.writeInt(mConnectionCapabilities);
Andrew Lee100e2932014-09-08 15:34:24 -0700322 destination.writeParcelable(mAddress, 0);
323 destination.writeInt(mAddressPresentation);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700324 destination.writeString(mCallerDisplayName);
325 destination.writeInt(mCallerDisplayNamePresentation);
326 destination.writeStrongBinder(
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700327 mVideoProvider != null ? mVideoProvider.asBinder() : null);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700328 destination.writeInt(mVideoState);
Andrew Lee100e2932014-09-08 15:34:24 -0700329 destination.writeByte((byte) (mRingbackRequested ? 1 : 0));
330 destination.writeByte((byte) (mIsVoipAudioMode ? 1 : 0));
Roshan Piuse927ec02015-07-15 15:47:21 -0700331 destination.writeLong(mConnectTimeMillis);
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700332 destination.writeParcelable(mStatusHints, 0);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700333 destination.writeParcelable(mDisconnectCause, 0);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700334 destination.writeStringList(mConferenceableConnectionIds);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700335 destination.writeBundle(mExtras);
Tyler Gunn720c6642016-03-22 09:02:47 -0700336 destination.writeInt(mConnectionProperties);
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800337 destination.writeInt(mSupportedAudioRoutes);
Tyler Gunn78da7812017-05-09 14:34:57 -0700338 destination.writeString(mParentCallId);
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700339 destination.writeLong(mConnectElapsedTimeMillis);
Tyler Gunn6986a632019-06-25 13:45:32 -0700340 destination.writeInt(mCallDirection);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700341 }
342}