blob: 552e2503166dd1d201098afdf3d4febfe185554a [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;
Santos Cordone8dc4be2014-07-21 01:28:28 -070049
50 /** @hide */
51 public ParcelableConnection(
52 PhoneAccountHandle phoneAccount,
53 int state,
54 int capabilities,
Andrew Lee100e2932014-09-08 15:34:24 -070055 Uri address,
56 int addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -070057 String callerDisplayName,
58 int callerDisplayNamePresentation,
Ihab Awadb19a0bc2014-08-07 19:46:01 -070059 IVideoProvider videoProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -070060 int videoState,
Andrew Lee100e2932014-09-08 15:34:24 -070061 boolean ringbackRequested,
62 boolean isVoipAudioMode,
Ihab Awad6107bab2014-08-18 09:23:25 -070063 StatusHints statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -070064 DisconnectCause disconnectCause,
Jay Shrauner8f988432015-04-16 12:52:19 -070065 List<String> conferenceableConnectionIds) {
Santos Cordone8dc4be2014-07-21 01:28:28 -070066 mPhoneAccount = phoneAccount;
67 mState = state;
Ihab Awad5c9c86e2014-11-12 13:41:16 -080068 mConnectionCapabilities = capabilities;
Andrew Lee100e2932014-09-08 15:34:24 -070069 mAddress = address;
70 mAddressPresentation = addressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -070071 mCallerDisplayName = callerDisplayName;
72 mCallerDisplayNamePresentation = callerDisplayNamePresentation;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070073 mVideoProvider = videoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -070074 mVideoState = videoState;
Andrew Lee100e2932014-09-08 15:34:24 -070075 mRingbackRequested = ringbackRequested;
76 mIsVoipAudioMode = isVoipAudioMode;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -070077 mStatusHints = statusHints;
Sailesh Nepalcf7020b2014-08-20 10:07:19 -070078 mDisconnectCause = disconnectCause;
Ihab Awadb8e85c72014-08-23 20:34:57 -070079 this.mConferenceableConnectionIds = conferenceableConnectionIds;
Santos Cordone8dc4be2014-07-21 01:28:28 -070080 }
81
82 public PhoneAccountHandle getPhoneAccount() {
83 return mPhoneAccount;
84 }
85
86 public int getState() {
87 return mState;
88 }
89
90 // Bit mask of actions a call supports, values are defined in {@link CallCapabilities}.
Ihab Awad5c9c86e2014-11-12 13:41:16 -080091 public int getConnectionCapabilities() {
92 return mConnectionCapabilities;
Santos Cordone8dc4be2014-07-21 01:28:28 -070093 }
94
95 public Uri getHandle() {
Andrew Lee100e2932014-09-08 15:34:24 -070096 return mAddress;
Santos Cordone8dc4be2014-07-21 01:28:28 -070097 }
98
99 public int getHandlePresentation() {
Andrew Lee100e2932014-09-08 15:34:24 -0700100 return mAddressPresentation;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700101 }
102
103 public String getCallerDisplayName() {
104 return mCallerDisplayName;
105 }
106
107 public int getCallerDisplayNamePresentation() {
108 return mCallerDisplayNamePresentation;
109 }
110
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700111 public IVideoProvider getVideoProvider() {
112 return mVideoProvider;
Santos Cordone8dc4be2014-07-21 01:28:28 -0700113 }
114
115 public int getVideoState() {
116 return mVideoState;
117 }
118
Andrew Lee100e2932014-09-08 15:34:24 -0700119 public boolean isRingbackRequested() {
120 return mRingbackRequested;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700121 }
122
Andrew Lee100e2932014-09-08 15:34:24 -0700123 public boolean getIsVoipAudioMode() {
124 return mIsVoipAudioMode;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700125 }
126
127 public final StatusHints getStatusHints() {
128 return mStatusHints;
129 }
130
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700131 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -0700132 return mDisconnectCause;
Ihab Awad6107bab2014-08-18 09:23:25 -0700133 }
134
Ihab Awadb8e85c72014-08-23 20:34:57 -0700135 public final List<String> getConferenceableConnectionIds() {
136 return mConferenceableConnectionIds;
137 }
138
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700139 @Override
140 public String toString() {
141 return new StringBuilder()
142 .append("ParcelableConnection [act:")
143 .append(mPhoneAccount)
144 .append(", state:")
145 .append(mState)
146 .append(", capabilities:")
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800147 .append(Connection.capabilitiesToString(mConnectionCapabilities))
Santos Cordon7c7bc7f2014-07-28 18:15:48 -0700148 .toString();
149 }
150
Santos Cordone8dc4be2014-07-21 01:28:28 -0700151 public static final Parcelable.Creator<ParcelableConnection> CREATOR =
152 new Parcelable.Creator<ParcelableConnection> () {
153 @Override
154 public ParcelableConnection createFromParcel(Parcel source) {
155 ClassLoader classLoader = ParcelableConnection.class.getClassLoader();
156
157 PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
158 int state = source.readInt();
159 int capabilities = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700160 Uri address = source.readParcelable(classLoader);
161 int addressPresentation = source.readInt();
Santos Cordone8dc4be2014-07-21 01:28:28 -0700162 String callerDisplayName = source.readString();
163 int callerDisplayNamePresentation = source.readInt();
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700164 IVideoProvider videoCallProvider =
165 IVideoProvider.Stub.asInterface(source.readStrongBinder());
Santos Cordone8dc4be2014-07-21 01:28:28 -0700166 int videoState = source.readInt();
Andrew Lee100e2932014-09-08 15:34:24 -0700167 boolean ringbackRequested = source.readByte() == 1;
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700168 boolean audioModeIsVoip = source.readByte() == 1;
169 StatusHints statusHints = source.readParcelable(classLoader);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700170 DisconnectCause disconnectCause = source.readParcelable(classLoader);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700171 List<String> conferenceableConnectionIds = new ArrayList<>();
172 source.readStringList(conferenceableConnectionIds);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700173
174 return new ParcelableConnection(
175 phoneAccount,
176 state,
177 capabilities,
Andrew Lee100e2932014-09-08 15:34:24 -0700178 address,
179 addressPresentation,
Santos Cordone8dc4be2014-07-21 01:28:28 -0700180 callerDisplayName,
181 callerDisplayNamePresentation,
Andrew Lee50aca232014-07-22 16:41:54 -0700182 videoCallProvider,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700183 videoState,
Andrew Lee100e2932014-09-08 15:34:24 -0700184 ringbackRequested,
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700185 audioModeIsVoip,
Ihab Awad6107bab2014-08-18 09:23:25 -0700186 statusHints,
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700187 disconnectCause,
Jay Shrauner8f988432015-04-16 12:52:19 -0700188 conferenceableConnectionIds);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700189 }
190
191 @Override
192 public ParcelableConnection[] newArray(int size) {
193 return new ParcelableConnection[size];
194 }
195 };
196
197 /** {@inheritDoc} */
198 @Override
199 public int describeContents() {
200 return 0;
201 }
202
203 /** Writes ParcelableConnection object into a Parcel. */
204 @Override
205 public void writeToParcel(Parcel destination, int flags) {
206 destination.writeParcelable(mPhoneAccount, 0);
207 destination.writeInt(mState);
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800208 destination.writeInt(mConnectionCapabilities);
Andrew Lee100e2932014-09-08 15:34:24 -0700209 destination.writeParcelable(mAddress, 0);
210 destination.writeInt(mAddressPresentation);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700211 destination.writeString(mCallerDisplayName);
212 destination.writeInt(mCallerDisplayNamePresentation);
213 destination.writeStrongBinder(
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700214 mVideoProvider != null ? mVideoProvider.asBinder() : null);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700215 destination.writeInt(mVideoState);
Andrew Lee100e2932014-09-08 15:34:24 -0700216 destination.writeByte((byte) (mRingbackRequested ? 1 : 0));
217 destination.writeByte((byte) (mIsVoipAudioMode ? 1 : 0));
Sailesh Nepal8b9d3ca2014-08-14 17:39:34 -0700218 destination.writeParcelable(mStatusHints, 0);
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700219 destination.writeParcelable(mDisconnectCause, 0);
Ihab Awadb8e85c72014-08-23 20:34:57 -0700220 destination.writeStringList(mConferenceableConnectionIds);
Santos Cordone8dc4be2014-07-21 01:28:28 -0700221 }
222}