Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 1 | /* |
| 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 Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 17 | package android.telecom; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 18 | |
| 19 | import android.net.Uri; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 20 | import android.os.Bundle; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 21 | import android.os.Parcel; |
| 22 | import android.os.Parcelable; |
| 23 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 24 | import com.android.internal.telecom.IVideoProvider; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 25 | |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 26 | import java.util.ArrayList; |
| 27 | import java.util.List; |
| 28 | |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 29 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 30 | * 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 Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 32 | * first created. |
| 33 | * @hide |
| 34 | */ |
| 35 | public final class ParcelableConnection implements Parcelable { |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 36 | private final PhoneAccountHandle mPhoneAccount; |
| 37 | private final int mState; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 38 | private final int mConnectionCapabilities; |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 39 | private final int mConnectionProperties; |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 40 | private final Uri mAddress; |
| 41 | private final int mAddressPresentation; |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 42 | private final String mCallerDisplayName; |
| 43 | private final int mCallerDisplayNamePresentation; |
| 44 | private final IVideoProvider mVideoProvider; |
| 45 | private final int mVideoState; |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 46 | private final boolean mRingbackRequested; |
| 47 | private final boolean mIsVoipAudioMode; |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 48 | private final long mConnectTimeMillis; |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 49 | private final StatusHints mStatusHints; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 50 | private final DisconnectCause mDisconnectCause; |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 51 | private final List<String> mConferenceableConnectionIds; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 52 | private final Bundle mExtras; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 53 | |
| 54 | /** @hide */ |
| 55 | public ParcelableConnection( |
| 56 | PhoneAccountHandle phoneAccount, |
| 57 | int state, |
| 58 | int capabilities, |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 59 | int properties, |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 60 | Uri address, |
| 61 | int addressPresentation, |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 62 | String callerDisplayName, |
| 63 | int callerDisplayNamePresentation, |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 64 | IVideoProvider videoProvider, |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 65 | int videoState, |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 66 | boolean ringbackRequested, |
| 67 | boolean isVoipAudioMode, |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 68 | long connectTimeMillis, |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 69 | StatusHints statusHints, |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 70 | DisconnectCause disconnectCause, |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 71 | List<String> conferenceableConnectionIds, |
| 72 | Bundle extras) { |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 73 | mPhoneAccount = phoneAccount; |
| 74 | mState = state; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 75 | mConnectionCapabilities = capabilities; |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 76 | mConnectionProperties = properties; |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 77 | mAddress = address; |
| 78 | mAddressPresentation = addressPresentation; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 79 | mCallerDisplayName = callerDisplayName; |
| 80 | mCallerDisplayNamePresentation = callerDisplayNamePresentation; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 81 | mVideoProvider = videoProvider; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 82 | mVideoState = videoState; |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 83 | mRingbackRequested = ringbackRequested; |
| 84 | mIsVoipAudioMode = isVoipAudioMode; |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 85 | mConnectTimeMillis = connectTimeMillis; |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 86 | mStatusHints = statusHints; |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 87 | mDisconnectCause = disconnectCause; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 88 | mConferenceableConnectionIds = conferenceableConnectionIds; |
| 89 | mExtras = extras; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | public PhoneAccountHandle getPhoneAccount() { |
| 93 | return mPhoneAccount; |
| 94 | } |
| 95 | |
| 96 | public int getState() { |
| 97 | return mState; |
| 98 | } |
| 99 | |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 100 | /** |
| 101 | * Returns the current connection capabilities bit-mask. Connection capabilities are defined as |
| 102 | * {@code CAPABILITY_*} constants in {@link Connection}. |
| 103 | * |
| 104 | * @return Bit-mask containing capabilities of the connection. |
| 105 | */ |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 106 | public int getConnectionCapabilities() { |
| 107 | return mConnectionCapabilities; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 108 | } |
| 109 | |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 110 | /** |
| 111 | * Returns the current connection properties bit-mask. Connection properties are defined as |
| 112 | * {@code PROPERTY_*} constants in {@link Connection}. |
| 113 | * |
| 114 | * @return Bit-mask containing properties of the connection. |
| 115 | */ |
| 116 | public int getConnectionProperties() { |
| 117 | return mConnectionProperties; |
| 118 | } |
| 119 | |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 120 | public Uri getHandle() { |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 121 | return mAddress; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | public int getHandlePresentation() { |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 125 | return mAddressPresentation; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | public String getCallerDisplayName() { |
| 129 | return mCallerDisplayName; |
| 130 | } |
| 131 | |
| 132 | public int getCallerDisplayNamePresentation() { |
| 133 | return mCallerDisplayNamePresentation; |
| 134 | } |
| 135 | |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 136 | public IVideoProvider getVideoProvider() { |
| 137 | return mVideoProvider; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | public int getVideoState() { |
| 141 | return mVideoState; |
| 142 | } |
| 143 | |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 144 | public boolean isRingbackRequested() { |
| 145 | return mRingbackRequested; |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 146 | } |
| 147 | |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 148 | public boolean getIsVoipAudioMode() { |
| 149 | return mIsVoipAudioMode; |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 150 | } |
| 151 | |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 152 | public long getConnectTimeMillis() { |
| 153 | return mConnectTimeMillis; |
| 154 | } |
| 155 | |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 156 | public final StatusHints getStatusHints() { |
| 157 | return mStatusHints; |
| 158 | } |
| 159 | |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 160 | public final DisconnectCause getDisconnectCause() { |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 161 | return mDisconnectCause; |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 162 | } |
| 163 | |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 164 | public final List<String> getConferenceableConnectionIds() { |
| 165 | return mConferenceableConnectionIds; |
| 166 | } |
| 167 | |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 168 | public final Bundle getExtras() { |
| 169 | return mExtras; |
| 170 | } |
| 171 | |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 172 | @Override |
| 173 | public String toString() { |
| 174 | return new StringBuilder() |
| 175 | .append("ParcelableConnection [act:") |
| 176 | .append(mPhoneAccount) |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 177 | .append("], state:") |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 178 | .append(mState) |
| 179 | .append(", capabilities:") |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 180 | .append(Connection.capabilitiesToString(mConnectionCapabilities)) |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 181 | .append(", properties:") |
| 182 | .append(Connection.propertiesToString(mConnectionProperties)) |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 183 | .append(", extras:") |
| 184 | .append(mExtras) |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 185 | .toString(); |
| 186 | } |
| 187 | |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 188 | public static final Parcelable.Creator<ParcelableConnection> CREATOR = |
| 189 | new Parcelable.Creator<ParcelableConnection> () { |
| 190 | @Override |
| 191 | public ParcelableConnection createFromParcel(Parcel source) { |
| 192 | ClassLoader classLoader = ParcelableConnection.class.getClassLoader(); |
| 193 | |
| 194 | PhoneAccountHandle phoneAccount = source.readParcelable(classLoader); |
| 195 | int state = source.readInt(); |
| 196 | int capabilities = source.readInt(); |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 197 | Uri address = source.readParcelable(classLoader); |
| 198 | int addressPresentation = source.readInt(); |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 199 | String callerDisplayName = source.readString(); |
| 200 | int callerDisplayNamePresentation = source.readInt(); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 201 | IVideoProvider videoCallProvider = |
| 202 | IVideoProvider.Stub.asInterface(source.readStrongBinder()); |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 203 | int videoState = source.readInt(); |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 204 | boolean ringbackRequested = source.readByte() == 1; |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 205 | boolean audioModeIsVoip = source.readByte() == 1; |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 206 | long connectTimeMillis = source.readLong(); |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 207 | StatusHints statusHints = source.readParcelable(classLoader); |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 208 | DisconnectCause disconnectCause = source.readParcelable(classLoader); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 209 | List<String> conferenceableConnectionIds = new ArrayList<>(); |
| 210 | source.readStringList(conferenceableConnectionIds); |
Jeff Sharkey | f0ec2e0 | 2016-03-21 12:37:54 -0600 | [diff] [blame] | 211 | Bundle extras = Bundle.setDefusable(source.readBundle(classLoader), true); |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 212 | int properties = source.readInt(); |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 213 | |
| 214 | return new ParcelableConnection( |
| 215 | phoneAccount, |
| 216 | state, |
| 217 | capabilities, |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 218 | properties, |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 219 | address, |
| 220 | addressPresentation, |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 221 | callerDisplayName, |
| 222 | callerDisplayNamePresentation, |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 223 | videoCallProvider, |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 224 | videoState, |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 225 | ringbackRequested, |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 226 | audioModeIsVoip, |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 227 | connectTimeMillis, |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 228 | statusHints, |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 229 | disconnectCause, |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 230 | conferenceableConnectionIds, |
| 231 | extras); |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | @Override |
| 235 | public ParcelableConnection[] newArray(int size) { |
| 236 | return new ParcelableConnection[size]; |
| 237 | } |
| 238 | }; |
| 239 | |
| 240 | /** {@inheritDoc} */ |
| 241 | @Override |
| 242 | public int describeContents() { |
| 243 | return 0; |
| 244 | } |
| 245 | |
| 246 | /** Writes ParcelableConnection object into a Parcel. */ |
| 247 | @Override |
| 248 | public void writeToParcel(Parcel destination, int flags) { |
| 249 | destination.writeParcelable(mPhoneAccount, 0); |
| 250 | destination.writeInt(mState); |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 251 | destination.writeInt(mConnectionCapabilities); |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 252 | destination.writeParcelable(mAddress, 0); |
| 253 | destination.writeInt(mAddressPresentation); |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 254 | destination.writeString(mCallerDisplayName); |
| 255 | destination.writeInt(mCallerDisplayNamePresentation); |
| 256 | destination.writeStrongBinder( |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 257 | mVideoProvider != null ? mVideoProvider.asBinder() : null); |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 258 | destination.writeInt(mVideoState); |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 259 | destination.writeByte((byte) (mRingbackRequested ? 1 : 0)); |
| 260 | destination.writeByte((byte) (mIsVoipAudioMode ? 1 : 0)); |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 261 | destination.writeLong(mConnectTimeMillis); |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 262 | destination.writeParcelable(mStatusHints, 0); |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 263 | destination.writeParcelable(mDisconnectCause, 0); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 264 | destination.writeStringList(mConferenceableConnectionIds); |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 265 | destination.writeBundle(mExtras); |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 266 | destination.writeInt(mConnectionProperties); |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 267 | } |
| 268 | } |