Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -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 | |
| 17 | package android.telecomm; |
| 18 | |
| 19 | import android.net.Uri; |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 20 | import android.os.Parcel; |
| 21 | import android.os.Parcelable; |
Andrew Lee | 5dc3075 | 2014-06-27 17:02:19 -0700 | [diff] [blame] | 22 | import android.os.RemoteException; |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 23 | import android.telephony.DisconnectCause; |
| 24 | |
Andrew Lee | 5dc3075 | 2014-06-27 17:02:19 -0700 | [diff] [blame] | 25 | import com.android.internal.telecomm.ICallVideoProvider; |
| 26 | |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 27 | import java.util.ArrayList; |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 28 | import java.util.List; |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 29 | |
| 30 | /** |
| 31 | * Information about a call that is used between InCallService and Telecomm. |
| 32 | */ |
| 33 | public final class InCallCall implements Parcelable { |
| 34 | private final String mId; |
| 35 | private final CallState mState; |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 36 | private final int mDisconnectCauseCode; |
| 37 | private final String mDisconnectCauseMsg; |
Ihab Awad | c067754 | 2014-06-10 13:29:47 -0700 | [diff] [blame] | 38 | private final List<String> mCannedSmsResponses; |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 39 | private final int mCapabilities; |
| 40 | private final long mConnectTimeMillis; |
| 41 | private final Uri mHandle; |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 42 | private final int mHandlePresentation; |
| 43 | private final String mCallerDisplayName; |
| 44 | private final int mCallerDisplayNamePresentation; |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 45 | private final GatewayInfo mGatewayInfo; |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame^] | 46 | private final PhoneAccountHandle mAccount; |
Andrew Lee | 5dc3075 | 2014-06-27 17:02:19 -0700 | [diff] [blame] | 47 | private final ICallVideoProvider mCallVideoProvider; |
| 48 | private RemoteCallVideoProvider mRemoteCallVideoProvider; |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 49 | private final String mParentCallId; |
| 50 | private final List<String> mChildCallIds; |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 51 | private final StatusHints mStatusHints; |
Andrew Lee | 85f5d42 | 2014-07-11 17:22:03 -0700 | [diff] [blame] | 52 | private final int mVideoState; |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 53 | |
| 54 | /** @hide */ |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 55 | public InCallCall( |
| 56 | String id, |
| 57 | CallState state, |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 58 | int disconnectCauseCode, |
| 59 | String disconnectCauseMsg, |
Ihab Awad | c067754 | 2014-06-10 13:29:47 -0700 | [diff] [blame] | 60 | List<String> cannedSmsResponses, |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 61 | int capabilities, |
| 62 | long connectTimeMillis, |
| 63 | Uri handle, |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 64 | int handlePresentation, |
| 65 | String callerDisplayName, |
| 66 | int callerDisplayNamePresentation, |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 67 | GatewayInfo gatewayInfo, |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame^] | 68 | PhoneAccountHandle account, |
Andrew Lee | 5dc3075 | 2014-06-27 17:02:19 -0700 | [diff] [blame] | 69 | ICallVideoProvider callVideoProvider, |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 70 | String parentCallId, |
Tyler Gunn | 8d83fa9 | 2014-07-01 11:31:21 -0700 | [diff] [blame] | 71 | List<String> childCallIds, |
Andrew Lee | 85f5d42 | 2014-07-11 17:22:03 -0700 | [diff] [blame] | 72 | StatusHints statusHints, |
| 73 | int videoState) { |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 74 | mId = id; |
| 75 | mState = state; |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 76 | mDisconnectCauseCode = disconnectCauseCode; |
| 77 | mDisconnectCauseMsg = disconnectCauseMsg; |
Ihab Awad | c067754 | 2014-06-10 13:29:47 -0700 | [diff] [blame] | 78 | mCannedSmsResponses = cannedSmsResponses; |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 79 | mCapabilities = capabilities; |
| 80 | mConnectTimeMillis = connectTimeMillis; |
| 81 | mHandle = handle; |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 82 | mHandlePresentation = handlePresentation; |
| 83 | mCallerDisplayName = callerDisplayName; |
| 84 | mCallerDisplayNamePresentation = callerDisplayNamePresentation; |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 85 | mGatewayInfo = gatewayInfo; |
Sailesh Nepal | 2bed956 | 2014-07-02 21:26:12 -0700 | [diff] [blame] | 86 | mAccount = account; |
Andrew Lee | 5dc3075 | 2014-06-27 17:02:19 -0700 | [diff] [blame] | 87 | mCallVideoProvider = callVideoProvider; |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 88 | mParentCallId = parentCallId; |
| 89 | mChildCallIds = childCallIds; |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 90 | mStatusHints = statusHints; |
Andrew Lee | 85f5d42 | 2014-07-11 17:22:03 -0700 | [diff] [blame] | 91 | mVideoState = videoState; |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | /** The unique ID of the call. */ |
| 95 | public String getId() { |
| 96 | return mId; |
| 97 | } |
| 98 | |
| 99 | /** The current state of the call. */ |
| 100 | public CallState getState() { |
| 101 | return mState; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Reason for disconnection, values are defined in {@link DisconnectCause}. Valid when call |
Sailesh Nepal | c1a48ef | 2014-04-08 14:32:20 -0700 | [diff] [blame] | 106 | * state is {@link CallState#DISCONNECTED}. |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 107 | */ |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 108 | public int getDisconnectCauseCode() { |
| 109 | return mDisconnectCauseCode; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Further optional textual information about the reason for disconnection. Valid when call |
| 114 | * state is {@link CallState#DISCONNECTED}. |
| 115 | */ |
| 116 | public String getDisconnectCauseMsg() { |
| 117 | return mDisconnectCauseMsg; |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 118 | } |
| 119 | |
Ihab Awad | c067754 | 2014-06-10 13:29:47 -0700 | [diff] [blame] | 120 | /** |
| 121 | * The set of possible text message responses when this call is incoming. |
| 122 | */ |
| 123 | public List<String> getCannedSmsResponses() { |
| 124 | return mCannedSmsResponses; |
| 125 | } |
| 126 | |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 127 | // Bit mask of actions a call supports, values are defined in {@link CallCapabilities}. |
| 128 | public int getCapabilities() { |
| 129 | return mCapabilities; |
| 130 | } |
| 131 | |
| 132 | /** The time that the call switched to the active state. */ |
| 133 | public long getConnectTimeMillis() { |
| 134 | return mConnectTimeMillis; |
| 135 | } |
| 136 | |
| 137 | /** The endpoint to which the call is connected. */ |
| 138 | public Uri getHandle() { |
| 139 | return mHandle; |
| 140 | } |
| 141 | |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 142 | /** The {@link CallPropertyPresentation} which controls how the handle is shown. */ |
| 143 | public int getHandlePresentation() { |
| 144 | return mHandlePresentation; |
| 145 | } |
| 146 | |
| 147 | /** The endpoint to which the call is connected. */ |
| 148 | public String getCallerDisplayName() { |
| 149 | return mCallerDisplayName; |
| 150 | } |
| 151 | |
| 152 | /** The {@link CallPropertyPresentation} which controls how the caller display name is shown. */ |
| 153 | public int getCallerDisplayNamePresentation() { |
| 154 | return mCallerDisplayNamePresentation; |
| 155 | } |
| 156 | |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 157 | /** Gateway information for the call. */ |
| 158 | public GatewayInfo getGatewayInfo() { |
| 159 | return mGatewayInfo; |
| 160 | } |
| 161 | |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame^] | 162 | /** PhoneAccountHandle information for the call. */ |
| 163 | public PhoneAccountHandle getAccount() { |
Ihab Awad | 9c3f188 | 2014-06-30 21:17:13 -0700 | [diff] [blame] | 164 | return mAccount; |
Nancy Chen | 5ffbfcc | 2014-06-25 14:22:55 -0700 | [diff] [blame] | 165 | } |
| 166 | |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 167 | /** |
Andrew Lee | 5dc3075 | 2014-06-27 17:02:19 -0700 | [diff] [blame] | 168 | * Returns an object for remotely communicating through the call video provider's binder. |
| 169 | * @return The call video provider. |
| 170 | */ |
| 171 | public RemoteCallVideoProvider getCallVideoProvider() throws RemoteException { |
Tyler Gunn | 807de8a | 2014-06-30 14:22:57 -0700 | [diff] [blame] | 172 | if (mRemoteCallVideoProvider == null && mCallVideoProvider != null) { |
Andrew Lee | 5dc3075 | 2014-06-27 17:02:19 -0700 | [diff] [blame] | 173 | try { |
| 174 | mRemoteCallVideoProvider = new RemoteCallVideoProvider(mCallVideoProvider); |
| 175 | } catch (RemoteException ignored) { |
| 176 | // Ignore RemoteException. |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | return mRemoteCallVideoProvider; |
| 181 | } |
| 182 | |
| 183 | /** |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 184 | * The conference call to which this call is conferenced. Null if not conferenced. |
| 185 | * @hide |
| 186 | */ |
| 187 | public String getParentCallId() { |
| 188 | return mParentCallId; |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * The child call-IDs if this call is a conference call. Returns an empty list if this is not |
| 193 | * a conference call or if the conference call contains no children. |
| 194 | * @hide |
| 195 | */ |
| 196 | public List<String> getChildCallIds() { |
| 197 | return mChildCallIds; |
| 198 | } |
| 199 | |
Tyler Gunn | 8d83fa9 | 2014-07-01 11:31:21 -0700 | [diff] [blame] | 200 | /** |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 201 | * The status label and icon. |
| 202 | * |
| 203 | * @return Status hints. |
| 204 | */ |
| 205 | public StatusHints getStatusHints() { |
| 206 | return mStatusHints; |
| 207 | } |
| 208 | |
Andrew Lee | 85f5d42 | 2014-07-11 17:22:03 -0700 | [diff] [blame] | 209 | /** |
| 210 | * The video state. |
| 211 | * @return The video state of the call. |
| 212 | */ |
| 213 | public int getVideoState() { |
| 214 | return mVideoState; |
| 215 | } |
| 216 | |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 217 | /** Responsible for creating InCallCall objects for deserialized Parcels. */ |
| 218 | public static final Parcelable.Creator<InCallCall> CREATOR = |
| 219 | new Parcelable.Creator<InCallCall> () { |
| 220 | @Override |
| 221 | public InCallCall createFromParcel(Parcel source) { |
Ihab Awad | c067754 | 2014-06-10 13:29:47 -0700 | [diff] [blame] | 222 | ClassLoader classLoader = InCallCall.class.getClassLoader(); |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 223 | String id = source.readString(); |
| 224 | CallState state = CallState.valueOf(source.readString()); |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 225 | int disconnectCauseCode = source.readInt(); |
| 226 | String disconnectCauseMsg = source.readString(); |
Ihab Awad | c067754 | 2014-06-10 13:29:47 -0700 | [diff] [blame] | 227 | List<String> cannedSmsResponses = new ArrayList<>(); |
| 228 | source.readList(cannedSmsResponses, classLoader); |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 229 | int capabilities = source.readInt(); |
| 230 | long connectTimeMillis = source.readLong(); |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 231 | Uri handle = source.readParcelable(classLoader); |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 232 | int handlePresentation = source.readInt(); |
| 233 | String callerDisplayName = source.readString(); |
| 234 | int callerDisplayNamePresentation = source.readInt(); |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 235 | GatewayInfo gatewayInfo = source.readParcelable(classLoader); |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame^] | 236 | PhoneAccountHandle account = source.readParcelable(classLoader); |
Andrew Lee | 5dc3075 | 2014-06-27 17:02:19 -0700 | [diff] [blame] | 237 | ICallVideoProvider callVideoProvider = |
| 238 | ICallVideoProvider.Stub.asInterface(source.readStrongBinder()); |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 239 | String parentCallId = source.readString(); |
| 240 | List<String> childCallIds = new ArrayList<>(); |
| 241 | source.readList(childCallIds, classLoader); |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 242 | StatusHints statusHints = source.readParcelable(classLoader); |
Andrew Lee | 85f5d42 | 2014-07-11 17:22:03 -0700 | [diff] [blame] | 243 | int videoState = source.readInt(); |
Ihab Awad | c067754 | 2014-06-10 13:29:47 -0700 | [diff] [blame] | 244 | return new InCallCall(id, state, disconnectCauseCode, disconnectCauseMsg, |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 245 | cannedSmsResponses, capabilities, connectTimeMillis, handle, handlePresentation, |
| 246 | callerDisplayName, callerDisplayNamePresentation, gatewayInfo, |
Andrew Lee | 85f5d42 | 2014-07-11 17:22:03 -0700 | [diff] [blame] | 247 | account, callVideoProvider, parentCallId, childCallIds, statusHints, |
| 248 | videoState); |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | @Override |
| 252 | public InCallCall[] newArray(int size) { |
| 253 | return new InCallCall[size]; |
| 254 | } |
| 255 | }; |
| 256 | |
| 257 | /** {@inheritDoc} */ |
| 258 | @Override |
| 259 | public int describeContents() { |
| 260 | return 0; |
| 261 | } |
| 262 | |
| 263 | /** Writes InCallCall object into a Parcel. */ |
| 264 | @Override |
| 265 | public void writeToParcel(Parcel destination, int flags) { |
| 266 | destination.writeString(mId); |
| 267 | destination.writeString(mState.name()); |
Ihab Awad | fbb092f | 2014-06-03 18:40:45 -0700 | [diff] [blame] | 268 | destination.writeInt(mDisconnectCauseCode); |
| 269 | destination.writeString(mDisconnectCauseMsg); |
Ihab Awad | c067754 | 2014-06-10 13:29:47 -0700 | [diff] [blame] | 270 | destination.writeList(mCannedSmsResponses); |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 271 | destination.writeInt(mCapabilities); |
| 272 | destination.writeLong(mConnectTimeMillis); |
| 273 | destination.writeParcelable(mHandle, 0); |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 274 | destination.writeInt(mHandlePresentation); |
| 275 | destination.writeString(mCallerDisplayName); |
| 276 | destination.writeInt(mCallerDisplayNamePresentation); |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 277 | destination.writeParcelable(mGatewayInfo, 0); |
Ihab Awad | 9c3f188 | 2014-06-30 21:17:13 -0700 | [diff] [blame] | 278 | destination.writeParcelable(mAccount, 0); |
Tyler Gunn | 807de8a | 2014-06-30 14:22:57 -0700 | [diff] [blame] | 279 | destination.writeStrongBinder( |
| 280 | mCallVideoProvider != null ? mCallVideoProvider.asBinder() : null); |
Santos Cordon | 980acb9 | 2014-05-31 10:31:19 -0700 | [diff] [blame] | 281 | destination.writeString(mParentCallId); |
| 282 | destination.writeList(mChildCallIds); |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 283 | destination.writeParcelable(mStatusHints, 0); |
Andrew Lee | 85f5d42 | 2014-07-11 17:22:03 -0700 | [diff] [blame] | 284 | destination.writeInt(mVideoState); |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 285 | } |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 286 | |
| 287 | @Override |
| 288 | public String toString() { |
| 289 | return String.format("[%s, parent:%s, children:%s]", mId, mParentCallId, mChildCallIds); |
| 290 | } |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 291 | } |