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