blob: e9dba686ff8244a4446bf628f008e7298b7944cd [file] [log] [blame]
Santos Cordone8dc4be2014-07-21 01:28:28 -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;
Santos Cordone8dc4be2014-07-21 01:28:28 -070018
19import android.net.Uri;
Santos Cordon6b7f9552015-05-27 17:21:45 -070020import android.os.Bundle;
Santos Cordone8dc4be2014-07-21 01:28:28 -070021import android.os.Parcel;
22import android.os.Parcelable;
23
Tyler Gunnef9f6f92014-09-12 22:16:17 -070024import com.android.internal.telecom.IVideoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -070025
Ihab Awadb8e85c72014-08-23 20:34:57 -070026import java.util.ArrayList;
27import java.util.List;
28
Santos Cordone8dc4be2014-07-21 01:28:28 -070029/**
Tyler Gunnef9f6f92014-09-12 22:16:17 -070030 * 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
Santos Cordone8dc4be2014-07-21 01:28:28 -070032 * first created.
33 * @hide
34 */
35public final class ParcelableConnection implements Parcelable {
Ihab Awadb8e85c72014-08-23 20:34:57 -070036 private final PhoneAccountHandle mPhoneAccount;
37 private final int mState;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080038 private final int mConnectionCapabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -070039 private final int mConnectionProperties;
Christine Hallstrom2830ce92016-11-30 16:06:42 -080040 private final int mSupportedAudioRoutes;
Andrew Lee100e2932014-09-08 15:34:24 -070041 private final Uri mAddress;
42 private final int mAddressPresentation;
Ihab Awadb8e85c72014-08-23 20:34:57 -070043 private final String mCallerDisplayName;
44 private final int mCallerDisplayNamePresentation;
45 private final IVideoProvider mVideoProvider;
46 private final int mVideoState;
Andrew Lee100e2932014-09-08 15:34:24 -070047 private final boolean mRingbackRequested;
48 private final boolean mIsVoipAudioMode;
Roshan Piuse927ec02015-07-15 15:47:21 -070049 private final long mConnectTimeMillis;
Ihab Awadb8e85c72014-08-23 20:34:57 -070050 private final StatusHints mStatusHints;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070051 private final DisconnectCause mDisconnectCause;
Ihab Awadb8e85c72014-08-23 20:34:57 -070052 private final List<String> mConferenceableConnectionIds;
Santos Cordon6b7f9552015-05-27 17:21:45 -070053 private final Bundle mExtras;
Santos Cordone8dc4be2014-07-21 01:28:28 -070054
55 /** @hide */
56 public ParcelableConnection(
57 PhoneAccountHandle phoneAccount,
58 int state,
59 int capabilities,
Tyler Gunn720c6642016-03-22 09:02:47 -070060 int properties,
Christine Hallstrom2830ce92016-11-30 16:06:42 -080061 int supportedAudioRoutes,
Andrew Lee100e2932014-09-08 15:34:24 -070062 Uri address,
63 int addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -070064 String callerDisplayName,
65 int callerDisplayNamePresentation,
Ihab Awadb19a0bc2014-08-07 19:46:01 -070066 IVideoProvider videoProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -070067 int videoState,
Andrew Lee100e2932014-09-08 15:34:24 -070068 boolean ringbackRequested,
69 boolean isVoipAudioMode,
Roshan Piuse927ec02015-07-15 15:47:21 -070070 long connectTimeMillis,
Ihab Awad6107bab2014-08-18 09:23:25 -070071 StatusHints statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -070072 DisconnectCause disconnectCause,
Santos Cordon6b7f9552015-05-27 17:21:45 -070073 List<String> conferenceableConnectionIds,
74 Bundle extras) {
Santos Cordone8dc4be2014-07-21 01:28:28 -070075 mPhoneAccount = phoneAccount;
76 mState = state;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080077 mConnectionCapabilities = capabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -070078 mConnectionProperties = properties;
Christine Hallstrom2830ce92016-11-30 16:06:42 -080079 mSupportedAudioRoutes = supportedAudioRoutes;
Andrew Lee100e2932014-09-08 15:34:24 -070080 mAddress = address;
81 mAddressPresentation = addressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -070082 mCallerDisplayName = callerDisplayName;
83 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070084 mVideoProvider = videoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -070085 mVideoState = videoState;
Andrew Lee100e2932014-09-08 15:34:24 -070086 mRingbackRequested = ringbackRequested;
87 mIsVoipAudioMode = isVoipAudioMode;
Roshan Piuse927ec02015-07-15 15:47:21 -070088 mConnectTimeMillis = connectTimeMillis;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -070089 mStatusHints = statusHints;
Sailesh Nepalcf7020b2014-08-20 10:07:19 -070090 mDisconnectCause = disconnectCause;
Santos Cordon6b7f9552015-05-27 17:21:45 -070091 mConferenceableConnectionIds = conferenceableConnectionIds;
92 mExtras = extras;
Santos Cordone8dc4be2014-07-21 01:28:28 -070093 }
94
95 public PhoneAccountHandle getPhoneAccount() {
96 return mPhoneAccount;
97 }
98
99 public int getState() {
100 return mState;
101 }
102
Tyler Gunn720c6642016-03-22 09:02:47 -0700103 /**
104 * Returns the current connection capabilities bit-mask. Connection capabilities are defined as
105 * {@code CAPABILITY_*} constants in {@link Connection}.
106 *
107 * @return Bit-mask containing capabilities of the connection.
108 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800109 public int getConnectionCapabilities() {
110 return mConnectionCapabilities;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700111 }
112
Tyler Gunn720c6642016-03-22 09:02:47 -0700113 /**
114 * Returns the current connection properties bit-mask. Connection properties are defined as
115 * {@code PROPERTY_*} constants in {@link Connection}.
116 *
117 * @return Bit-mask containing properties of the connection.
118 */
119 public int getConnectionProperties() {
120 return mConnectionProperties;
121 }
122
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800123 public int getSupportedAudioRoutes() {
124 return mSupportedAudioRoutes;
125 }
126
Santos Cordone8dc4be2014-07-21 01:28:28 -0700127 public Uri getHandle() {
Andrew Lee100e2932014-09-08 15:34:24 -0700128 return mAddress;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700129 }
130
131 public int getHandlePresentation() {
Andrew Lee100e2932014-09-08 15:34:24 -0700132 return mAddressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700133 }
134
135 public String getCallerDisplayName() {
136 return mCallerDisplayName;
137 }
138
139 public int getCallerDisplayNamePresentation() {
140 return mCallerDisplayNamePresentation;
141 }
142
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700143 public IVideoProvider getVideoProvider() {
144 return mVideoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700145 }
146
147 public int getVideoState() {
148 return mVideoState;
149 }
150
Andrew Lee100e2932014-09-08 15:34:24 -0700151 public boolean isRingbackRequested() {
152 return mRingbackRequested;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700153 }
154
Andrew Lee100e2932014-09-08 15:34:24 -0700155 public boolean getIsVoipAudioMode() {
156 return mIsVoipAudioMode;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700157 }
158
Roshan Piuse927ec02015-07-15 15:47:21 -0700159 public long getConnectTimeMillis() {
160 return mConnectTimeMillis;
161 }
162
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700163 public final StatusHints getStatusHints() {
164 return mStatusHints;
165 }
166
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700167 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -0700168 return mDisconnectCause;
Ihab Awad6107bab2014-08-18 09:23:25 -0700169 }
170
Ihab Awadb8e85c72014-08-23 20:34:57 -0700171 public final List<String> getConferenceableConnectionIds() {
172 return mConferenceableConnectionIds;
173 }
174
Santos Cordon6b7f9552015-05-27 17:21:45 -0700175 public final Bundle getExtras() {
176 return mExtras;
177 }
178
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700179 @Override
180 public String toString() {
181 return new StringBuilder()
182 .append("ParcelableConnection [act:")
183 .append(mPhoneAccount)
Santos Cordon6b7f9552015-05-27 17:21:45 -0700184 .append("], state:")
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700185 .append(mState)
186 .append(", capabilities:")
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800187 .append(Connection.capabilitiesToString(mConnectionCapabilities))
Tyler Gunn720c6642016-03-22 09:02:47 -0700188 .append(", properties:")
189 .append(Connection.propertiesToString(mConnectionProperties))
Santos Cordon6b7f9552015-05-27 17:21:45 -0700190 .append(", extras:")
191 .append(mExtras)
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700192 .toString();
193 }
194
Santos Cordone8dc4be2014-07-21 01:28:28 -0700195 public static final Parcelable.Creator<ParcelableConnection> CREATOR =
196 new Parcelable.Creator<ParcelableConnection> () {
197 @Override
198 public ParcelableConnection createFromParcel(Parcel source) {
199 ClassLoader classLoader = ParcelableConnection.class.getClassLoader();
200
201 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
202 int state = source.readInt();
203 int capabilities = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700204 Uri address = source.readParcelable(classLoader);
205 int addressPresentation = source.readInt();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700206 String callerDisplayName = source.readString();
207 int callerDisplayNamePresentation = source.readInt();
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700208 IVideoProvider videoCallProvider =
209 IVideoProvider.Stub.asInterface(source.readStrongBinder());
Santos Cordone8dc4be2014-07-21 01:28:28 -0700210 int videoState = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700211 boolean ringbackRequested = source.readByte() == 1;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700212 boolean audioModeIsVoip = source.readByte() == 1;
Roshan Piuse927ec02015-07-15 15:47:21 -0700213 long connectTimeMillis = source.readLong();
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700214 StatusHints statusHints = source.readParcelable(classLoader);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700215 DisconnectCause disconnectCause = source.readParcelable(classLoader);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700216 List<String> conferenceableConnectionIds = new ArrayList<>();
217 source.readStringList(conferenceableConnectionIds);
Jeff Sharkeyf0ec2e02016-03-21 12:37:54 -0600218 Bundle extras = Bundle.setDefusable(source.readBundle(classLoader), true);
Tyler Gunn720c6642016-03-22 09:02:47 -0700219 int properties = source.readInt();
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800220 int supportedAudioRoutes = source.readInt();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700221
222 return new ParcelableConnection(
223 phoneAccount,
224 state,
225 capabilities,
Tyler Gunn720c6642016-03-22 09:02:47 -0700226 properties,
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800227 supportedAudioRoutes,
Andrew Lee100e2932014-09-08 15:34:24 -0700228 address,
229 addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -0700230 callerDisplayName,
231 callerDisplayNamePresentation,
Andrew Lee50aca232014-07-22 16:41:54 -0700232 videoCallProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700233 videoState,
Andrew Lee100e2932014-09-08 15:34:24 -0700234 ringbackRequested,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700235 audioModeIsVoip,
Roshan Piuse927ec02015-07-15 15:47:21 -0700236 connectTimeMillis,
Ihab Awad6107bab2014-08-18 09:23:25 -0700237 statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700238 disconnectCause,
Santos Cordon6b7f9552015-05-27 17:21:45 -0700239 conferenceableConnectionIds,
240 extras);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700241 }
242
243 @Override
244 public ParcelableConnection[] newArray(int size) {
245 return new ParcelableConnection[size];
246 }
247 };
248
249 /** {@inheritDoc} */
250 @Override
251 public int describeContents() {
252 return 0;
253 }
254
255 /** Writes ParcelableConnection object into a Parcel. */
256 @Override
257 public void writeToParcel(Parcel destination, int flags) {
258 destination.writeParcelable(mPhoneAccount, 0);
259 destination.writeInt(mState);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800260 destination.writeInt(mConnectionCapabilities);
Andrew Lee100e2932014-09-08 15:34:24 -0700261 destination.writeParcelable(mAddress, 0);
262 destination.writeInt(mAddressPresentation);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700263 destination.writeString(mCallerDisplayName);
264 destination.writeInt(mCallerDisplayNamePresentation);
265 destination.writeStrongBinder(
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700266 mVideoProvider != null ? mVideoProvider.asBinder() : null);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700267 destination.writeInt(mVideoState);
Andrew Lee100e2932014-09-08 15:34:24 -0700268 destination.writeByte((byte) (mRingbackRequested ? 1 : 0));
269 destination.writeByte((byte) (mIsVoipAudioMode ? 1 : 0));
Roshan Piuse927ec02015-07-15 15:47:21 -0700270 destination.writeLong(mConnectTimeMillis);
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700271 destination.writeParcelable(mStatusHints, 0);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700272 destination.writeParcelable(mDisconnectCause, 0);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700273 destination.writeStringList(mConferenceableConnectionIds);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700274 destination.writeBundle(mExtras);
Tyler Gunn720c6642016-03-22 09:02:47 -0700275 destination.writeInt(mConnectionProperties);
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800276 destination.writeInt(mSupportedAudioRoutes);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700277 }
278}