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