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 int mConnectionProperties;
     38     private List<String> mConnectionIds;
     39     private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
     40     private final IVideoProvider mVideoProvider;
     41     private final int mVideoState;
     42     private StatusHints mStatusHints;
     43     private Bundle mExtras;
     44 
     45     public ParcelableConference(
     46             PhoneAccountHandle phoneAccount,
     47             int state,
     48             int connectionCapabilities,
     49             int connectionProperties,
     50             List<String> connectionIds,
     51             IVideoProvider videoProvider,
     52             int videoState,
     53             long connectTimeMillis,
     54             StatusHints statusHints,
     55             Bundle extras) {
     56         mPhoneAccount = phoneAccount;
     57         mState = state;
     58         mConnectionCapabilities = connectionCapabilities;
     59         mConnectionProperties = connectionProperties;
     60         mConnectionIds = connectionIds;
     61         mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
     62         mVideoProvider = videoProvider;
     63         mVideoState = videoState;
     64         mConnectTimeMillis = connectTimeMillis;
     65         mStatusHints = statusHints;
     66         mExtras = extras;
     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: ")
     77                 .append(Connection.capabilitiesToString(mConnectionCapabilities))
     78                 .append(", properties: ")
     79                 .append(Connection.propertiesToString(mConnectionProperties))
     80                 .append(", connectTime: ")
     81                 .append(mConnectTimeMillis)
     82                 .append(", children: ")
     83                 .append(mConnectionIds)
     84                 .append(", VideoState: ")
     85                 .append(mVideoState)
     86                 .append(", VideoProvider: ")
     87                 .append(mVideoProvider)
     88                 .toString();
     89     }
     90 
     91     public PhoneAccountHandle getPhoneAccount() {
     92         return mPhoneAccount;
     93     }
     94 
     95     public int getState() {
     96         return mState;
     97     }
     98 
     99     public int getConnectionCapabilities() {
    100         return mConnectionCapabilities;
    101     }
    102 
    103     public int getConnectionProperties() {
    104         return mConnectionProperties;
    105     }
    106 
    107     public List<String> getConnectionIds() {
    108         return mConnectionIds;
    109     }
    110 
    111     public long getConnectTimeMillis() {
    112         return mConnectTimeMillis;
    113     }
    114     public IVideoProvider getVideoProvider() {
    115         return mVideoProvider;
    116     }
    117 
    118     public int getVideoState() {
    119         return mVideoState;
    120     }
    121 
    122     public StatusHints getStatusHints() {
    123         return mStatusHints;
    124     }
    125 
    126     public Bundle getExtras() {
    127         return mExtras;
    128     }
    129 
    130     public static final Parcelable.Creator<ParcelableConference> CREATOR =
    131             new Parcelable.Creator<ParcelableConference> () {
    132         @Override
    133         public ParcelableConference createFromParcel(Parcel source) {
    134             ClassLoader classLoader = ParcelableConference.class.getClassLoader();
    135             PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
    136             int state = source.readInt();
    137             int capabilities = source.readInt();
    138             List<String> connectionIds = new ArrayList<>(2);
    139             source.readList(connectionIds, classLoader);
    140             long connectTimeMillis = source.readLong();
    141             IVideoProvider videoCallProvider =
    142                     IVideoProvider.Stub.asInterface(source.readStrongBinder());
    143             int videoState = source.readInt();
    144             StatusHints statusHints = source.readParcelable(classLoader);
    145             Bundle extras = source.readBundle(classLoader);
    146             int properties = source.readInt();
    147 
    148             return new ParcelableConference(phoneAccount, state, capabilities, properties,
    149                     connectionIds, videoCallProvider, videoState, connectTimeMillis, statusHints,
    150                     extras);
    151         }
    152 
    153         @Override
    154         public ParcelableConference[] newArray(int size) {
    155             return new ParcelableConference[size];
    156         }
    157     };
    158 
    159     /** {@inheritDoc} */
    160     @Override
    161     public int describeContents() {
    162         return 0;
    163     }
    164 
    165     /** Writes ParcelableConference object into a Parcel. */
    166     @Override
    167     public void writeToParcel(Parcel destination, int flags) {
    168         destination.writeParcelable(mPhoneAccount, 0);
    169         destination.writeInt(mState);
    170         destination.writeInt(mConnectionCapabilities);
    171         destination.writeList(mConnectionIds);
    172         destination.writeLong(mConnectTimeMillis);
    173         destination.writeStrongBinder(
    174                 mVideoProvider != null ? mVideoProvider.asBinder() : null);
    175         destination.writeInt(mVideoState);
    176         destination.writeParcelable(mStatusHints, 0);
    177         destination.writeBundle(mExtras);
    178         destination.writeInt(mConnectionProperties);
    179     }
    180 }
    181