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