blob: ce51c967e021c1cdffcae3953a60c92ec2460766 [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;
Andrew Lee100e2932014-09-08 15:34:24 -070039 private final Uri mAddress;
40 private final int mAddressPresentation;
Ihab Awadb8e85c72014-08-23 20:34:57 -070041 private final String mCallerDisplayName;
42 private final int mCallerDisplayNamePresentation;
43 private final IVideoProvider mVideoProvider;
44 private final int mVideoState;
Andrew Lee100e2932014-09-08 15:34:24 -070045 private final boolean mRingbackRequested;
46 private final boolean mIsVoipAudioMode;
Roshan Piuse927ec02015-07-15 15:47:21 -070047 private final long mConnectTimeMillis;
Ihab Awadb8e85c72014-08-23 20:34:57 -070048 private final StatusHints mStatusHints;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070049 private final DisconnectCause mDisconnectCause;
Ihab Awadb8e85c72014-08-23 20:34:57 -070050 private final List<String> mConferenceableConnectionIds;
Santos Cordon6b7f9552015-05-27 17:21:45 -070051 private final Bundle mExtras;
Santos Cordone8dc4be2014-07-21 01:28:28 -070052
53 /** @hide */
54 public ParcelableConnection(
55 PhoneAccountHandle phoneAccount,
56 int state,
57 int capabilities,
Andrew Lee100e2932014-09-08 15:34:24 -070058 Uri address,
59 int addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -070060 String callerDisplayName,
61 int callerDisplayNamePresentation,
Ihab Awadb19a0bc2014-08-07 19:46:01 -070062 IVideoProvider videoProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -070063 int videoState,
Andrew Lee100e2932014-09-08 15:34:24 -070064 boolean ringbackRequested,
65 boolean isVoipAudioMode,
Roshan Piuse927ec02015-07-15 15:47:21 -070066 long connectTimeMillis,
Ihab Awad6107bab2014-08-18 09:23:25 -070067 StatusHints statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -070068 DisconnectCause disconnectCause,
Santos Cordon6b7f9552015-05-27 17:21:45 -070069 List<String> conferenceableConnectionIds,
70 Bundle extras) {
Santos Cordone8dc4be2014-07-21 01:28:28 -070071 mPhoneAccount = phoneAccount;
72 mState = state;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080073 mConnectionCapabilities = capabilities;
Andrew Lee100e2932014-09-08 15:34:24 -070074 mAddress = address;
75 mAddressPresentation = addressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -070076 mCallerDisplayName = callerDisplayName;
77 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070078 mVideoProvider = videoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -070079 mVideoState = videoState;
Andrew Lee100e2932014-09-08 15:34:24 -070080 mRingbackRequested = ringbackRequested;
81 mIsVoipAudioMode = isVoipAudioMode;
Roshan Piuse927ec02015-07-15 15:47:21 -070082 mConnectTimeMillis = connectTimeMillis;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -070083 mStatusHints = statusHints;
Sailesh Nepalcf7020b2014-08-20 10:07:19 -070084 mDisconnectCause = disconnectCause;
Santos Cordon6b7f9552015-05-27 17:21:45 -070085 mConferenceableConnectionIds = conferenceableConnectionIds;
86 mExtras = extras;
Santos Cordone8dc4be2014-07-21 01:28:28 -070087 }
88
89 public PhoneAccountHandle getPhoneAccount() {
90 return mPhoneAccount;
91 }
92
93 public int getState() {
94 return mState;
95 }
96
97 // Bit mask of actions a call supports, values are defined in {@link CallCapabilities}.
Ihab Awad5c9c86e2014-11-12 13:41:16 -080098 public int getConnectionCapabilities() {
99 return mConnectionCapabilities;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700100 }
101
102 public Uri getHandle() {
Andrew Lee100e2932014-09-08 15:34:24 -0700103 return mAddress;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700104 }
105
106 public int getHandlePresentation() {
Andrew Lee100e2932014-09-08 15:34:24 -0700107 return mAddressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700108 }
109
110 public String getCallerDisplayName() {
111 return mCallerDisplayName;
112 }
113
114 public int getCallerDisplayNamePresentation() {
115 return mCallerDisplayNamePresentation;
116 }
117
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700118 public IVideoProvider getVideoProvider() {
119 return mVideoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700120 }
121
122 public int getVideoState() {
123 return mVideoState;
124 }
125
Andrew Lee100e2932014-09-08 15:34:24 -0700126 public boolean isRingbackRequested() {
127 return mRingbackRequested;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700128 }
129
Andrew Lee100e2932014-09-08 15:34:24 -0700130 public boolean getIsVoipAudioMode() {
131 return mIsVoipAudioMode;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700132 }
133
Roshan Piuse927ec02015-07-15 15:47:21 -0700134 public long getConnectTimeMillis() {
135 return mConnectTimeMillis;
136 }
137
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700138 public final StatusHints getStatusHints() {
139 return mStatusHints;
140 }
141
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700142 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -0700143 return mDisconnectCause;
Ihab Awad6107bab2014-08-18 09:23:25 -0700144 }
145
Ihab Awadb8e85c72014-08-23 20:34:57 -0700146 public final List<String> getConferenceableConnectionIds() {
147 return mConferenceableConnectionIds;
148 }
149
Santos Cordon6b7f9552015-05-27 17:21:45 -0700150 public final Bundle getExtras() {
151 return mExtras;
152 }
153
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700154 @Override
155 public String toString() {
156 return new StringBuilder()
157 .append("ParcelableConnection [act:")
158 .append(mPhoneAccount)
Santos Cordon6b7f9552015-05-27 17:21:45 -0700159 .append("], state:")
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700160 .append(mState)
161 .append(", capabilities:")
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800162 .append(Connection.capabilitiesToString(mConnectionCapabilities))
Santos Cordon6b7f9552015-05-27 17:21:45 -0700163 .append(", extras:")
164 .append(mExtras)
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700165 .toString();
166 }
167
Santos Cordone8dc4be2014-07-21 01:28:28 -0700168 public static final Parcelable.Creator<ParcelableConnection> CREATOR =
169 new Parcelable.Creator<ParcelableConnection> () {
170 @Override
171 public ParcelableConnection createFromParcel(Parcel source) {
172 ClassLoader classLoader = ParcelableConnection.class.getClassLoader();
173
174 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
175 int state = source.readInt();
176 int capabilities = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700177 Uri address = source.readParcelable(classLoader);
178 int addressPresentation = source.readInt();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700179 String callerDisplayName = source.readString();
180 int callerDisplayNamePresentation = source.readInt();
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700181 IVideoProvider videoCallProvider =
182 IVideoProvider.Stub.asInterface(source.readStrongBinder());
Santos Cordone8dc4be2014-07-21 01:28:28 -0700183 int videoState = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700184 boolean ringbackRequested = source.readByte() == 1;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700185 boolean audioModeIsVoip = source.readByte() == 1;
Roshan Piuse927ec02015-07-15 15:47:21 -0700186 long connectTimeMillis = source.readLong();
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700187 StatusHints statusHints = source.readParcelable(classLoader);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700188 DisconnectCause disconnectCause = source.readParcelable(classLoader);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700189 List<String> conferenceableConnectionIds = new ArrayList<>();
190 source.readStringList(conferenceableConnectionIds);
Jeff Sharkeyf0ec2e02016-03-21 12:37:54 -0600191 Bundle extras = Bundle.setDefusable(source.readBundle(classLoader), true);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700192
193 return new ParcelableConnection(
194 phoneAccount,
195 state,
196 capabilities,
Andrew Lee100e2932014-09-08 15:34:24 -0700197 address,
198 addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -0700199 callerDisplayName,
200 callerDisplayNamePresentation,
Andrew Lee50aca232014-07-22 16:41:54 -0700201 videoCallProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700202 videoState,
Andrew Lee100e2932014-09-08 15:34:24 -0700203 ringbackRequested,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700204 audioModeIsVoip,
Roshan Piuse927ec02015-07-15 15:47:21 -0700205 connectTimeMillis,
Ihab Awad6107bab2014-08-18 09:23:25 -0700206 statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700207 disconnectCause,
Santos Cordon6b7f9552015-05-27 17:21:45 -0700208 conferenceableConnectionIds,
209 extras);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700210 }
211
212 @Override
213 public ParcelableConnection[] newArray(int size) {
214 return new ParcelableConnection[size];
215 }
216 };
217
218 /** {@inheritDoc} */
219 @Override
220 public int describeContents() {
221 return 0;
222 }
223
224 /** Writes ParcelableConnection object into a Parcel. */
225 @Override
226 public void writeToParcel(Parcel destination, int flags) {
227 destination.writeParcelable(mPhoneAccount, 0);
228 destination.writeInt(mState);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800229 destination.writeInt(mConnectionCapabilities);
Andrew Lee100e2932014-09-08 15:34:24 -0700230 destination.writeParcelable(mAddress, 0);
231 destination.writeInt(mAddressPresentation);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700232 destination.writeString(mCallerDisplayName);
233 destination.writeInt(mCallerDisplayNamePresentation);
234 destination.writeStrongBinder(
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700235 mVideoProvider != null ? mVideoProvider.asBinder() : null);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700236 destination.writeInt(mVideoState);
Andrew Lee100e2932014-09-08 15:34:24 -0700237 destination.writeByte((byte) (mRingbackRequested ? 1 : 0));
238 destination.writeByte((byte) (mIsVoipAudioMode ? 1 : 0));
Roshan Piuse927ec02015-07-15 15:47:21 -0700239 destination.writeLong(mConnectTimeMillis);
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700240 destination.writeParcelable(mStatusHints, 0);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700241 destination.writeParcelable(mDisconnectCause, 0);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700242 destination.writeStringList(mConferenceableConnectionIds);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700243 destination.writeBundle(mExtras);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700244 }
245}