blob: c5c3d11a169024c84aa7dd2b6022c8a08c20aa9e [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;
Santos Cordon980acb92014-05-31 10:31:19 -070057
Santos Cordon88b771d2014-07-19 13:10:40 -070058 public ParcelableCall(
Sailesh Nepal60437932014-04-05 16:44:55 -070059 String id,
Ihab Awadb19a0bc2014-08-07 19:46:01 -070060 int state,
Andrew Lee7f3d41f2014-09-11 17:33:16 -070061 DisconnectCause disconnectCause,
Ihab Awadc0677542014-06-10 13:29:47 -070062 List<String> cannedSmsResponses,
Sailesh Nepal60437932014-04-05 16:44:55 -070063 int capabilities,
Andrew Lee223ad142014-08-27 16:33:08 -070064 int properties,
Sailesh Nepal60437932014-04-05 16:44:55 -070065 long connectTimeMillis,
66 Uri handle,
Sailesh Nepal61203862014-07-11 14:50:13 -070067 int handlePresentation,
68 String callerDisplayName,
69 int callerDisplayNamePresentation,
Sailesh Nepal60437932014-04-05 16:44:55 -070070 GatewayInfo gatewayInfo,
Evan Charlton8c8a0622014-07-20 12:31:00 -070071 PhoneAccountHandle accountHandle,
Ihab Awadb19a0bc2014-08-07 19:46:01 -070072 IVideoProvider videoCallProvider,
Santos Cordon980acb92014-05-31 10:31:19 -070073 String parentCallId,
Tyler Gunn8d83fa92014-07-01 11:31:21 -070074 List<String> childCallIds,
Andrew Lee85f5d422014-07-11 17:22:03 -070075 StatusHints statusHints,
Santos Cordon7c7bc7f2014-07-28 18:15:48 -070076 int videoState,
Nancy Chen10798dc2014-08-08 14:00:25 -070077 List<String> conferenceableCallIds,
Jay Shrauner8f988432015-04-16 12:52:19 -070078 Bundle extras) {
Sailesh Nepal60437932014-04-05 16:44:55 -070079 mId = id;
80 mState = state;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070081 mDisconnectCause = disconnectCause;
Ihab Awadc0677542014-06-10 13:29:47 -070082 mCannedSmsResponses = cannedSmsResponses;
Sailesh Nepal60437932014-04-05 16:44:55 -070083 mCapabilities = capabilities;
Andrew Lee223ad142014-08-27 16:33:08 -070084 mProperties = properties;
Sailesh Nepal60437932014-04-05 16:44:55 -070085 mConnectTimeMillis = connectTimeMillis;
86 mHandle = handle;
Sailesh Nepal61203862014-07-11 14:50:13 -070087 mHandlePresentation = handlePresentation;
88 mCallerDisplayName = callerDisplayName;
89 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
Sailesh Nepal60437932014-04-05 16:44:55 -070090 mGatewayInfo = gatewayInfo;
Evan Charlton8c8a0622014-07-20 12:31:00 -070091 mAccountHandle = accountHandle;
Andrew Lee50aca232014-07-22 16:41:54 -070092 mVideoCallProvider = videoCallProvider;
Santos Cordon980acb92014-05-31 10:31:19 -070093 mParentCallId = parentCallId;
94 mChildCallIds = childCallIds;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070095 mStatusHints = statusHints;
Andrew Lee85f5d422014-07-11 17:22:03 -070096 mVideoState = videoState;
Santos Cordon7c7bc7f2014-07-28 18:15:48 -070097 mConferenceableCallIds = Collections.unmodifiableList(conferenceableCallIds);
Nancy Chen10798dc2014-08-08 14:00:25 -070098 mExtras = extras;
Sailesh Nepal60437932014-04-05 16:44:55 -070099 }
100
101 /** The unique ID of the call. */
102 public String getId() {
103 return mId;
104 }
105
106 /** The current state of the call. */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700107 public int getState() {
Sailesh Nepal60437932014-04-05 16:44:55 -0700108 return mState;
109 }
110
111 /**
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700112 * Reason for disconnection, as described by {@link android.telecomm.DisconnectCause}. Valid
113 * when call state is {@link CallState#DISCONNECTED}.
Sailesh Nepal60437932014-04-05 16:44:55 -0700114 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700115 public DisconnectCause getDisconnectCause() {
116 return mDisconnectCause;
Sailesh Nepal60437932014-04-05 16:44:55 -0700117 }
118
Ihab Awadc0677542014-06-10 13:29:47 -0700119 /**
120 * The set of possible text message responses when this call is incoming.
121 */
122 public List<String> getCannedSmsResponses() {
123 return mCannedSmsResponses;
124 }
125
Sailesh Nepal60437932014-04-05 16:44:55 -0700126 // Bit mask of actions a call supports, values are defined in {@link CallCapabilities}.
127 public int getCapabilities() {
128 return mCapabilities;
129 }
130
Andrew Lee223ad142014-08-27 16:33:08 -0700131 /** Bitmask of properties of the call. */
132 public int getProperties() { return mProperties; }
133
Sailesh Nepal60437932014-04-05 16:44:55 -0700134 /** The time that the call switched to the active state. */
135 public long getConnectTimeMillis() {
136 return mConnectTimeMillis;
137 }
138
139 /** The endpoint to which the call is connected. */
140 public Uri getHandle() {
141 return mHandle;
142 }
143
Nancy Chen9d568c02014-09-08 14:17:59 -0700144 /**
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700145 * The presentation requirements for the handle. See {@link TelecomManager} for valid values.
Nancy Chen9d568c02014-09-08 14:17:59 -0700146 */
Sailesh Nepal61203862014-07-11 14:50:13 -0700147 public int getHandlePresentation() {
148 return mHandlePresentation;
149 }
150
151 /** The endpoint to which the call is connected. */
152 public String getCallerDisplayName() {
153 return mCallerDisplayName;
154 }
155
Nancy Chen9d568c02014-09-08 14:17:59 -0700156 /**
157 * The presentation requirements for the caller display name.
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700158 * See {@link TelecomManager} for valid values.
Nancy Chen9d568c02014-09-08 14:17:59 -0700159 */
Sailesh Nepal61203862014-07-11 14:50:13 -0700160 public int getCallerDisplayNamePresentation() {
161 return mCallerDisplayNamePresentation;
162 }
163
Sailesh Nepal60437932014-04-05 16:44:55 -0700164 /** Gateway information for the call. */
165 public GatewayInfo getGatewayInfo() {
166 return mGatewayInfo;
167 }
168
Evan Charlton6eb262c2014-07-19 18:18:19 -0700169 /** PhoneAccountHandle information for the call. */
Evan Charlton8c8a0622014-07-20 12:31:00 -0700170 public PhoneAccountHandle getAccountHandle() {
171 return mAccountHandle;
Nancy Chen5ffbfcc2014-06-25 14:22:55 -0700172 }
173
Sailesh Nepal60437932014-04-05 16:44:55 -0700174 /**
Andrew Lee50aca232014-07-22 16:41:54 -0700175 * Returns an object for remotely communicating through the video call provider's binder.
176 * @return The video call.
Andrew Lee5dc30752014-06-27 17:02:19 -0700177 */
Andrew Lee50aca232014-07-22 16:41:54 -0700178 public InCallService.VideoCall getVideoCall() {
179 if (mVideoCall == null && mVideoCallProvider != null) {
Andrew Lee5dc30752014-06-27 17:02:19 -0700180 try {
Andrew Lee50aca232014-07-22 16:41:54 -0700181 mVideoCall = new VideoCallImpl(mVideoCallProvider);
Andrew Lee5dc30752014-06-27 17:02:19 -0700182 } catch (RemoteException ignored) {
183 // Ignore RemoteException.
184 }
185 }
186
Andrew Lee50aca232014-07-22 16:41:54 -0700187 return mVideoCall;
Andrew Lee5dc30752014-06-27 17:02:19 -0700188 }
189
190 /**
Santos Cordon980acb92014-05-31 10:31:19 -0700191 * The conference call to which this call is conferenced. Null if not conferenced.
Santos Cordon980acb92014-05-31 10:31:19 -0700192 */
193 public String getParentCallId() {
194 return mParentCallId;
195 }
196
197 /**
198 * The child call-IDs if this call is a conference call. Returns an empty list if this is not
199 * a conference call or if the conference call contains no children.
Santos Cordon980acb92014-05-31 10:31:19 -0700200 */
201 public List<String> getChildCallIds() {
202 return mChildCallIds;
203 }
204
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700205 public List<String> getConferenceableCallIds() {
206 return mConferenceableCallIds;
207 }
208
Tyler Gunn8d83fa92014-07-01 11:31:21 -0700209 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700210 * The status label and icon.
211 *
212 * @return Status hints.
213 */
214 public StatusHints getStatusHints() {
215 return mStatusHints;
216 }
217
Andrew Lee85f5d422014-07-11 17:22:03 -0700218 /**
219 * The video state.
220 * @return The video state of the call.
221 */
222 public int getVideoState() {
223 return mVideoState;
224 }
225
Nancy Chen10798dc2014-08-08 14:00:25 -0700226 /**
227 * Any extras to pass with the call
228 *
229 * @return a bundle of extras
230 */
231 public Bundle getExtras() {
232 return mExtras;
233 }
234
Santos Cordon88b771d2014-07-19 13:10:40 -0700235 /** Responsible for creating ParcelableCall objects for deserialized Parcels. */
236 public static final Parcelable.Creator<ParcelableCall> CREATOR =
237 new Parcelable.Creator<ParcelableCall> () {
Sailesh Nepal60437932014-04-05 16:44:55 -0700238 @Override
Santos Cordon88b771d2014-07-19 13:10:40 -0700239 public ParcelableCall createFromParcel(Parcel source) {
240 ClassLoader classLoader = ParcelableCall.class.getClassLoader();
Sailesh Nepal60437932014-04-05 16:44:55 -0700241 String id = source.readString();
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700242 int state = source.readInt();
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700243 DisconnectCause disconnectCause = source.readParcelable(classLoader);
Ihab Awadc0677542014-06-10 13:29:47 -0700244 List<String> cannedSmsResponses = new ArrayList<>();
245 source.readList(cannedSmsResponses, classLoader);
Sailesh Nepal60437932014-04-05 16:44:55 -0700246 int capabilities = source.readInt();
Andrew Lee223ad142014-08-27 16:33:08 -0700247 int properties = source.readInt();
Sailesh Nepal60437932014-04-05 16:44:55 -0700248 long connectTimeMillis = source.readLong();
Sailesh Nepal60437932014-04-05 16:44:55 -0700249 Uri handle = source.readParcelable(classLoader);
Sailesh Nepal61203862014-07-11 14:50:13 -0700250 int handlePresentation = source.readInt();
251 String callerDisplayName = source.readString();
252 int callerDisplayNamePresentation = source.readInt();
Sailesh Nepal60437932014-04-05 16:44:55 -0700253 GatewayInfo gatewayInfo = source.readParcelable(classLoader);
Evan Charlton8c8a0622014-07-20 12:31:00 -0700254 PhoneAccountHandle accountHandle = source.readParcelable(classLoader);
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700255 IVideoProvider videoCallProvider =
256 IVideoProvider.Stub.asInterface(source.readStrongBinder());
Santos Cordon980acb92014-05-31 10:31:19 -0700257 String parentCallId = source.readString();
258 List<String> childCallIds = new ArrayList<>();
259 source.readList(childCallIds, classLoader);
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700260 StatusHints statusHints = source.readParcelable(classLoader);
Andrew Lee85f5d422014-07-11 17:22:03 -0700261 int videoState = source.readInt();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700262 List<String> conferenceableCallIds = new ArrayList<>();
263 source.readList(conferenceableCallIds, classLoader);
Nancy Chen10798dc2014-08-08 14:00:25 -0700264 Bundle extras = source.readParcelable(classLoader);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700265 return new ParcelableCall(
266 id,
267 state,
268 disconnectCause,
269 cannedSmsResponses,
270 capabilities,
271 properties,
272 connectTimeMillis,
273 handle,
274 handlePresentation,
275 callerDisplayName,
276 callerDisplayNamePresentation,
277 gatewayInfo,
278 accountHandle,
279 videoCallProvider,
280 parentCallId,
281 childCallIds,
282 statusHints,
283 videoState,
284 conferenceableCallIds,
Jay Shrauner8f988432015-04-16 12:52:19 -0700285 extras);
Sailesh Nepal60437932014-04-05 16:44:55 -0700286 }
287
288 @Override
Santos Cordon88b771d2014-07-19 13:10:40 -0700289 public ParcelableCall[] newArray(int size) {
290 return new ParcelableCall[size];
Sailesh Nepal60437932014-04-05 16:44:55 -0700291 }
292 };
293
294 /** {@inheritDoc} */
295 @Override
296 public int describeContents() {
297 return 0;
298 }
299
Santos Cordon88b771d2014-07-19 13:10:40 -0700300 /** Writes ParcelableCall object into a Parcel. */
Sailesh Nepal60437932014-04-05 16:44:55 -0700301 @Override
302 public void writeToParcel(Parcel destination, int flags) {
303 destination.writeString(mId);
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700304 destination.writeInt(mState);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700305 destination.writeParcelable(mDisconnectCause, 0);
Ihab Awadc0677542014-06-10 13:29:47 -0700306 destination.writeList(mCannedSmsResponses);
Sailesh Nepal60437932014-04-05 16:44:55 -0700307 destination.writeInt(mCapabilities);
Andrew Lee223ad142014-08-27 16:33:08 -0700308 destination.writeInt(mProperties);
Sailesh Nepal60437932014-04-05 16:44:55 -0700309 destination.writeLong(mConnectTimeMillis);
310 destination.writeParcelable(mHandle, 0);
Sailesh Nepal61203862014-07-11 14:50:13 -0700311 destination.writeInt(mHandlePresentation);
312 destination.writeString(mCallerDisplayName);
313 destination.writeInt(mCallerDisplayNamePresentation);
Sailesh Nepal60437932014-04-05 16:44:55 -0700314 destination.writeParcelable(mGatewayInfo, 0);
Evan Charlton8c8a0622014-07-20 12:31:00 -0700315 destination.writeParcelable(mAccountHandle, 0);
Tyler Gunn807de8a2014-06-30 14:22:57 -0700316 destination.writeStrongBinder(
Andrew Lee50aca232014-07-22 16:41:54 -0700317 mVideoCallProvider != null ? mVideoCallProvider.asBinder() : null);
Santos Cordon980acb92014-05-31 10:31:19 -0700318 destination.writeString(mParentCallId);
319 destination.writeList(mChildCallIds);
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700320 destination.writeParcelable(mStatusHints, 0);
Andrew Lee85f5d422014-07-11 17:22:03 -0700321 destination.writeInt(mVideoState);
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700322 destination.writeList(mConferenceableCallIds);
Nancy Chen10798dc2014-08-08 14:00:25 -0700323 destination.writeParcelable(mExtras, 0);
Sailesh Nepal60437932014-04-05 16:44:55 -0700324 }
Santos Cordonb6939982014-06-04 20:20:58 -0700325
326 @Override
327 public String toString() {
328 return String.format("[%s, parent:%s, children:%s]", mId, mParentCallId, mChildCallIds);
329 }
Sailesh Nepal60437932014-04-05 16:44:55 -0700330}