blob: f5689d882ba8c31df394390d0e15cdb6f09d05f8 [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
Santos Cordon6b7f9552015-05-27 17:21:45 -070019import android.os.Bundle;
Santos Cordon823fd3c2014-08-07 18:35:18 -070020import android.os.Parcel;
21import android.os.Parcelable;
22
23import java.util.ArrayList;
24import java.util.List;
25
Rekha Kumar07366812015-03-24 16:42:31 -070026import com.android.internal.telecom.IVideoProvider;
27
Santos Cordon823fd3c2014-08-07 18:35:18 -070028/**
29 * A parcelable representation of a conference connection.
30 * @hide
31 */
32public final class ParcelableConference implements Parcelable {
33
34 private PhoneAccountHandle mPhoneAccount;
35 private int mState;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080036 private int mConnectionCapabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -070037 private int mConnectionProperties;
Santos Cordon823fd3c2014-08-07 18:35:18 -070038 private List<String> mConnectionIds;
Andrew Leeedc625f2015-04-14 13:38:12 -070039 private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Rekha Kumar07366812015-03-24 16:42:31 -070040 private final IVideoProvider mVideoProvider;
41 private final int mVideoState;
Andrew Leeedc625f2015-04-14 13:38:12 -070042 private StatusHints mStatusHints;
Santos Cordon6b7f9552015-05-27 17:21:45 -070043 private Bundle mExtras;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080044
45 public ParcelableConference(
46 PhoneAccountHandle phoneAccount,
47 int state,
48 int connectionCapabilities,
Tyler Gunn720c6642016-03-22 09:02:47 -070049 int connectionProperties,
Tyler Gunncd5d33c2015-01-12 09:02:01 -080050 List<String> connectionIds,
Rekha Kumar07366812015-03-24 16:42:31 -070051 IVideoProvider videoProvider,
52 int videoState,
Andrew Leeedc625f2015-04-14 13:38:12 -070053 long connectTimeMillis,
Santos Cordon6b7f9552015-05-27 17:21:45 -070054 StatusHints statusHints,
55 Bundle extras) {
Andrew Leeedc625f2015-04-14 13:38:12 -070056 mPhoneAccount = phoneAccount;
57 mState = state;
58 mConnectionCapabilities = connectionCapabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -070059 mConnectionProperties = connectionProperties;
Andrew Leeedc625f2015-04-14 13:38:12 -070060 mConnectionIds = connectionIds;
Andrew Lee0f51da32015-04-16 13:11:55 -070061 mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
62 mVideoProvider = videoProvider;
63 mVideoState = videoState;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080064 mConnectTimeMillis = connectTimeMillis;
Andrew Leeedc625f2015-04-14 13:38:12 -070065 mStatusHints = statusHints;
Santos Cordon6b7f9552015-05-27 17:21:45 -070066 mExtras = extras;
Santos Cordon823fd3c2014-08-07 18:35:18 -070067 }
68
69 @Override
70 public String toString() {
71 return (new StringBuffer())
72 .append("account: ")
73 .append(mPhoneAccount)
74 .append(", state: ")
75 .append(Connection.stateToString(mState))
76 .append(", capabilities: ")
Ihab Awad5c9c86e2014-11-12 13:41:16 -080077 .append(Connection.capabilitiesToString(mConnectionCapabilities))
Tyler Gunn720c6642016-03-22 09:02:47 -070078 .append(", properties: ")
79 .append(Connection.propertiesToString(mConnectionProperties))
Tyler Gunncd5d33c2015-01-12 09:02:01 -080080 .append(", connectTime: ")
81 .append(mConnectTimeMillis)
Santos Cordon823fd3c2014-08-07 18:35:18 -070082 .append(", children: ")
83 .append(mConnectionIds)
Rekha Kumar07366812015-03-24 16:42:31 -070084 .append(", VideoState: ")
85 .append(mVideoState)
86 .append(", VideoProvider: ")
87 .append(mVideoProvider)
Santos Cordon823fd3c2014-08-07 18:35:18 -070088 .toString();
89 }
90
91 public PhoneAccountHandle getPhoneAccount() {
92 return mPhoneAccount;
93 }
94
95 public int getState() {
96 return mState;
97 }
98
Ihab Awad5c9c86e2014-11-12 13:41:16 -080099 public int getConnectionCapabilities() {
100 return mConnectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -0700101 }
102
Tyler Gunn720c6642016-03-22 09:02:47 -0700103 public int getConnectionProperties() {
104 return mConnectionProperties;
105 }
106
Santos Cordon823fd3c2014-08-07 18:35:18 -0700107 public List<String> getConnectionIds() {
108 return mConnectionIds;
109 }
110
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800111 public long getConnectTimeMillis() {
112 return mConnectTimeMillis;
113 }
Rekha Kumar07366812015-03-24 16:42:31 -0700114 public IVideoProvider getVideoProvider() {
115 return mVideoProvider;
116 }
117
118 public int getVideoState() {
119 return mVideoState;
120 }
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800121
Andrew Leeedc625f2015-04-14 13:38:12 -0700122 public StatusHints getStatusHints() {
123 return mStatusHints;
124 }
125
Santos Cordon6b7f9552015-05-27 17:21:45 -0700126 public Bundle getExtras() {
127 return mExtras;
128 }
129
Santos Cordon823fd3c2014-08-07 18:35:18 -0700130 public static final Parcelable.Creator<ParcelableConference> CREATOR =
131 new Parcelable.Creator<ParcelableConference> () {
132 @Override
133 public ParcelableConference createFromParcel(Parcel source) {
134 ClassLoader classLoader = ParcelableConference.class.getClassLoader();
135 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
136 int state = source.readInt();
137 int capabilities = source.readInt();
138 List<String> connectionIds = new ArrayList<>(2);
139 source.readList(connectionIds, classLoader);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800140 long connectTimeMillis = source.readLong();
Rekha Kumar07366812015-03-24 16:42:31 -0700141 IVideoProvider videoCallProvider =
142 IVideoProvider.Stub.asInterface(source.readStrongBinder());
143 int videoState = source.readInt();
Tyler Gunnd7017c42015-04-27 13:13:32 -0700144 StatusHints statusHints = source.readParcelable(classLoader);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700145 Bundle extras = source.readBundle(classLoader);
Tyler Gunn720c6642016-03-22 09:02:47 -0700146 int properties = source.readInt();
Rekha Kumar07366812015-03-24 16:42:31 -0700147
Tyler Gunn720c6642016-03-22 09:02:47 -0700148 return new ParcelableConference(phoneAccount, state, capabilities, properties,
149 connectionIds, videoCallProvider, videoState, connectTimeMillis, statusHints,
150 extras);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700151 }
152
153 @Override
154 public ParcelableConference[] newArray(int size) {
155 return new ParcelableConference[size];
156 }
157 };
158
159 /** {@inheritDoc} */
160 @Override
161 public int describeContents() {
162 return 0;
163 }
164
165 /** Writes ParcelableConference object into a Parcel. */
166 @Override
167 public void writeToParcel(Parcel destination, int flags) {
168 destination.writeParcelable(mPhoneAccount, 0);
169 destination.writeInt(mState);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800170 destination.writeInt(mConnectionCapabilities);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700171 destination.writeList(mConnectionIds);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800172 destination.writeLong(mConnectTimeMillis);
Rekha Kumar07366812015-03-24 16:42:31 -0700173 destination.writeStrongBinder(
174 mVideoProvider != null ? mVideoProvider.asBinder() : null);
175 destination.writeInt(mVideoState);
Andrew Leeedc625f2015-04-14 13:38:12 -0700176 destination.writeParcelable(mStatusHints, 0);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700177 destination.writeBundle(mExtras);
Tyler Gunn720c6642016-03-22 09:02:47 -0700178 destination.writeInt(mConnectionProperties);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700179 }
180}