Home | History | Annotate | Download | only in telecom
      1 /*
      2  * Copyright (C) 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.Parcel;
     21 import android.os.Parcelable;
     22 
     23 /**
     24  * Parcelable representation of a participant's state in a conference call.
     25  * @hide
     26  */
     27 public class ConferenceParticipant implements Parcelable {
     28 
     29     /**
     30      * The conference participant's handle (e.g., phone number).
     31      */
     32     private final Uri mHandle;
     33 
     34     /**
     35      * The display name for the participant.
     36      */
     37     private final String mDisplayName;
     38 
     39     /**
     40      * The endpoint Uri which uniquely identifies this conference participant.  E.g. for an IMS
     41      * conference call, this is the endpoint URI for the participant on the IMS conference server.
     42      */
     43     private final Uri mEndpoint;
     44 
     45     /**
     46      * The state of the participant in the conference.
     47      *
     48      * @see android.telecom.Connection
     49      */
     50     private final int mState;
     51 
     52     /**
     53      * Creates an instance of {@code ConferenceParticipant}.
     54      *
     55      * @param handle      The conference participant's handle (e.g., phone number).
     56      * @param displayName The display name for the participant.
     57      * @param endpoint    The enpoint Uri which uniquely identifies this conference participant.
     58      * @param state       The state of the participant in the conference.
     59      */
     60     public ConferenceParticipant(Uri handle, String displayName, Uri endpoint, int state) {
     61         mHandle = handle;
     62         mDisplayName = displayName;
     63         mEndpoint = endpoint;
     64         mState = state;
     65     }
     66 
     67     /**
     68      * Responsible for creating {@code ConferenceParticipant} objects for deserialized Parcels.
     69      */
     70     public static final Parcelable.Creator<ConferenceParticipant> CREATOR =
     71             new Parcelable.Creator<ConferenceParticipant>() {
     72 
     73                 @Override
     74                 public ConferenceParticipant createFromParcel(Parcel source) {
     75                     ClassLoader classLoader = ParcelableCall.class.getClassLoader();
     76                     Uri handle = source.readParcelable(classLoader);
     77                     String displayName = source.readString();
     78                     Uri endpoint = source.readParcelable(classLoader);
     79                     int state = source.readInt();
     80                     return new ConferenceParticipant(handle, displayName, endpoint, state);
     81                 }
     82 
     83                 @Override
     84                 public ConferenceParticipant[] newArray(int size) {
     85                     return new ConferenceParticipant[size];
     86                 }
     87             };
     88 
     89     @Override
     90     public int describeContents() {
     91         return 0;
     92     }
     93 
     94     /**
     95      * Writes the {@code ConferenceParticipant} to a parcel.
     96      *
     97      * @param dest The Parcel in which the object should be written.
     98      * @param flags Additional flags about how the object should be written.
     99      */
    100     @Override
    101     public void writeToParcel(Parcel dest, int flags) {
    102         dest.writeParcelable(mHandle, 0);
    103         dest.writeString(mDisplayName);
    104         dest.writeParcelable(mEndpoint, 0);
    105         dest.writeInt(mState);
    106     }
    107 
    108     /**
    109      * Builds a string representation of this instance.
    110      *
    111      * @return String representing the conference participant.
    112      */
    113     @Override
    114     public String toString() {
    115         StringBuilder sb = new StringBuilder();
    116         sb.append("[ConferenceParticipant Handle: ");
    117         sb.append(Log.pii(mHandle));
    118         sb.append(" DisplayName: ");
    119         sb.append(Log.pii(mDisplayName));
    120         sb.append(" Endpoint: ");
    121         sb.append(Log.pii(mEndpoint));
    122         sb.append(" State: ");
    123         sb.append(Connection.stateToString(mState));
    124         sb.append("]");
    125         return sb.toString();
    126     }
    127 
    128     /**
    129      * The conference participant's handle (e.g., phone number).
    130      */
    131     public Uri getHandle() {
    132         return mHandle;
    133     }
    134 
    135     /**
    136      * The display name for the participant.
    137      */
    138     public String getDisplayName() {
    139         return mDisplayName;
    140     }
    141 
    142     /**
    143      * The enpoint Uri which uniquely identifies this conference participant.  E.g. for an IMS
    144      * conference call, this is the endpoint URI for the participant on the IMS conference server.
    145      */
    146     public Uri getEndpoint() {
    147         return mEndpoint;
    148     }
    149 
    150     /**
    151      * The state of the participant in the conference.
    152      *
    153      * @see android.telecom.Connection
    154      */
    155     public int getState() {
    156         return mState;
    157     }
    158 }
    159