• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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 com.android.internal.telephony.cdnr;
18 
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 
22 import java.util.Objects;
23 
24 /**
25  * A container of carrier display name.
26  */
27 public class CarrierDisplayNameData implements Parcelable {
28     /** Service provider name. */
29     private final String mSpn;
30 
31     /** Data service provider name. */
32     private final String mDataSpn;
33 
34     /** PLMN network name */
35     private final String mPlmn;
36 
37     /** {@code True} if display service provider name is required. */
38     private final boolean mShowSpn;
39 
40     /** {@code True} if display PLMN network name is required. */
41     private final boolean mShowPlmn;
42 
CarrierDisplayNameData(String spn, String dataSpn, boolean showSpn, String plmn, boolean showPlmn)43     private CarrierDisplayNameData(String spn, String dataSpn, boolean showSpn, String plmn,
44             boolean showPlmn) {
45         this.mSpn = spn;
46         this.mDataSpn = dataSpn;
47         this.mShowSpn = showSpn;
48         this.mPlmn = plmn;
49         this.mShowPlmn = showPlmn;
50     }
51 
52     /**
53      * Get the service provider name.
54      * @return service provider name.
55      */
getSpn()56     public String getSpn() {
57         return mSpn;
58     }
59 
60     /**
61      * Get the service provider name of data provider.
62      * @return service provider name of data provider.
63      */
getDataSpn()64     public String getDataSpn() {
65         return mDataSpn;
66     }
67 
68     /**
69      * Get the PLMN network name.
70      * @return PLMN network name.
71      */
getPlmn()72     public String getPlmn() {
73         return mPlmn;
74     }
75 
76     /**
77      * Whether the spn should be displayed.
78      * @return
79      */
shouldShowSpn()80     public boolean shouldShowSpn() {
81         return mShowSpn;
82     }
83 
84     /**
85      * Whether the PLMN should be displayed.
86      * @return
87      */
shouldShowPlmn()88     public boolean shouldShowPlmn() {
89         return mShowPlmn;
90     }
91 
92     @Override
toString()93     public String toString() {
94         return String.format("{ spn = %s, dataSpn = %s, showSpn = %b, plmn = %s, showPlmn = %b",
95                 mSpn, mDataSpn, mShowSpn, mPlmn, mShowPlmn);
96     }
97 
98     @Override
describeContents()99     public int describeContents() {
100         return 0;
101     }
102 
103     @Override
writeToParcel(Parcel dest, int flags)104     public void writeToParcel(Parcel dest, int flags) {
105         dest.writeString(mSpn);
106         dest.writeString(mDataSpn);
107         dest.writeString(mPlmn);
108         dest.writeBoolean(mShowSpn);
109         dest.writeBoolean(mShowPlmn);
110     }
111 
CarrierDisplayNameData(Parcel source)112     private CarrierDisplayNameData(Parcel source) {
113         mSpn = source.readString();
114         mDataSpn = source.readString();
115         mPlmn = source.readString();
116         mShowSpn = source.readBoolean();
117         mShowPlmn = source.readBoolean();
118     }
119 
120     public static final Parcelable.Creator<CarrierDisplayNameData> CREATOR =
121             new Creator<CarrierDisplayNameData>() {
122                 @Override
123                 public CarrierDisplayNameData createFromParcel(Parcel source) {
124                     return new CarrierDisplayNameData(source);
125                 }
126 
127                 @Override
128                 public CarrierDisplayNameData[] newArray(int size) {
129                     return new CarrierDisplayNameData[size];
130                 }
131             };
132 
133     @Override
equals(Object o)134     public boolean equals(Object o) {
135         if (this == o) return true;
136         if (o == null || getClass() != o.getClass()) return false;
137         CarrierDisplayNameData that = (CarrierDisplayNameData) o;
138         return mShowSpn == that.mShowSpn
139                 && mShowPlmn == that.mShowPlmn
140                 && Objects.equals(mSpn, that.mSpn)
141                 && Objects.equals(mDataSpn, that.mDataSpn)
142                 && Objects.equals(mPlmn, that.mPlmn);
143     }
144 
145     @Override
hashCode()146     public int hashCode() {
147         return Objects.hash(mSpn, mDataSpn, mPlmn, mShowSpn, mShowPlmn);
148     }
149 
150     /** Builder class for {@link com.android.internal.telephony.cdnr.CarrierDisplayNameData}. */
151     public static final class Builder {
152         private String mSpn;
153         private String mDataSpn;
154         private String mPlmn;
155         private boolean mShowSpn;
156         private boolean mShowPlmn;
157 
Builder()158         public Builder() {
159             mSpn = null;
160             mDataSpn = null;
161             mPlmn = null;
162             mShowPlmn = false;
163             mShowSpn = false;
164         }
165 
166         /** Create a {@link com.android.internal.telephony.cdnr.CarrierDisplayNameData} instance. */
build()167         public CarrierDisplayNameData build() {
168             return new CarrierDisplayNameData(mSpn, mDataSpn, mShowSpn, mPlmn, mShowPlmn);
169         }
170 
171         /** Set service provider name. */
setSpn(String spn)172         public Builder setSpn(String spn) {
173             mSpn = spn;
174             return this;
175         }
176 
177         /** Set data service provider name. */
setDataSpn(String dataSpn)178         public Builder setDataSpn(String dataSpn) {
179             mDataSpn = dataSpn;
180             return this;
181         }
182 
183         /** Set PLMN network name. */
setPlmn(String plmn)184         public Builder setPlmn(String plmn) {
185             mPlmn = plmn;
186             return this;
187         }
188 
189         /** Set whether the service provider name should be displayed. */
setShowSpn(boolean showSpn)190         public Builder setShowSpn(boolean showSpn) {
191             mShowSpn = showSpn;
192             return this;
193         }
194 
195         /** Set whether the PLMN network name should be displayed. */
setShowPlmn(boolean showPlmn)196         public Builder setShowPlmn(boolean showPlmn) {
197             mShowPlmn = showPlmn;
198             return this;
199         }
200     }
201 }
202