blob: 6dcfa6d56ef32d21425edc07bcf8141a76295103 [file] [log] [blame]
Santos Cordon823fd3c2014-08-07 18:35:18 -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 Cordon823fd3c2014-08-07 18:35:18 -070018
Tyler Gunnac60f952019-05-31 07:23:16 -070019import android.net.Uri;
Santos Cordon6b7f9552015-05-27 17:21:45 -070020import android.os.Bundle;
Santos Cordon823fd3c2014-08-07 18:35:18 -070021import android.os.Parcel;
22import android.os.Parcelable;
23
Pranav Madapurmathac29a0c2023-05-25 21:58:19 +000024import com.android.internal.telecom.IVideoProvider;
25
Santos Cordon823fd3c2014-08-07 18:35:18 -070026import java.util.ArrayList;
Brad Ebinger43e02652020-04-09 15:30:57 -070027import java.util.Collections;
Santos Cordon823fd3c2014-08-07 18:35:18 -070028import java.util.List;
29
30/**
31 * A parcelable representation of a conference connection.
32 * @hide
33 */
34public final class ParcelableConference implements Parcelable {
35
Brad Ebinger43e02652020-04-09 15:30:57 -070036 public static final class Builder {
37 private final PhoneAccountHandle mPhoneAccount;
38 private final int mState;
39 private int mConnectionCapabilities;
40 private int mConnectionProperties;
41 private List<String> mConnectionIds = Collections.emptyList();
42 private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
43 private IVideoProvider mVideoProvider;
44 private int mVideoState = VideoProfile.STATE_AUDIO_ONLY;
45 private StatusHints mStatusHints;
46 private Bundle mExtras;
47 private long mConnectElapsedTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
48 private Uri mAddress;
49 private int mAddressPresentation = TelecomManager.PRESENTATION_UNKNOWN;
50 private String mCallerDisplayName;
51 private int mCallerDisplayNamePresentation = TelecomManager.PRESENTATION_UNKNOWN;;
52 private DisconnectCause mDisconnectCause;
53 private boolean mRingbackRequested;
54 private int mCallDirection = Call.Details.DIRECTION_UNKNOWN;
55
56 public Builder(
57 PhoneAccountHandle phoneAccount,
58 int state) {
59 mPhoneAccount = phoneAccount;
60 mState = state;
61 }
62
63 public Builder setDisconnectCause(DisconnectCause cause) {
64 mDisconnectCause = cause;
65 return this;
66 }
67
68 public Builder setRingbackRequested(boolean requested) {
69 mRingbackRequested = requested;
70 return this;
71 }
72
73 public Builder setCallerDisplayName(String callerDisplayName,
74 @TelecomManager.Presentation int callerDisplayNamePresentation) {
75 mCallerDisplayName = callerDisplayName;
76 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
77 return this;
78 }
79
80 public Builder setAddress(Uri address,
81 @TelecomManager.Presentation int addressPresentation) {
82 mAddress = address;
83 mAddressPresentation = addressPresentation;
84 return this;
85 }
86
87 public Builder setExtras(Bundle extras) {
88 mExtras = extras;
89 return this;
90 }
91
92 public Builder setStatusHints(StatusHints hints) {
93 mStatusHints = hints;
94 return this;
95 }
96
97 public Builder setConnectTimeMillis(long connectTimeMillis, long connectElapsedTimeMillis) {
98 mConnectTimeMillis = connectTimeMillis;
99 mConnectElapsedTimeMillis = connectElapsedTimeMillis;
100 return this;
101 }
102
103 public Builder setVideoAttributes(IVideoProvider provider,
104 @VideoProfile.VideoState int videoState) {
105 mVideoProvider = provider;
106 mVideoState = videoState;
107 return this;
108 }
109
110 public Builder setConnectionIds(List<String> connectionIds) {
111 mConnectionIds = connectionIds;
112 return this;
113 }
114
115 public Builder setConnectionProperties(int properties) {
116 mConnectionProperties = properties;
117 return this;
118 }
119
120 public Builder setConnectionCapabilities(int capabilities) {
121 mConnectionCapabilities = capabilities;
122 return this;
123 }
124
125 public Builder setCallDirection(int callDirection) {
126 mCallDirection = callDirection;
127 return this;
128 }
129
130 public ParcelableConference build() {
131 return new ParcelableConference(mPhoneAccount, mState, mConnectionCapabilities,
132 mConnectionProperties, mConnectionIds, mVideoProvider, mVideoState,
133 mConnectTimeMillis, mConnectElapsedTimeMillis, mStatusHints, mExtras, mAddress,
134 mAddressPresentation, mCallerDisplayName, mCallerDisplayNamePresentation,
135 mDisconnectCause, mRingbackRequested, mCallDirection);
136 }
137 }
138
139
140 private final PhoneAccountHandle mPhoneAccount;
141 private final int mState;
142 private final int mConnectionCapabilities;
143 private final int mConnectionProperties;
144 private final List<String> mConnectionIds;
145 private final long mConnectTimeMillis;
Rekha Kumar07366812015-03-24 16:42:31 -0700146 private final IVideoProvider mVideoProvider;
147 private final int mVideoState;
Brad Ebinger43e02652020-04-09 15:30:57 -0700148 private final StatusHints mStatusHints;
149 private final Bundle mExtras;
150 private final long mConnectElapsedTimeMillis;
Tyler Gunnac60f952019-05-31 07:23:16 -0700151 private final Uri mAddress;
152 private final int mAddressPresentation;
153 private final String mCallerDisplayName;
154 private final int mCallerDisplayNamePresentation;
Brad Ebinger43e02652020-04-09 15:30:57 -0700155 private final DisconnectCause mDisconnectCause;
156 private final boolean mRingbackRequested;
157 private final int mCallDirection;
Ravi Paluri80aa2142019-12-02 11:57:37 +0530158
Brad Ebinger43e02652020-04-09 15:30:57 -0700159 private ParcelableConference(
Ravi Paluri80aa2142019-12-02 11:57:37 +0530160 PhoneAccountHandle phoneAccount,
161 int state,
162 int connectionCapabilities,
163 int connectionProperties,
164 List<String> connectionIds,
165 IVideoProvider videoProvider,
166 int videoState,
167 long connectTimeMillis,
168 long connectElapsedTimeMillis,
169 StatusHints statusHints,
170 Bundle extras,
171 Uri address,
172 int addressPresentation,
173 String callerDisplayName,
174 int callerDisplayNamePresentation,
175 DisconnectCause disconnectCause,
Brad Ebinger43e02652020-04-09 15:30:57 -0700176 boolean ringbackRequested,
177 int callDirection) {
Andrew Leeedc625f2015-04-14 13:38:12 -0700178 mPhoneAccount = phoneAccount;
179 mState = state;
180 mConnectionCapabilities = connectionCapabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -0700181 mConnectionProperties = connectionProperties;
Andrew Leeedc625f2015-04-14 13:38:12 -0700182 mConnectionIds = connectionIds;
Andrew Lee0f51da32015-04-16 13:11:55 -0700183 mVideoProvider = videoProvider;
184 mVideoState = videoState;
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800185 mConnectTimeMillis = connectTimeMillis;
Andrew Leeedc625f2015-04-14 13:38:12 -0700186 mStatusHints = statusHints;
Santos Cordon6b7f9552015-05-27 17:21:45 -0700187 mExtras = extras;
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700188 mConnectElapsedTimeMillis = connectElapsedTimeMillis;
Tyler Gunnac60f952019-05-31 07:23:16 -0700189 mAddress = address;
190 mAddressPresentation = addressPresentation;
191 mCallerDisplayName = callerDisplayName;
192 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
Brad Ebinger43e02652020-04-09 15:30:57 -0700193 mDisconnectCause = disconnectCause;
194 mRingbackRequested = ringbackRequested;
195 mCallDirection = callDirection;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700196 }
197
198 @Override
199 public String toString() {
200 return (new StringBuffer())
201 .append("account: ")
202 .append(mPhoneAccount)
203 .append(", state: ")
204 .append(Connection.stateToString(mState))
205 .append(", capabilities: ")
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800206 .append(Connection.capabilitiesToString(mConnectionCapabilities))
Tyler Gunn720c6642016-03-22 09:02:47 -0700207 .append(", properties: ")
208 .append(Connection.propertiesToString(mConnectionProperties))
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800209 .append(", connectTime: ")
210 .append(mConnectTimeMillis)
Santos Cordon823fd3c2014-08-07 18:35:18 -0700211 .append(", children: ")
212 .append(mConnectionIds)
Rekha Kumar07366812015-03-24 16:42:31 -0700213 .append(", VideoState: ")
214 .append(mVideoState)
215 .append(", VideoProvider: ")
216 .append(mVideoProvider)
Ravi Paluri80aa2142019-12-02 11:57:37 +0530217 .append(", isRingbackRequested: ")
218 .append(mRingbackRequested)
219 .append(", disconnectCause: ")
220 .append(mDisconnectCause)
Brad Ebinger43e02652020-04-09 15:30:57 -0700221 .append(", callDirection: ")
222 .append(mCallDirection)
Santos Cordon823fd3c2014-08-07 18:35:18 -0700223 .toString();
224 }
225
226 public PhoneAccountHandle getPhoneAccount() {
227 return mPhoneAccount;
228 }
229
230 public int getState() {
231 return mState;
232 }
233
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800234 public int getConnectionCapabilities() {
235 return mConnectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700236 }
237
Tyler Gunn720c6642016-03-22 09:02:47 -0700238 public int getConnectionProperties() {
239 return mConnectionProperties;
240 }
241
Santos Cordon823fd3c2014-08-07 18:35:18 -0700242 public List<String> getConnectionIds() {
243 return mConnectionIds;
244 }
245
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800246 public long getConnectTimeMillis() {
247 return mConnectTimeMillis;
248 }
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700249
250 public long getConnectElapsedTimeMillis() {
251 return mConnectElapsedTimeMillis;
252 }
253
Rekha Kumar07366812015-03-24 16:42:31 -0700254 public IVideoProvider getVideoProvider() {
255 return mVideoProvider;
256 }
257
258 public int getVideoState() {
259 return mVideoState;
260 }
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800261
Andrew Leeedc625f2015-04-14 13:38:12 -0700262 public StatusHints getStatusHints() {
263 return mStatusHints;
264 }
265
Santos Cordon6b7f9552015-05-27 17:21:45 -0700266 public Bundle getExtras() {
267 return mExtras;
268 }
269
Tyler Gunnac60f952019-05-31 07:23:16 -0700270 public Uri getHandle() {
271 return mAddress;
272 }
273
Ravi Paluri80aa2142019-12-02 11:57:37 +0530274 public final DisconnectCause getDisconnectCause() {
275 return mDisconnectCause;
276 }
277
278 public boolean isRingbackRequested() {
279 return mRingbackRequested;
280 }
Brad Ebinger43e02652020-04-09 15:30:57 -0700281
Tyler Gunnac60f952019-05-31 07:23:16 -0700282 public int getHandlePresentation() {
283 return mAddressPresentation;
284 }
285
Brad Ebinger43e02652020-04-09 15:30:57 -0700286 public int getCallDirection() {
287 return mCallDirection;
288 }
289
Pranav Madapurmathac29a0c2023-05-25 21:58:19 +0000290 public String getCallerDisplayName() {
291 return mCallerDisplayName;
292 }
293
294 public int getCallerDisplayNamePresentation() {
295 return mCallerDisplayNamePresentation;
296 }
297
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -0700298 public static final @android.annotation.NonNull Parcelable.Creator<ParcelableConference> CREATOR =
Santos Cordon823fd3c2014-08-07 18:35:18 -0700299 new Parcelable.Creator<ParcelableConference> () {
300 @Override
301 public ParcelableConference createFromParcel(Parcel source) {
302 ClassLoader classLoader = ParcelableConference.class.getClassLoader();
Bernardo Rufino1a5cb382022-01-14 17:35:36 +0000303 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader, android.telecom.PhoneAccountHandle.class);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700304 int state = source.readInt();
305 int capabilities = source.readInt();
306 List<String> connectionIds = new ArrayList<>(2);
Bernardo Rufino1a5cb382022-01-14 17:35:36 +0000307 source.readList(connectionIds, classLoader, java.lang.String.class);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800308 long connectTimeMillis = source.readLong();
Rekha Kumar07366812015-03-24 16:42:31 -0700309 IVideoProvider videoCallProvider =
310 IVideoProvider.Stub.asInterface(source.readStrongBinder());
311 int videoState = source.readInt();
Bernardo Rufino1a5cb382022-01-14 17:35:36 +0000312 StatusHints statusHints = source.readParcelable(classLoader, android.telecom.StatusHints.class);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700313 Bundle extras = source.readBundle(classLoader);
Tyler Gunn720c6642016-03-22 09:02:47 -0700314 int properties = source.readInt();
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700315 long connectElapsedTimeMillis = source.readLong();
Bernardo Rufino1a5cb382022-01-14 17:35:36 +0000316 Uri address = source.readParcelable(classLoader, android.net.Uri.class);
Tyler Gunnac60f952019-05-31 07:23:16 -0700317 int addressPresentation = source.readInt();
318 String callerDisplayName = source.readString();
319 int callerDisplayNamePresentation = source.readInt();
Bernardo Rufino1a5cb382022-01-14 17:35:36 +0000320 DisconnectCause disconnectCause = source.readParcelable(classLoader, android.telecom.DisconnectCause.class);
Ravi Paluri80aa2142019-12-02 11:57:37 +0530321 boolean isRingbackRequested = source.readInt() == 1;
Brad Ebinger43e02652020-04-09 15:30:57 -0700322 int callDirection = source.readInt();
Rekha Kumar07366812015-03-24 16:42:31 -0700323
Tyler Gunn720c6642016-03-22 09:02:47 -0700324 return new ParcelableConference(phoneAccount, state, capabilities, properties,
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700325 connectionIds, videoCallProvider, videoState, connectTimeMillis,
Tyler Gunnac60f952019-05-31 07:23:16 -0700326 connectElapsedTimeMillis, statusHints, extras, address, addressPresentation,
Ravi Paluri80aa2142019-12-02 11:57:37 +0530327 callerDisplayName, callerDisplayNamePresentation, disconnectCause,
Brad Ebinger43e02652020-04-09 15:30:57 -0700328 isRingbackRequested, callDirection);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700329 }
330
331 @Override
332 public ParcelableConference[] newArray(int size) {
333 return new ParcelableConference[size];
334 }
335 };
336
337 /** {@inheritDoc} */
338 @Override
339 public int describeContents() {
340 return 0;
341 }
342
343 /** Writes ParcelableConference object into a Parcel. */
344 @Override
345 public void writeToParcel(Parcel destination, int flags) {
346 destination.writeParcelable(mPhoneAccount, 0);
347 destination.writeInt(mState);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800348 destination.writeInt(mConnectionCapabilities);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700349 destination.writeList(mConnectionIds);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800350 destination.writeLong(mConnectTimeMillis);
Rekha Kumar07366812015-03-24 16:42:31 -0700351 destination.writeStrongBinder(
352 mVideoProvider != null ? mVideoProvider.asBinder() : null);
353 destination.writeInt(mVideoState);
Andrew Leeedc625f2015-04-14 13:38:12 -0700354 destination.writeParcelable(mStatusHints, 0);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700355 destination.writeBundle(mExtras);
Tyler Gunn720c6642016-03-22 09:02:47 -0700356 destination.writeInt(mConnectionProperties);
Tyler Gunnb2f875b2017-08-04 09:27:26 -0700357 destination.writeLong(mConnectElapsedTimeMillis);
Tyler Gunnac60f952019-05-31 07:23:16 -0700358 destination.writeParcelable(mAddress, 0);
359 destination.writeInt(mAddressPresentation);
360 destination.writeString(mCallerDisplayName);
361 destination.writeInt(mCallerDisplayNamePresentation);
Ravi Paluri80aa2142019-12-02 11:57:37 +0530362 destination.writeParcelable(mDisconnectCause, 0);
363 destination.writeInt(mRingbackRequested ? 1 : 0);
Brad Ebinger43e02652020-04-09 15:30:57 -0700364 destination.writeInt(mCallDirection);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700365 }
366}