| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 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 | |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 17 | package android.telecom; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 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; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 33 | private int mConnectionCapabilities; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 34 | private List<String> mConnectionIds; |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame^] | 35 | private long mConnectTimeMillis; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 36 | |
| 37 | public ParcelableConference( |
| 38 | PhoneAccountHandle phoneAccount, |
| 39 | int state, |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 40 | int connectionCapabilities, |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 41 | List<String> connectionIds) { |
| 42 | mPhoneAccount = phoneAccount; |
| 43 | mState = state; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 44 | mConnectionCapabilities = connectionCapabilities; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 45 | mConnectionIds = connectionIds; |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame^] | 46 | 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 Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 57 | } |
| 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 Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 67 | .append(Connection.capabilitiesToString(mConnectionCapabilities)) |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame^] | 68 | .append(", connectTime: ") |
| 69 | .append(mConnectTimeMillis) |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 70 | .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 Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 83 | public int getConnectionCapabilities() { |
| 84 | return mConnectionCapabilities; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | public List<String> getConnectionIds() { |
| 88 | return mConnectionIds; |
| 89 | } |
| 90 | |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame^] | 91 | public long getConnectTimeMillis() { |
| 92 | return mConnectTimeMillis; |
| 93 | } |
| 94 | |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 95 | 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 Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame^] | 105 | long connectTimeMillis = source.readLong(); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 106 | |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame^] | 107 | return new ParcelableConference(phoneAccount, state, capabilities, connectionIds, |
| 108 | connectTimeMillis); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 109 | } |
| 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 Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 128 | destination.writeInt(mConnectionCapabilities); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 129 | destination.writeList(mConnectionIds); |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame^] | 130 | destination.writeLong(mConnectTimeMillis); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 131 | } |
| 132 | } |