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