• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package android.telecom;
18 
19 import android.os.Bundle;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22 
23 import java.util.ArrayList;
24 import java.util.List;
25 
26 import com.android.internal.telecom.IVideoProvider;
27 
28 /**
29  * A parcelable representation of a conference connection.
30  * @hide
31  */
32 public final class ParcelableConference implements Parcelable {
33 
34     private PhoneAccountHandle mPhoneAccount;
35     private int mState;
36     private int mConnectionCapabilities;
37     private int mConnectionProperties;
38     private List<String> mConnectionIds;
39     private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
40     private final IVideoProvider mVideoProvider;
41     private final int mVideoState;
42     private StatusHints mStatusHints;
43     private Bundle mExtras;
44     private long mConnectElapsedTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
45 
ParcelableConference( PhoneAccountHandle phoneAccount, int state, int connectionCapabilities, int connectionProperties, List<String> connectionIds, IVideoProvider videoProvider, int videoState, long connectTimeMillis, long connectElapsedTimeMillis, StatusHints statusHints, Bundle extras)46     public ParcelableConference(
47             PhoneAccountHandle phoneAccount,
48             int state,
49             int connectionCapabilities,
50             int connectionProperties,
51             List<String> connectionIds,
52             IVideoProvider videoProvider,
53             int videoState,
54             long connectTimeMillis,
55             long connectElapsedTimeMillis,
56             StatusHints statusHints,
57             Bundle extras) {
58         mPhoneAccount = phoneAccount;
59         mState = state;
60         mConnectionCapabilities = connectionCapabilities;
61         mConnectionProperties = connectionProperties;
62         mConnectionIds = connectionIds;
63         mVideoProvider = videoProvider;
64         mVideoState = videoState;
65         mConnectTimeMillis = connectTimeMillis;
66         mStatusHints = statusHints;
67         mExtras = extras;
68         mConnectElapsedTimeMillis = connectElapsedTimeMillis;
69     }
70 
71     @Override
toString()72     public String toString() {
73         return (new StringBuffer())
74                 .append("account: ")
75                 .append(mPhoneAccount)
76                 .append(", state: ")
77                 .append(Connection.stateToString(mState))
78                 .append(", capabilities: ")
79                 .append(Connection.capabilitiesToString(mConnectionCapabilities))
80                 .append(", properties: ")
81                 .append(Connection.propertiesToString(mConnectionProperties))
82                 .append(", connectTime: ")
83                 .append(mConnectTimeMillis)
84                 .append(", children: ")
85                 .append(mConnectionIds)
86                 .append(", VideoState: ")
87                 .append(mVideoState)
88                 .append(", VideoProvider: ")
89                 .append(mVideoProvider)
90                 .toString();
91     }
92 
getPhoneAccount()93     public PhoneAccountHandle getPhoneAccount() {
94         return mPhoneAccount;
95     }
96 
getState()97     public int getState() {
98         return mState;
99     }
100 
getConnectionCapabilities()101     public int getConnectionCapabilities() {
102         return mConnectionCapabilities;
103     }
104 
getConnectionProperties()105     public int getConnectionProperties() {
106         return mConnectionProperties;
107     }
108 
getConnectionIds()109     public List<String> getConnectionIds() {
110         return mConnectionIds;
111     }
112 
getConnectTimeMillis()113     public long getConnectTimeMillis() {
114         return mConnectTimeMillis;
115     }
116 
getConnectElapsedTimeMillis()117     public long getConnectElapsedTimeMillis() {
118         return mConnectElapsedTimeMillis;
119     }
120 
getVideoProvider()121     public IVideoProvider getVideoProvider() {
122         return mVideoProvider;
123     }
124 
getVideoState()125     public int getVideoState() {
126         return mVideoState;
127     }
128 
getStatusHints()129     public StatusHints getStatusHints() {
130         return mStatusHints;
131     }
132 
getExtras()133     public Bundle getExtras() {
134         return mExtras;
135     }
136 
137     public static final Parcelable.Creator<ParcelableConference> CREATOR =
138             new Parcelable.Creator<ParcelableConference> () {
139         @Override
140         public ParcelableConference createFromParcel(Parcel source) {
141             ClassLoader classLoader = ParcelableConference.class.getClassLoader();
142             PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
143             int state = source.readInt();
144             int capabilities = source.readInt();
145             List<String> connectionIds = new ArrayList<>(2);
146             source.readList(connectionIds, classLoader);
147             long connectTimeMillis = source.readLong();
148             IVideoProvider videoCallProvider =
149                     IVideoProvider.Stub.asInterface(source.readStrongBinder());
150             int videoState = source.readInt();
151             StatusHints statusHints = source.readParcelable(classLoader);
152             Bundle extras = source.readBundle(classLoader);
153             int properties = source.readInt();
154             long connectElapsedTimeMillis = source.readLong();
155 
156             return new ParcelableConference(phoneAccount, state, capabilities, properties,
157                     connectionIds, videoCallProvider, videoState, connectTimeMillis,
158                     connectElapsedTimeMillis, statusHints, extras);
159         }
160 
161         @Override
162         public ParcelableConference[] newArray(int size) {
163             return new ParcelableConference[size];
164         }
165     };
166 
167     /** {@inheritDoc} */
168     @Override
describeContents()169     public int describeContents() {
170         return 0;
171     }
172 
173     /** Writes ParcelableConference object into a Parcel. */
174     @Override
writeToParcel(Parcel destination, int flags)175     public void writeToParcel(Parcel destination, int flags) {
176         destination.writeParcelable(mPhoneAccount, 0);
177         destination.writeInt(mState);
178         destination.writeInt(mConnectionCapabilities);
179         destination.writeList(mConnectionIds);
180         destination.writeLong(mConnectTimeMillis);
181         destination.writeStrongBinder(
182                 mVideoProvider != null ? mVideoProvider.asBinder() : null);
183         destination.writeInt(mVideoState);
184         destination.writeParcelable(mStatusHints, 0);
185         destination.writeBundle(mExtras);
186         destination.writeInt(mConnectionProperties);
187         destination.writeLong(mConnectElapsedTimeMillis);
188     }
189 }
190