blob: 683ab6a638b7e6dd19ada49335e4d66b63598844 [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;
Ihab Awadb8e85c72014-08-23 20:34:57 -070047 private final StatusHints mStatusHints;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070048 private final DisconnectCause mDisconnectCause;
Ihab Awadb8e85c72014-08-23 20:34:57 -070049 private final List<String> mConferenceableConnectionIds;
Santos Cordon6b7f9552015-05-27 17:21:45 -070050 private final Bundle mExtras;
Santos Cordone8dc4be2014-07-21 01:28:28 -070051
52 /** @hide */
53 public ParcelableConnection(
54 PhoneAccountHandle phoneAccount,
55 int state,
56 int capabilities,
Andrew Lee100e2932014-09-08 15:34:24 -070057 Uri address,
58 int addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -070059 String callerDisplayName,
60 int callerDisplayNamePresentation,
Ihab Awadb19a0bc2014-08-07 19:46:01 -070061 IVideoProvider videoProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -070062 int videoState,
Andrew Lee100e2932014-09-08 15:34:24 -070063 boolean ringbackRequested,
64 boolean isVoipAudioMode,
Ihab Awad6107bab2014-08-18 09:23:25 -070065 StatusHints statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -070066 DisconnectCause disconnectCause,
Santos Cordon6b7f9552015-05-27 17:21:45 -070067 List<String> conferenceableConnectionIds,
68 Bundle extras) {
Santos Cordone8dc4be2014-07-21 01:28:28 -070069 mPhoneAccount = phoneAccount;
70 mState = state;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080071 mConnectionCapabilities = capabilities;
Andrew Lee100e2932014-09-08 15:34:24 -070072 mAddress = address;
73 mAddressPresentation = addressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -070074 mCallerDisplayName = callerDisplayName;
75 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070076 mVideoProvider = videoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -070077 mVideoState = videoState;
Andrew Lee100e2932014-09-08 15:34:24 -070078 mRingbackRequested = ringbackRequested;
79 mIsVoipAudioMode = isVoipAudioMode;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -070080 mStatusHints = statusHints;
Sailesh Nepalcf7020b2014-08-20 10:07:19 -070081 mDisconnectCause = disconnectCause;
Santos Cordon6b7f9552015-05-27 17:21:45 -070082 mConferenceableConnectionIds = conferenceableConnectionIds;
83 mExtras = extras;
Santos Cordone8dc4be2014-07-21 01:28:28 -070084 }
85
86 public PhoneAccountHandle getPhoneAccount() {
87 return mPhoneAccount;
88 }
89
90 public int getState() {
91 return mState;
92 }
93
94 // Bit mask of actions a call supports, values are defined in {@link CallCapabilities}.
Ihab Awad5c9c86e2014-11-12 13:41:16 -080095 public int getConnectionCapabilities() {
96 return mConnectionCapabilities;
Santos Cordone8dc4be2014-07-21 01:28:28 -070097 }
98
99 public Uri getHandle() {
Andrew Lee100e2932014-09-08 15:34:24 -0700100 return mAddress;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700101 }
102
103 public int getHandlePresentation() {
Andrew Lee100e2932014-09-08 15:34:24 -0700104 return mAddressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700105 }
106
107 public String getCallerDisplayName() {
108 return mCallerDisplayName;
109 }
110
111 public int getCallerDisplayNamePresentation() {
112 return mCallerDisplayNamePresentation;
113 }
114
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700115 public IVideoProvider getVideoProvider() {
116 return mVideoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700117 }
118
119 public int getVideoState() {
120 return mVideoState;
121 }
122
Andrew Lee100e2932014-09-08 15:34:24 -0700123 public boolean isRingbackRequested() {
124 return mRingbackRequested;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700125 }
126
Andrew Lee100e2932014-09-08 15:34:24 -0700127 public boolean getIsVoipAudioMode() {
128 return mIsVoipAudioMode;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700129 }
130
131 public final StatusHints getStatusHints() {
132 return mStatusHints;
133 }
134
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700135 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -0700136 return mDisconnectCause;
Ihab Awad6107bab2014-08-18 09:23:25 -0700137 }
138
Ihab Awadb8e85c72014-08-23 20:34:57 -0700139 public final List<String> getConferenceableConnectionIds() {
140 return mConferenceableConnectionIds;
141 }
142
Santos Cordon6b7f9552015-05-27 17:21:45 -0700143 public final Bundle getExtras() {
144 return mExtras;
145 }
146
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700147 @Override
148 public String toString() {
149 return new StringBuilder()
150 .append("ParcelableConnection [act:")
151 .append(mPhoneAccount)
Santos Cordon6b7f9552015-05-27 17:21:45 -0700152 .append("], state:")
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700153 .append(mState)
154 .append(", capabilities:")
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800155 .append(Connection.capabilitiesToString(mConnectionCapabilities))
Santos Cordon6b7f9552015-05-27 17:21:45 -0700156 .append(", extras:")
157 .append(mExtras)
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700158 .toString();
159 }
160
Santos Cordone8dc4be2014-07-21 01:28:28 -0700161 public static final Parcelable.Creator<ParcelableConnection> CREATOR =
162 new Parcelable.Creator<ParcelableConnection> () {
163 @Override
164 public ParcelableConnection createFromParcel(Parcel source) {
165 ClassLoader classLoader = ParcelableConnection.class.getClassLoader();
166
167 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
168 int state = source.readInt();
169 int capabilities = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700170 Uri address = source.readParcelable(classLoader);
171 int addressPresentation = source.readInt();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700172 String callerDisplayName = source.readString();
173 int callerDisplayNamePresentation = source.readInt();
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700174 IVideoProvider videoCallProvider =
175 IVideoProvider.Stub.asInterface(source.readStrongBinder());
Santos Cordone8dc4be2014-07-21 01:28:28 -0700176 int videoState = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700177 boolean ringbackRequested = source.readByte() == 1;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700178 boolean audioModeIsVoip = source.readByte() == 1;
179 StatusHints statusHints = source.readParcelable(classLoader);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700180 DisconnectCause disconnectCause = source.readParcelable(classLoader);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700181 List<String> conferenceableConnectionIds = new ArrayList<>();
182 source.readStringList(conferenceableConnectionIds);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700183 Bundle extras = source.readBundle(classLoader);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700184
185 return new ParcelableConnection(
186 phoneAccount,
187 state,
188 capabilities,
Andrew Lee100e2932014-09-08 15:34:24 -0700189 address,
190 addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -0700191 callerDisplayName,
192 callerDisplayNamePresentation,
Andrew Lee50aca232014-07-22 16:41:54 -0700193 videoCallProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700194 videoState,
Andrew Lee100e2932014-09-08 15:34:24 -0700195 ringbackRequested,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700196 audioModeIsVoip,
Ihab Awad6107bab2014-08-18 09:23:25 -0700197 statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700198 disconnectCause,
Santos Cordon6b7f9552015-05-27 17:21:45 -0700199 conferenceableConnectionIds,
200 extras);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700201 }
202
203 @Override
204 public ParcelableConnection[] newArray(int size) {
205 return new ParcelableConnection[size];
206 }
207 };
208
209 /** {@inheritDoc} */
210 @Override
211 public int describeContents() {
212 return 0;
213 }
214
215 /** Writes ParcelableConnection object into a Parcel. */
216 @Override
217 public void writeToParcel(Parcel destination, int flags) {
218 destination.writeParcelable(mPhoneAccount, 0);
219 destination.writeInt(mState);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800220 destination.writeInt(mConnectionCapabilities);
Andrew Lee100e2932014-09-08 15:34:24 -0700221 destination.writeParcelable(mAddress, 0);
222 destination.writeInt(mAddressPresentation);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700223 destination.writeString(mCallerDisplayName);
224 destination.writeInt(mCallerDisplayNamePresentation);
225 destination.writeStrongBinder(
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700226 mVideoProvider != null ? mVideoProvider.asBinder() : null);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700227 destination.writeInt(mVideoState);
Andrew Lee100e2932014-09-08 15:34:24 -0700228 destination.writeByte((byte) (mRingbackRequested ? 1 : 0));
229 destination.writeByte((byte) (mIsVoipAudioMode ? 1 : 0));
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700230 destination.writeParcelable(mStatusHints, 0);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700231 destination.writeParcelable(mDisconnectCause, 0);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700232 destination.writeStringList(mConferenceableConnectionIds);
Santos Cordon6b7f9552015-05-27 17:21:45 -0700233 destination.writeBundle(mExtras);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700234 }
235}