blob: 870f5ee8a01cb44cf5a0703531440f5bd4a3d60f [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;
Santos Cordon823fd3c2014-08-07 18:35:18 -070037 private List<String> mConnectionIds;
Andrew Leeedc625f2015-04-14 13:38:12 -070038 private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Rekha Kumar07366812015-03-24 16:42:31 -070039 private final IVideoProvider mVideoProvider;
40 private final int mVideoState;
Andrew Leeedc625f2015-04-14 13:38:12 -070041 private StatusHints mStatusHints;
Santos Cordon6b7f9552015-05-27 17:21:45 -070042 private Bundle mExtras;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080043
44 public ParcelableConference(
45 PhoneAccountHandle phoneAccount,
46 int state,
47 int connectionCapabilities,
48 List<String> connectionIds,
Rekha Kumar07366812015-03-24 16:42:31 -070049 IVideoProvider videoProvider,
50 int videoState,
Andrew Leeedc625f2015-04-14 13:38:12 -070051 long connectTimeMillis,
Santos Cordon6b7f9552015-05-27 17:21:45 -070052 StatusHints statusHints,
53 Bundle extras) {
Andrew Leeedc625f2015-04-14 13:38:12 -070054 mPhoneAccount = phoneAccount;
55 mState = state;
56 mConnectionCapabilities = connectionCapabilities;
57 mConnectionIds = connectionIds;
Andrew Lee0f51da32015-04-16 13:11:55 -070058 mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
59 mVideoProvider = videoProvider;
60 mVideoState = videoState;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080061 mConnectTimeMillis = connectTimeMillis;
Andrew Leeedc625f2015-04-14 13:38:12 -070062 mStatusHints = statusHints;
Santos Cordon6b7f9552015-05-27 17:21:45 -070063 mExtras = extras;
Santos Cordon823fd3c2014-08-07 18:35:18 -070064 }
65
66 @Override
67 public String toString() {
68 return (new StringBuffer())
69 .append("account: ")
70 .append(mPhoneAccount)
71 .append(", state: ")
72 .append(Connection.stateToString(mState))
73 .append(", capabilities: ")
Ihab Awad5c9c86e2014-11-12 13:41:16 -080074 .append(Connection.capabilitiesToString(mConnectionCapabilities))
Tyler Gunncd5d33c2015-01-12 09:02:01 -080075 .append(", connectTime: ")
76 .append(mConnectTimeMillis)
Santos Cordon823fd3c2014-08-07 18:35:18 -070077 .append(", children: ")
78 .append(mConnectionIds)
Rekha Kumar07366812015-03-24 16:42:31 -070079 .append(", VideoState: ")
80 .append(mVideoState)
81 .append(", VideoProvider: ")
82 .append(mVideoProvider)
Santos Cordon823fd3c2014-08-07 18:35:18 -070083 .toString();
84 }
85
86 public PhoneAccountHandle getPhoneAccount() {
87 return mPhoneAccount;
88 }
89
90 public int getState() {
91 return mState;
92 }
93
Ihab Awad5c9c86e2014-11-12 13:41:16 -080094 public int getConnectionCapabilities() {
95 return mConnectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -070096 }
97
98 public List<String> getConnectionIds() {
99 return mConnectionIds;
100 }
101
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800102 public long getConnectTimeMillis() {
103 return mConnectTimeMillis;
104 }
Rekha Kumar07366812015-03-24 16:42:31 -0700105 public IVideoProvider getVideoProvider() {
106 return mVideoProvider;
107 }
108
109 public int getVideoState() {
110 return mVideoState;
111 }
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800112
Andrew Leeedc625f2015-04-14 13:38:12 -0700113 public StatusHints getStatusHints() {
114 return mStatusHints;
115 }
116
Santos Cordon6b7f9552015-05-27 17:21:45 -0700117 public Bundle getExtras() {
118 return mExtras;
119 }
120
Santos Cordon823fd3c2014-08-07 18:35:18 -0700121 public static final Parcelable.Creator<ParcelableConference> CREATOR =
122 new Parcelable.Creator<ParcelableConference> () {
123 @Override
124 public ParcelableConference createFromParcel(Parcel source) {
125 ClassLoader classLoader = ParcelableConference.class.getClassLoader();
126 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
127 int state = source.readInt();
128 int capabilities = source.readInt();
129 List<String> connectionIds = new ArrayList<>(2);
130 source.readList(connectionIds, classLoader);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800131 long connectTimeMillis = source.readLong();
Rekha Kumar07366812015-03-24 16:42:31 -0700132 IVideoProvider videoCallProvider =
133 IVideoProvider.Stub.asInterface(source.readStrongBinder());
134 int videoState = source.readInt();
Tyler Gunnd7017c42015-04-27 13:13:32 -0700135 StatusHints statusHints = source.readParcelable(classLoader);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700136 Bundle extras = source.readBundle(classLoader);
Rekha Kumar07366812015-03-24 16:42:31 -0700137
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800138 return new ParcelableConference(phoneAccount, state, capabilities, connectionIds,
Santos Cordon6b7f9552015-05-27 17:21:45 -0700139 videoCallProvider, videoState, connectTimeMillis, statusHints, extras);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700140 }
141
142 @Override
143 public ParcelableConference[] newArray(int size) {
144 return new ParcelableConference[size];
145 }
146 };
147
148 /** {@inheritDoc} */
149 @Override
150 public int describeContents() {
151 return 0;
152 }
153
154 /** Writes ParcelableConference object into a Parcel. */
155 @Override
156 public void writeToParcel(Parcel destination, int flags) {
157 destination.writeParcelable(mPhoneAccount, 0);
158 destination.writeInt(mState);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800159 destination.writeInt(mConnectionCapabilities);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700160 destination.writeList(mConnectionIds);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800161 destination.writeLong(mConnectTimeMillis);
Rekha Kumar07366812015-03-24 16:42:31 -0700162 destination.writeStrongBinder(
163 mVideoProvider != null ? mVideoProvider.asBinder() : null);
164 destination.writeInt(mVideoState);
Andrew Leeedc625f2015-04-14 13:38:12 -0700165 destination.writeParcelable(mStatusHints, 0);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700166 destination.writeBundle(mExtras);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700167 }
168}