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.net.Uri;
     20 import android.os.Bundle;
     21 import android.os.Parcel;
     22 import android.os.Parcelable;
     23 
     24 import java.util.ArrayList;
     25 import java.util.List;
     26 
     27 import com.android.internal.telecom.IVideoProvider;
     28 
     29 /**
     30  * A parcelable representation of a conference connection.
     31  * @hide
     32  */
     33 public final class ParcelableConference implements Parcelable {
     34 
     35     private PhoneAccountHandle mPhoneAccount;
     36     private int mState;
     37     private int mConnectionCapabilities;
     38     private int mConnectionProperties;
     39     private List<String> mConnectionIds;
     40     private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
     41     private final IVideoProvider mVideoProvider;
     42     private final int mVideoState;
     43     private StatusHints mStatusHints;
     44     private Bundle mExtras;
     45     private long mConnectElapsedTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
     46     private final Uri mAddress;
     47     private final int mAddressPresentation;
     48     private final String mCallerDisplayName;
     49     private final int mCallerDisplayNamePresentation;
     50 
     51     public ParcelableConference(
     52             PhoneAccountHandle phoneAccount,
     53             int state,
     54             int connectionCapabilities,
     55             int connectionProperties,
     56             List<String> connectionIds,
     57             IVideoProvider videoProvider,
     58             int videoState,
     59             long connectTimeMillis,
     60             long connectElapsedTimeMillis,
     61             StatusHints statusHints,
     62             Bundle extras,
     63             Uri address,
     64             int addressPresentation,
     65             String callerDisplayName,
     66             int callerDisplayNamePresentation) {
     67         mPhoneAccount = phoneAccount;
     68         mState = state;
     69         mConnectionCapabilities = connectionCapabilities;
     70         mConnectionProperties = connectionProperties;
     71         mConnectionIds = connectionIds;
     72         mVideoProvider = videoProvider;
     73         mVideoState = videoState;
     74         mConnectTimeMillis = connectTimeMillis;
     75         mStatusHints = statusHints;
     76         mExtras = extras;
     77         mConnectElapsedTimeMillis = connectElapsedTimeMillis;
     78         mAddress = address;
     79         mAddressPresentation = addressPresentation;
     80         mCallerDisplayName = callerDisplayName;
     81         mCallerDisplayNamePresentation = callerDisplayNamePresentation;
     82     }
     83 
     84     @Override
     85     public String toString() {
     86         return (new StringBuffer())
     87                 .append("account: ")
     88                 .append(mPhoneAccount)
     89                 .append(", state: ")
     90                 .append(Connection.stateToString(mState))
     91                 .append(", capabilities: ")
     92                 .append(Connection.capabilitiesToString(mConnectionCapabilities))
     93                 .append(", properties: ")
     94                 .append(Connection.propertiesToString(mConnectionProperties))
     95                 .append(", connectTime: ")
     96                 .append(mConnectTimeMillis)
     97                 .append(", children: ")
     98                 .append(mConnectionIds)
     99                 .append(", VideoState: ")
    100                 .append(mVideoState)
    101                 .append(", VideoProvider: ")
    102                 .append(mVideoProvider)
    103                 .toString();
    104     }
    105 
    106     public PhoneAccountHandle getPhoneAccount() {
    107         return mPhoneAccount;
    108     }
    109 
    110     public int getState() {
    111         return mState;
    112     }
    113 
    114     public int getConnectionCapabilities() {
    115         return mConnectionCapabilities;
    116     }
    117 
    118     public int getConnectionProperties() {
    119         return mConnectionProperties;
    120     }
    121 
    122     public List<String> getConnectionIds() {
    123         return mConnectionIds;
    124     }
    125 
    126     public long getConnectTimeMillis() {
    127         return mConnectTimeMillis;
    128     }
    129 
    130     public long getConnectElapsedTimeMillis() {
    131         return mConnectElapsedTimeMillis;
    132     }
    133 
    134     public IVideoProvider getVideoProvider() {
    135         return mVideoProvider;
    136     }
    137 
    138     public int getVideoState() {
    139         return mVideoState;
    140     }
    141 
    142     public StatusHints getStatusHints() {
    143         return mStatusHints;
    144     }
    145 
    146     public Bundle getExtras() {
    147         return mExtras;
    148     }
    149 
    150     public Uri getHandle() {
    151         return mAddress;
    152     }
    153 
    154     public int getHandlePresentation() {
    155         return mAddressPresentation;
    156     }
    157 
    158     public static final @android.annotation.NonNull Parcelable.Creator<ParcelableConference> CREATOR =
    159             new Parcelable.Creator<ParcelableConference> () {
    160         @Override
    161         public ParcelableConference createFromParcel(Parcel source) {
    162             ClassLoader classLoader = ParcelableConference.class.getClassLoader();
    163             PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
    164             int state = source.readInt();
    165             int capabilities = source.readInt();
    166             List<String> connectionIds = new ArrayList<>(2);
    167             source.readList(connectionIds, classLoader);
    168             long connectTimeMillis = source.readLong();
    169             IVideoProvider videoCallProvider =
    170                     IVideoProvider.Stub.asInterface(source.readStrongBinder());
    171             int videoState = source.readInt();
    172             StatusHints statusHints = source.readParcelable(classLoader);
    173             Bundle extras = source.readBundle(classLoader);
    174             int properties = source.readInt();
    175             long connectElapsedTimeMillis = source.readLong();
    176             Uri address = source.readParcelable(classLoader);
    177             int addressPresentation = source.readInt();
    178             String callerDisplayName = source.readString();
    179             int callerDisplayNamePresentation = source.readInt();
    180 
    181             return new ParcelableConference(phoneAccount, state, capabilities, properties,
    182                     connectionIds, videoCallProvider, videoState, connectTimeMillis,
    183                     connectElapsedTimeMillis, statusHints, extras, address, addressPresentation,
    184                     callerDisplayName, callerDisplayNamePresentation);
    185         }
    186 
    187         @Override
    188         public ParcelableConference[] newArray(int size) {
    189             return new ParcelableConference[size];
    190         }
    191     };
    192 
    193     /** {@inheritDoc} */
    194     @Override
    195     public int describeContents() {
    196         return 0;
    197     }
    198 
    199     /** Writes ParcelableConference object into a Parcel. */
    200     @Override
    201     public void writeToParcel(Parcel destination, int flags) {
    202         destination.writeParcelable(mPhoneAccount, 0);
    203         destination.writeInt(mState);
    204         destination.writeInt(mConnectionCapabilities);
    205         destination.writeList(mConnectionIds);
    206         destination.writeLong(mConnectTimeMillis);
    207         destination.writeStrongBinder(
    208                 mVideoProvider != null ? mVideoProvider.asBinder() : null);
    209         destination.writeInt(mVideoState);
    210         destination.writeParcelable(mStatusHints, 0);
    211         destination.writeBundle(mExtras);
    212         destination.writeInt(mConnectionProperties);
    213         destination.writeLong(mConnectElapsedTimeMillis);
    214         destination.writeParcelable(mAddress, 0);
    215         destination.writeInt(mAddressPresentation);
    216         destination.writeString(mCallerDisplayName);
    217         destination.writeInt(mCallerDisplayNamePresentation);
    218     }
    219 }
    220