blob: b60b99da3bcda6d8d966df1a9acd1ffb6fe3bd7d [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;
20import android.os.Parcel;
21import android.os.Parcelable;
22
Tyler Gunnef9f6f92014-09-12 22:16:17 -070023import com.android.internal.telecom.IVideoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -070024
Ihab Awadb8e85c72014-08-23 20:34:57 -070025import java.util.ArrayList;
26import java.util.List;
27
Santos Cordone8dc4be2014-07-21 01:28:28 -070028/**
Tyler Gunnef9f6f92014-09-12 22:16:17 -070029 * Information about a connection that is used between Telecom and the ConnectionService.
30 * This is used to send initial Connection information to Telecom when the connection is
Santos Cordone8dc4be2014-07-21 01:28:28 -070031 * first created.
32 * @hide
33 */
34public final class ParcelableConnection implements Parcelable {
Ihab Awadb8e85c72014-08-23 20:34:57 -070035 private final PhoneAccountHandle mPhoneAccount;
36 private final int mState;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080037 private final int mConnectionCapabilities;
Andrew Lee100e2932014-09-08 15:34:24 -070038 private final Uri mAddress;
39 private final int mAddressPresentation;
Ihab Awadb8e85c72014-08-23 20:34:57 -070040 private final String mCallerDisplayName;
41 private final int mCallerDisplayNamePresentation;
42 private final IVideoProvider mVideoProvider;
43 private final int mVideoState;
Andrew Lee100e2932014-09-08 15:34:24 -070044 private final boolean mRingbackRequested;
45 private final boolean mIsVoipAudioMode;
Ihab Awadb8e85c72014-08-23 20:34:57 -070046 private final StatusHints mStatusHints;
Andrew Lee7f3d41f2014-09-11 17:33:16 -070047 private final DisconnectCause mDisconnectCause;
Ihab Awadb8e85c72014-08-23 20:34:57 -070048 private final List<String> mConferenceableConnectionIds;
Rekha Kumar07366812015-03-24 16:42:31 -070049 private final int mCallSubstate;
Santos Cordone8dc4be2014-07-21 01:28:28 -070050
51 /** @hide */
52 public ParcelableConnection(
53 PhoneAccountHandle phoneAccount,
54 int state,
55 int capabilities,
Andrew Lee100e2932014-09-08 15:34:24 -070056 Uri address,
57 int addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -070058 String callerDisplayName,
59 int callerDisplayNamePresentation,
Ihab Awadb19a0bc2014-08-07 19:46:01 -070060 IVideoProvider videoProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -070061 int videoState,
Andrew Lee100e2932014-09-08 15:34:24 -070062 boolean ringbackRequested,
63 boolean isVoipAudioMode,
Ihab Awad6107bab2014-08-18 09:23:25 -070064 StatusHints statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -070065 DisconnectCause disconnectCause,
Rekha Kumar07366812015-03-24 16:42:31 -070066 List<String> conferenceableConnectionIds,
67 int callSubstate) {
Santos Cordone8dc4be2014-07-21 01:28:28 -070068 mPhoneAccount = phoneAccount;
69 mState = state;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080070 mConnectionCapabilities = capabilities;
Andrew Lee100e2932014-09-08 15:34:24 -070071 mAddress = address;
72 mAddressPresentation = addressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -070073 mCallerDisplayName = callerDisplayName;
74 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070075 mVideoProvider = videoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -070076 mVideoState = videoState;
Andrew Lee100e2932014-09-08 15:34:24 -070077 mRingbackRequested = ringbackRequested;
78 mIsVoipAudioMode = isVoipAudioMode;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -070079 mStatusHints = statusHints;
Sailesh Nepalcf7020b2014-08-20 10:07:19 -070080 mDisconnectCause = disconnectCause;
Ihab Awadb8e85c72014-08-23 20:34:57 -070081 this.mConferenceableConnectionIds = conferenceableConnectionIds;
Rekha Kumar07366812015-03-24 16:42:31 -070082 mCallSubstate = callSubstate;
Santos Cordone8dc4be2014-07-21 01:28:28 -070083 }
84
85 public PhoneAccountHandle getPhoneAccount() {
86 return mPhoneAccount;
87 }
88
89 public int getState() {
90 return mState;
91 }
92
93 // Bit mask of actions a call supports, values are defined in {@link CallCapabilities}.
Ihab Awad5c9c86e2014-11-12 13:41:16 -080094 public int getConnectionCapabilities() {
95 return mConnectionCapabilities;
Santos Cordone8dc4be2014-07-21 01:28:28 -070096 }
97
98 public Uri getHandle() {
Andrew Lee100e2932014-09-08 15:34:24 -070099 return mAddress;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700100 }
101
102 public int getHandlePresentation() {
Andrew Lee100e2932014-09-08 15:34:24 -0700103 return mAddressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700104 }
105
106 public String getCallerDisplayName() {
107 return mCallerDisplayName;
108 }
109
110 public int getCallerDisplayNamePresentation() {
111 return mCallerDisplayNamePresentation;
112 }
113
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700114 public IVideoProvider getVideoProvider() {
115 return mVideoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700116 }
117
118 public int getVideoState() {
119 return mVideoState;
120 }
121
Andrew Lee100e2932014-09-08 15:34:24 -0700122 public boolean isRingbackRequested() {
123 return mRingbackRequested;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700124 }
125
Andrew Lee100e2932014-09-08 15:34:24 -0700126 public boolean getIsVoipAudioMode() {
127 return mIsVoipAudioMode;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700128 }
129
130 public final StatusHints getStatusHints() {
131 return mStatusHints;
132 }
133
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700134 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -0700135 return mDisconnectCause;
Ihab Awad6107bab2014-08-18 09:23:25 -0700136 }
137
Ihab Awadb8e85c72014-08-23 20:34:57 -0700138 public final List<String> getConferenceableConnectionIds() {
139 return mConferenceableConnectionIds;
140 }
141
Rekha Kumar07366812015-03-24 16:42:31 -0700142 public int getCallSubstate() {
143 return mCallSubstate;
144 }
145
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700146 @Override
147 public String toString() {
148 return new StringBuilder()
149 .append("ParcelableConnection [act:")
150 .append(mPhoneAccount)
151 .append(", state:")
152 .append(mState)
153 .append(", capabilities:")
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800154 .append(Connection.capabilitiesToString(mConnectionCapabilities))
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700155 .toString();
156 }
157
Santos Cordone8dc4be2014-07-21 01:28:28 -0700158 public static final Parcelable.Creator<ParcelableConnection> CREATOR =
159 new Parcelable.Creator<ParcelableConnection> () {
160 @Override
161 public ParcelableConnection createFromParcel(Parcel source) {
162 ClassLoader classLoader = ParcelableConnection.class.getClassLoader();
163
164 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
165 int state = source.readInt();
166 int capabilities = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700167 Uri address = source.readParcelable(classLoader);
168 int addressPresentation = source.readInt();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700169 String callerDisplayName = source.readString();
170 int callerDisplayNamePresentation = source.readInt();
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700171 IVideoProvider videoCallProvider =
172 IVideoProvider.Stub.asInterface(source.readStrongBinder());
Santos Cordone8dc4be2014-07-21 01:28:28 -0700173 int videoState = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700174 boolean ringbackRequested = source.readByte() == 1;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700175 boolean audioModeIsVoip = source.readByte() == 1;
176 StatusHints statusHints = source.readParcelable(classLoader);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700177 DisconnectCause disconnectCause = source.readParcelable(classLoader);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700178 List<String> conferenceableConnectionIds = new ArrayList<>();
179 source.readStringList(conferenceableConnectionIds);
Rekha Kumar07366812015-03-24 16:42:31 -0700180 int callSubstate = source.readInt();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700181
182 return new ParcelableConnection(
183 phoneAccount,
184 state,
185 capabilities,
Andrew Lee100e2932014-09-08 15:34:24 -0700186 address,
187 addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -0700188 callerDisplayName,
189 callerDisplayNamePresentation,
Andrew Lee50aca232014-07-22 16:41:54 -0700190 videoCallProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700191 videoState,
Andrew Lee100e2932014-09-08 15:34:24 -0700192 ringbackRequested,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700193 audioModeIsVoip,
Ihab Awad6107bab2014-08-18 09:23:25 -0700194 statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700195 disconnectCause,
Rekha Kumar07366812015-03-24 16:42:31 -0700196 conferenceableConnectionIds,
197 callSubstate);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700198 }
199
200 @Override
201 public ParcelableConnection[] newArray(int size) {
202 return new ParcelableConnection[size];
203 }
204 };
205
206 /** {@inheritDoc} */
207 @Override
208 public int describeContents() {
209 return 0;
210 }
211
212 /** Writes ParcelableConnection object into a Parcel. */
213 @Override
214 public void writeToParcel(Parcel destination, int flags) {
215 destination.writeParcelable(mPhoneAccount, 0);
216 destination.writeInt(mState);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800217 destination.writeInt(mConnectionCapabilities);
Andrew Lee100e2932014-09-08 15:34:24 -0700218 destination.writeParcelable(mAddress, 0);
219 destination.writeInt(mAddressPresentation);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700220 destination.writeString(mCallerDisplayName);
221 destination.writeInt(mCallerDisplayNamePresentation);
222 destination.writeStrongBinder(
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700223 mVideoProvider != null ? mVideoProvider.asBinder() : null);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700224 destination.writeInt(mVideoState);
Andrew Lee100e2932014-09-08 15:34:24 -0700225 destination.writeByte((byte) (mRingbackRequested ? 1 : 0));
226 destination.writeByte((byte) (mIsVoipAudioMode ? 1 : 0));
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700227 destination.writeParcelable(mStatusHints, 0);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700228 destination.writeParcelable(mDisconnectCause, 0);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700229 destination.writeStringList(mConferenceableConnectionIds);
Rekha Kumar07366812015-03-24 16:42:31 -0700230 destination.writeInt(mCallSubstate);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700231 }
232}