ImsExternalCallState.java revision f604fc33c699b9f91315588ea4d6c6cd3b09a372
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
17package com.android.ims;
18
19import android.net.Uri;
20import android.os.Parcel;
21import android.os.Parcelable;
22import 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 VICE Dialog Information
32 * @hide
33 */
34public 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    public int mCallId;
43    // Number
44    public Uri mAddress;
45    public boolean mIsPullable;
46    // CALL_STATE_CONFIRMED / CALL_STATE_TERMINATED
47    public int mCallState;
48    // ImsCallProfile#CALL_TYPE_*
49    public int mCallType;
50    public boolean mIsHeld;
51
52    public ImsExternalCallState() {
53    }
54
55    public ImsExternalCallState(Parcel in) {
56        mCallId = in.readInt();
57        ClassLoader classLoader = ImsExternalCallState.class.getClassLoader();
58        mAddress = in.readParcelable(classLoader);
59        mIsPullable = (in.readInt() != 0);
60        mCallState = in.readInt();
61        mCallType = in.readInt();
62        mIsHeld = (in.readInt() != 0);
63        Rlog.d(TAG, "ImsExternalCallState const = " +
64                "callid = " + getCallId() +
65                ", address = " + getAddress() +
66                ", mCallState = " + getCallState() +
67                ", calltype = " + getCallType() +
68                ", isheld = " + isCallHeld());
69    }
70
71    @Override
72    public int describeContents() {
73        return 0;
74    }
75
76    @Override
77    public void writeToParcel(Parcel out, int flags) {
78        out.writeInt(mCallId);
79        out.writeParcelable(mAddress, 0);
80        out.writeInt(mIsPullable ? 1 : 0);
81        out.writeInt(mCallState);
82        out.writeInt(mCallType);
83        out.writeInt(mIsHeld ? 1 : 0);
84    }
85
86    public static final Parcelable.Creator<ImsExternalCallState> CREATOR =
87            new Parcelable.Creator<ImsExternalCallState>() {
88        @Override
89        public ImsExternalCallState createFromParcel(Parcel in) {
90            return new ImsExternalCallState(in);
91        }
92
93        @Override
94        public ImsExternalCallState[] newArray(int size) {
95            return new ImsExternalCallState[size];
96        }
97    };
98
99    public int getCallId() {
100        return mCallId;
101    }
102
103    public Uri getAddress() {
104        return mAddress;
105    }
106
107    public boolean isCallPullable() {
108        return mIsPullable;
109    }
110
111    public int getCallState() {
112        return mCallState;
113    }
114
115    public int getCallType() {
116        return mCallType;
117    }
118
119    public boolean isCallHeld() {
120        return mIsHeld;
121    }
122
123    @Override
124    public String toString() {
125        return "ImsExternalCallState { mCallId = " + mCallId +
126                ", mAddress = " + mAddress +
127                ", mIsPullable = " + mIsPullable +
128                ", mCallState = " + mCallState +
129                ", mCallType = " + mCallType +
130                ", mIsHeld = " + mIsHeld + "}";
131    }
132}
133