• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package android.telecom;
18 
19 import android.net.Uri;
20 import android.os.Bundle;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23 import android.os.RemoteException;
24 
25 import java.util.ArrayList;
26 import java.util.Collections;
27 import java.util.List;
28 
29 import com.android.internal.telecom.IVideoProvider;
30 
31 /**
32  * Information about a call that is used between InCallService and Telecom.
33  * @hide
34  */
35 public final class ParcelableCall implements Parcelable {
36     private final String mId;
37     private final int mState;
38     private final DisconnectCause mDisconnectCause;
39     private final List<String> mCannedSmsResponses;
40     private final int mCapabilities;
41     private final int mProperties;
42     private final long mConnectTimeMillis;
43     private final Uri mHandle;
44     private final int mHandlePresentation;
45     private final String mCallerDisplayName;
46     private final int mCallerDisplayNamePresentation;
47     private final GatewayInfo mGatewayInfo;
48     private final PhoneAccountHandle mAccountHandle;
49     private final boolean mIsVideoCallProviderChanged;
50     private final IVideoProvider mVideoCallProvider;
51     private VideoCallImpl mVideoCall;
52     private final String mParentCallId;
53     private final List<String> mChildCallIds;
54     private final StatusHints mStatusHints;
55     private final int mVideoState;
56     private final List<String> mConferenceableCallIds;
57     private final Bundle mIntentExtras;
58     private final Bundle mExtras;
59 
ParcelableCall( String id, int state, DisconnectCause disconnectCause, List<String> cannedSmsResponses, int capabilities, int properties, long connectTimeMillis, Uri handle, int handlePresentation, String callerDisplayName, int callerDisplayNamePresentation, GatewayInfo gatewayInfo, PhoneAccountHandle accountHandle, boolean isVideoCallProviderChanged, IVideoProvider videoCallProvider, String parentCallId, List<String> childCallIds, StatusHints statusHints, int videoState, List<String> conferenceableCallIds, Bundle intentExtras, Bundle extras)60     public ParcelableCall(
61             String id,
62             int state,
63             DisconnectCause disconnectCause,
64             List<String> cannedSmsResponses,
65             int capabilities,
66             int properties,
67             long connectTimeMillis,
68             Uri handle,
69             int handlePresentation,
70             String callerDisplayName,
71             int callerDisplayNamePresentation,
72             GatewayInfo gatewayInfo,
73             PhoneAccountHandle accountHandle,
74             boolean isVideoCallProviderChanged,
75             IVideoProvider videoCallProvider,
76             String parentCallId,
77             List<String> childCallIds,
78             StatusHints statusHints,
79             int videoState,
80             List<String> conferenceableCallIds,
81             Bundle intentExtras,
82             Bundle extras) {
83         mId = id;
84         mState = state;
85         mDisconnectCause = disconnectCause;
86         mCannedSmsResponses = cannedSmsResponses;
87         mCapabilities = capabilities;
88         mProperties = properties;
89         mConnectTimeMillis = connectTimeMillis;
90         mHandle = handle;
91         mHandlePresentation = handlePresentation;
92         mCallerDisplayName = callerDisplayName;
93         mCallerDisplayNamePresentation = callerDisplayNamePresentation;
94         mGatewayInfo = gatewayInfo;
95         mAccountHandle = accountHandle;
96         mIsVideoCallProviderChanged = isVideoCallProviderChanged;
97         mVideoCallProvider = videoCallProvider;
98         mParentCallId = parentCallId;
99         mChildCallIds = childCallIds;
100         mStatusHints = statusHints;
101         mVideoState = videoState;
102         mConferenceableCallIds = Collections.unmodifiableList(conferenceableCallIds);
103         mIntentExtras = intentExtras;
104         mExtras = extras;
105     }
106 
107     /** The unique ID of the call. */
getId()108     public String getId() {
109         return mId;
110     }
111 
112     /** The current state of the call. */
getState()113     public int getState() {
114         return mState;
115     }
116 
117     /**
118      * Reason for disconnection, as described by {@link android.telecomm.DisconnectCause}. Valid
119      * when call state is {@link CallState#DISCONNECTED}.
120      */
getDisconnectCause()121     public DisconnectCause getDisconnectCause() {
122         return mDisconnectCause;
123     }
124 
125     /**
126      * The set of possible text message responses when this call is incoming.
127      */
getCannedSmsResponses()128     public List<String> getCannedSmsResponses() {
129         return mCannedSmsResponses;
130     }
131 
132     // Bit mask of actions a call supports, values are defined in {@link CallCapabilities}.
getCapabilities()133     public int getCapabilities() {
134         return mCapabilities;
135     }
136 
137     /** Bitmask of properties of the call. */
getProperties()138     public int getProperties() { return mProperties; }
139 
140     /** The time that the call switched to the active state. */
getConnectTimeMillis()141     public long getConnectTimeMillis() {
142         return mConnectTimeMillis;
143     }
144 
145     /** The endpoint to which the call is connected. */
getHandle()146     public Uri getHandle() {
147         return mHandle;
148     }
149 
150     /**
151      * The presentation requirements for the handle. See {@link TelecomManager} for valid values.
152      */
getHandlePresentation()153     public int getHandlePresentation() {
154         return mHandlePresentation;
155     }
156 
157     /** The endpoint to which the call is connected. */
getCallerDisplayName()158     public String getCallerDisplayName() {
159         return mCallerDisplayName;
160     }
161 
162     /**
163      * The presentation requirements for the caller display name.
164      * See {@link TelecomManager} for valid values.
165      */
getCallerDisplayNamePresentation()166     public int getCallerDisplayNamePresentation() {
167         return mCallerDisplayNamePresentation;
168     }
169 
170     /** Gateway information for the call. */
getGatewayInfo()171     public GatewayInfo getGatewayInfo() {
172         return mGatewayInfo;
173     }
174 
175     /** PhoneAccountHandle information for the call. */
getAccountHandle()176     public PhoneAccountHandle getAccountHandle() {
177         return mAccountHandle;
178     }
179 
180     /**
181      * Returns an object for remotely communicating through the video call provider's binder.
182 
183      * @return The video call.
184      */
getVideoCallImpl()185     public VideoCallImpl getVideoCallImpl() {
186         if (mVideoCall == null && mVideoCallProvider != null) {
187             try {
188                 mVideoCall = new VideoCallImpl(mVideoCallProvider);
189             } catch (RemoteException ignored) {
190                 // Ignore RemoteException.
191             }
192         }
193 
194         return mVideoCall;
195     }
196 
197     /**
198      * The conference call to which this call is conferenced. Null if not conferenced.
199      */
getParentCallId()200     public String getParentCallId() {
201         return mParentCallId;
202     }
203 
204     /**
205      * The child call-IDs if this call is a conference call. Returns an empty list if this is not
206      * a conference call or if the conference call contains no children.
207      */
getChildCallIds()208     public List<String> getChildCallIds() {
209         return mChildCallIds;
210     }
211 
getConferenceableCallIds()212     public List<String> getConferenceableCallIds() {
213         return mConferenceableCallIds;
214     }
215 
216     /**
217      * The status label and icon.
218      *
219      * @return Status hints.
220      */
getStatusHints()221     public StatusHints getStatusHints() {
222         return mStatusHints;
223     }
224 
225     /**
226      * The video state.
227      * @return The video state of the call.
228      */
getVideoState()229     public int getVideoState() {
230         return mVideoState;
231     }
232 
233     /**
234      * Any extras associated with this call.
235      *
236      * @return a bundle of extras
237      */
getExtras()238     public Bundle getExtras() {
239         return mExtras;
240     }
241 
242     /**
243      * Extras passed in as part of the original call intent.
244      *
245      * @return The intent extras.
246      */
getIntentExtras()247     public Bundle getIntentExtras() {
248         return mIntentExtras;
249     }
250 
251     /**
252      * Indicates to the receiver of the {@link ParcelableCall} whether a change has occurred in the
253      * {@link android.telecom.InCallService.VideoCall} associated with this call.  Since
254      * {@link #getVideoCall()} creates a new {@link VideoCallImpl}, it is useful to know whether
255      * the provider has changed (which can influence whether it is accessed).
256      *
257      * @return {@code true} if the video call changed, {@code false} otherwise.
258      */
isVideoCallProviderChanged()259     public boolean isVideoCallProviderChanged() {
260         return mIsVideoCallProviderChanged;
261     }
262 
263     /** Responsible for creating ParcelableCall objects for deserialized Parcels. */
264     public static final Parcelable.Creator<ParcelableCall> CREATOR =
265             new Parcelable.Creator<ParcelableCall> () {
266         @Override
267         public ParcelableCall createFromParcel(Parcel source) {
268             ClassLoader classLoader = ParcelableCall.class.getClassLoader();
269             String id = source.readString();
270             int state = source.readInt();
271             DisconnectCause disconnectCause = source.readParcelable(classLoader);
272             List<String> cannedSmsResponses = new ArrayList<>();
273             source.readList(cannedSmsResponses, classLoader);
274             int capabilities = source.readInt();
275             int properties = source.readInt();
276             long connectTimeMillis = source.readLong();
277             Uri handle = source.readParcelable(classLoader);
278             int handlePresentation = source.readInt();
279             String callerDisplayName = source.readString();
280             int callerDisplayNamePresentation = source.readInt();
281             GatewayInfo gatewayInfo = source.readParcelable(classLoader);
282             PhoneAccountHandle accountHandle = source.readParcelable(classLoader);
283             boolean isVideoCallProviderChanged = source.readByte() == 1;
284             IVideoProvider videoCallProvider =
285                     IVideoProvider.Stub.asInterface(source.readStrongBinder());
286             String parentCallId = source.readString();
287             List<String> childCallIds = new ArrayList<>();
288             source.readList(childCallIds, classLoader);
289             StatusHints statusHints = source.readParcelable(classLoader);
290             int videoState = source.readInt();
291             List<String> conferenceableCallIds = new ArrayList<>();
292             source.readList(conferenceableCallIds, classLoader);
293             Bundle intentExtras = source.readBundle(classLoader);
294             Bundle extras = source.readBundle(classLoader);
295             return new ParcelableCall(
296                     id,
297                     state,
298                     disconnectCause,
299                     cannedSmsResponses,
300                     capabilities,
301                     properties,
302                     connectTimeMillis,
303                     handle,
304                     handlePresentation,
305                     callerDisplayName,
306                     callerDisplayNamePresentation,
307                     gatewayInfo,
308                     accountHandle,
309                     isVideoCallProviderChanged,
310                     videoCallProvider,
311                     parentCallId,
312                     childCallIds,
313                     statusHints,
314                     videoState,
315                     conferenceableCallIds,
316                     intentExtras,
317                     extras);
318         }
319 
320         @Override
321         public ParcelableCall[] newArray(int size) {
322             return new ParcelableCall[size];
323         }
324     };
325 
326     /** {@inheritDoc} */
327     @Override
describeContents()328     public int describeContents() {
329         return 0;
330     }
331 
332     /** Writes ParcelableCall object into a Parcel. */
333     @Override
writeToParcel(Parcel destination, int flags)334     public void writeToParcel(Parcel destination, int flags) {
335         destination.writeString(mId);
336         destination.writeInt(mState);
337         destination.writeParcelable(mDisconnectCause, 0);
338         destination.writeList(mCannedSmsResponses);
339         destination.writeInt(mCapabilities);
340         destination.writeInt(mProperties);
341         destination.writeLong(mConnectTimeMillis);
342         destination.writeParcelable(mHandle, 0);
343         destination.writeInt(mHandlePresentation);
344         destination.writeString(mCallerDisplayName);
345         destination.writeInt(mCallerDisplayNamePresentation);
346         destination.writeParcelable(mGatewayInfo, 0);
347         destination.writeParcelable(mAccountHandle, 0);
348         destination.writeByte((byte) (mIsVideoCallProviderChanged ? 1 : 0));
349         destination.writeStrongBinder(
350                 mVideoCallProvider != null ? mVideoCallProvider.asBinder() : null);
351         destination.writeString(mParentCallId);
352         destination.writeList(mChildCallIds);
353         destination.writeParcelable(mStatusHints, 0);
354         destination.writeInt(mVideoState);
355         destination.writeList(mConferenceableCallIds);
356         destination.writeBundle(mIntentExtras);
357         destination.writeBundle(mExtras);
358     }
359 
360     @Override
toString()361     public String toString() {
362         return String.format("[%s, parent:%s, children:%s]", mId, mParentCallId, mChildCallIds);
363     }
364 }
365