blob: 2b9ce9b46ad70e9a0b030240edfbc4517f7e07bb [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 Gunnd57d76c2019-09-24 14:53:23 -070057 private @Connection.VerificationStatus int mCallerNumberVerificationStatus;
Tyler Gunn78da7812017-05-09 14:34:57 -070058
59 /** @hide */
60 public ParcelableConnection(
61 PhoneAccountHandle phoneAccount,
62 int state,
63 int capabilities,
64 int properties,
65 int supportedAudioRoutes,
66 Uri address,
67 int addressPresentation,
68 String callerDisplayName,
69 int callerDisplayNamePresentation,
70 IVideoProvider videoProvider,
71 int videoState,
72 boolean ringbackRequested,
73 boolean isVoipAudioMode,
74 long connectTimeMillis,
Tyler Gunnb2f875b2017-08-04 09:27:26 -070075 long connectElapsedTimeMillis,
Tyler Gunn78da7812017-05-09 14:34:57 -070076 StatusHints statusHints,
77 DisconnectCause disconnectCause,
78 List<String> conferenceableConnectionIds,
79 Bundle extras,
Tyler Gunn6986a632019-06-25 13:45:32 -070080 String parentCallId,
Tyler Gunnd57d76c2019-09-24 14:53:23 -070081 @Call.Details.CallDirection int callDirection,
82 @Connection.VerificationStatus int callerNumberVerificationStatus) {
Tyler Gunn78da7812017-05-09 14:34:57 -070083 this(phoneAccount, state, capabilities, properties, supportedAudioRoutes, address,
84 addressPresentation, callerDisplayName, callerDisplayNamePresentation,
85 videoProvider, videoState, ringbackRequested, isVoipAudioMode, connectTimeMillis,
Tyler Gunnb2f875b2017-08-04 09:27:26 -070086 connectElapsedTimeMillis, statusHints, disconnectCause, conferenceableConnectionIds,
Tyler Gunnd57d76c2019-09-24 14:53:23 -070087 extras, callerNumberVerificationStatus);
Tyler Gunn78da7812017-05-09 14:34:57 -070088 mParentCallId = parentCallId;
Tyler Gunn6986a632019-06-25 13:45:32 -070089 mCallDirection = callDirection;
Tyler Gunn78da7812017-05-09 14:34:57 -070090 }
Santos Cordone8dc4be2014-07-21 01:28:28 -070091
92 /** @hide */
93 public ParcelableConnection(
94 PhoneAccountHandle phoneAccount,
95 int state,
96 int capabilities,
Tyler Gunn720c6642016-03-22 09:02:47 -070097 int properties,
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -080098 int supportedAudioRoutes,
Andrew Lee100e2932014-09-08 15:34:24 -070099 Uri address,
100 int addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -0700101 String callerDisplayName,
102 int callerDisplayNamePresentation,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700103 IVideoProvider videoProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700104 int videoState,
Andrew Lee100e2932014-09-08 15:34:24 -0700105 boolean ringbackRequested,
106 boolean isVoipAudioMode,
Roshan Piuse927ec02015-07-15 15:47:21 -0700107 long connectTimeMillis,
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700108 long connectElapsedTimeMillis,
Ihab Awad6107bab2014-08-18 09:23:25 -0700109 StatusHints statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700110 DisconnectCause disconnectCause,
Santos Cordon6b7f9552015-05-27 17:21:45 -0700111 List<String> conferenceableConnectionIds,
Tyler Gunnd57d76c2019-09-24 14:53:23 -0700112 Bundle extras,
113 @Connection.VerificationStatus int callerNumberVerificationStatus) {
Santos Cordone8dc4be2014-07-21 01:28:28 -0700114 mPhoneAccount = phoneAccount;
115 mState = state;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800116 mConnectionCapabilities = capabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -0700117 mConnectionProperties = properties;
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800118 mSupportedAudioRoutes = supportedAudioRoutes;
Andrew Lee100e2932014-09-08 15:34:24 -0700119 mAddress = address;
120 mAddressPresentation = addressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700121 mCallerDisplayName = callerDisplayName;
122 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700123 mVideoProvider = videoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700124 mVideoState = videoState;
Andrew Lee100e2932014-09-08 15:34:24 -0700125 mRingbackRequested = ringbackRequested;
126 mIsVoipAudioMode = isVoipAudioMode;
Roshan Piuse927ec02015-07-15 15:47:21 -0700127 mConnectTimeMillis = connectTimeMillis;
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700128 mConnectElapsedTimeMillis = connectElapsedTimeMillis;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700129 mStatusHints = statusHints;
Sailesh Nepalcf7020b2014-08-20 10:07:19 -0700130 mDisconnectCause = disconnectCause;
Santos Cordon6b7f9552015-05-27 17:21:45 -0700131 mConferenceableConnectionIds = conferenceableConnectionIds;
132 mExtras = extras;
Tyler Gunn78da7812017-05-09 14:34:57 -0700133 mParentCallId = null;
Tyler Gunn6986a632019-06-25 13:45:32 -0700134 mCallDirection = Call.Details.DIRECTION_UNKNOWN;
Tyler Gunnd57d76c2019-09-24 14:53:23 -0700135 mCallerNumberVerificationStatus = callerNumberVerificationStatus;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700136 }
137
138 public PhoneAccountHandle getPhoneAccount() {
139 return mPhoneAccount;
140 }
141
142 public int getState() {
143 return mState;
144 }
145
Tyler Gunn720c6642016-03-22 09:02:47 -0700146 /**
147 * Returns the current connection capabilities bit-mask. Connection capabilities are defined as
148 * {@code CAPABILITY_*} constants in {@link Connection}.
149 *
150 * @return Bit-mask containing capabilities of the connection.
151 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800152 public int getConnectionCapabilities() {
153 return mConnectionCapabilities;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700154 }
155
Tyler Gunn720c6642016-03-22 09:02:47 -0700156 /**
157 * Returns the current connection properties bit-mask. Connection properties are defined as
158 * {@code PROPERTY_*} constants in {@link Connection}.
159 *
160 * @return Bit-mask containing properties of the connection.
161 */
162 public int getConnectionProperties() {
163 return mConnectionProperties;
164 }
165
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800166 public int getSupportedAudioRoutes() {
167 return mSupportedAudioRoutes;
168 }
169
Santos Cordone8dc4be2014-07-21 01:28:28 -0700170 public Uri getHandle() {
Andrew Lee100e2932014-09-08 15:34:24 -0700171 return mAddress;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700172 }
173
174 public int getHandlePresentation() {
Andrew Lee100e2932014-09-08 15:34:24 -0700175 return mAddressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700176 }
177
178 public String getCallerDisplayName() {
179 return mCallerDisplayName;
180 }
181
182 public int getCallerDisplayNamePresentation() {
183 return mCallerDisplayNamePresentation;
184 }
185
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700186 public IVideoProvider getVideoProvider() {
187 return mVideoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700188 }
189
190 public int getVideoState() {
191 return mVideoState;
192 }
193
Andrew Lee100e2932014-09-08 15:34:24 -0700194 public boolean isRingbackRequested() {
195 return mRingbackRequested;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700196 }
197
Andrew Lee100e2932014-09-08 15:34:24 -0700198 public boolean getIsVoipAudioMode() {
199 return mIsVoipAudioMode;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700200 }
201
Roshan Piuse927ec02015-07-15 15:47:21 -0700202 public long getConnectTimeMillis() {
203 return mConnectTimeMillis;
204 }
205
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700206 public long getConnectElapsedTimeMillis() {
207 return mConnectElapsedTimeMillis;
208 }
209
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700210 public final StatusHints getStatusHints() {
211 return mStatusHints;
212 }
213
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700214 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -0700215 return mDisconnectCause;
Ihab Awad6107bab2014-08-18 09:23:25 -0700216 }
217
Ihab Awadb8e85c72014-08-23 20:34:57 -0700218 public final List<String> getConferenceableConnectionIds() {
219 return mConferenceableConnectionIds;
220 }
221
Santos Cordon6b7f9552015-05-27 17:21:45 -0700222 public final Bundle getExtras() {
223 return mExtras;
224 }
225
Tyler Gunn78da7812017-05-09 14:34:57 -0700226 public final String getParentCallId() {
227 return mParentCallId;
228 }
229
Tyler Gunn6986a632019-06-25 13:45:32 -0700230 public @Call.Details.CallDirection int getCallDirection() {
231 return mCallDirection;
232 }
233
Tyler Gunnd57d76c2019-09-24 14:53:23 -0700234 public @Connection.VerificationStatus int getCallerNumberVerificationStatus() {
235 return mCallerNumberVerificationStatus;
236 }
237
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700238 @Override
239 public String toString() {
240 return new StringBuilder()
241 .append("ParcelableConnection [act:")
242 .append(mPhoneAccount)
Santos Cordon6b7f9552015-05-27 17:21:45 -0700243 .append("], state:")
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700244 .append(mState)
245 .append(", capabilities:")
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800246 .append(Connection.capabilitiesToString(mConnectionCapabilities))
Tyler Gunn720c6642016-03-22 09:02:47 -0700247 .append(", properties:")
248 .append(Connection.propertiesToString(mConnectionProperties))
Santos Cordon6b7f9552015-05-27 17:21:45 -0700249 .append(", extras:")
250 .append(mExtras)
Tyler Gunn78da7812017-05-09 14:34:57 -0700251 .append(", parent:")
252 .append(mParentCallId)
Tyler Gunn6986a632019-06-25 13:45:32 -0700253 .append(", callDirection:")
254 .append(mCallDirection)
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700255 .toString();
256 }
257
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -0700258 public static final @android.annotation.NonNull Parcelable.Creator<ParcelableConnection> CREATOR =
Santos Cordone8dc4be2014-07-21 01:28:28 -0700259 new Parcelable.Creator<ParcelableConnection> () {
260 @Override
261 public ParcelableConnection createFromParcel(Parcel source) {
262 ClassLoader classLoader = ParcelableConnection.class.getClassLoader();
263
264 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
265 int state = source.readInt();
266 int capabilities = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700267 Uri address = source.readParcelable(classLoader);
268 int addressPresentation = source.readInt();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700269 String callerDisplayName = source.readString();
270 int callerDisplayNamePresentation = source.readInt();
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700271 IVideoProvider videoCallProvider =
272 IVideoProvider.Stub.asInterface(source.readStrongBinder());
Santos Cordone8dc4be2014-07-21 01:28:28 -0700273 int videoState = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700274 boolean ringbackRequested = source.readByte() == 1;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700275 boolean audioModeIsVoip = source.readByte() == 1;
Roshan Piuse927ec02015-07-15 15:47:21 -0700276 long connectTimeMillis = source.readLong();
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700277 StatusHints statusHints = source.readParcelable(classLoader);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700278 DisconnectCause disconnectCause = source.readParcelable(classLoader);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700279 List<String> conferenceableConnectionIds = new ArrayList<>();
280 source.readStringList(conferenceableConnectionIds);
Jeff Sharkeyf0ec2e02016-03-21 12:37:54 -0600281 Bundle extras = Bundle.setDefusable(source.readBundle(classLoader), true);
Tyler Gunn720c6642016-03-22 09:02:47 -0700282 int properties = source.readInt();
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800283 int supportedAudioRoutes = source.readInt();
Tyler Gunn78da7812017-05-09 14:34:57 -0700284 String parentCallId = source.readString();
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700285 long connectElapsedTimeMillis = source.readLong();
Tyler Gunn6986a632019-06-25 13:45:32 -0700286 int callDirection = source.readInt();
Tyler Gunnd57d76c2019-09-24 14:53:23 -0700287 int callerNumberVerificationStatus = source.readInt();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700288
289 return new ParcelableConnection(
290 phoneAccount,
291 state,
292 capabilities,
Tyler Gunn720c6642016-03-22 09:02:47 -0700293 properties,
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800294 supportedAudioRoutes,
Andrew Lee100e2932014-09-08 15:34:24 -0700295 address,
296 addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -0700297 callerDisplayName,
298 callerDisplayNamePresentation,
Andrew Lee50aca232014-07-22 16:41:54 -0700299 videoCallProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700300 videoState,
Andrew Lee100e2932014-09-08 15:34:24 -0700301 ringbackRequested,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700302 audioModeIsVoip,
Roshan Piuse927ec02015-07-15 15:47:21 -0700303 connectTimeMillis,
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700304 connectElapsedTimeMillis,
Ihab Awad6107bab2014-08-18 09:23:25 -0700305 statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700306 disconnectCause,
Santos Cordon6b7f9552015-05-27 17:21:45 -0700307 conferenceableConnectionIds,
Tyler Gunn78da7812017-05-09 14:34:57 -0700308 extras,
Tyler Gunn6986a632019-06-25 13:45:32 -0700309 parentCallId,
Tyler Gunnd57d76c2019-09-24 14:53:23 -0700310 callDirection,
311 callerNumberVerificationStatus);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700312 }
313
314 @Override
315 public ParcelableConnection[] newArray(int size) {
316 return new ParcelableConnection[size];
317 }
318 };
319
320 /** {@inheritDoc} */
321 @Override
322 public int describeContents() {
323 return 0;
324 }
325
326 /** Writes ParcelableConnection object into a Parcel. */
327 @Override
328 public void writeToParcel(Parcel destination, int flags) {
329 destination.writeParcelable(mPhoneAccount, 0);
330 destination.writeInt(mState);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800331 destination.writeInt(mConnectionCapabilities);
Andrew Lee100e2932014-09-08 15:34:24 -0700332 destination.writeParcelable(mAddress, 0);
333 destination.writeInt(mAddressPresentation);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700334 destination.writeString(mCallerDisplayName);
335 destination.writeInt(mCallerDisplayNamePresentation);
336 destination.writeStrongBinder(
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700337 mVideoProvider != null ? mVideoProvider.asBinder() : null);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700338 destination.writeInt(mVideoState);
Andrew Lee100e2932014-09-08 15:34:24 -0700339 destination.writeByte((byte) (mRingbackRequested ? 1 : 0));
340 destination.writeByte((byte) (mIsVoipAudioMode ? 1 : 0));
Roshan Piuse927ec02015-07-15 15:47:21 -0700341 destination.writeLong(mConnectTimeMillis);
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700342 destination.writeParcelable(mStatusHints, 0);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700343 destination.writeParcelable(mDisconnectCause, 0);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700344 destination.writeStringList(mConferenceableConnectionIds);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700345 destination.writeBundle(mExtras);
Tyler Gunn720c6642016-03-22 09:02:47 -0700346 destination.writeInt(mConnectionProperties);
Christine Hallstrom4e22d6d2016-11-30 16:06:42 -0800347 destination.writeInt(mSupportedAudioRoutes);
Tyler Gunn78da7812017-05-09 14:34:57 -0700348 destination.writeString(mParentCallId);
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700349 destination.writeLong(mConnectElapsedTimeMillis);
Tyler Gunn6986a632019-06-25 13:45:32 -0700350 destination.writeInt(mCallDirection);
Tyler Gunnd57d76c2019-09-24 14:53:23 -0700351 destination.writeInt(mCallerNumberVerificationStatus);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700352 }
353}