Home | History | Annotate | Download | only in telecom
      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.Bundle;
     20 import android.os.Parcel;
     21 import android.os.Parcelable;
     22 
     23 import java.util.ArrayList;
     24 import java.util.List;
     25 
     26 import com.android.internal.telecom.IVideoProvider;
     27 
     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;
     36     private int mConnectionCapabilities;
     37     private List<String> mConnectionIds;
     38     private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
     39     private final IVideoProvider mVideoProvider;
     40     private final int mVideoState;
     41     private StatusHints mStatusHints;
     42     private Bundle mExtras;
     43 
     44     public ParcelableConference(
     45             PhoneAccountHandle phoneAccount,
     46             int state,
     47             int connectionCapabilities,
     48             List<String> connectionIds,
     49             IVideoProvider videoProvider,
     50             int videoState,
     51             long connectTimeMillis,
     52             StatusHints statusHints,
     53             Bundle extras) {
     54         mPhoneAccount = phoneAccount;
     55         mState = state;
     56         mConnectionCapabilities = connectionCapabilities;
     57         mConnectionIds = connectionIds;
     58         mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
     59         mVideoProvider = videoProvider;
     60         mVideoState = videoState;
     61         mConnectTimeMillis = connectTimeMillis;
     62         mStatusHints = statusHints;
     63         mExtras = extras;
     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: ")
     74                 .append(Connection.capabilitiesToString(mConnectionCapabilities))
     75                 .append(", connectTime: ")
     76                 .append(mConnectTimeMillis)
     77                 .append(", children: ")
     78                 .append(mConnectionIds)
     79                 .append(", VideoState: ")
     80                 .append(mVideoState)
     81                 .append(", VideoProvider: ")
     82                 .append(mVideoProvider)
     83                 .toString();
     84     }
     85 
     86     public PhoneAccountHandle getPhoneAccount() {
     87         return mPhoneAccount;
     88     }
     89 
     90     public int getState() {
     91         return mState;
     92     }
     93 
     94     public int getConnectionCapabilities() {
     95         return mConnectionCapabilities;
     96     }
     97 
     98     public List<String> getConnectionIds() {
     99         return mConnectionIds;
    100     }
    101 
    102     public long getConnectTimeMillis() {
    103         return mConnectTimeMillis;
    104     }
    105     public IVideoProvider getVideoProvider() {
    106         return mVideoProvider;
    107     }
    108 
    109     public int getVideoState() {
    110         return mVideoState;
    111     }
    112 
    113     public StatusHints getStatusHints() {
    114         return mStatusHints;
    115     }
    116 
    117     public Bundle getExtras() {
    118         return mExtras;
    119     }
    120 
    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);
    131             long connectTimeMillis = source.readLong();
    132             IVideoProvider videoCallProvider =
    133                     IVideoProvider.Stub.asInterface(source.readStrongBinder());
    134             int videoState = source.readInt();
    135             StatusHints statusHints = source.readParcelable(classLoader);
    136             Bundle extras = source.readBundle(classLoader);
    137 
    138             return new ParcelableConference(phoneAccount, state, capabilities, connectionIds,
    139                     videoCallProvider, videoState, connectTimeMillis, statusHints, extras);
    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);
    159         destination.writeInt(mConnectionCapabilities);
    160         destination.writeList(mConnectionIds);
    161         destination.writeLong(mConnectTimeMillis);
    162         destination.writeStrongBinder(
    163                 mVideoProvider != null ? mVideoProvider.asBinder() : null);
    164         destination.writeInt(mVideoState);
    165         destination.writeParcelable(mStatusHints, 0);
    166         destination.writeBundle(mExtras);
    167     }
    168 }
    169