1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437
|
/*
* Copyright 2014, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telecom;
import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.telecom.Call.Details.CallDirection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.android.internal.telecom.IVideoProvider;
/**
* Information about a call that is used between InCallService and Telecom.
* @hide
*/
public final class ParcelableCall implements Parcelable {
private final String mId;
private final int mState;
private final DisconnectCause mDisconnectCause;
private final List<String> mCannedSmsResponses;
private final int mCapabilities;
private final int mProperties;
private final int mSupportedAudioRoutes;
private final long mConnectTimeMillis;
private final Uri mHandle;
private final int mHandlePresentation;
private final String mCallerDisplayName;
private final int mCallerDisplayNamePresentation;
private final GatewayInfo mGatewayInfo;
private final PhoneAccountHandle mAccountHandle;
private final boolean mIsVideoCallProviderChanged;
private final IVideoProvider mVideoCallProvider;
private VideoCallImpl mVideoCall;
private final boolean mIsRttCallChanged;
private final ParcelableRttCall mRttCall;
private final String mParentCallId;
private final List<String> mChildCallIds;
private final StatusHints mStatusHints;
private final int mVideoState;
private final List<String> mConferenceableCallIds;
private final Bundle mIntentExtras;
private final Bundle mExtras;
private final long mCreationTimeMillis;
private final int mCallDirection;
public ParcelableCall(
String id,
int state,
DisconnectCause disconnectCause,
List<String> cannedSmsResponses,
int capabilities,
int properties,
int supportedAudioRoutes,
long connectTimeMillis,
Uri handle,
int handlePresentation,
String callerDisplayName,
int callerDisplayNamePresentation,
GatewayInfo gatewayInfo,
PhoneAccountHandle accountHandle,
boolean isVideoCallProviderChanged,
IVideoProvider videoCallProvider,
boolean isRttCallChanged,
ParcelableRttCall rttCall,
String parentCallId,
List<String> childCallIds,
StatusHints statusHints,
int videoState,
List<String> conferenceableCallIds,
Bundle intentExtras,
Bundle extras,
long creationTimeMillis,
int callDirection) {
mId = id;
mState = state;
mDisconnectCause = disconnectCause;
mCannedSmsResponses = cannedSmsResponses;
mCapabilities = capabilities;
mProperties = properties;
mSupportedAudioRoutes = supportedAudioRoutes;
mConnectTimeMillis = connectTimeMillis;
mHandle = handle;
mHandlePresentation = handlePresentation;
mCallerDisplayName = callerDisplayName;
mCallerDisplayNamePresentation = callerDisplayNamePresentation;
mGatewayInfo = gatewayInfo;
mAccountHandle = accountHandle;
mIsVideoCallProviderChanged = isVideoCallProviderChanged;
mVideoCallProvider = videoCallProvider;
mIsRttCallChanged = isRttCallChanged;
mRttCall = rttCall;
mParentCallId = parentCallId;
mChildCallIds = childCallIds;
mStatusHints = statusHints;
mVideoState = videoState;
mConferenceableCallIds = Collections.unmodifiableList(conferenceableCallIds);
mIntentExtras = intentExtras;
mExtras = extras;
mCreationTimeMillis = creationTimeMillis;
mCallDirection = callDirection;
}
/** The unique ID of the call. */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public String getId() {
return mId;
}
/** The current state of the call. */
public int getState() {
return mState;
}
/**
* Reason for disconnection, as described by {@link android.telecomm.DisconnectCause}. Valid
* when call state is {@link CallState#DISCONNECTED}.
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public DisconnectCause getDisconnectCause() {
return mDisconnectCause;
}
/**
* The set of possible text message responses when this call is incoming.
*/
public List<String> getCannedSmsResponses() {
return mCannedSmsResponses;
}
// Bit mask of actions a call supports, values are defined in {@link CallCapabilities}.
public int getCapabilities() {
return mCapabilities;
}
/** Bitmask of properties of the call. */
public int getProperties() { return mProperties; }
/** Bitmask of supported routes of the call */
public int getSupportedAudioRoutes() {
return mSupportedAudioRoutes;
}
/** The time that the call switched to the active state. */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public long getConnectTimeMillis() {
return mConnectTimeMillis;
}
/** The endpoint to which the call is connected. */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public Uri getHandle() {
return mHandle;
}
/**
* The presentation requirements for the handle. See {@link TelecomManager} for valid values.
*/
public int getHandlePresentation() {
return mHandlePresentation;
}
/** The endpoint to which the call is connected. */
public String getCallerDisplayName() {
return mCallerDisplayName;
}
/**
* The presentation requirements for the caller display name.
* See {@link TelecomManager} for valid values.
*/
public int getCallerDisplayNamePresentation() {
return mCallerDisplayNamePresentation;
}
/** Gateway information for the call. */
public GatewayInfo getGatewayInfo() {
return mGatewayInfo;
}
/** PhoneAccountHandle information for the call. */
public PhoneAccountHandle getAccountHandle() {
return mAccountHandle;
}
/**
* Returns an object for remotely communicating through the video call provider's binder.
*
* @param callingPackageName the package name of the calling InCallService.
* @param targetSdkVersion the target SDK version of the calling InCallService.
* @return The video call.
*/
public VideoCallImpl getVideoCallImpl(String callingPackageName, int targetSdkVersion) {
if (mVideoCall == null && mVideoCallProvider != null) {
try {
mVideoCall = new VideoCallImpl(mVideoCallProvider, callingPackageName,
targetSdkVersion);
} catch (RemoteException ignored) {
// Ignore RemoteException.
}
}
return mVideoCall;
}
public boolean getIsRttCallChanged() {
return mIsRttCallChanged;
}
/**
* RTT communication channel information
* @return The ParcelableRttCall
*/
public ParcelableRttCall getParcelableRttCall() {
return mRttCall;
}
/**
* The conference call to which this call is conferenced. Null if not conferenced.
*/
public String getParentCallId() {
return mParentCallId;
}
/**
* The child call-IDs if this call is a conference call. Returns an empty list if this is not
* a conference call or if the conference call contains no children.
*/
public List<String> getChildCallIds() {
return mChildCallIds;
}
public List<String> getConferenceableCallIds() {
return mConferenceableCallIds;
}
/**
* The status label and icon.
*
* @return Status hints.
*/
public StatusHints getStatusHints() {
return mStatusHints;
}
/**
* The video state.
* @return The video state of the call.
*/
public int getVideoState() {
return mVideoState;
}
/**
* Any extras associated with this call.
*
* @return a bundle of extras
*/
public Bundle getExtras() {
return mExtras;
}
/**
* Extras passed in as part of the original call intent.
*
* @return The intent extras.
*/
public Bundle getIntentExtras() {
return mIntentExtras;
}
/**
* Indicates to the receiver of the {@link ParcelableCall} whether a change has occurred in the
* {@link android.telecom.InCallService.VideoCall} associated with this call. Since
* {@link #getVideoCall()} creates a new {@link VideoCallImpl}, it is useful to know whether
* the provider has changed (which can influence whether it is accessed).
*
* @return {@code true} if the video call changed, {@code false} otherwise.
*/
public boolean isVideoCallProviderChanged() {
return mIsVideoCallProviderChanged;
}
/**
* @return The time the call was created, in milliseconds since the epoch.
*/
public long getCreationTimeMillis() {
return mCreationTimeMillis;
}
/**
* Indicates whether the call is an incoming or outgoing call.
*/
public @CallDirection int getCallDirection() {
return mCallDirection;
}
/** Responsible for creating ParcelableCall objects for deserialized Parcels. */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public static final @android.annotation.NonNull Parcelable.Creator<ParcelableCall> CREATOR =
new Parcelable.Creator<ParcelableCall> () {
@Override
public ParcelableCall createFromParcel(Parcel source) {
ClassLoader classLoader = ParcelableCall.class.getClassLoader();
String id = source.readString();
int state = source.readInt();
DisconnectCause disconnectCause = source.readParcelable(classLoader);
List<String> cannedSmsResponses = new ArrayList<>();
source.readList(cannedSmsResponses, classLoader);
int capabilities = source.readInt();
int properties = source.readInt();
long connectTimeMillis = source.readLong();
Uri handle = source.readParcelable(classLoader);
int handlePresentation = source.readInt();
String callerDisplayName = source.readString();
int callerDisplayNamePresentation = source.readInt();
GatewayInfo gatewayInfo = source.readParcelable(classLoader);
PhoneAccountHandle accountHandle = source.readParcelable(classLoader);
boolean isVideoCallProviderChanged = source.readByte() == 1;
IVideoProvider videoCallProvider =
IVideoProvider.Stub.asInterface(source.readStrongBinder());
String parentCallId = source.readString();
List<String> childCallIds = new ArrayList<>();
source.readList(childCallIds, classLoader);
StatusHints statusHints = source.readParcelable(classLoader);
int videoState = source.readInt();
List<String> conferenceableCallIds = new ArrayList<>();
source.readList(conferenceableCallIds, classLoader);
Bundle intentExtras = source.readBundle(classLoader);
Bundle extras = source.readBundle(classLoader);
int supportedAudioRoutes = source.readInt();
boolean isRttCallChanged = source.readByte() == 1;
ParcelableRttCall rttCall = source.readParcelable(classLoader);
long creationTimeMillis = source.readLong();
int callDirection = source.readInt();
return new ParcelableCall(
id,
state,
disconnectCause,
cannedSmsResponses,
capabilities,
properties,
supportedAudioRoutes,
connectTimeMillis,
handle,
handlePresentation,
callerDisplayName,
callerDisplayNamePresentation,
gatewayInfo,
accountHandle,
isVideoCallProviderChanged,
videoCallProvider,
isRttCallChanged,
rttCall,
parentCallId,
childCallIds,
statusHints,
videoState,
conferenceableCallIds,
intentExtras,
extras,
creationTimeMillis,
callDirection);
}
@Override
public ParcelableCall[] newArray(int size) {
return new ParcelableCall[size];
}
};
/** {@inheritDoc} */
@Override
public int describeContents() {
return 0;
}
/** Writes ParcelableCall object into a Parcel. */
@Override
public void writeToParcel(Parcel destination, int flags) {
destination.writeString(mId);
destination.writeInt(mState);
destination.writeParcelable(mDisconnectCause, 0);
destination.writeList(mCannedSmsResponses);
destination.writeInt(mCapabilities);
destination.writeInt(mProperties);
destination.writeLong(mConnectTimeMillis);
destination.writeParcelable(mHandle, 0);
destination.writeInt(mHandlePresentation);
destination.writeString(mCallerDisplayName);
destination.writeInt(mCallerDisplayNamePresentation);
destination.writeParcelable(mGatewayInfo, 0);
destination.writeParcelable(mAccountHandle, 0);
destination.writeByte((byte) (mIsVideoCallProviderChanged ? 1 : 0));
destination.writeStrongBinder(
mVideoCallProvider != null ? mVideoCallProvider.asBinder() : null);
destination.writeString(mParentCallId);
destination.writeList(mChildCallIds);
destination.writeParcelable(mStatusHints, 0);
destination.writeInt(mVideoState);
destination.writeList(mConferenceableCallIds);
destination.writeBundle(mIntentExtras);
destination.writeBundle(mExtras);
destination.writeInt(mSupportedAudioRoutes);
destination.writeByte((byte) (mIsRttCallChanged ? 1 : 0));
destination.writeParcelable(mRttCall, 0);
destination.writeLong(mCreationTimeMillis);
destination.writeInt(mCallDirection);
}
@Override
public String toString() {
return String.format("[%s, parent:%s, children:%s]", mId, mParentCallId, mChildCallIds);
}
}
|