blob: a3fce9ca67097a548493018f1f0145ad958c71b3 [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;
Christine Hallstrom2830ce92016-11-30 16:06:42 -080042 private final int mSupportedAudioRoutes;
Sailesh Nepal60437932014-04-05 16:44:55 -070043 private final long mConnectTimeMillis;
44 private final Uri mHandle;
Sailesh Nepal61203862014-07-11 14:50:13 -070045 private final int mHandlePresentation;
46 private final String mCallerDisplayName;
47 private final int mCallerDisplayNamePresentation;
Sailesh Nepal60437932014-04-05 16:44:55 -070048 private final GatewayInfo mGatewayInfo;
Evan Charlton8c8a0622014-07-20 12:31:00 -070049 private final PhoneAccountHandle mAccountHandle;
Tyler Gunn75958422015-04-15 14:23:42 -070050 private final boolean mIsVideoCallProviderChanged;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070051 private final IVideoProvider mVideoCallProvider;
Tyler Gunn584ba6c2015-12-08 10:53:41 -080052 private VideoCallImpl mVideoCall;
Santos Cordon980acb92014-05-31 10:31:19 -070053 private final String mParentCallId;
54 private final List<String> mChildCallIds;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070055 private final StatusHints mStatusHints;
Andrew Lee85f5d422014-07-11 17:22:03 -070056 private final int mVideoState;
Santos Cordon7c7bc7f2014-07-28 18:15:48 -070057 private final List<String> mConferenceableCallIds;
Santos Cordon6b7f9552015-05-27 17:21:45 -070058 private final Bundle mIntentExtras;
Nancy Chen10798dc2014-08-08 14:00:25 -070059 private final Bundle mExtras;
Santos Cordon980acb92014-05-31 10:31:19 -070060
Santos Cordon88b771d2014-07-19 13:10:40 -070061 public ParcelableCall(
Sailesh Nepal60437932014-04-05 16:44:55 -070062 String id,
Ihab Awadb19a0bc2014-08-07 19:46:01 -070063 int state,
Andrew Lee7f3d41f2014-09-11 17:33:16 -070064 DisconnectCause disconnectCause,
Ihab Awadc0677542014-06-10 13:29:47 -070065 List<String> cannedSmsResponses,
Sailesh Nepal60437932014-04-05 16:44:55 -070066 int capabilities,
Andrew Lee223ad142014-08-27 16:33:08 -070067 int properties,
Christine Hallstrom2830ce92016-11-30 16:06:42 -080068 int supportedAudioRoutes,
Sailesh Nepal60437932014-04-05 16:44:55 -070069 long connectTimeMillis,
70 Uri handle,
Sailesh Nepal61203862014-07-11 14:50:13 -070071 int handlePresentation,
72 String callerDisplayName,
73 int callerDisplayNamePresentation,
Sailesh Nepal60437932014-04-05 16:44:55 -070074 GatewayInfo gatewayInfo,
Evan Charlton8c8a0622014-07-20 12:31:00 -070075 PhoneAccountHandle accountHandle,
Tyler Gunn75958422015-04-15 14:23:42 -070076 boolean isVideoCallProviderChanged,
Ihab Awadb19a0bc2014-08-07 19:46:01 -070077 IVideoProvider videoCallProvider,
Santos Cordon980acb92014-05-31 10:31:19 -070078 String parentCallId,
Tyler Gunn8d83fa92014-07-01 11:31:21 -070079 List<String> childCallIds,
Andrew Lee85f5d422014-07-11 17:22:03 -070080 StatusHints statusHints,
Santos Cordon7c7bc7f2014-07-28 18:15:48 -070081 int videoState,
Nancy Chen10798dc2014-08-08 14:00:25 -070082 List<String> conferenceableCallIds,
Santos Cordon6b7f9552015-05-27 17:21:45 -070083 Bundle intentExtras,
Jay Shrauner8f988432015-04-16 12:52:19 -070084 Bundle extras) {
Sailesh Nepal60437932014-04-05 16:44:55 -070085 mId = id;
86 mState = state;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070087 mDisconnectCause = disconnectCause;
Ihab Awadc0677542014-06-10 13:29:47 -070088 mCannedSmsResponses = cannedSmsResponses;
Sailesh Nepal60437932014-04-05 16:44:55 -070089 mCapabilities = capabilities;
Andrew Lee223ad142014-08-27 16:33:08 -070090 mProperties = properties;
Christine Hallstrom2830ce92016-11-30 16:06:42 -080091 mSupportedAudioRoutes = supportedAudioRoutes;
Sailesh Nepal60437932014-04-05 16:44:55 -070092 mConnectTimeMillis = connectTimeMillis;
93 mHandle = handle;
Sailesh Nepal61203862014-07-11 14:50:13 -070094 mHandlePresentation = handlePresentation;
95 mCallerDisplayName = callerDisplayName;
96 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
Sailesh Nepal60437932014-04-05 16:44:55 -070097 mGatewayInfo = gatewayInfo;
Evan Charlton8c8a0622014-07-20 12:31:00 -070098 mAccountHandle = accountHandle;
Tyler Gunn75958422015-04-15 14:23:42 -070099 mIsVideoCallProviderChanged = isVideoCallProviderChanged;
Andrew Lee50aca232014-07-22 16:41:54 -0700100 mVideoCallProvider = videoCallProvider;
Santos Cordon980acb92014-05-31 10:31:19 -0700101 mParentCallId = parentCallId;
102 mChildCallIds = childCallIds;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700103 mStatusHints = statusHints;
Andrew Lee85f5d422014-07-11 17:22:03 -0700104 mVideoState = videoState;
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700105 mConferenceableCallIds = Collections.unmodifiableList(conferenceableCallIds);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700106 mIntentExtras = intentExtras;
Nancy Chen10798dc2014-08-08 14:00:25 -0700107 mExtras = extras;
Sailesh Nepal60437932014-04-05 16:44:55 -0700108 }
109
110 /** The unique ID of the call. */
111 public String getId() {
112 return mId;
113 }
114
115 /** The current state of the call. */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700116 public int getState() {
Sailesh Nepal60437932014-04-05 16:44:55 -0700117 return mState;
118 }
119
120 /**
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700121 * Reason for disconnection, as described by {@link android.telecomm.DisconnectCause}. Valid
122 * when call state is {@link CallState#DISCONNECTED}.
Sailesh Nepal60437932014-04-05 16:44:55 -0700123 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700124 public DisconnectCause getDisconnectCause() {
125 return mDisconnectCause;
Sailesh Nepal60437932014-04-05 16:44:55 -0700126 }
127
Ihab Awadc0677542014-06-10 13:29:47 -0700128 /**
129 * The set of possible text message responses when this call is incoming.
130 */
131 public List<String> getCannedSmsResponses() {
132 return mCannedSmsResponses;
133 }
134
Sailesh Nepal60437932014-04-05 16:44:55 -0700135 // Bit mask of actions a call supports, values are defined in {@link CallCapabilities}.
136 public int getCapabilities() {
137 return mCapabilities;
138 }
139
Andrew Lee223ad142014-08-27 16:33:08 -0700140 /** Bitmask of properties of the call. */
141 public int getProperties() { return mProperties; }
142
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800143 /** Bitmask of supported routes of the call */
144 public int getSupportedAudioRoutes() {
145 return mSupportedAudioRoutes;
146 }
147
Sailesh Nepal60437932014-04-05 16:44:55 -0700148 /** The time that the call switched to the active state. */
149 public long getConnectTimeMillis() {
150 return mConnectTimeMillis;
151 }
152
153 /** The endpoint to which the call is connected. */
154 public Uri getHandle() {
155 return mHandle;
156 }
157
Nancy Chen9d568c02014-09-08 14:17:59 -0700158 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700159 * The presentation requirements for the handle. See {@link TelecomManager} for valid values.
Nancy Chen9d568c02014-09-08 14:17:59 -0700160 */
Sailesh Nepal61203862014-07-11 14:50:13 -0700161 public int getHandlePresentation() {
162 return mHandlePresentation;
163 }
164
165 /** The endpoint to which the call is connected. */
166 public String getCallerDisplayName() {
167 return mCallerDisplayName;
168 }
169
Nancy Chen9d568c02014-09-08 14:17:59 -0700170 /**
171 * The presentation requirements for the caller display name.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700172 * See {@link TelecomManager} for valid values.
Nancy Chen9d568c02014-09-08 14:17:59 -0700173 */
Sailesh Nepal61203862014-07-11 14:50:13 -0700174 public int getCallerDisplayNamePresentation() {
175 return mCallerDisplayNamePresentation;
176 }
177
Sailesh Nepal60437932014-04-05 16:44:55 -0700178 /** Gateway information for the call. */
179 public GatewayInfo getGatewayInfo() {
180 return mGatewayInfo;
181 }
182
Evan Charlton6eb262c2014-07-19 18:18:19 -0700183 /** PhoneAccountHandle information for the call. */
Evan Charlton8c8a0622014-07-20 12:31:00 -0700184 public PhoneAccountHandle getAccountHandle() {
185 return mAccountHandle;
Nancy Chen5ffbfcc2014-06-25 14:22:55 -0700186 }
187
Sailesh Nepal60437932014-04-05 16:44:55 -0700188 /**
Andrew Lee50aca232014-07-22 16:41:54 -0700189 * Returns an object for remotely communicating through the video call provider's binder.
Tyler Gunn584ba6c2015-12-08 10:53:41 -0800190
Andrew Lee50aca232014-07-22 16:41:54 -0700191 * @return The video call.
Andrew Lee5dc30752014-06-27 17:02:19 -0700192 */
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -0800193 public VideoCallImpl getVideoCallImpl(String callingPackageName) {
Andrew Lee50aca232014-07-22 16:41:54 -0700194 if (mVideoCall == null && mVideoCallProvider != null) {
Andrew Lee5dc30752014-06-27 17:02:19 -0700195 try {
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -0800196 mVideoCall = new VideoCallImpl(mVideoCallProvider, callingPackageName);
Andrew Lee5dc30752014-06-27 17:02:19 -0700197 } catch (RemoteException ignored) {
198 // Ignore RemoteException.
199 }
200 }
201
Andrew Lee50aca232014-07-22 16:41:54 -0700202 return mVideoCall;
Andrew Lee5dc30752014-06-27 17:02:19 -0700203 }
204
205 /**
Santos Cordon980acb92014-05-31 10:31:19 -0700206 * The conference call to which this call is conferenced. Null if not conferenced.
Santos Cordon980acb92014-05-31 10:31:19 -0700207 */
208 public String getParentCallId() {
209 return mParentCallId;
210 }
211
212 /**
213 * The child call-IDs if this call is a conference call. Returns an empty list if this is not
214 * a conference call or if the conference call contains no children.
Santos Cordon980acb92014-05-31 10:31:19 -0700215 */
216 public List<String> getChildCallIds() {
217 return mChildCallIds;
218 }
219
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700220 public List<String> getConferenceableCallIds() {
221 return mConferenceableCallIds;
222 }
223
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700224 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700225 * The status label and icon.
226 *
227 * @return Status hints.
228 */
229 public StatusHints getStatusHints() {
230 return mStatusHints;
231 }
232
Andrew Lee85f5d422014-07-11 17:22:03 -0700233 /**
234 * The video state.
235 * @return The video state of the call.
236 */
237 public int getVideoState() {
238 return mVideoState;
239 }
240
Nancy Chen10798dc2014-08-08 14:00:25 -0700241 /**
Santos Cordon6b7f9552015-05-27 17:21:45 -0700242 * Any extras associated with this call.
Nancy Chen10798dc2014-08-08 14:00:25 -0700243 *
244 * @return a bundle of extras
245 */
246 public Bundle getExtras() {
247 return mExtras;
248 }
249
Rekha Kumar07366812015-03-24 16:42:31 -0700250 /**
Santos Cordon6b7f9552015-05-27 17:21:45 -0700251 * Extras passed in as part of the original call intent.
252 *
253 * @return The intent extras.
254 */
255 public Bundle getIntentExtras() {
256 return mIntentExtras;
257 }
258
259 /**
Tyler Gunn75958422015-04-15 14:23:42 -0700260 * Indicates to the receiver of the {@link ParcelableCall} whether a change has occurred in the
261 * {@link android.telecom.InCallService.VideoCall} associated with this call. Since
262 * {@link #getVideoCall()} creates a new {@link VideoCallImpl}, it is useful to know whether
263 * the provider has changed (which can influence whether it is accessed).
264 *
265 * @return {@code true} if the video call changed, {@code false} otherwise.
266 */
267 public boolean isVideoCallProviderChanged() {
268 return mIsVideoCallProviderChanged;
269 }
270
Santos Cordon88b771d2014-07-19 13:10:40 -0700271 /** Responsible for creating ParcelableCall objects for deserialized Parcels. */
272 public static final Parcelable.Creator<ParcelableCall> CREATOR =
273 new Parcelable.Creator<ParcelableCall> () {
Sailesh Nepal60437932014-04-05 16:44:55 -0700274 @Override
Santos Cordon88b771d2014-07-19 13:10:40 -0700275 public ParcelableCall createFromParcel(Parcel source) {
276 ClassLoader classLoader = ParcelableCall.class.getClassLoader();
Sailesh Nepal60437932014-04-05 16:44:55 -0700277 String id = source.readString();
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700278 int state = source.readInt();
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700279 DisconnectCause disconnectCause = source.readParcelable(classLoader);
Ihab Awadc0677542014-06-10 13:29:47 -0700280 List<String> cannedSmsResponses = new ArrayList<>();
281 source.readList(cannedSmsResponses, classLoader);
Sailesh Nepal60437932014-04-05 16:44:55 -0700282 int capabilities = source.readInt();
Andrew Lee223ad142014-08-27 16:33:08 -0700283 int properties = source.readInt();
Sailesh Nepal60437932014-04-05 16:44:55 -0700284 long connectTimeMillis = source.readLong();
Sailesh Nepal60437932014-04-05 16:44:55 -0700285 Uri handle = source.readParcelable(classLoader);
Sailesh Nepal61203862014-07-11 14:50:13 -0700286 int handlePresentation = source.readInt();
287 String callerDisplayName = source.readString();
288 int callerDisplayNamePresentation = source.readInt();
Sailesh Nepal60437932014-04-05 16:44:55 -0700289 GatewayInfo gatewayInfo = source.readParcelable(classLoader);
Evan Charlton8c8a0622014-07-20 12:31:00 -0700290 PhoneAccountHandle accountHandle = source.readParcelable(classLoader);
Tyler Gunn75958422015-04-15 14:23:42 -0700291 boolean isVideoCallProviderChanged = source.readByte() == 1;
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700292 IVideoProvider videoCallProvider =
293 IVideoProvider.Stub.asInterface(source.readStrongBinder());
Santos Cordon980acb92014-05-31 10:31:19 -0700294 String parentCallId = source.readString();
295 List<String> childCallIds = new ArrayList<>();
296 source.readList(childCallIds, classLoader);
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700297 StatusHints statusHints = source.readParcelable(classLoader);
Andrew Lee85f5d422014-07-11 17:22:03 -0700298 int videoState = source.readInt();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700299 List<String> conferenceableCallIds = new ArrayList<>();
300 source.readList(conferenceableCallIds, classLoader);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700301 Bundle intentExtras = source.readBundle(classLoader);
302 Bundle extras = source.readBundle(classLoader);
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800303 int supportedAudioRoutes = source.readInt();
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700304 return new ParcelableCall(
305 id,
306 state,
307 disconnectCause,
308 cannedSmsResponses,
309 capabilities,
310 properties,
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800311 supportedAudioRoutes,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700312 connectTimeMillis,
313 handle,
314 handlePresentation,
315 callerDisplayName,
316 callerDisplayNamePresentation,
317 gatewayInfo,
318 accountHandle,
Tyler Gunn75958422015-04-15 14:23:42 -0700319 isVideoCallProviderChanged,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700320 videoCallProvider,
321 parentCallId,
322 childCallIds,
323 statusHints,
324 videoState,
325 conferenceableCallIds,
Santos Cordon6b7f9552015-05-27 17:21:45 -0700326 intentExtras,
Jay Shrauner8f988432015-04-16 12:52:19 -0700327 extras);
Sailesh Nepal60437932014-04-05 16:44:55 -0700328 }
329
330 @Override
Santos Cordon88b771d2014-07-19 13:10:40 -0700331 public ParcelableCall[] newArray(int size) {
332 return new ParcelableCall[size];
Sailesh Nepal60437932014-04-05 16:44:55 -0700333 }
334 };
335
336 /** {@inheritDoc} */
337 @Override
338 public int describeContents() {
339 return 0;
340 }
341
Santos Cordon88b771d2014-07-19 13:10:40 -0700342 /** Writes ParcelableCall object into a Parcel. */
Sailesh Nepal60437932014-04-05 16:44:55 -0700343 @Override
344 public void writeToParcel(Parcel destination, int flags) {
345 destination.writeString(mId);
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700346 destination.writeInt(mState);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700347 destination.writeParcelable(mDisconnectCause, 0);
Ihab Awadc0677542014-06-10 13:29:47 -0700348 destination.writeList(mCannedSmsResponses);
Sailesh Nepal60437932014-04-05 16:44:55 -0700349 destination.writeInt(mCapabilities);
Andrew Lee223ad142014-08-27 16:33:08 -0700350 destination.writeInt(mProperties);
Sailesh Nepal60437932014-04-05 16:44:55 -0700351 destination.writeLong(mConnectTimeMillis);
352 destination.writeParcelable(mHandle, 0);
Sailesh Nepal61203862014-07-11 14:50:13 -0700353 destination.writeInt(mHandlePresentation);
354 destination.writeString(mCallerDisplayName);
355 destination.writeInt(mCallerDisplayNamePresentation);
Sailesh Nepal60437932014-04-05 16:44:55 -0700356 destination.writeParcelable(mGatewayInfo, 0);
Evan Charlton8c8a0622014-07-20 12:31:00 -0700357 destination.writeParcelable(mAccountHandle, 0);
Tyler Gunn75958422015-04-15 14:23:42 -0700358 destination.writeByte((byte) (mIsVideoCallProviderChanged ? 1 : 0));
Tyler Gunn807de8a2014-06-30 14:22:57 -0700359 destination.writeStrongBinder(
Andrew Lee50aca232014-07-22 16:41:54 -0700360 mVideoCallProvider != null ? mVideoCallProvider.asBinder() : null);
Santos Cordon980acb92014-05-31 10:31:19 -0700361 destination.writeString(mParentCallId);
362 destination.writeList(mChildCallIds);
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700363 destination.writeParcelable(mStatusHints, 0);
Andrew Lee85f5d422014-07-11 17:22:03 -0700364 destination.writeInt(mVideoState);
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700365 destination.writeList(mConferenceableCallIds);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700366 destination.writeBundle(mIntentExtras);
367 destination.writeBundle(mExtras);
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800368 destination.writeInt(mSupportedAudioRoutes);
Sailesh Nepal60437932014-04-05 16:44:55 -0700369 }
Santos Cordonb6939982014-06-04 20:20:58 -0700370
371 @Override
372 public String toString() {
373 return String.format("[%s, parent:%s, children:%s]", mId, mParentCallId, mChildCallIds);
374 }
Sailesh Nepal60437932014-04-05 16:44:55 -0700375}