• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 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.telephony.data;
18 
19 import android.annotation.NonNull;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22 
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.Objects;
26 
27 
28 /**
29  * Class that stores information specific to QOS session.
30  *
31  * @hide
32  */
33 public final class QosBearerSession implements Parcelable{
34 
35     final int qosBearerSessionId;
36     final Qos qos;
37     final List<QosBearerFilter> qosBearerFilterList;
38 
QosBearerSession(int qosBearerSessionId, @NonNull Qos qos, @NonNull List<QosBearerFilter> qosBearerFilterList)39     public QosBearerSession(int qosBearerSessionId, @NonNull Qos qos,
40             @NonNull List<QosBearerFilter> qosBearerFilterList) {
41         this.qosBearerSessionId = qosBearerSessionId;
42         this.qos = qos;
43         this.qosBearerFilterList = new ArrayList<>();
44         this.qosBearerFilterList.addAll(qosBearerFilterList);
45     }
46 
QosBearerSession(Parcel source)47     private QosBearerSession(Parcel source) {
48         qosBearerSessionId = source.readInt();
49         qos = source.readParcelable(Qos.class.getClassLoader(), android.telephony.data.Qos.class);
50         qosBearerFilterList = new ArrayList<>();
51         source.readList(qosBearerFilterList, QosBearerFilter.class.getClassLoader(), android.telephony.data.QosBearerFilter.class);
52     }
53 
getQosBearerSessionId()54     public int getQosBearerSessionId() {
55         return qosBearerSessionId;
56     }
57 
getQos()58     public Qos getQos() {
59         return qos;
60     }
61 
getQosBearerFilterList()62     public List<QosBearerFilter> getQosBearerFilterList() {
63         return qosBearerFilterList;
64     }
65 
66     @Override
writeToParcel(@onNull Parcel dest, int flags)67     public void writeToParcel(@NonNull Parcel dest, int flags) {
68         dest.writeInt(qosBearerSessionId);
69         if (qos.getType() == Qos.QOS_TYPE_EPS) {
70             dest.writeParcelable((EpsQos)qos, flags);
71         } else {
72             dest.writeParcelable((NrQos)qos, flags);
73         }
74         dest.writeList(qosBearerFilterList);
75     }
76 
77     @Override
describeContents()78     public int describeContents() {
79         return 0;
80     }
81 
82     @Override
toString()83     public String toString() {
84         return "QosBearerSession {"
85                 + " qosBearerSessionId=" + qosBearerSessionId
86                 + " qos=" + qos
87                 + " qosBearerFilterList=" + qosBearerFilterList + "}";
88     }
89 
90     @Override
hashCode()91     public int hashCode() {
92         return Objects.hash(qosBearerSessionId, qos, qosBearerFilterList);
93     }
94 
95     @Override
equals(Object o)96     public boolean equals(Object o) {
97         if (this == o) return true;
98 
99         if (o == null || !(o instanceof QosBearerSession)) {
100             return false;
101         }
102 
103         QosBearerSession other = (QosBearerSession) o;
104         return this.qosBearerSessionId == other.qosBearerSessionId
105                 && this.qos.equals(other.qos)
106                 && this.qosBearerFilterList.size() == other.qosBearerFilterList.size()
107                 && this.qosBearerFilterList.containsAll(other.qosBearerFilterList);
108     }
109 
110 
111     public static final @NonNull Parcelable.Creator<QosBearerSession> CREATOR =
112             new Parcelable.Creator<QosBearerSession>() {
113                 @Override
114                 public QosBearerSession createFromParcel(Parcel source) {
115                     return new QosBearerSession(source);
116                 }
117 
118                 @Override
119                 public QosBearerSession[] newArray(int size) {
120                     return new QosBearerSession[size];
121                 }
122             };
123 }
124