• 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 
24 import com.android.internal.telecom.IVideoProvider;
25 
26 import java.util.ArrayList;
27 import java.util.List;
28 
29 /**
30  * Information about a connection that is used between Telecom and the ConnectionService.
31  * This is used to send initial Connection information to Telecom when the connection is
32  * first created.
33  * @hide
34  */
35 public final class ParcelableConnection implements Parcelable {
36     private final PhoneAccountHandle mPhoneAccount;
37     private final int mState;
38     private final int mConnectionCapabilities;
39     private final int mConnectionProperties;
40     private final int mSupportedAudioRoutes;
41     private final Uri mAddress;
42     private final int mAddressPresentation;
43     private final String mCallerDisplayName;
44     private final int mCallerDisplayNamePresentation;
45     private final IVideoProvider mVideoProvider;
46     private final int mVideoState;
47     private final boolean mRingbackRequested;
48     private final boolean mIsVoipAudioMode;
49     private final long mConnectTimeMillis;
50     private final long mConnectElapsedTimeMillis;
51     private final StatusHints mStatusHints;
52     private final DisconnectCause mDisconnectCause;
53     private final List<String> mConferenceableConnectionIds;
54     private final Bundle mExtras;
55     private String mParentCallId;
56 
57     /** @hide */
ParcelableConnection( PhoneAccountHandle phoneAccount, int state, int capabilities, int properties, int supportedAudioRoutes, Uri address, int addressPresentation, String callerDisplayName, int callerDisplayNamePresentation, IVideoProvider videoProvider, int videoState, boolean ringbackRequested, boolean isVoipAudioMode, long connectTimeMillis, long connectElapsedTimeMillis, StatusHints statusHints, DisconnectCause disconnectCause, List<String> conferenceableConnectionIds, Bundle extras, String parentCallId)58     public ParcelableConnection(
59             PhoneAccountHandle phoneAccount,
60             int state,
61             int capabilities,
62             int properties,
63             int supportedAudioRoutes,
64             Uri address,
65             int addressPresentation,
66             String callerDisplayName,
67             int callerDisplayNamePresentation,
68             IVideoProvider videoProvider,
69             int videoState,
70             boolean ringbackRequested,
71             boolean isVoipAudioMode,
72             long connectTimeMillis,
73             long connectElapsedTimeMillis,
74             StatusHints statusHints,
75             DisconnectCause disconnectCause,
76             List<String> conferenceableConnectionIds,
77             Bundle extras,
78             String parentCallId) {
79         this(phoneAccount, state, capabilities, properties, supportedAudioRoutes, address,
80                 addressPresentation, callerDisplayName, callerDisplayNamePresentation,
81                 videoProvider, videoState, ringbackRequested, isVoipAudioMode, connectTimeMillis,
82                 connectElapsedTimeMillis, statusHints, disconnectCause, conferenceableConnectionIds,
83                 extras);
84         mParentCallId = parentCallId;
85     }
86 
87     /** @hide */
ParcelableConnection( PhoneAccountHandle phoneAccount, int state, int capabilities, int properties, int supportedAudioRoutes, Uri address, int addressPresentation, String callerDisplayName, int callerDisplayNamePresentation, IVideoProvider videoProvider, int videoState, boolean ringbackRequested, boolean isVoipAudioMode, long connectTimeMillis, long connectElapsedTimeMillis, StatusHints statusHints, DisconnectCause disconnectCause, List<String> conferenceableConnectionIds, Bundle extras)88     public ParcelableConnection(
89             PhoneAccountHandle phoneAccount,
90             int state,
91             int capabilities,
92             int properties,
93             int supportedAudioRoutes,
94             Uri address,
95             int addressPresentation,
96             String callerDisplayName,
97             int callerDisplayNamePresentation,
98             IVideoProvider videoProvider,
99             int videoState,
100             boolean ringbackRequested,
101             boolean isVoipAudioMode,
102             long connectTimeMillis,
103             long connectElapsedTimeMillis,
104             StatusHints statusHints,
105             DisconnectCause disconnectCause,
106             List<String> conferenceableConnectionIds,
107             Bundle extras) {
108         mPhoneAccount = phoneAccount;
109         mState = state;
110         mConnectionCapabilities = capabilities;
111         mConnectionProperties = properties;
112         mSupportedAudioRoutes = supportedAudioRoutes;
113         mAddress = address;
114         mAddressPresentation = addressPresentation;
115         mCallerDisplayName = callerDisplayName;
116         mCallerDisplayNamePresentation = callerDisplayNamePresentation;
117         mVideoProvider = videoProvider;
118         mVideoState = videoState;
119         mRingbackRequested = ringbackRequested;
120         mIsVoipAudioMode = isVoipAudioMode;
121         mConnectTimeMillis = connectTimeMillis;
122         mConnectElapsedTimeMillis = connectElapsedTimeMillis;
123         mStatusHints = statusHints;
124         mDisconnectCause = disconnectCause;
125         mConferenceableConnectionIds = conferenceableConnectionIds;
126         mExtras = extras;
127         mParentCallId = null;
128     }
129 
getPhoneAccount()130     public PhoneAccountHandle getPhoneAccount() {
131         return mPhoneAccount;
132     }
133 
getState()134     public int getState() {
135         return mState;
136     }
137 
138     /**
139      * Returns the current connection capabilities bit-mask.  Connection capabilities are defined as
140      * {@code CAPABILITY_*} constants in {@link Connection}.
141      *
142      * @return Bit-mask containing capabilities of the connection.
143      */
getConnectionCapabilities()144     public int getConnectionCapabilities() {
145         return mConnectionCapabilities;
146     }
147 
148     /**
149      * Returns the current connection properties bit-mask.  Connection properties are defined as
150      * {@code PROPERTY_*} constants in {@link Connection}.
151      *
152      * @return Bit-mask containing properties of the connection.
153      */
getConnectionProperties()154     public int getConnectionProperties() {
155         return mConnectionProperties;
156     }
157 
getSupportedAudioRoutes()158     public int getSupportedAudioRoutes() {
159         return mSupportedAudioRoutes;
160     }
161 
getHandle()162     public Uri getHandle() {
163         return mAddress;
164     }
165 
getHandlePresentation()166     public int getHandlePresentation() {
167         return mAddressPresentation;
168     }
169 
getCallerDisplayName()170     public String getCallerDisplayName() {
171         return mCallerDisplayName;
172     }
173 
getCallerDisplayNamePresentation()174     public int getCallerDisplayNamePresentation() {
175         return mCallerDisplayNamePresentation;
176     }
177 
getVideoProvider()178     public IVideoProvider getVideoProvider() {
179         return mVideoProvider;
180     }
181 
getVideoState()182     public int getVideoState() {
183         return mVideoState;
184     }
185 
isRingbackRequested()186     public boolean isRingbackRequested() {
187         return mRingbackRequested;
188     }
189 
getIsVoipAudioMode()190     public boolean getIsVoipAudioMode() {
191         return mIsVoipAudioMode;
192     }
193 
getConnectTimeMillis()194     public long getConnectTimeMillis() {
195         return mConnectTimeMillis;
196     }
197 
getConnectElapsedTimeMillis()198     public long getConnectElapsedTimeMillis() {
199         return mConnectElapsedTimeMillis;
200     }
201 
getStatusHints()202     public final StatusHints getStatusHints() {
203         return mStatusHints;
204     }
205 
getDisconnectCause()206     public final DisconnectCause getDisconnectCause() {
207         return mDisconnectCause;
208     }
209 
getConferenceableConnectionIds()210     public final List<String> getConferenceableConnectionIds() {
211         return mConferenceableConnectionIds;
212     }
213 
getExtras()214     public final Bundle getExtras() {
215         return mExtras;
216     }
217 
getParentCallId()218     public final String getParentCallId() {
219         return mParentCallId;
220     }
221 
222     @Override
toString()223     public String toString() {
224         return new StringBuilder()
225                 .append("ParcelableConnection [act:")
226                 .append(mPhoneAccount)
227                 .append("], state:")
228                 .append(mState)
229                 .append(", capabilities:")
230                 .append(Connection.capabilitiesToString(mConnectionCapabilities))
231                 .append(", properties:")
232                 .append(Connection.propertiesToString(mConnectionProperties))
233                 .append(", extras:")
234                 .append(mExtras)
235                 .append(", parent:")
236                 .append(mParentCallId)
237                 .toString();
238     }
239 
240     public static final Parcelable.Creator<ParcelableConnection> CREATOR =
241             new Parcelable.Creator<ParcelableConnection> () {
242         @Override
243         public ParcelableConnection createFromParcel(Parcel source) {
244             ClassLoader classLoader = ParcelableConnection.class.getClassLoader();
245 
246             PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
247             int state = source.readInt();
248             int capabilities = source.readInt();
249             Uri address = source.readParcelable(classLoader);
250             int addressPresentation = source.readInt();
251             String callerDisplayName = source.readString();
252             int callerDisplayNamePresentation = source.readInt();
253             IVideoProvider videoCallProvider =
254                     IVideoProvider.Stub.asInterface(source.readStrongBinder());
255             int videoState = source.readInt();
256             boolean ringbackRequested = source.readByte() == 1;
257             boolean audioModeIsVoip = source.readByte() == 1;
258             long connectTimeMillis = source.readLong();
259             StatusHints statusHints = source.readParcelable(classLoader);
260             DisconnectCause disconnectCause = source.readParcelable(classLoader);
261             List<String> conferenceableConnectionIds = new ArrayList<>();
262             source.readStringList(conferenceableConnectionIds);
263             Bundle extras = Bundle.setDefusable(source.readBundle(classLoader), true);
264             int properties = source.readInt();
265             int supportedAudioRoutes = source.readInt();
266             String parentCallId = source.readString();
267             long connectElapsedTimeMillis = source.readLong();
268 
269             return new ParcelableConnection(
270                     phoneAccount,
271                     state,
272                     capabilities,
273                     properties,
274                     supportedAudioRoutes,
275                     address,
276                     addressPresentation,
277                     callerDisplayName,
278                     callerDisplayNamePresentation,
279                     videoCallProvider,
280                     videoState,
281                     ringbackRequested,
282                     audioModeIsVoip,
283                     connectTimeMillis,
284                     connectElapsedTimeMillis,
285                     statusHints,
286                     disconnectCause,
287                     conferenceableConnectionIds,
288                     extras,
289                     parentCallId);
290         }
291 
292         @Override
293         public ParcelableConnection[] newArray(int size) {
294             return new ParcelableConnection[size];
295         }
296     };
297 
298     /** {@inheritDoc} */
299     @Override
describeContents()300     public int describeContents() {
301         return 0;
302     }
303 
304     /** Writes ParcelableConnection object into a Parcel. */
305     @Override
writeToParcel(Parcel destination, int flags)306     public void writeToParcel(Parcel destination, int flags) {
307         destination.writeParcelable(mPhoneAccount, 0);
308         destination.writeInt(mState);
309         destination.writeInt(mConnectionCapabilities);
310         destination.writeParcelable(mAddress, 0);
311         destination.writeInt(mAddressPresentation);
312         destination.writeString(mCallerDisplayName);
313         destination.writeInt(mCallerDisplayNamePresentation);
314         destination.writeStrongBinder(
315                 mVideoProvider != null ? mVideoProvider.asBinder() : null);
316         destination.writeInt(mVideoState);
317         destination.writeByte((byte) (mRingbackRequested ? 1 : 0));
318         destination.writeByte((byte) (mIsVoipAudioMode ? 1 : 0));
319         destination.writeLong(mConnectTimeMillis);
320         destination.writeParcelable(mStatusHints, 0);
321         destination.writeParcelable(mDisconnectCause, 0);
322         destination.writeStringList(mConferenceableConnectionIds);
323         destination.writeBundle(mExtras);
324         destination.writeInt(mConnectionProperties);
325         destination.writeInt(mSupportedAudioRoutes);
326         destination.writeString(mParentCallId);
327         destination.writeLong(mConnectElapsedTimeMillis);
328     }
329 }
330