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