| 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 | |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 25 | import com.android.internal.telecom.IVideoProvider; |
| 26 | |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 27 | /** |
| 28 | * A parcelable representation of a conference connection. |
| 29 | * @hide |
| 30 | */ |
| 31 | public final class ParcelableConference implements Parcelable { |
| 32 | |
| 33 | private PhoneAccountHandle mPhoneAccount; |
| 34 | private int mState; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 35 | private int mConnectionCapabilities; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 36 | private List<String> mConnectionIds; |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 37 | private long mConnectTimeMillis; |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 38 | private final IVideoProvider mVideoProvider; |
| 39 | private final int mVideoState; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 40 | |
| 41 | public ParcelableConference( |
| 42 | PhoneAccountHandle phoneAccount, |
| 43 | int state, |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 44 | int connectionCapabilities, |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 45 | List<String> connectionIds, |
| 46 | IVideoProvider videoProvider, |
| 47 | int videoState) { |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 48 | mPhoneAccount = phoneAccount; |
| 49 | mState = state; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 50 | mConnectionCapabilities = connectionCapabilities; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 51 | mConnectionIds = connectionIds; |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 52 | mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED; |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 53 | mVideoProvider = videoProvider; |
| 54 | mVideoState = videoState; |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | public ParcelableConference( |
| 58 | PhoneAccountHandle phoneAccount, |
| 59 | int state, |
| 60 | int connectionCapabilities, |
| 61 | List<String> connectionIds, |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 62 | IVideoProvider videoProvider, |
| 63 | int videoState, |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 64 | long connectTimeMillis) { |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 65 | this(phoneAccount, state, connectionCapabilities, connectionIds, videoProvider, videoState); |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 66 | mConnectTimeMillis = connectTimeMillis; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public String toString() { |
| 71 | return (new StringBuffer()) |
| 72 | .append("account: ") |
| 73 | .append(mPhoneAccount) |
| 74 | .append(", state: ") |
| 75 | .append(Connection.stateToString(mState)) |
| 76 | .append(", capabilities: ") |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 77 | .append(Connection.capabilitiesToString(mConnectionCapabilities)) |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 78 | .append(", connectTime: ") |
| 79 | .append(mConnectTimeMillis) |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 80 | .append(", children: ") |
| 81 | .append(mConnectionIds) |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 82 | .append(", VideoState: ") |
| 83 | .append(mVideoState) |
| 84 | .append(", VideoProvider: ") |
| 85 | .append(mVideoProvider) |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 86 | .toString(); |
| 87 | } |
| 88 | |
| 89 | public PhoneAccountHandle getPhoneAccount() { |
| 90 | return mPhoneAccount; |
| 91 | } |
| 92 | |
| 93 | public int getState() { |
| 94 | return mState; |
| 95 | } |
| 96 | |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 97 | public int getConnectionCapabilities() { |
| 98 | return mConnectionCapabilities; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | public List<String> getConnectionIds() { |
| 102 | return mConnectionIds; |
| 103 | } |
| 104 | |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 105 | public long getConnectTimeMillis() { |
| 106 | return mConnectTimeMillis; |
| 107 | } |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 108 | public IVideoProvider getVideoProvider() { |
| 109 | return mVideoProvider; |
| 110 | } |
| 111 | |
| 112 | public int getVideoState() { |
| 113 | return mVideoState; |
| 114 | } |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 115 | |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 116 | public static final Parcelable.Creator<ParcelableConference> CREATOR = |
| 117 | new Parcelable.Creator<ParcelableConference> () { |
| 118 | @Override |
| 119 | public ParcelableConference createFromParcel(Parcel source) { |
| 120 | ClassLoader classLoader = ParcelableConference.class.getClassLoader(); |
| 121 | PhoneAccountHandle phoneAccount = source.readParcelable(classLoader); |
| 122 | int state = source.readInt(); |
| 123 | int capabilities = source.readInt(); |
| 124 | List<String> connectionIds = new ArrayList<>(2); |
| 125 | source.readList(connectionIds, classLoader); |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 126 | long connectTimeMillis = source.readLong(); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 127 | |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 128 | IVideoProvider videoCallProvider = |
| 129 | IVideoProvider.Stub.asInterface(source.readStrongBinder()); |
| 130 | int videoState = source.readInt(); |
| 131 | |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 132 | return new ParcelableConference(phoneAccount, state, capabilities, connectionIds, |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 133 | videoCallProvider, videoState); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | @Override |
| 137 | public ParcelableConference[] newArray(int size) { |
| 138 | return new ParcelableConference[size]; |
| 139 | } |
| 140 | }; |
| 141 | |
| 142 | /** {@inheritDoc} */ |
| 143 | @Override |
| 144 | public int describeContents() { |
| 145 | return 0; |
| 146 | } |
| 147 | |
| 148 | /** Writes ParcelableConference object into a Parcel. */ |
| 149 | @Override |
| 150 | public void writeToParcel(Parcel destination, int flags) { |
| 151 | destination.writeParcelable(mPhoneAccount, 0); |
| 152 | destination.writeInt(mState); |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 153 | destination.writeInt(mConnectionCapabilities); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 154 | destination.writeList(mConnectionIds); |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 155 | destination.writeLong(mConnectTimeMillis); |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 156 | destination.writeStrongBinder( |
| 157 | mVideoProvider != null ? mVideoProvider.asBinder() : null); |
| 158 | destination.writeInt(mVideoState); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 159 | } |
| 160 | } |