195d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu/*
295d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu * Copyright (C) 2017 The Android Open Source Project
395d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu *
495d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu * Licensed under the Apache License, Version 2.0 (the "License");
595d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu * you may not use this file except in compliance with the License.
695d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu * You may obtain a copy of the License at
795d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu *
895d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu *      http://www.apache.org/licenses/LICENSE-2.0
995d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu *
1095d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu * Unless required by applicable law or agreed to in writing, software
1195d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu * distributed under the License is distributed on an "AS IS" BASIS,
1295d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1395d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu * See the License for the specific language governing permissions and
1495d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu * limitations under the License
1595d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu */
1695d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu
1795d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liupackage android.telecom;
1895d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu
1995d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liuimport android.os.Parcel;
2095d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liuimport android.os.ParcelFileDescriptor;
2195d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liuimport android.os.Parcelable;
2295d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu
2395d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liuimport java.io.FileInputStream;
2495d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liuimport java.io.FileOutputStream;
2595d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liuimport java.io.InputStreamReader;
2695d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liuimport java.io.OutputStreamWriter;
2795d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liuimport java.nio.charset.StandardCharsets;
2895d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu
2995d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu/**
3095d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu * Data container for information associated with the RTT connection on a call.
3195d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu * @hide
3295d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu */
3395d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liupublic class ParcelableRttCall implements Parcelable {
3495d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    private final int mRttMode;
3595d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    private final ParcelFileDescriptor mTransmitStream;
3695d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    private final ParcelFileDescriptor mReceiveStream;
3795d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu
3895d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    public ParcelableRttCall(
3995d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu            int rttMode,
4095d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu            ParcelFileDescriptor transmitStream,
4195d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu            ParcelFileDescriptor receiveStream) {
4295d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        mRttMode = rttMode;
4395d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        mTransmitStream = transmitStream;
4495d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        mReceiveStream = receiveStream;
4595d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    }
4695d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu
4795d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    protected ParcelableRttCall(Parcel in) {
4895d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        mRttMode = in.readInt();
4995d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        mTransmitStream = in.readParcelable(ParcelFileDescriptor.class.getClassLoader());
5095d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        mReceiveStream = in.readParcelable(ParcelFileDescriptor.class.getClassLoader());
5195d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    }
5295d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu
5395d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    public static final Creator<ParcelableRttCall> CREATOR = new Creator<ParcelableRttCall>() {
5495d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        @Override
5595d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        public ParcelableRttCall createFromParcel(Parcel in) {
5695d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu            return new ParcelableRttCall(in);
5795d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        }
5895d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu
5995d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        @Override
6095d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        public ParcelableRttCall[] newArray(int size) {
6195d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu            return new ParcelableRttCall[size];
6295d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        }
6395d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    };
6495d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu
6595d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    @Override
6695d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    public int describeContents() {
6795d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        return 0;
6895d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    }
6995d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu
7095d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    @Override
7195d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    public void writeToParcel(Parcel dest, int flags) {
7295d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        dest.writeInt(mRttMode);
7395d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        dest.writeParcelable(mTransmitStream, flags);
7495d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        dest.writeParcelable(mReceiveStream, flags);
7595d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    }
7695d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu
7795d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    public int getRttMode() {
7895d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        return mRttMode;
7995d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    }
8095d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu
8195d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    public ParcelFileDescriptor getReceiveStream() {
8295d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        return mReceiveStream;
8395d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    }
8495d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu
8595d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    public ParcelFileDescriptor getTransmitStream() {
8695d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu        return mTransmitStream;
8795d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu    }
8895d5587d0aad9dfd49f798408f4212f95ce68fc7Hall Liu}
89