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; |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 39 | private final Uri mAddress; |
| 40 | private final int mAddressPresentation; |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 41 | private final String mCallerDisplayName; |
| 42 | private final int mCallerDisplayNamePresentation; |
| 43 | private final IVideoProvider mVideoProvider; |
| 44 | private final int mVideoState; |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 45 | private final boolean mRingbackRequested; |
| 46 | private final boolean mIsVoipAudioMode; |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 47 | private final long mConnectTimeMillis; |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 48 | private final StatusHints mStatusHints; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 49 | private final DisconnectCause mDisconnectCause; |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 50 | private final List<String> mConferenceableConnectionIds; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 51 | private final Bundle mExtras; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 52 | |
| 53 | /** @hide */ |
| 54 | public ParcelableConnection( |
| 55 | PhoneAccountHandle phoneAccount, |
| 56 | int state, |
| 57 | int capabilities, |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 58 | Uri address, |
| 59 | int addressPresentation, |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 60 | String callerDisplayName, |
| 61 | int callerDisplayNamePresentation, |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 62 | IVideoProvider videoProvider, |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 63 | int videoState, |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 64 | boolean ringbackRequested, |
| 65 | boolean isVoipAudioMode, |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 66 | long connectTimeMillis, |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 67 | StatusHints statusHints, |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 68 | DisconnectCause disconnectCause, |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 69 | List<String> conferenceableConnectionIds, |
| 70 | Bundle extras) { |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 71 | mPhoneAccount = phoneAccount; |
| 72 | mState = state; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 73 | mConnectionCapabilities = capabilities; |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 74 | mAddress = address; |
| 75 | mAddressPresentation = addressPresentation; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 76 | mCallerDisplayName = callerDisplayName; |
| 77 | mCallerDisplayNamePresentation = callerDisplayNamePresentation; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 78 | mVideoProvider = videoProvider; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 79 | mVideoState = videoState; |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 80 | mRingbackRequested = ringbackRequested; |
| 81 | mIsVoipAudioMode = isVoipAudioMode; |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 82 | mConnectTimeMillis = connectTimeMillis; |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 83 | mStatusHints = statusHints; |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 84 | mDisconnectCause = disconnectCause; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 85 | mConferenceableConnectionIds = conferenceableConnectionIds; |
| 86 | mExtras = extras; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 87 | } |
| 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 Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 98 | public int getConnectionCapabilities() { |
| 99 | return mConnectionCapabilities; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | public Uri getHandle() { |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 103 | return mAddress; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | public int getHandlePresentation() { |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 107 | return mAddressPresentation; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | public String getCallerDisplayName() { |
| 111 | return mCallerDisplayName; |
| 112 | } |
| 113 | |
| 114 | public int getCallerDisplayNamePresentation() { |
| 115 | return mCallerDisplayNamePresentation; |
| 116 | } |
| 117 | |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 118 | public IVideoProvider getVideoProvider() { |
| 119 | return mVideoProvider; |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | public int getVideoState() { |
| 123 | return mVideoState; |
| 124 | } |
| 125 | |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 126 | public boolean isRingbackRequested() { |
| 127 | return mRingbackRequested; |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 128 | } |
| 129 | |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 130 | public boolean getIsVoipAudioMode() { |
| 131 | return mIsVoipAudioMode; |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 134 | public long getConnectTimeMillis() { |
| 135 | return mConnectTimeMillis; |
| 136 | } |
| 137 | |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 138 | public final StatusHints getStatusHints() { |
| 139 | return mStatusHints; |
| 140 | } |
| 141 | |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 142 | public final DisconnectCause getDisconnectCause() { |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 143 | return mDisconnectCause; |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 146 | public final List<String> getConferenceableConnectionIds() { |
| 147 | return mConferenceableConnectionIds; |
| 148 | } |
| 149 | |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 150 | public final Bundle getExtras() { |
| 151 | return mExtras; |
| 152 | } |
| 153 | |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 154 | @Override |
| 155 | public String toString() { |
| 156 | return new StringBuilder() |
| 157 | .append("ParcelableConnection [act:") |
| 158 | .append(mPhoneAccount) |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 159 | .append("], state:") |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 160 | .append(mState) |
| 161 | .append(", capabilities:") |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 162 | .append(Connection.capabilitiesToString(mConnectionCapabilities)) |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 163 | .append(", extras:") |
| 164 | .append(mExtras) |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 165 | .toString(); |
| 166 | } |
| 167 | |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 168 | 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 Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 177 | Uri address = source.readParcelable(classLoader); |
| 178 | int addressPresentation = source.readInt(); |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 179 | String callerDisplayName = source.readString(); |
| 180 | int callerDisplayNamePresentation = source.readInt(); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 181 | IVideoProvider videoCallProvider = |
| 182 | IVideoProvider.Stub.asInterface(source.readStrongBinder()); |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 183 | int videoState = source.readInt(); |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 184 | boolean ringbackRequested = source.readByte() == 1; |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 185 | boolean audioModeIsVoip = source.readByte() == 1; |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 186 | long connectTimeMillis = source.readLong(); |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 187 | StatusHints statusHints = source.readParcelable(classLoader); |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 188 | DisconnectCause disconnectCause = source.readParcelable(classLoader); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 189 | List<String> conferenceableConnectionIds = new ArrayList<>(); |
| 190 | source.readStringList(conferenceableConnectionIds); |
Jeff Sharkey | f0ec2e0 | 2016-03-21 12:37:54 -0600 | [diff] [blame] | 191 | Bundle extras = Bundle.setDefusable(source.readBundle(classLoader), true); |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 192 | |
| 193 | return new ParcelableConnection( |
| 194 | phoneAccount, |
| 195 | state, |
| 196 | capabilities, |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 197 | address, |
| 198 | addressPresentation, |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 199 | callerDisplayName, |
| 200 | callerDisplayNamePresentation, |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 201 | videoCallProvider, |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 202 | videoState, |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 203 | ringbackRequested, |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 204 | audioModeIsVoip, |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 205 | connectTimeMillis, |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 206 | statusHints, |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 207 | disconnectCause, |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 208 | conferenceableConnectionIds, |
| 209 | extras); |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 210 | } |
| 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 Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 229 | destination.writeInt(mConnectionCapabilities); |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 230 | destination.writeParcelable(mAddress, 0); |
| 231 | destination.writeInt(mAddressPresentation); |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 232 | destination.writeString(mCallerDisplayName); |
| 233 | destination.writeInt(mCallerDisplayNamePresentation); |
| 234 | destination.writeStrongBinder( |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 235 | mVideoProvider != null ? mVideoProvider.asBinder() : null); |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 236 | destination.writeInt(mVideoState); |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 237 | destination.writeByte((byte) (mRingbackRequested ? 1 : 0)); |
| 238 | destination.writeByte((byte) (mIsVoipAudioMode ? 1 : 0)); |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 239 | destination.writeLong(mConnectTimeMillis); |
Sailesh Nepal | 8b9d3ca | 2014-08-14 17:39:34 -0700 | [diff] [blame] | 240 | destination.writeParcelable(mStatusHints, 0); |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 241 | destination.writeParcelable(mDisconnectCause, 0); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 242 | destination.writeStringList(mConferenceableConnectionIds); |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 243 | destination.writeBundle(mExtras); |
Santos Cordon | e8dc4be | 2014-07-21 01:28:28 -0700 | [diff] [blame] | 244 | } |
| 245 | } |