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.Parcel; 20 import android.os.Parcelable; 21 22 import java.util.ArrayList; 23 import java.util.List; 24 25 /** 26 * A parcelable representation of a conference connection. 27 * @hide 28 */ 29 public final class ParcelableConference implements Parcelable { 30 31 private PhoneAccountHandle mPhoneAccount; 32 private int mState; 33 private int mCapabilities; 34 private List<String> mConnectionIds; 35 36 public ParcelableConference( 37 PhoneAccountHandle phoneAccount, 38 int state, 39 int capabilities, 40 List<String> connectionIds) { 41 mPhoneAccount = phoneAccount; 42 mState = state; 43 mCapabilities = capabilities; 44 mConnectionIds = connectionIds; 45 } 46 47 @Override 48 public String toString() { 49 return (new StringBuffer()) 50 .append("account: ") 51 .append(mPhoneAccount) 52 .append(", state: ") 53 .append(Connection.stateToString(mState)) 54 .append(", capabilities: ") 55 .append(PhoneCapabilities.toString(mCapabilities)) 56 .append(", children: ") 57 .append(mConnectionIds) 58 .toString(); 59 } 60 61 public PhoneAccountHandle getPhoneAccount() { 62 return mPhoneAccount; 63 } 64 65 public int getState() { 66 return mState; 67 } 68 69 public int getCapabilities() { 70 return mCapabilities; 71 } 72 73 public List<String> getConnectionIds() { 74 return mConnectionIds; 75 } 76 77 public static final Parcelable.Creator<ParcelableConference> CREATOR = 78 new Parcelable.Creator<ParcelableConference> () { 79 @Override 80 public ParcelableConference createFromParcel(Parcel source) { 81 ClassLoader classLoader = ParcelableConference.class.getClassLoader(); 82 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader); 83 int state = source.readInt(); 84 int capabilities = source.readInt(); 85 List<String> connectionIds = new ArrayList<>(2); 86 source.readList(connectionIds, classLoader); 87 88 return new ParcelableConference(phoneAccount, state, capabilities, connectionIds); 89 } 90 91 @Override 92 public ParcelableConference[] newArray(int size) { 93 return new ParcelableConference[size]; 94 } 95 }; 96 97 /** {@inheritDoc} */ 98 @Override 99 public int describeContents() { 100 return 0; 101 } 102 103 /** Writes ParcelableConference object into a Parcel. */ 104 @Override 105 public void writeToParcel(Parcel destination, int flags) { 106 destination.writeParcelable(mPhoneAccount, 0); 107 destination.writeInt(mState); 108 destination.writeInt(mCapabilities); 109 destination.writeList(mConnectionIds); 110 } 111 } 112