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