1 /*
2  * Copyright (c) 2016 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 com.android.ims;
18 
19 import android.net.Uri;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22 import android.telephony.Rlog;
23 
24 /*
25  * This file contains all the api's through which
26  * information received in Dialog Event Package can be
27  * queried
28  */
29 
30 /**
31  * Parcelable object to handle MultiEndpoint Dialog Information
32  * @hide
33  */
34 public class ImsExternalCallState implements Parcelable {
35 
36     private static final String TAG = "ImsExternalCallState";
37 
38     // Dialog States
39     public static final int CALL_STATE_CONFIRMED = 1;
40     public static final int CALL_STATE_TERMINATED = 2;
41     // Dialog Id
42     private int mCallId;
43     // Number
44     private Uri mAddress;
45     private boolean mIsPullable;
46     // CALL_STATE_CONFIRMED / CALL_STATE_TERMINATED
47     private int mCallState;
48     // ImsCallProfile#CALL_TYPE_*
49     private int mCallType;
50     private boolean mIsHeld;
51 
ImsExternalCallState()52     public ImsExternalCallState() {
53     }
54 
ImsExternalCallState(int callId, Uri address, boolean isPullable, int callState, int callType, boolean isCallheld)55     public ImsExternalCallState(int callId, Uri address, boolean isPullable, int callState,
56             int callType, boolean isCallheld) {
57         mCallId = callId;
58         mAddress = address;
59         mIsPullable = isPullable;
60         mCallState = callState;
61         mCallType = callType;
62         mIsHeld = isCallheld;
63         Rlog.d(TAG, "ImsExternalCallState = " + this);
64     }
65 
ImsExternalCallState(Parcel in)66     public ImsExternalCallState(Parcel in) {
67         mCallId = in.readInt();
68         ClassLoader classLoader = ImsExternalCallState.class.getClassLoader();
69         mAddress = in.readParcelable(classLoader);
70         mIsPullable = (in.readInt() != 0);
71         mCallState = in.readInt();
72         mCallType = in.readInt();
73         mIsHeld = (in.readInt() != 0);
74         Rlog.d(TAG, "ImsExternalCallState const = " + this);
75     }
76 
77     @Override
describeContents()78     public int describeContents() {
79         return 0;
80     }
81 
82     @Override
writeToParcel(Parcel out, int flags)83     public void writeToParcel(Parcel out, int flags) {
84         out.writeInt(mCallId);
85         out.writeParcelable(mAddress, 0);
86         out.writeInt(mIsPullable ? 1 : 0);
87         out.writeInt(mCallState);
88         out.writeInt(mCallType);
89         out.writeInt(mIsHeld ? 1 : 0);
90         Rlog.d(TAG, "ImsExternalCallState writeToParcel = " + out.toString());
91     }
92 
93     public static final Parcelable.Creator<ImsExternalCallState> CREATOR =
94             new Parcelable.Creator<ImsExternalCallState>() {
95         @Override
96         public ImsExternalCallState createFromParcel(Parcel in) {
97             return new ImsExternalCallState(in);
98         }
99 
100         @Override
101         public ImsExternalCallState[] newArray(int size) {
102             return new ImsExternalCallState[size];
103         }
104     };
105 
getCallId()106     public int getCallId() {
107         return mCallId;
108     }
109 
getAddress()110     public Uri getAddress() {
111         return mAddress;
112     }
113 
isCallPullable()114     public boolean isCallPullable() {
115         return mIsPullable;
116     }
117 
getCallState()118     public int getCallState() {
119         return mCallState;
120     }
121 
getCallType()122     public int getCallType() {
123         return mCallType;
124     }
125 
isCallHeld()126     public boolean isCallHeld() {
127         return mIsHeld;
128     }
129 
130     @Override
toString()131     public String toString() {
132         return "ImsExternalCallState { mCallId = " + mCallId +
133                 ", mAddress = " + mAddress +
134                 ", mIsPullable = " + mIsPullable +
135                 ", mCallState = " + mCallState +
136                 ", mCallType = " + mCallType +
137                 ", mIsHeld = " + mIsHeld + "}";
138     }
139 }
140