blob: dcc2713ec96bece4fcfc28b7a777136eec5d651f [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
25/**
26 * A parcelable representation of a conference connection.
27 * @hide
28 */
29public final class ParcelableConference implements Parcelable {
30
31 private PhoneAccountHandle mPhoneAccount;
32 private int mState;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080033 private int mConnectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -070034 private List<String> mConnectionIds;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080035 private long mConnectTimeMillis;
Santos Cordon823fd3c2014-08-07 18:35:18 -070036
37 public ParcelableConference(
38 PhoneAccountHandle phoneAccount,
39 int state,
Ihab Awad5c9c86e2014-11-12 13:41:16 -080040 int connectionCapabilities,
Santos Cordon823fd3c2014-08-07 18:35:18 -070041 List<String> connectionIds) {
42 mPhoneAccount = phoneAccount;
43 mState = state;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080044 mConnectionCapabilities = connectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -070045 mConnectionIds = connectionIds;
Tyler Gunncd5d33c2015-01-12 09:02:01 -080046 mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
47 }
48
49 public ParcelableConference(
50 PhoneAccountHandle phoneAccount,
51 int state,
52 int connectionCapabilities,
53 List<String> connectionIds,
54 long connectTimeMillis) {
55 this(phoneAccount, state, connectionCapabilities, connectionIds);
56 mConnectTimeMillis = connectTimeMillis;
Santos Cordon823fd3c2014-08-07 18:35:18 -070057 }
58
59 @Override
60 public String toString() {
61 return (new StringBuffer())
62 .append("account: ")
63 .append(mPhoneAccount)
64 .append(", state: ")
65 .append(Connection.stateToString(mState))
66 .append(", capabilities: ")
Ihab Awad5c9c86e2014-11-12 13:41:16 -080067 .append(Connection.capabilitiesToString(mConnectionCapabilities))
Tyler Gunncd5d33c2015-01-12 09:02:01 -080068 .append(", connectTime: ")
69 .append(mConnectTimeMillis)
Santos Cordon823fd3c2014-08-07 18:35:18 -070070 .append(", children: ")
71 .append(mConnectionIds)
72 .toString();
73 }
74
75 public PhoneAccountHandle getPhoneAccount() {
76 return mPhoneAccount;
77 }
78
79 public int getState() {
80 return mState;
81 }
82
Ihab Awad5c9c86e2014-11-12 13:41:16 -080083 public int getConnectionCapabilities() {
84 return mConnectionCapabilities;
Santos Cordon823fd3c2014-08-07 18:35:18 -070085 }
86
87 public List<String> getConnectionIds() {
88 return mConnectionIds;
89 }
90
Tyler Gunncd5d33c2015-01-12 09:02:01 -080091 public long getConnectTimeMillis() {
92 return mConnectTimeMillis;
93 }
94
Santos Cordon823fd3c2014-08-07 18:35:18 -070095 public static final Parcelable.Creator<ParcelableConference> CREATOR =
96 new Parcelable.Creator<ParcelableConference> () {
97 @Override
98 public ParcelableConference createFromParcel(Parcel source) {
99 ClassLoader classLoader = ParcelableConference.class.getClassLoader();
100 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
101 int state = source.readInt();
102 int capabilities = source.readInt();
103 List<String> connectionIds = new ArrayList<>(2);
104 source.readList(connectionIds, classLoader);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800105 long connectTimeMillis = source.readLong();
Santos Cordon823fd3c2014-08-07 18:35:18 -0700106
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800107 return new ParcelableConference(phoneAccount, state, capabilities, connectionIds,
108 connectTimeMillis);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700109 }
110
111 @Override
112 public ParcelableConference[] newArray(int size) {
113 return new ParcelableConference[size];
114 }
115 };
116
117 /** {@inheritDoc} */
118 @Override
119 public int describeContents() {
120 return 0;
121 }
122
123 /** Writes ParcelableConference object into a Parcel. */
124 @Override
125 public void writeToParcel(Parcel destination, int flags) {
126 destination.writeParcelable(mPhoneAccount, 0);
127 destination.writeInt(mState);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800128 destination.writeInt(mConnectionCapabilities);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700129 destination.writeList(mConnectionIds);
Tyler Gunncd5d33c2015-01-12 09:02:01 -0800130 destination.writeLong(mConnectTimeMillis);
Santos Cordon823fd3c2014-08-07 18:35:18 -0700131 }
132}