blob: 44dd567f78911a31e04e820dc668ad9bcef2182a [file] [log] [blame]
Sailesh Nepal60437932014-04-05 16:44:55 -07001/*
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
17package android.telecomm;
18
19import android.net.Uri;
Sailesh Nepal60437932014-04-05 16:44:55 -070020import android.os.Parcel;
21import android.os.Parcelable;
Andrew Lee5dc30752014-06-27 17:02:19 -070022import android.os.RemoteException;
Sailesh Nepal60437932014-04-05 16:44:55 -070023import android.telephony.DisconnectCause;
24
Andrew Lee5dc30752014-06-27 17:02:19 -070025import com.android.internal.telecomm.ICallVideoProvider;
26
Santos Cordon980acb92014-05-31 10:31:19 -070027import java.util.ArrayList;
28import java.util.Collections;
29import java.util.List;
Sailesh Nepal60437932014-04-05 16:44:55 -070030
31/**
32 * Information about a call that is used between InCallService and Telecomm.
33 */
34public final class InCallCall implements Parcelable {
35 private final String mId;
36 private final CallState mState;
Ihab Awadfbb092f2014-06-03 18:40:45 -070037 private final int mDisconnectCauseCode;
38 private final String mDisconnectCauseMsg;
Ihab Awadc0677542014-06-10 13:29:47 -070039 private final List<String> mCannedSmsResponses;
Sailesh Nepal60437932014-04-05 16:44:55 -070040 private final int mCapabilities;
41 private final long mConnectTimeMillis;
42 private final Uri mHandle;
43 private final GatewayInfo mGatewayInfo;
Nancy Chen5ffbfcc2014-06-25 14:22:55 -070044 private final Subscription mSubscription;
Sailesh Nepal60437932014-04-05 16:44:55 -070045 private final CallServiceDescriptor mCurrentCallServiceDescriptor;
46 private final CallServiceDescriptor mHandoffCallServiceDescriptor;
Andrew Lee5dc30752014-06-27 17:02:19 -070047 private final ICallVideoProvider mCallVideoProvider;
48 private RemoteCallVideoProvider mRemoteCallVideoProvider;
Santos Cordon980acb92014-05-31 10:31:19 -070049 private final String mParentCallId;
50 private final List<String> mChildCallIds;
Tyler Gunn8d83fa92014-07-01 11:31:21 -070051 private final int mFeatures;
Santos Cordon980acb92014-05-31 10:31:19 -070052
53 /** @hide */
Sailesh Nepal60437932014-04-05 16:44:55 -070054 public InCallCall(
55 String id,
56 CallState state,
Ihab Awadfbb092f2014-06-03 18:40:45 -070057 int disconnectCauseCode,
58 String disconnectCauseMsg,
Ihab Awadc0677542014-06-10 13:29:47 -070059 List<String> cannedSmsResponses,
Sailesh Nepal60437932014-04-05 16:44:55 -070060 int capabilities,
61 long connectTimeMillis,
62 Uri handle,
63 GatewayInfo gatewayInfo,
Nancy Chen5ffbfcc2014-06-25 14:22:55 -070064 Subscription subscription,
Sailesh Nepal60437932014-04-05 16:44:55 -070065 CallServiceDescriptor descriptor,
Santos Cordon980acb92014-05-31 10:31:19 -070066 CallServiceDescriptor handoffDescriptor,
Andrew Lee5dc30752014-06-27 17:02:19 -070067 ICallVideoProvider callVideoProvider,
Santos Cordon980acb92014-05-31 10:31:19 -070068 String parentCallId,
Tyler Gunn8d83fa92014-07-01 11:31:21 -070069 List<String> childCallIds,
70 int features) {
Sailesh Nepal60437932014-04-05 16:44:55 -070071 mId = id;
72 mState = state;
Ihab Awadfbb092f2014-06-03 18:40:45 -070073 mDisconnectCauseCode = disconnectCauseCode;
74 mDisconnectCauseMsg = disconnectCauseMsg;
Ihab Awadc0677542014-06-10 13:29:47 -070075 mCannedSmsResponses = cannedSmsResponses;
Sailesh Nepal60437932014-04-05 16:44:55 -070076 mCapabilities = capabilities;
77 mConnectTimeMillis = connectTimeMillis;
78 mHandle = handle;
79 mGatewayInfo = gatewayInfo;
Nancy Chen5ffbfcc2014-06-25 14:22:55 -070080 mSubscription = subscription;
Sailesh Nepal60437932014-04-05 16:44:55 -070081 mCurrentCallServiceDescriptor = descriptor;
82 mHandoffCallServiceDescriptor = handoffDescriptor;
Andrew Lee5dc30752014-06-27 17:02:19 -070083 mCallVideoProvider = callVideoProvider;
Santos Cordon980acb92014-05-31 10:31:19 -070084 mParentCallId = parentCallId;
85 mChildCallIds = childCallIds;
Tyler Gunn8d83fa92014-07-01 11:31:21 -070086 mFeatures = features;
Sailesh Nepal60437932014-04-05 16:44:55 -070087 }
88
89 /** The unique ID of the call. */
90 public String getId() {
91 return mId;
92 }
93
94 /** The current state of the call. */
95 public CallState getState() {
96 return mState;
97 }
98
99 /**
100 * Reason for disconnection, values are defined in {@link DisconnectCause}. Valid when call
Sailesh Nepalc1a48ef2014-04-08 14:32:20 -0700101 * state is {@link CallState#DISCONNECTED}.
Sailesh Nepal60437932014-04-05 16:44:55 -0700102 */
Ihab Awadfbb092f2014-06-03 18:40:45 -0700103 public int getDisconnectCauseCode() {
104 return mDisconnectCauseCode;
105 }
106
107 /**
108 * Further optional textual information about the reason for disconnection. Valid when call
109 * state is {@link CallState#DISCONNECTED}.
110 */
111 public String getDisconnectCauseMsg() {
112 return mDisconnectCauseMsg;
Sailesh Nepal60437932014-04-05 16:44:55 -0700113 }
114
Ihab Awadc0677542014-06-10 13:29:47 -0700115 /**
116 * The set of possible text message responses when this call is incoming.
117 */
118 public List<String> getCannedSmsResponses() {
119 return mCannedSmsResponses;
120 }
121
Sailesh Nepal60437932014-04-05 16:44:55 -0700122 // Bit mask of actions a call supports, values are defined in {@link CallCapabilities}.
123 public int getCapabilities() {
124 return mCapabilities;
125 }
126
127 /** The time that the call switched to the active state. */
128 public long getConnectTimeMillis() {
129 return mConnectTimeMillis;
130 }
131
132 /** The endpoint to which the call is connected. */
133 public Uri getHandle() {
134 return mHandle;
135 }
136
137 /** Gateway information for the call. */
138 public GatewayInfo getGatewayInfo() {
139 return mGatewayInfo;
140 }
141
Nancy Chen5ffbfcc2014-06-25 14:22:55 -0700142 /** Subscription information for the call. */
143 public Subscription getSubscription() {
144 return mSubscription;
145 }
146
Sailesh Nepal60437932014-04-05 16:44:55 -0700147 /** The descriptor for the call service currently routing this call. */
148 public CallServiceDescriptor getCurrentCallServiceDescriptor() {
149 return mCurrentCallServiceDescriptor;
150 }
151
152 /**
153 * The descriptor for the call service that this call is being switched to, null if handoff is
154 * not in progress.
155 */
156 public CallServiceDescriptor getHandoffCallServiceDescriptor() {
157 return mHandoffCallServiceDescriptor;
158 }
159
Santos Cordon980acb92014-05-31 10:31:19 -0700160 /**
Andrew Lee5dc30752014-06-27 17:02:19 -0700161 * Returns an object for remotely communicating through the call video provider's binder.
162 * @return The call video provider.
163 */
164 public RemoteCallVideoProvider getCallVideoProvider() throws RemoteException {
Tyler Gunn807de8a2014-06-30 14:22:57 -0700165 if (mRemoteCallVideoProvider == null && mCallVideoProvider != null) {
Andrew Lee5dc30752014-06-27 17:02:19 -0700166 try {
167 mRemoteCallVideoProvider = new RemoteCallVideoProvider(mCallVideoProvider);
168 } catch (RemoteException ignored) {
169 // Ignore RemoteException.
170 }
171 }
172
173 return mRemoteCallVideoProvider;
174 }
175
176 /**
Santos Cordon980acb92014-05-31 10:31:19 -0700177 * The conference call to which this call is conferenced. Null if not conferenced.
178 * @hide
179 */
180 public String getParentCallId() {
181 return mParentCallId;
182 }
183
184 /**
185 * The child call-IDs if this call is a conference call. Returns an empty list if this is not
186 * a conference call or if the conference call contains no children.
187 * @hide
188 */
189 public List<String> getChildCallIds() {
190 return mChildCallIds;
191 }
192
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700193 /**
194 * The features of this call (e.g. VoLTE, VoWIFI).
195 *
196 * @return Features.
197 */
198 public int getFeatures() {
199 return mFeatures;
200 }
201
Sailesh Nepal60437932014-04-05 16:44:55 -0700202 /** Responsible for creating InCallCall objects for deserialized Parcels. */
203 public static final Parcelable.Creator<InCallCall> CREATOR =
204 new Parcelable.Creator<InCallCall> () {
205 @Override
206 public InCallCall createFromParcel(Parcel source) {
Ihab Awadc0677542014-06-10 13:29:47 -0700207 ClassLoader classLoader = InCallCall.class.getClassLoader();
Sailesh Nepal60437932014-04-05 16:44:55 -0700208 String id = source.readString();
209 CallState state = CallState.valueOf(source.readString());
Ihab Awadfbb092f2014-06-03 18:40:45 -0700210 int disconnectCauseCode = source.readInt();
211 String disconnectCauseMsg = source.readString();
Ihab Awadc0677542014-06-10 13:29:47 -0700212 List<String> cannedSmsResponses = new ArrayList<>();
213 source.readList(cannedSmsResponses, classLoader);
Sailesh Nepal60437932014-04-05 16:44:55 -0700214 int capabilities = source.readInt();
215 long connectTimeMillis = source.readLong();
Sailesh Nepal60437932014-04-05 16:44:55 -0700216 Uri handle = source.readParcelable(classLoader);
217 GatewayInfo gatewayInfo = source.readParcelable(classLoader);
Nancy Chen5ffbfcc2014-06-25 14:22:55 -0700218 Subscription subscription = source.readParcelable(classLoader);
Sailesh Nepal60437932014-04-05 16:44:55 -0700219 CallServiceDescriptor descriptor = source.readParcelable(classLoader);
220 CallServiceDescriptor handoffDescriptor = source.readParcelable(classLoader);
Andrew Lee5dc30752014-06-27 17:02:19 -0700221 ICallVideoProvider callVideoProvider =
222 ICallVideoProvider.Stub.asInterface(source.readStrongBinder());
Santos Cordon980acb92014-05-31 10:31:19 -0700223 String parentCallId = source.readString();
224 List<String> childCallIds = new ArrayList<>();
225 source.readList(childCallIds, classLoader);
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700226 int features = source.readInt();
Ihab Awadc0677542014-06-10 13:29:47 -0700227 return new InCallCall(id, state, disconnectCauseCode, disconnectCauseMsg,
228 cannedSmsResponses, capabilities, connectTimeMillis, handle, gatewayInfo,
Andrew Lee5dc30752014-06-27 17:02:19 -0700229 subscription, descriptor, handoffDescriptor, callVideoProvider, parentCallId,
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700230 childCallIds, features);
Sailesh Nepal60437932014-04-05 16:44:55 -0700231 }
232
233 @Override
234 public InCallCall[] newArray(int size) {
235 return new InCallCall[size];
236 }
237 };
238
239 /** {@inheritDoc} */
240 @Override
241 public int describeContents() {
242 return 0;
243 }
244
245 /** Writes InCallCall object into a Parcel. */
246 @Override
247 public void writeToParcel(Parcel destination, int flags) {
248 destination.writeString(mId);
249 destination.writeString(mState.name());
Ihab Awadfbb092f2014-06-03 18:40:45 -0700250 destination.writeInt(mDisconnectCauseCode);
251 destination.writeString(mDisconnectCauseMsg);
Ihab Awadc0677542014-06-10 13:29:47 -0700252 destination.writeList(mCannedSmsResponses);
Sailesh Nepal60437932014-04-05 16:44:55 -0700253 destination.writeInt(mCapabilities);
254 destination.writeLong(mConnectTimeMillis);
255 destination.writeParcelable(mHandle, 0);
256 destination.writeParcelable(mGatewayInfo, 0);
Nancy Chen5ffbfcc2014-06-25 14:22:55 -0700257 destination.writeParcelable(mSubscription, 0);
Sailesh Nepal60437932014-04-05 16:44:55 -0700258 destination.writeParcelable(mCurrentCallServiceDescriptor, 0);
259 destination.writeParcelable(mHandoffCallServiceDescriptor, 0);
Tyler Gunn807de8a2014-06-30 14:22:57 -0700260 destination.writeStrongBinder(
261 mCallVideoProvider != null ? mCallVideoProvider.asBinder() : null);
Santos Cordon980acb92014-05-31 10:31:19 -0700262 destination.writeString(mParentCallId);
263 destination.writeList(mChildCallIds);
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700264 destination.writeInt(mFeatures);
Sailesh Nepal60437932014-04-05 16:44:55 -0700265 }
Santos Cordonb6939982014-06-04 20:20:58 -0700266
267 @Override
268 public String toString() {
269 return String.format("[%s, parent:%s, children:%s]", mId, mParentCallId, mChildCallIds);
270 }
Sailesh Nepal60437932014-04-05 16:44:55 -0700271}