blob: bf6c31816bba312e7f906f9c7a03d87d8e967588 [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
Tyler Gunnef9f6f92014-09-12 22:16:17 -070017package android.telecom;
Sailesh Nepal60437932014-04-05 16:44:55 -070018
19import android.net.Uri;
Nancy Chen10798dc2014-08-08 14:00:25 -070020import android.os.Bundle;
Sailesh Nepal60437932014-04-05 16:44:55 -070021import android.os.Parcel;
22import android.os.Parcelable;
Andrew Lee5dc30752014-06-27 17:02:19 -070023import android.os.RemoteException;
Sailesh Nepal60437932014-04-05 16:44:55 -070024
Santos Cordon980acb92014-05-31 10:31:19 -070025import java.util.ArrayList;
Santos Cordon7c7bc7f2014-07-28 18:15:48 -070026import java.util.Collections;
Santos Cordon980acb92014-05-31 10:31:19 -070027import java.util.List;
Sailesh Nepal60437932014-04-05 16:44:55 -070028
Tyler Gunnef9f6f92014-09-12 22:16:17 -070029import com.android.internal.telecom.IVideoProvider;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070030
Sailesh Nepal60437932014-04-05 16:44:55 -070031/**
Tyler Gunnef9f6f92014-09-12 22:16:17 -070032 * Information about a call that is used between InCallService and Telecom.
Santos Cordon88b771d2014-07-19 13:10:40 -070033 * @hide
Sailesh Nepal60437932014-04-05 16:44:55 -070034 */
Santos Cordon88b771d2014-07-19 13:10:40 -070035public final class ParcelableCall implements Parcelable {
Sailesh Nepal60437932014-04-05 16:44:55 -070036 private final String mId;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070037 private final int mState;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070038 private final DisconnectCause mDisconnectCause;
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;
Andrew Lee223ad142014-08-27 16:33:08 -070041 private final int mProperties;
Sailesh Nepal60437932014-04-05 16:44:55 -070042 private final long mConnectTimeMillis;
43 private final Uri mHandle;
Sailesh Nepal61203862014-07-11 14:50:13 -070044 private final int mHandlePresentation;
45 private final String mCallerDisplayName;
46 private final int mCallerDisplayNamePresentation;
Sailesh Nepal60437932014-04-05 16:44:55 -070047 private final GatewayInfo mGatewayInfo;
Evan Charlton8c8a0622014-07-20 12:31:00 -070048 private final PhoneAccountHandle mAccountHandle;
Tyler Gunn75958422015-04-15 14:23:42 -070049 private final boolean mIsVideoCallProviderChanged;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070050 private final IVideoProvider mVideoCallProvider;
Andrew Lee50aca232014-07-22 16:41:54 -070051 private InCallService.VideoCall mVideoCall;
Santos Cordon980acb92014-05-31 10:31:19 -070052 private final String mParentCallId;
53 private final List<String> mChildCallIds;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070054 private final StatusHints mStatusHints;
Andrew Lee85f5d422014-07-11 17:22:03 -070055 private final int mVideoState;
Santos Cordon7c7bc7f2014-07-28 18:15:48 -070056 private final List<String> mConferenceableCallIds;
Nancy Chen10798dc2014-08-08 14:00:25 -070057 private final Bundle mExtras;
Rekha Kumar07366812015-03-24 16:42:31 -070058 private int mCallSubstate;
Santos Cordon980acb92014-05-31 10:31:19 -070059
Santos Cordon88b771d2014-07-19 13:10:40 -070060 public ParcelableCall(
Sailesh Nepal60437932014-04-05 16:44:55 -070061 String id,
Ihab Awadb19a0bc2014-08-07 19:46:01 -070062 int state,
Andrew Lee7f3d41f2014-09-11 17:33:16 -070063 DisconnectCause disconnectCause,
Ihab Awadc0677542014-06-10 13:29:47 -070064 List<String> cannedSmsResponses,
Sailesh Nepal60437932014-04-05 16:44:55 -070065 int capabilities,
Andrew Lee223ad142014-08-27 16:33:08 -070066 int properties,
Sailesh Nepal60437932014-04-05 16:44:55 -070067 long connectTimeMillis,
68 Uri handle,
Sailesh Nepal61203862014-07-11 14:50:13 -070069 int handlePresentation,
70 String callerDisplayName,
71 int callerDisplayNamePresentation,
Sailesh Nepal60437932014-04-05 16:44:55 -070072 GatewayInfo gatewayInfo,
Evan Charlton8c8a0622014-07-20 12:31:00 -070073 PhoneAccountHandle accountHandle,
Tyler Gunn75958422015-04-15 14:23:42 -070074 boolean isVideoCallProviderChanged,
Ihab Awadb19a0bc2014-08-07 19:46:01 -070075 IVideoProvider videoCallProvider,
Santos Cordon980acb92014-05-31 10:31:19 -070076 String parentCallId,
Tyler Gunn8d83fa92014-07-01 11:31:21 -070077 List<String> childCallIds,
Andrew Lee85f5d422014-07-11 17:22:03 -070078 StatusHints statusHints,
Santos Cordon7c7bc7f2014-07-28 18:15:48 -070079 int videoState,
Nancy Chen10798dc2014-08-08 14:00:25 -070080 List<String> conferenceableCallIds,
Rekha Kumar07366812015-03-24 16:42:31 -070081 Bundle extras,
82 int callSubstate) {
Sailesh Nepal60437932014-04-05 16:44:55 -070083 mId = id;
84 mState = state;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070085 mDisconnectCause = disconnectCause;
Ihab Awadc0677542014-06-10 13:29:47 -070086 mCannedSmsResponses = cannedSmsResponses;
Sailesh Nepal60437932014-04-05 16:44:55 -070087 mCapabilities = capabilities;
Andrew Lee223ad142014-08-27 16:33:08 -070088 mProperties = properties;
Sailesh Nepal60437932014-04-05 16:44:55 -070089 mConnectTimeMillis = connectTimeMillis;
90 mHandle = handle;
Sailesh Nepal61203862014-07-11 14:50:13 -070091 mHandlePresentation = handlePresentation;
92 mCallerDisplayName = callerDisplayName;
93 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
Sailesh Nepal60437932014-04-05 16:44:55 -070094 mGatewayInfo = gatewayInfo;
Evan Charlton8c8a0622014-07-20 12:31:00 -070095 mAccountHandle = accountHandle;
Tyler Gunn75958422015-04-15 14:23:42 -070096 mIsVideoCallProviderChanged = isVideoCallProviderChanged;
Andrew Lee50aca232014-07-22 16:41:54 -070097 mVideoCallProvider = videoCallProvider;
Santos Cordon980acb92014-05-31 10:31:19 -070098 mParentCallId = parentCallId;
99 mChildCallIds = childCallIds;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700100 mStatusHints = statusHints;
Andrew Lee85f5d422014-07-11 17:22:03 -0700101 mVideoState = videoState;
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700102 mConferenceableCallIds = Collections.unmodifiableList(conferenceableCallIds);
Nancy Chen10798dc2014-08-08 14:00:25 -0700103 mExtras = extras;
Rekha Kumar07366812015-03-24 16:42:31 -0700104 mCallSubstate = callSubstate;
Sailesh Nepal60437932014-04-05 16:44:55 -0700105 }
106
107 /** The unique ID of the call. */
108 public String getId() {
109 return mId;
110 }
111
112 /** The current state of the call. */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700113 public int getState() {
Sailesh Nepal60437932014-04-05 16:44:55 -0700114 return mState;
115 }
116
117 /**
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700118 * Reason for disconnection, as described by {@link android.telecomm.DisconnectCause}. Valid
119 * when call state is {@link CallState#DISCONNECTED}.
Sailesh Nepal60437932014-04-05 16:44:55 -0700120 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700121 public DisconnectCause getDisconnectCause() {
122 return mDisconnectCause;
Sailesh Nepal60437932014-04-05 16:44:55 -0700123 }
124
Ihab Awadc0677542014-06-10 13:29:47 -0700125 /**
126 * The set of possible text message responses when this call is incoming.
127 */
128 public List<String> getCannedSmsResponses() {
129 return mCannedSmsResponses;
130 }
131
Sailesh Nepal60437932014-04-05 16:44:55 -0700132 // Bit mask of actions a call supports, values are defined in {@link CallCapabilities}.
133 public int getCapabilities() {
134 return mCapabilities;
135 }
136
Andrew Lee223ad142014-08-27 16:33:08 -0700137 /** Bitmask of properties of the call. */
138 public int getProperties() { return mProperties; }
139
Sailesh Nepal60437932014-04-05 16:44:55 -0700140 /** The time that the call switched to the active state. */
141 public long getConnectTimeMillis() {
142 return mConnectTimeMillis;
143 }
144
145 /** The endpoint to which the call is connected. */
146 public Uri getHandle() {
147 return mHandle;
148 }
149
Nancy Chen9d568c02014-09-08 14:17:59 -0700150 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700151 * The presentation requirements for the handle. See {@link TelecomManager} for valid values.
Nancy Chen9d568c02014-09-08 14:17:59 -0700152 */
Sailesh Nepal61203862014-07-11 14:50:13 -0700153 public int getHandlePresentation() {
154 return mHandlePresentation;
155 }
156
157 /** The endpoint to which the call is connected. */
158 public String getCallerDisplayName() {
159 return mCallerDisplayName;
160 }
161
Nancy Chen9d568c02014-09-08 14:17:59 -0700162 /**
163 * The presentation requirements for the caller display name.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700164 * See {@link TelecomManager} for valid values.
Nancy Chen9d568c02014-09-08 14:17:59 -0700165 */
Sailesh Nepal61203862014-07-11 14:50:13 -0700166 public int getCallerDisplayNamePresentation() {
167 return mCallerDisplayNamePresentation;
168 }
169
Sailesh Nepal60437932014-04-05 16:44:55 -0700170 /** Gateway information for the call. */
171 public GatewayInfo getGatewayInfo() {
172 return mGatewayInfo;
173 }
174
Evan Charlton6eb262c2014-07-19 18:18:19 -0700175 /** PhoneAccountHandle information for the call. */
Evan Charlton8c8a0622014-07-20 12:31:00 -0700176 public PhoneAccountHandle getAccountHandle() {
177 return mAccountHandle;
Nancy Chen5ffbfcc2014-06-25 14:22:55 -0700178 }
179
Sailesh Nepal60437932014-04-05 16:44:55 -0700180 /**
Andrew Lee50aca232014-07-22 16:41:54 -0700181 * Returns an object for remotely communicating through the video call provider's binder.
182 * @return The video call.
Andrew Lee5dc30752014-06-27 17:02:19 -0700183 */
Andrew Lee50aca232014-07-22 16:41:54 -0700184 public InCallService.VideoCall getVideoCall() {
185 if (mVideoCall == null && mVideoCallProvider != null) {
Andrew Lee5dc30752014-06-27 17:02:19 -0700186 try {
Andrew Lee50aca232014-07-22 16:41:54 -0700187 mVideoCall = new VideoCallImpl(mVideoCallProvider);
Andrew Lee5dc30752014-06-27 17:02:19 -0700188 } catch (RemoteException ignored) {
189 // Ignore RemoteException.
190 }
191 }
192
Andrew Lee50aca232014-07-22 16:41:54 -0700193 return mVideoCall;
Andrew Lee5dc30752014-06-27 17:02:19 -0700194 }
195
196 /**
Santos Cordon980acb92014-05-31 10:31:19 -0700197 * The conference call to which this call is conferenced. Null if not conferenced.
Santos Cordon980acb92014-05-31 10:31:19 -0700198 */
199 public String getParentCallId() {
200 return mParentCallId;
201 }
202
203 /**
204 * The child call-IDs if this call is a conference call. Returns an empty list if this is not
205 * a conference call or if the conference call contains no children.
Santos Cordon980acb92014-05-31 10:31:19 -0700206 */
207 public List<String> getChildCallIds() {
208 return mChildCallIds;
209 }
210
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700211 public List<String> getConferenceableCallIds() {
212 return mConferenceableCallIds;
213 }
214
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700215 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700216 * The status label and icon.
217 *
218 * @return Status hints.
219 */
220 public StatusHints getStatusHints() {
221 return mStatusHints;
222 }
223
Andrew Lee85f5d422014-07-11 17:22:03 -0700224 /**
225 * The video state.
226 * @return The video state of the call.
227 */
228 public int getVideoState() {
229 return mVideoState;
230 }
231
Nancy Chen10798dc2014-08-08 14:00:25 -0700232 /**
233 * Any extras to pass with the call
234 *
235 * @return a bundle of extras
236 */
237 public Bundle getExtras() {
238 return mExtras;
239 }
240
Rekha Kumar07366812015-03-24 16:42:31 -0700241 /**
242 * The call substate.
243 * @return The substate of the call.
244 */
245 public int getCallSubstate() {
246 return mCallSubstate;
247 }
248
Tyler Gunn75958422015-04-15 14:23:42 -0700249 /**
250 * Indicates to the receiver of the {@link ParcelableCall} whether a change has occurred in the
251 * {@link android.telecom.InCallService.VideoCall} associated with this call. Since
252 * {@link #getVideoCall()} creates a new {@link VideoCallImpl}, it is useful to know whether
253 * the provider has changed (which can influence whether it is accessed).
254 *
255 * @return {@code true} if the video call changed, {@code false} otherwise.
256 */
257 public boolean isVideoCallProviderChanged() {
258 return mIsVideoCallProviderChanged;
259 }
260
Santos Cordon88b771d2014-07-19 13:10:40 -0700261 /** Responsible for creating ParcelableCall objects for deserialized Parcels. */
262 public static final Parcelable.Creator<ParcelableCall> CREATOR =
263 new Parcelable.Creator<ParcelableCall> () {
Sailesh Nepal60437932014-04-05 16:44:55 -0700264 @Override
Santos Cordon88b771d2014-07-19 13:10:40 -0700265 public ParcelableCall createFromParcel(Parcel source) {
266 ClassLoader classLoader = ParcelableCall.class.getClassLoader();
Sailesh Nepal60437932014-04-05 16:44:55 -0700267 String id = source.readString();
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700268 int state = source.readInt();
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700269 DisconnectCause disconnectCause = source.readParcelable(classLoader);
Ihab Awadc0677542014-06-10 13:29:47 -0700270 List<String> cannedSmsResponses = new ArrayList<>();
271 source.readList(cannedSmsResponses, classLoader);
Sailesh Nepal60437932014-04-05 16:44:55 -0700272 int capabilities = source.readInt();
Andrew Lee223ad142014-08-27 16:33:08 -0700273 int properties = source.readInt();
Sailesh Nepal60437932014-04-05 16:44:55 -0700274 long connectTimeMillis = source.readLong();
Sailesh Nepal60437932014-04-05 16:44:55 -0700275 Uri handle = source.readParcelable(classLoader);
Sailesh Nepal61203862014-07-11 14:50:13 -0700276 int handlePresentation = source.readInt();
277 String callerDisplayName = source.readString();
278 int callerDisplayNamePresentation = source.readInt();
Sailesh Nepal60437932014-04-05 16:44:55 -0700279 GatewayInfo gatewayInfo = source.readParcelable(classLoader);
Evan Charlton8c8a0622014-07-20 12:31:00 -0700280 PhoneAccountHandle accountHandle = source.readParcelable(classLoader);
Tyler Gunn75958422015-04-15 14:23:42 -0700281 boolean isVideoCallProviderChanged = source.readByte() == 1;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700282 IVideoProvider videoCallProvider =
283 IVideoProvider.Stub.asInterface(source.readStrongBinder());
Santos Cordon980acb92014-05-31 10:31:19 -0700284 String parentCallId = source.readString();
285 List<String> childCallIds = new ArrayList<>();
286 source.readList(childCallIds, classLoader);
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700287 StatusHints statusHints = source.readParcelable(classLoader);
Andrew Lee85f5d422014-07-11 17:22:03 -0700288 int videoState = source.readInt();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700289 List<String> conferenceableCallIds = new ArrayList<>();
290 source.readList(conferenceableCallIds, classLoader);
Nancy Chen10798dc2014-08-08 14:00:25 -0700291 Bundle extras = source.readParcelable(classLoader);
Rekha Kumar07366812015-03-24 16:42:31 -0700292 int callSubstate = source.readInt();
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700293 return new ParcelableCall(
294 id,
295 state,
296 disconnectCause,
297 cannedSmsResponses,
298 capabilities,
299 properties,
300 connectTimeMillis,
301 handle,
302 handlePresentation,
303 callerDisplayName,
304 callerDisplayNamePresentation,
305 gatewayInfo,
306 accountHandle,
Tyler Gunn75958422015-04-15 14:23:42 -0700307 isVideoCallProviderChanged,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700308 videoCallProvider,
309 parentCallId,
310 childCallIds,
311 statusHints,
312 videoState,
313 conferenceableCallIds,
Rekha Kumar07366812015-03-24 16:42:31 -0700314 extras,
315 callSubstate);
Sailesh Nepal60437932014-04-05 16:44:55 -0700316 }
317
318 @Override
Santos Cordon88b771d2014-07-19 13:10:40 -0700319 public ParcelableCall[] newArray(int size) {
320 return new ParcelableCall[size];
Sailesh Nepal60437932014-04-05 16:44:55 -0700321 }
322 };
323
324 /** {@inheritDoc} */
325 @Override
326 public int describeContents() {
327 return 0;
328 }
329
Santos Cordon88b771d2014-07-19 13:10:40 -0700330 /** Writes ParcelableCall object into a Parcel. */
Sailesh Nepal60437932014-04-05 16:44:55 -0700331 @Override
332 public void writeToParcel(Parcel destination, int flags) {
333 destination.writeString(mId);
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700334 destination.writeInt(mState);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700335 destination.writeParcelable(mDisconnectCause, 0);
Ihab Awadc0677542014-06-10 13:29:47 -0700336 destination.writeList(mCannedSmsResponses);
Sailesh Nepal60437932014-04-05 16:44:55 -0700337 destination.writeInt(mCapabilities);
Andrew Lee223ad142014-08-27 16:33:08 -0700338 destination.writeInt(mProperties);
Sailesh Nepal60437932014-04-05 16:44:55 -0700339 destination.writeLong(mConnectTimeMillis);
340 destination.writeParcelable(mHandle, 0);
Sailesh Nepal61203862014-07-11 14:50:13 -0700341 destination.writeInt(mHandlePresentation);
342 destination.writeString(mCallerDisplayName);
343 destination.writeInt(mCallerDisplayNamePresentation);
Sailesh Nepal60437932014-04-05 16:44:55 -0700344 destination.writeParcelable(mGatewayInfo, 0);
Evan Charlton8c8a0622014-07-20 12:31:00 -0700345 destination.writeParcelable(mAccountHandle, 0);
Tyler Gunn75958422015-04-15 14:23:42 -0700346 destination.writeByte((byte) (mIsVideoCallProviderChanged ? 1 : 0));
Tyler Gunn807de8a2014-06-30 14:22:57 -0700347 destination.writeStrongBinder(
Andrew Lee50aca232014-07-22 16:41:54 -0700348 mVideoCallProvider != null ? mVideoCallProvider.asBinder() : null);
Santos Cordon980acb92014-05-31 10:31:19 -0700349 destination.writeString(mParentCallId);
350 destination.writeList(mChildCallIds);
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700351 destination.writeParcelable(mStatusHints, 0);
Andrew Lee85f5d422014-07-11 17:22:03 -0700352 destination.writeInt(mVideoState);
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700353 destination.writeList(mConferenceableCallIds);
Nancy Chen10798dc2014-08-08 14:00:25 -0700354 destination.writeParcelable(mExtras, 0);
Rekha Kumar07366812015-03-24 16:42:31 -0700355 destination.writeInt(mCallSubstate);
Sailesh Nepal60437932014-04-05 16:44:55 -0700356 }
Santos Cordonb6939982014-06-04 20:20:58 -0700357
358 @Override
359 public String toString() {
360 return String.format("[%s, parent:%s, children:%s]", mId, mParentCallId, mChildCallIds);
361 }
Sailesh Nepal60437932014-04-05 16:44:55 -0700362}