Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 90f426fa authored by Daniel Bright's avatar Daniel Bright Committed by Gerrit Code Review
Browse files

Merge "Add indication APIs to expose QOS from LTE and NR bearers"

parents fcb4e29a 0f14f81d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ stubs_defaults {
        "android.hardware.cas-V1.2-java",
        "android.hardware.health-V1.0-java-constants",
        "android.hardware.radio-V1.5-java",
        "android.hardware.radio-V1.6-java",
        "android.hardware.thermal-V1.0-java-constants",
        "android.hardware.thermal-V2.0-java",
        "android.hardware.tv.input-V1.0-java-constants",
+97 −10
Original line number Diff line number Diff line
@@ -134,6 +134,8 @@ public final class DataCallResponse implements Parcelable {
    private final int mMtuV6;
    private final @HandoverFailureMode int mHandoverFailureMode;
    private final int mPduSessionId;
    private final Qos mDefaultQos;
    private final List<QosSession> mQosSessions;

    /**
     * @param cause Data call fail cause. {@link DataFailCause#NONE} indicates no error.
@@ -182,6 +184,8 @@ public final class DataCallResponse implements Parcelable {
        mMtu = mMtuV4 = mMtuV6 = mtu;
        mHandoverFailureMode = HANDOVER_FAILURE_MODE_LEGACY;
        mPduSessionId = PDU_SESSION_ID_NOT_SET;
        mDefaultQos = null;
        mQosSessions = new ArrayList<>();
    }

    private DataCallResponse(@DataFailureCause int cause, long suggestedRetryTime, int id,
@@ -189,7 +193,8 @@ public final class DataCallResponse implements Parcelable {
            @Nullable String interfaceName, @Nullable List<LinkAddress> addresses,
            @Nullable List<InetAddress> dnsAddresses, @Nullable List<InetAddress> gatewayAddresses,
            @Nullable List<InetAddress> pcscfAddresses, int mtu, int mtuV4, int mtuV6,
            @HandoverFailureMode int handoverFailureMode, int pduSessionId) {
            @HandoverFailureMode int handoverFailureMode, int pduSessionId,
            @Nullable Qos defaultQos, @Nullable List<QosSession> qosSessions) {
        mCause = cause;
        mSuggestedRetryTime = suggestedRetryTime;
        mId = id;
@@ -209,6 +214,8 @@ public final class DataCallResponse implements Parcelable {
        mMtuV6 = mtuV6;
        mHandoverFailureMode = handoverFailureMode;
        mPduSessionId = pduSessionId;
        mDefaultQos = defaultQos;
        mQosSessions = qosSessions;
    }

    /** @hide */
@@ -233,6 +240,9 @@ public final class DataCallResponse implements Parcelable {
        mMtuV6 = source.readInt();
        mHandoverFailureMode = source.readInt();
        mPduSessionId = source.readInt();
        mDefaultQos = source.readParcelable(Qos.class.getClassLoader());
        mQosSessions = new ArrayList<>();
        source.readList(mQosSessions, QosSession.class.getClassLoader());
    }

    /**
@@ -350,6 +360,28 @@ public final class DataCallResponse implements Parcelable {
        return mPduSessionId;
    }

    /**
     * @return default QOS of the data call received from the network
     *
     * @hide
     */

    @Nullable
    public Qos getDefaultQos() {
        return mDefaultQos;
    }

    /**
     * @return All the dedicated bearer QOS sessions of the data call received from the network
     *
     * @hide
     */

    @NonNull
    public List<QosSession> getQosSessions() {
        return mQosSessions;
    }

    @NonNull
    @Override
    public String toString() {
@@ -370,6 +402,8 @@ public final class DataCallResponse implements Parcelable {
           .append(" mtuV6=").append(getMtuV6())
           .append(" handoverFailureMode=").append(getHandoverFailureMode())
           .append(" pduSessionId=").append(getPduSessionId())
           .append(" defaultQos=").append(mDefaultQos)
           .append(" qosSessions=").append(mQosSessions)
           .append("}");
        return sb.toString();
    }
@@ -383,12 +417,22 @@ public final class DataCallResponse implements Parcelable {
        }

        DataCallResponse other = (DataCallResponse) o;
        return this.mCause == other.mCause
                && this.mSuggestedRetryTime == other.mSuggestedRetryTime
                && this.mId == other.mId
                && this.mLinkStatus == other.mLinkStatus
                && this.mProtocolType == other.mProtocolType
                && this.mInterfaceName.equals(other.mInterfaceName)

        final boolean isQosSame = (mDefaultQos == null || other.mDefaultQos == null) ?
                mDefaultQos == other.mDefaultQos :
                mDefaultQos.equals(other.mDefaultQos);

        final boolean isQosSessionsSame = (mQosSessions == null || mQosSessions == null) ?
                mQosSessions == other.mQosSessions :
                mQosSessions.size() == other.mQosSessions.size()
                && mQosSessions.containsAll(other.mQosSessions);

        return mCause == other.mCause
                && mSuggestedRetryTime == other.mSuggestedRetryTime
                && mId == other.mId
                && mLinkStatus == other.mLinkStatus
                && mProtocolType == other.mProtocolType
                && mInterfaceName.equals(other.mInterfaceName)
                && mAddresses.size() == other.mAddresses.size()
                && mAddresses.containsAll(other.mAddresses)
                && mDnsAddresses.size() == other.mDnsAddresses.size()
@@ -401,14 +445,17 @@ public final class DataCallResponse implements Parcelable {
                && mMtuV4 == other.mMtuV4
                && mMtuV6 == other.mMtuV6
                && mHandoverFailureMode == other.mHandoverFailureMode
                && mPduSessionId == other.mPduSessionId;
                && mPduSessionId == other.mPduSessionId
                && isQosSame
                && isQosSessionsSame;
    }

    @Override
    public int hashCode() {
        return Objects.hash(mCause, mSuggestedRetryTime, mId, mLinkStatus, mProtocolType,
                mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses, mPcscfAddresses,
                mMtu, mMtuV4, mMtuV6, mHandoverFailureMode, mPduSessionId);
                mMtu, mMtuV4, mMtuV6, mHandoverFailureMode, mPduSessionId, mDefaultQos,
                mQosSessions);
    }

    @Override
@@ -433,6 +480,12 @@ public final class DataCallResponse implements Parcelable {
        dest.writeInt(mMtuV6);
        dest.writeInt(mHandoverFailureMode);
        dest.writeInt(mPduSessionId);
        if (mDefaultQos.getType() == Qos.QOS_TYPE_EPS) {
            dest.writeParcelable((EpsQos)mDefaultQos, flags);
        } else {
            dest.writeParcelable((NrQos)mDefaultQos, flags);
        }
        dest.writeList(mQosSessions);
    }

    public static final @android.annotation.NonNull Parcelable.Creator<DataCallResponse> CREATOR =
@@ -512,6 +565,10 @@ public final class DataCallResponse implements Parcelable {

        private int mPduSessionId = PDU_SESSION_ID_NOT_SET;

        private Qos mDefaultQos;

        private List<QosSession> mQosSessions = new ArrayList<>();

        /**
         * Default constructor for Builder.
         */
@@ -705,6 +762,35 @@ public final class DataCallResponse implements Parcelable {
            return this;
        }

        /**
         * Set the default QOS for this data connection.
         *
         * @param defaultQos QOS (Quality Of Service) received from network.
         *
         * @return The same instance of the builder.
         *
         * @hide
         */
        public @NonNull Builder setDefaultQos(@Nullable Qos defaultQos) {
            mDefaultQos = defaultQos;
            return this;
        }

        /**
         * Set the dedicated bearer QOS sessions for this data connection.
         *
         * @param qosSessions Dedicated bearer QOS (Quality Of Service) sessions received
         * from network.
         *
         * @return The same instance of the builder.
         *
         * @hide
         */
        public @NonNull Builder setQosSessions(@NonNull List<QosSession> qosSessions) {
            mQosSessions = qosSessions;
            return this;
        }

        /**
         * Build the DataCallResponse.
         *
@@ -713,7 +799,8 @@ public final class DataCallResponse implements Parcelable {
        public @NonNull DataCallResponse build() {
            return new DataCallResponse(mCause, mSuggestedRetryTime, mId, mLinkStatus,
                    mProtocolType, mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses,
                    mPcscfAddresses, mMtu, mMtuV4, mMtuV6, mHandoverFailureMode, mPduSessionId);
                    mPcscfAddresses, mMtu, mMtuV4, mMtuV6, mHandoverFailureMode, mPduSessionId,
                    mDefaultQos, mQosSessions);
        }
    }
}
+105 −0
Original line number Diff line number Diff line
/**
 * Copyright 2020 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.telephony.data;

import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.Objects;


/**
 * Class that stores information specific to NR QOS.
 *
 * @hide
 */
public final class EpsQos extends Qos implements Parcelable {

    int qosClassId;

    public EpsQos() {
        super(Qos.QOS_TYPE_EPS,
                new android.hardware.radio.V1_6.QosBandwidth(),
                new android.hardware.radio.V1_6.QosBandwidth());
    }

    public EpsQos(@NonNull android.hardware.radio.V1_6.EpsQos qos) {
        super(Qos.QOS_TYPE_EPS, qos.downlink, qos.uplink);
        qosClassId = qos.qci;
    }

    private EpsQos(Parcel source) {
        super(source);
        qosClassId = source.readInt();
    }

    public static @NonNull EpsQos createFromParcelBody(@NonNull Parcel in) {
        return new EpsQos(in);
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        super.writeToParcel(Qos.QOS_TYPE_EPS, dest, flags);
        dest.writeInt(qosClassId);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), qosClassId);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;

        if (o == null || !(o instanceof EpsQos)) {
            return false;
        }

        EpsQos other = (EpsQos) o;

        return this.qosClassId == other.qosClassId
               && super.equals(other);
    }

    @Override
    public String toString() {
        return "EpsQos {"
                + " qosClassId=" + qosClassId
                + " downlink=" + downlink
                + " uplink=" + uplink + "}";
    }

    public static final @NonNull Parcelable.Creator<EpsQos> CREATOR =
            new Parcelable.Creator<EpsQos>() {
                @Override
                public EpsQos createFromParcel(Parcel source) {
                    return new EpsQos(source);
                }

                @Override
                public EpsQos[] newArray(int size) {
                    return new EpsQos[size];
                }
            };
}
+112 −0
Original line number Diff line number Diff line
/**
 * Copyright 2020 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.telephony.data;

import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.Objects;

/**
 * Class that stores information specific to NR QOS.
 *
 * @hide
 */
public final class NrQos extends Qos implements Parcelable {
    int qosFlowId;
    int fiveQi;
    int averagingWindowMs;

    public NrQos(@NonNull android.hardware.radio.V1_6.NrQos qos) {
        super(Qos.QOS_TYPE_NR, qos.downlink, qos.uplink);
        fiveQi = qos.fiveQi;
        qosFlowId = qos.qfi;
        averagingWindowMs = qos.averagingWindowMs;
    }

    private NrQos(Parcel source) {
        super(source);
        this.qosFlowId = source.readInt();
        this.fiveQi = source.readInt();
        this.averagingWindowMs = source.readInt();
    }

    public static @NonNull NrQos createFromParcelBody(@NonNull Parcel in) {
        return new NrQos(in);
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        super.writeToParcel(Qos.QOS_TYPE_NR, dest, flags);
        dest.writeInt(qosFlowId);
        dest.writeInt(fiveQi);
        dest.writeInt(averagingWindowMs);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), qosFlowId, fiveQi, averagingWindowMs);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;

        if (o == null || !(o instanceof NrQos)) {
            return false;
        }

        NrQos other = (NrQos) o;

        if (!super.equals(other)) {
            return false;
        }

        return this.qosFlowId == other.qosFlowId
            && this.fiveQi == other.fiveQi
            && this.averagingWindowMs == other.averagingWindowMs;
    }

    @Override
    public String toString() {
        return "NrQos {"
                + " fiveQi=" + fiveQi
                + " downlink=" + downlink
                + " uplink=" + uplink
                + " qosFlowId=" + qosFlowId
                + " averagingWindowMs=" + averagingWindowMs + "}";
    }

    public static final @NonNull Parcelable.Creator<NrQos> CREATOR =
            new Parcelable.Creator<NrQos>() {
                @Override
                public NrQos createFromParcel(Parcel source) {
                    return new NrQos(source);
                }

                @Override
                public NrQos[] newArray(int size) {
                    return new NrQos[size];
                }
            };
}
+175 −0
Original line number Diff line number Diff line
/**
 * Copyright 2020 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.telephony.data;

import android.annotation.CallSuper;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Objects;

/**
 * Class that stores information specific to QOS.
 *
 * @hide
 */
public abstract class Qos {

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = "QOS_TYPE_",
            value = {QOS_TYPE_EPS, QOS_TYPE_NR})
    public @interface QosType {}

    @QosType
    final int type;

    static final int QOS_TYPE_EPS = 1;
    static final int QOS_TYPE_NR = 2;

    final QosBandwidth downlink;
    final QosBandwidth uplink;

    Qos(int type,
            @NonNull android.hardware.radio.V1_6.QosBandwidth downlink,
            @NonNull android.hardware.radio.V1_6.QosBandwidth uplink) {
        this.type = type;
        this.downlink = new QosBandwidth(downlink.maxBitrateKbps, downlink.guaranteedBitrateKbps);
        this.uplink = new QosBandwidth(uplink.maxBitrateKbps, uplink.guaranteedBitrateKbps);
    }

    static class QosBandwidth implements Parcelable {
        int maxBitrateKbps;
        int guaranteedBitrateKbps;

        QosBandwidth() {
        }

        QosBandwidth(int maxBitrateKbps, int guaranteedBitrateKbps) {
            this.maxBitrateKbps = maxBitrateKbps;
            this.guaranteedBitrateKbps = guaranteedBitrateKbps;
        }

        private QosBandwidth(Parcel source) {
            maxBitrateKbps = source.readInt();
            guaranteedBitrateKbps = source.readInt();
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(maxBitrateKbps);
            dest.writeInt(guaranteedBitrateKbps);
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public int hashCode() {
            return Objects.hash(maxBitrateKbps, guaranteedBitrateKbps);
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;

            if (o == null || !(o instanceof QosBandwidth)) {
                return false;
            }

            QosBandwidth other = (QosBandwidth) o;
            return maxBitrateKbps == other.maxBitrateKbps
                    && guaranteedBitrateKbps == other.guaranteedBitrateKbps;
        }

        @Override
        public String toString() {
            return "Bandwidth {"
                    + " maxBitrateKbps=" + maxBitrateKbps
                    + " guaranteedBitrateKbps=" + guaranteedBitrateKbps + "}";
        }

        public static final @NonNull Parcelable.Creator<QosBandwidth> CREATOR =
                new Parcelable.Creator<QosBandwidth>() {
                    @Override
                    public QosBandwidth createFromParcel(Parcel source) {
                        return new QosBandwidth(source);
                    }

                    @Override
                    public QosBandwidth[] newArray(int size) {
                        return new QosBandwidth[size];
                    }
                };
    };

    protected Qos(@NonNull Parcel source) {
        type = source.readInt();
        downlink = source.readParcelable(QosBandwidth.class.getClassLoader());
        uplink = source.readParcelable(QosBandwidth.class.getClassLoader());
    }

    /**
     * Used by child classes for parceling.
     *
     * @hide
     */
    @CallSuper
    public void writeToParcel(@QosType int type, Parcel dest, int flags) {
        dest.writeInt(type);
        dest.writeParcelable(downlink, flags);
        dest.writeParcelable(uplink, flags);
    }

    /** @hide */
    public static @NonNull Qos create(@NonNull android.hardware.radio.V1_6.Qos qos) {
        switch (qos.getDiscriminator()) {
            case android.hardware.radio.V1_6.Qos.hidl_discriminator.eps:
                  return new EpsQos(qos.eps());
            case android.hardware.radio.V1_6.Qos.hidl_discriminator.nr:
                  return new NrQos(qos.nr());
            default:
                  return null;
        }
    }

    /** @hide */
    public @QosType int getType() {
        return type;
    }

    @Override
    public int hashCode() {
        return Objects.hash(downlink, uplink);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;

        Qos other = (Qos) o;
        return type == other.type
                && downlink.equals(other.downlink)
                && uplink.equals(other.uplink);
    }
}
Loading