package android.telecom;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.android.internal.telecom.IVideoProvider;
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;
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) {
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;
}
public String getId() {
return mId;
}
public int getState() {
return mState;
}
public DisconnectCause getDisconnectCause() {
return mDisconnectCause;
}
public List<String> getCannedSmsResponses() {
return mCannedSmsResponses;
}
public int getCapabilities() {
return mCapabilities;
}
public int getProperties() { return mProperties; }
public int getSupportedAudioRoutes() {
return mSupportedAudioRoutes;
}
public long getConnectTimeMillis() {
return mConnectTimeMillis;
}
public Uri getHandle() {
return mHandle;
}
public int getHandlePresentation() {
return mHandlePresentation;
}
public String getCallerDisplayName() {
return mCallerDisplayName;
}
public int getCallerDisplayNamePresentation() {
return mCallerDisplayNamePresentation;
}
public GatewayInfo getGatewayInfo() {
return mGatewayInfo;
}
public PhoneAccountHandle getAccountHandle() {
return mAccountHandle;
}
public VideoCallImpl getVideoCallImpl(String callingPackageName, int targetSdkVersion) {
if (mVideoCall == null && mVideoCallProvider != null) {
try {
mVideoCall = new VideoCallImpl(mVideoCallProvider, callingPackageName,
targetSdkVersion);
} catch (RemoteException ignored) {
}
}
return mVideoCall;
}
public boolean getIsRttCallChanged() {
return mIsRttCallChanged;
}
public ParcelableRttCall getParcelableRttCall() {
return mRttCall;
}
public String getParentCallId() {
return mParentCallId;
}
public List<String> getChildCallIds() {
return mChildCallIds;
}
public List<String> getConferenceableCallIds() {
return mConferenceableCallIds;
}
public StatusHints getStatusHints() {
return mStatusHints;
}
public int getVideoState() {
return mVideoState;
}
public Bundle getExtras() {
return mExtras;
}
public Bundle getIntentExtras() {
return mIntentExtras;
}
public boolean isVideoCallProviderChanged() {
return mIsVideoCallProviderChanged;
}
public long getCreationTimeMillis() {
return mCreationTimeMillis;
}
public static final 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();
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);
}
@Override
public ParcelableCall[] newArray(int size) {
return new ParcelableCall[size];
}
};
@Override
public int describeContents() {
return 0;
}
@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);
}
@Override
public String toString() {
return String.format("[%s, parent:%s, children:%s]", mId, mParentCallId, mChildCallIds);
}
}