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