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