blob: ab825491a57cb046d50097624f79496c5c797462 [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
19import android.os.Parcel;
20import android.os.Parcelable;
21
22import java.util.ArrayList;
23import java.util.List;
24
Rekha Kumar07366812015-03-24 16:42:31 -070025import com.android.internal.telecom.IVideoProvider;
26
Santos Cordon823fd3c2014-08-07 18:35:18 -070027/**
28 * A parcelable representation of a conference connection.
29 * @hide
30 */
31public final class ParcelableConference implements Parcelable {
32
33 private PhoneAccountHandle mPhoneAccount;
34 private int mState;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080035 private int mConnectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -070036 private List<String> mConnectionIds;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080037 private long mConnectTimeMillis;
Rekha Kumar07366812015-03-24 16:42:31 -070038 private final IVideoProvider mVideoProvider;
39 private final int mVideoState;
Santos Cordon823fd3c2014-08-07 18:35:18 -070040
41 public ParcelableConference(
42 PhoneAccountHandle phoneAccount,
43 int state,
Ihab Awad5c9c86e2014-11-12 13:41:16 -080044 int connectionCapabilities,
Rekha Kumar07366812015-03-24 16:42:31 -070045 List<String> connectionIds,
46 IVideoProvider videoProvider,
47 int videoState) {
Santos Cordon823fd3c2014-08-07 18:35:18 -070048 mPhoneAccount = phoneAccount;
49 mState = state;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080050 mConnectionCapabilities = connectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -070051 mConnectionIds = connectionIds;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080052 mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Rekha Kumar07366812015-03-24 16:42:31 -070053 mVideoProvider = videoProvider;
54 mVideoState = videoState;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080055 }
56
57 public ParcelableConference(
58 PhoneAccountHandle phoneAccount,
59 int state,
60 int connectionCapabilities,
61 List<String> connectionIds,
Rekha Kumar07366812015-03-24 16:42:31 -070062 IVideoProvider videoProvider,
63 int videoState,
Tyler Gunncd5d33c2015-01-12 09:02:01 -080064 long connectTimeMillis) {
Rekha Kumar07366812015-03-24 16:42:31 -070065 this(phoneAccount, state, connectionCapabilities, connectionIds, videoProvider, videoState);
Tyler Gunncd5d33c2015-01-12 09:02:01 -080066 mConnectTimeMillis = connectTimeMillis;
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 Gunncd5d33c2015-01-12 09:02:01 -080078 .append(", connectTime: ")
79 .append(mConnectTimeMillis)
Santos Cordon823fd3c2014-08-07 18:35:18 -070080 .append(", children: ")
81 .append(mConnectionIds)
Rekha Kumar07366812015-03-24 16:42:31 -070082 .append(", VideoState: ")
83 .append(mVideoState)
84 .append(", VideoProvider: ")
85 .append(mVideoProvider)
Santos Cordon823fd3c2014-08-07 18:35:18 -070086 .toString();
87 }
88
89 public PhoneAccountHandle getPhoneAccount() {
90 return mPhoneAccount;
91 }
92
93 public int getState() {
94 return mState;
95 }
96
Ihab Awad5c9c86e2014-11-12 13:41:16 -080097 public int getConnectionCapabilities() {
98 return mConnectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -070099 }
100
101 public List<String> getConnectionIds() {
102 return mConnectionIds;
103 }
104
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800105 public long getConnectTimeMillis() {
106 return mConnectTimeMillis;
107 }
Rekha Kumar07366812015-03-24 16:42:31 -0700108 public IVideoProvider getVideoProvider() {
109 return mVideoProvider;
110 }
111
112 public int getVideoState() {
113 return mVideoState;
114 }
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800115
Santos Cordon823fd3c2014-08-07 18:35:18 -0700116 public static final Parcelable.Creator<ParcelableConference> CREATOR =
117 new Parcelable.Creator<ParcelableConference> () {
118 @Override
119 public ParcelableConference createFromParcel(Parcel source) {
120 ClassLoader classLoader = ParcelableConference.class.getClassLoader();
121 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
122 int state = source.readInt();
123 int capabilities = source.readInt();
124 List<String> connectionIds = new ArrayList<>(2);
125 source.readList(connectionIds, classLoader);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800126 long connectTimeMillis = source.readLong();
Santos Cordon823fd3c2014-08-07 18:35:18 -0700127
Rekha Kumar07366812015-03-24 16:42:31 -0700128 IVideoProvider videoCallProvider =
129 IVideoProvider.Stub.asInterface(source.readStrongBinder());
130 int videoState = source.readInt();
131
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800132 return new ParcelableConference(phoneAccount, state, capabilities, connectionIds,
Rekha Kumar07366812015-03-24 16:42:31 -0700133 videoCallProvider, videoState);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700134 }
135
136 @Override
137 public ParcelableConference[] newArray(int size) {
138 return new ParcelableConference[size];
139 }
140 };
141
142 /** {@inheritDoc} */
143 @Override
144 public int describeContents() {
145 return 0;
146 }
147
148 /** Writes ParcelableConference object into a Parcel. */
149 @Override
150 public void writeToParcel(Parcel destination, int flags) {
151 destination.writeParcelable(mPhoneAccount, 0);
152 destination.writeInt(mState);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800153 destination.writeInt(mConnectionCapabilities);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700154 destination.writeList(mConnectionIds);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800155 destination.writeLong(mConnectTimeMillis);
Rekha Kumar07366812015-03-24 16:42:31 -0700156 destination.writeStrongBinder(
157 mVideoProvider != null ? mVideoProvider.asBinder() : null);
158 destination.writeInt(mVideoState);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700159 }
160}