blob: adc648f2aa6cfde5c14129aed17fc8067e8d26e5 [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;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070049 private final IVideoProvider mVideoCallProvider;
Andrew Lee50aca232014-07-22 16:41:54 -070050 private InCallService.VideoCall mVideoCall;
Santos Cordon980acb92014-05-31 10:31:19 -070051 private final String mParentCallId;
52 private final List<String> mChildCallIds;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070053 private final StatusHints mStatusHints;
Andrew Lee85f5d422014-07-11 17:22:03 -070054 private final int mVideoState;
Santos Cordon7c7bc7f2014-07-28 18:15:48 -070055 private final List<String> mConferenceableCallIds;
Nancy Chen10798dc2014-08-08 14:00:25 -070056 private final Bundle mExtras;
Rekha Kumar07366812015-03-24 16:42:31 -070057 private int mCallSubstate;
Santos Cordon980acb92014-05-31 10:31:19 -070058
Santos Cordon88b771d2014-07-19 13:10:40 -070059 public ParcelableCall(
Sailesh Nepal60437932014-04-05 16:44:55 -070060 String id,
Ihab Awadb19a0bc2014-08-07 19:46:01 -070061 int state,
Andrew Lee7f3d41f2014-09-11 17:33:16 -070062 DisconnectCause disconnectCause,
Ihab Awadc0677542014-06-10 13:29:47 -070063 List<String> cannedSmsResponses,
Sailesh Nepal60437932014-04-05 16:44:55 -070064 int capabilities,
Andrew Lee223ad142014-08-27 16:33:08 -070065 int properties,
Sailesh Nepal60437932014-04-05 16:44:55 -070066 long connectTimeMillis,
67 Uri handle,
Sailesh Nepal61203862014-07-11 14:50:13 -070068 int handlePresentation,
69 String callerDisplayName,
70 int callerDisplayNamePresentation,
Sailesh Nepal60437932014-04-05 16:44:55 -070071 GatewayInfo gatewayInfo,
Evan Charlton8c8a0622014-07-20 12:31:00 -070072 PhoneAccountHandle accountHandle,
Ihab Awadb19a0bc2014-08-07 19:46:01 -070073 IVideoProvider videoCallProvider,
Santos Cordon980acb92014-05-31 10:31:19 -070074 String parentCallId,
Tyler Gunn8d83fa92014-07-01 11:31:21 -070075 List<String> childCallIds,
Andrew Lee85f5d422014-07-11 17:22:03 -070076 StatusHints statusHints,
Santos Cordon7c7bc7f2014-07-28 18:15:48 -070077 int videoState,
Nancy Chen10798dc2014-08-08 14:00:25 -070078 List<String> conferenceableCallIds,
Rekha Kumar07366812015-03-24 16:42:31 -070079 Bundle extras,
80 int callSubstate) {
Sailesh Nepal60437932014-04-05 16:44:55 -070081 mId = id;
82 mState = state;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070083 mDisconnectCause = disconnectCause;
Ihab Awadc0677542014-06-10 13:29:47 -070084 mCannedSmsResponses = cannedSmsResponses;
Sailesh Nepal60437932014-04-05 16:44:55 -070085 mCapabilities = capabilities;
Andrew Lee223ad142014-08-27 16:33:08 -070086 mProperties = properties;
Sailesh Nepal60437932014-04-05 16:44:55 -070087 mConnectTimeMillis = connectTimeMillis;
88 mHandle = handle;
Sailesh Nepal61203862014-07-11 14:50:13 -070089 mHandlePresentation = handlePresentation;
90 mCallerDisplayName = callerDisplayName;
91 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
Sailesh Nepal60437932014-04-05 16:44:55 -070092 mGatewayInfo = gatewayInfo;
Evan Charlton8c8a0622014-07-20 12:31:00 -070093 mAccountHandle = accountHandle;
Andrew Lee50aca232014-07-22 16:41:54 -070094 mVideoCallProvider = videoCallProvider;
Santos Cordon980acb92014-05-31 10:31:19 -070095 mParentCallId = parentCallId;
96 mChildCallIds = childCallIds;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070097 mStatusHints = statusHints;
Andrew Lee85f5d422014-07-11 17:22:03 -070098 mVideoState = videoState;
Santos Cordon7c7bc7f2014-07-28 18:15:48 -070099 mConferenceableCallIds = Collections.unmodifiableList(conferenceableCallIds);
Nancy Chen10798dc2014-08-08 14:00:25 -0700100 mExtras = extras;
Rekha Kumar07366812015-03-24 16:42:31 -0700101 mCallSubstate = callSubstate;
Sailesh Nepal60437932014-04-05 16:44:55 -0700102 }
103
104 /** The unique ID of the call. */
105 public String getId() {
106 return mId;
107 }
108
109 /** The current state of the call. */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700110 public int getState() {
Sailesh Nepal60437932014-04-05 16:44:55 -0700111 return mState;
112 }
113
114 /**
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700115 * Reason for disconnection, as described by {@link android.telecomm.DisconnectCause}. Valid
116 * when call state is {@link CallState#DISCONNECTED}.
Sailesh Nepal60437932014-04-05 16:44:55 -0700117 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700118 public DisconnectCause getDisconnectCause() {
119 return mDisconnectCause;
Sailesh Nepal60437932014-04-05 16:44:55 -0700120 }
121
Ihab Awadc0677542014-06-10 13:29:47 -0700122 /**
123 * The set of possible text message responses when this call is incoming.
124 */
125 public List<String> getCannedSmsResponses() {
126 return mCannedSmsResponses;
127 }
128
Sailesh Nepal60437932014-04-05 16:44:55 -0700129 // Bit mask of actions a call supports, values are defined in {@link CallCapabilities}.
130 public int getCapabilities() {
131 return mCapabilities;
132 }
133
Andrew Lee223ad142014-08-27 16:33:08 -0700134 /** Bitmask of properties of the call. */
135 public int getProperties() { return mProperties; }
136
Sailesh Nepal60437932014-04-05 16:44:55 -0700137 /** The time that the call switched to the active state. */
138 public long getConnectTimeMillis() {
139 return mConnectTimeMillis;
140 }
141
142 /** The endpoint to which the call is connected. */
143 public Uri getHandle() {
144 return mHandle;
145 }
146
Nancy Chen9d568c02014-09-08 14:17:59 -0700147 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700148 * The presentation requirements for the handle. See {@link TelecomManager} for valid values.
Nancy Chen9d568c02014-09-08 14:17:59 -0700149 */
Sailesh Nepal61203862014-07-11 14:50:13 -0700150 public int getHandlePresentation() {
151 return mHandlePresentation;
152 }
153
154 /** The endpoint to which the call is connected. */
155 public String getCallerDisplayName() {
156 return mCallerDisplayName;
157 }
158
Nancy Chen9d568c02014-09-08 14:17:59 -0700159 /**
160 * The presentation requirements for the caller display name.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700161 * See {@link TelecomManager} for valid values.
Nancy Chen9d568c02014-09-08 14:17:59 -0700162 */
Sailesh Nepal61203862014-07-11 14:50:13 -0700163 public int getCallerDisplayNamePresentation() {
164 return mCallerDisplayNamePresentation;
165 }
166
Sailesh Nepal60437932014-04-05 16:44:55 -0700167 /** Gateway information for the call. */
168 public GatewayInfo getGatewayInfo() {
169 return mGatewayInfo;
170 }
171
Evan Charlton6eb262c2014-07-19 18:18:19 -0700172 /** PhoneAccountHandle information for the call. */
Evan Charlton8c8a0622014-07-20 12:31:00 -0700173 public PhoneAccountHandle getAccountHandle() {
174 return mAccountHandle;
Nancy Chen5ffbfcc2014-06-25 14:22:55 -0700175 }
176
Sailesh Nepal60437932014-04-05 16:44:55 -0700177 /**
Andrew Lee50aca232014-07-22 16:41:54 -0700178 * Returns an object for remotely communicating through the video call provider's binder.
179 * @return The video call.
Andrew Lee5dc30752014-06-27 17:02:19 -0700180 */
Andrew Lee50aca232014-07-22 16:41:54 -0700181 public InCallService.VideoCall getVideoCall() {
182 if (mVideoCall == null && mVideoCallProvider != null) {
Andrew Lee5dc30752014-06-27 17:02:19 -0700183 try {
Andrew Lee50aca232014-07-22 16:41:54 -0700184 mVideoCall = new VideoCallImpl(mVideoCallProvider);
Andrew Lee5dc30752014-06-27 17:02:19 -0700185 } catch (RemoteException ignored) {
186 // Ignore RemoteException.
187 }
188 }
189
Andrew Lee50aca232014-07-22 16:41:54 -0700190 return mVideoCall;
Andrew Lee5dc30752014-06-27 17:02:19 -0700191 }
192
193 /**
Santos Cordon980acb92014-05-31 10:31:19 -0700194 * The conference call to which this call is conferenced. Null if not conferenced.
Santos Cordon980acb92014-05-31 10:31:19 -0700195 */
196 public String getParentCallId() {
197 return mParentCallId;
198 }
199
200 /**
201 * The child call-IDs if this call is a conference call. Returns an empty list if this is not
202 * a conference call or if the conference call contains no children.
Santos Cordon980acb92014-05-31 10:31:19 -0700203 */
204 public List<String> getChildCallIds() {
205 return mChildCallIds;
206 }
207
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700208 public List<String> getConferenceableCallIds() {
209 return mConferenceableCallIds;
210 }
211
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700212 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700213 * The status label and icon.
214 *
215 * @return Status hints.
216 */
217 public StatusHints getStatusHints() {
218 return mStatusHints;
219 }
220
Andrew Lee85f5d422014-07-11 17:22:03 -0700221 /**
222 * The video state.
223 * @return The video state of the call.
224 */
225 public int getVideoState() {
226 return mVideoState;
227 }
228
Nancy Chen10798dc2014-08-08 14:00:25 -0700229 /**
230 * Any extras to pass with the call
231 *
232 * @return a bundle of extras
233 */
234 public Bundle getExtras() {
235 return mExtras;
236 }
237
Rekha Kumar07366812015-03-24 16:42:31 -0700238 /**
239 * The call substate.
240 * @return The substate of the call.
241 */
242 public int getCallSubstate() {
243 return mCallSubstate;
244 }
245
Santos Cordon88b771d2014-07-19 13:10:40 -0700246 /** Responsible for creating ParcelableCall objects for deserialized Parcels. */
247 public static final Parcelable.Creator<ParcelableCall> CREATOR =
248 new Parcelable.Creator<ParcelableCall> () {
Sailesh Nepal60437932014-04-05 16:44:55 -0700249 @Override
Santos Cordon88b771d2014-07-19 13:10:40 -0700250 public ParcelableCall createFromParcel(Parcel source) {
251 ClassLoader classLoader = ParcelableCall.class.getClassLoader();
Sailesh Nepal60437932014-04-05 16:44:55 -0700252 String id = source.readString();
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700253 int state = source.readInt();
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700254 DisconnectCause disconnectCause = source.readParcelable(classLoader);
Ihab Awadc0677542014-06-10 13:29:47 -0700255 List<String> cannedSmsResponses = new ArrayList<>();
256 source.readList(cannedSmsResponses, classLoader);
Sailesh Nepal60437932014-04-05 16:44:55 -0700257 int capabilities = source.readInt();
Andrew Lee223ad142014-08-27 16:33:08 -0700258 int properties = source.readInt();
Sailesh Nepal60437932014-04-05 16:44:55 -0700259 long connectTimeMillis = source.readLong();
Sailesh Nepal60437932014-04-05 16:44:55 -0700260 Uri handle = source.readParcelable(classLoader);
Sailesh Nepal61203862014-07-11 14:50:13 -0700261 int handlePresentation = source.readInt();
262 String callerDisplayName = source.readString();
263 int callerDisplayNamePresentation = source.readInt();
Sailesh Nepal60437932014-04-05 16:44:55 -0700264 GatewayInfo gatewayInfo = source.readParcelable(classLoader);
Evan Charlton8c8a0622014-07-20 12:31:00 -0700265 PhoneAccountHandle accountHandle = source.readParcelable(classLoader);
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700266 IVideoProvider videoCallProvider =
267 IVideoProvider.Stub.asInterface(source.readStrongBinder());
Santos Cordon980acb92014-05-31 10:31:19 -0700268 String parentCallId = source.readString();
269 List<String> childCallIds = new ArrayList<>();
270 source.readList(childCallIds, classLoader);
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700271 StatusHints statusHints = source.readParcelable(classLoader);
Andrew Lee85f5d422014-07-11 17:22:03 -0700272 int videoState = source.readInt();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700273 List<String> conferenceableCallIds = new ArrayList<>();
274 source.readList(conferenceableCallIds, classLoader);
Nancy Chen10798dc2014-08-08 14:00:25 -0700275 Bundle extras = source.readParcelable(classLoader);
Rekha Kumar07366812015-03-24 16:42:31 -0700276 int callSubstate = source.readInt();
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700277 return new ParcelableCall(
278 id,
279 state,
280 disconnectCause,
281 cannedSmsResponses,
282 capabilities,
283 properties,
284 connectTimeMillis,
285 handle,
286 handlePresentation,
287 callerDisplayName,
288 callerDisplayNamePresentation,
289 gatewayInfo,
290 accountHandle,
291 videoCallProvider,
292 parentCallId,
293 childCallIds,
294 statusHints,
295 videoState,
296 conferenceableCallIds,
Rekha Kumar07366812015-03-24 16:42:31 -0700297 extras,
298 callSubstate);
Sailesh Nepal60437932014-04-05 16:44:55 -0700299 }
300
301 @Override
Santos Cordon88b771d2014-07-19 13:10:40 -0700302 public ParcelableCall[] newArray(int size) {
303 return new ParcelableCall[size];
Sailesh Nepal60437932014-04-05 16:44:55 -0700304 }
305 };
306
307 /** {@inheritDoc} */
308 @Override
309 public int describeContents() {
310 return 0;
311 }
312
Santos Cordon88b771d2014-07-19 13:10:40 -0700313 /** Writes ParcelableCall object into a Parcel. */
Sailesh Nepal60437932014-04-05 16:44:55 -0700314 @Override
315 public void writeToParcel(Parcel destination, int flags) {
316 destination.writeString(mId);
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700317 destination.writeInt(mState);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700318 destination.writeParcelable(mDisconnectCause, 0);
Ihab Awadc0677542014-06-10 13:29:47 -0700319 destination.writeList(mCannedSmsResponses);
Sailesh Nepal60437932014-04-05 16:44:55 -0700320 destination.writeInt(mCapabilities);
Andrew Lee223ad142014-08-27 16:33:08 -0700321 destination.writeInt(mProperties);
Sailesh Nepal60437932014-04-05 16:44:55 -0700322 destination.writeLong(mConnectTimeMillis);
323 destination.writeParcelable(mHandle, 0);
Sailesh Nepal61203862014-07-11 14:50:13 -0700324 destination.writeInt(mHandlePresentation);
325 destination.writeString(mCallerDisplayName);
326 destination.writeInt(mCallerDisplayNamePresentation);
Sailesh Nepal60437932014-04-05 16:44:55 -0700327 destination.writeParcelable(mGatewayInfo, 0);
Evan Charlton8c8a0622014-07-20 12:31:00 -0700328 destination.writeParcelable(mAccountHandle, 0);
Tyler Gunn807de8a2014-06-30 14:22:57 -0700329 destination.writeStrongBinder(
Andrew Lee50aca232014-07-22 16:41:54 -0700330 mVideoCallProvider != null ? mVideoCallProvider.asBinder() : null);
Santos Cordon980acb92014-05-31 10:31:19 -0700331 destination.writeString(mParentCallId);
332 destination.writeList(mChildCallIds);
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700333 destination.writeParcelable(mStatusHints, 0);
Andrew Lee85f5d422014-07-11 17:22:03 -0700334 destination.writeInt(mVideoState);
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700335 destination.writeList(mConferenceableCallIds);
Nancy Chen10798dc2014-08-08 14:00:25 -0700336 destination.writeParcelable(mExtras, 0);
Rekha Kumar07366812015-03-24 16:42:31 -0700337 destination.writeInt(mCallSubstate);
Sailesh Nepal60437932014-04-05 16:44:55 -0700338 }
Santos Cordonb6939982014-06-04 20:20:58 -0700339
340 @Override
341 public String toString() {
342 return String.format("[%s, parent:%s, children:%s]", mId, mParentCallId, mChildCallIds);
343 }
Sailesh Nepal60437932014-04-05 16:44:55 -0700344}