blob: e54e79de6056a2063793d70ba43194543911de44 [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;
Andrew Leeedc625f2015-04-14 13:38:12 -070037 private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Rekha Kumar07366812015-03-24 16:42:31 -070038 private final IVideoProvider mVideoProvider;
39 private final int mVideoState;
Andrew Leeedc625f2015-04-14 13:38:12 -070040 private StatusHints mStatusHints;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080041
42 public ParcelableConference(
43 PhoneAccountHandle phoneAccount,
44 int state,
45 int connectionCapabilities,
46 List<String> connectionIds,
Rekha Kumar07366812015-03-24 16:42:31 -070047 IVideoProvider videoProvider,
48 int videoState,
Andrew Leeedc625f2015-04-14 13:38:12 -070049 long connectTimeMillis,
50 StatusHints statusHints) {
51 mPhoneAccount = phoneAccount;
52 mState = state;
53 mConnectionCapabilities = connectionCapabilities;
54 mConnectionIds = connectionIds;
Andrew Lee0f51da32015-04-16 13:11:55 -070055 mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
56 mVideoProvider = videoProvider;
57 mVideoState = videoState;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080058 mConnectTimeMillis = connectTimeMillis;
Andrew Leeedc625f2015-04-14 13:38:12 -070059 mStatusHints = statusHints;
Santos Cordon823fd3c2014-08-07 18:35:18 -070060 }
61
62 @Override
63 public String toString() {
64 return (new StringBuffer())
65 .append("account: ")
66 .append(mPhoneAccount)
67 .append(", state: ")
68 .append(Connection.stateToString(mState))
69 .append(", capabilities: ")
Ihab Awad5c9c86e2014-11-12 13:41:16 -080070 .append(Connection.capabilitiesToString(mConnectionCapabilities))
Tyler Gunncd5d33c2015-01-12 09:02:01 -080071 .append(", connectTime: ")
72 .append(mConnectTimeMillis)
Santos Cordon823fd3c2014-08-07 18:35:18 -070073 .append(", children: ")
74 .append(mConnectionIds)
Rekha Kumar07366812015-03-24 16:42:31 -070075 .append(", VideoState: ")
76 .append(mVideoState)
77 .append(", VideoProvider: ")
78 .append(mVideoProvider)
Santos Cordon823fd3c2014-08-07 18:35:18 -070079 .toString();
80 }
81
82 public PhoneAccountHandle getPhoneAccount() {
83 return mPhoneAccount;
84 }
85
86 public int getState() {
87 return mState;
88 }
89
Ihab Awad5c9c86e2014-11-12 13:41:16 -080090 public int getConnectionCapabilities() {
91 return mConnectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -070092 }
93
94 public List<String> getConnectionIds() {
95 return mConnectionIds;
96 }
97
Tyler Gunncd5d33c2015-01-12 09:02:01 -080098 public long getConnectTimeMillis() {
99 return mConnectTimeMillis;
100 }
Rekha Kumar07366812015-03-24 16:42:31 -0700101 public IVideoProvider getVideoProvider() {
102 return mVideoProvider;
103 }
104
105 public int getVideoState() {
106 return mVideoState;
107 }
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800108
Andrew Leeedc625f2015-04-14 13:38:12 -0700109 public StatusHints getStatusHints() {
110 return mStatusHints;
111 }
112
Santos Cordon823fd3c2014-08-07 18:35:18 -0700113 public static final Parcelable.Creator<ParcelableConference> CREATOR =
114 new Parcelable.Creator<ParcelableConference> () {
115 @Override
116 public ParcelableConference createFromParcel(Parcel source) {
117 ClassLoader classLoader = ParcelableConference.class.getClassLoader();
118 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
119 int state = source.readInt();
120 int capabilities = source.readInt();
121 List<String> connectionIds = new ArrayList<>(2);
122 source.readList(connectionIds, classLoader);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800123 long connectTimeMillis = source.readLong();
Andrew Leeedc625f2015-04-14 13:38:12 -0700124 StatusHints statusHints = source.readParcelable(classLoader);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700125
Rekha Kumar07366812015-03-24 16:42:31 -0700126 IVideoProvider videoCallProvider =
127 IVideoProvider.Stub.asInterface(source.readStrongBinder());
128 int videoState = source.readInt();
129
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800130 return new ParcelableConference(phoneAccount, state, capabilities, connectionIds,
Andrew Lee0f51da32015-04-16 13:11:55 -0700131 videoCallProvider, videoState, connectTimeMillis, statusHints);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700132 }
133
134 @Override
135 public ParcelableConference[] newArray(int size) {
136 return new ParcelableConference[size];
137 }
138 };
139
140 /** {@inheritDoc} */
141 @Override
142 public int describeContents() {
143 return 0;
144 }
145
146 /** Writes ParcelableConference object into a Parcel. */
147 @Override
148 public void writeToParcel(Parcel destination, int flags) {
149 destination.writeParcelable(mPhoneAccount, 0);
150 destination.writeInt(mState);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800151 destination.writeInt(mConnectionCapabilities);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700152 destination.writeList(mConnectionIds);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800153 destination.writeLong(mConnectTimeMillis);
Rekha Kumar07366812015-03-24 16:42:31 -0700154 destination.writeStrongBinder(
155 mVideoProvider != null ? mVideoProvider.asBinder() : null);
156 destination.writeInt(mVideoState);
Andrew Leeedc625f2015-04-14 13:38:12 -0700157 destination.writeParcelable(mStatusHints, 0);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700158 }
159}