blob: 5e5e028625b6fe97f8fbb3e695e241fbf16a682e [file] [log] [blame]
Aurimas Liutikasdc3f8852024-07-11 10:07:48 -07001/*
2 * Copyright 2018 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
17package android.telephony;
18
19import android.annotation.IntDef;
20import android.annotation.NonNull;
21import android.annotation.Nullable;
22import android.annotation.SystemApi;
23import android.os.Parcel;
24import android.os.Parcelable;
25
26import com.android.internal.annotations.VisibleForTesting;
27
28import java.lang.annotation.Retention;
29import java.lang.annotation.RetentionPolicy;
30import java.util.Objects;
31
32
33/**
34 * Class that stores information specific to data network registration.
35 * @hide
36 */
37@SystemApi
38public final class DataSpecificRegistrationInfo implements Parcelable {
39
40 /** @hide */
41 @Retention(RetentionPolicy.SOURCE)
42 @IntDef(
43 prefix = "LTE_ATTACH_TYPE_",
44 value = {
45 LTE_ATTACH_TYPE_UNKNOWN,
46 LTE_ATTACH_TYPE_EPS_ONLY,
47 LTE_ATTACH_TYPE_COMBINED,
48 })
49 public @interface LteAttachResultType {}
50
51 /**
52 * Default value.
53 * Attach type is unknown.
54 */
55 public static final int LTE_ATTACH_TYPE_UNKNOWN = 0;
56
57 /**
58 * LTE is attached with EPS only.
59 *
60 * Reference: 3GPP TS 24.301 9.9.3 EMM information elements.
61 */
62 public static final int LTE_ATTACH_TYPE_EPS_ONLY = 1;
63
64 /**
65 * LTE combined EPS and IMSI attach.
66 *
67 * Reference: 3GPP TS 24.301 9.9.3 EMM information elements.
68 */
69 public static final int LTE_ATTACH_TYPE_COMBINED = 2;
70
71 /** @hide */
72 @Retention(RetentionPolicy.SOURCE)
73 @IntDef(flag = true, prefix = {"LTE_ATTACH_EXTRA_INFO_"},
74 value = {
75 LTE_ATTACH_EXTRA_INFO_NONE,
76 LTE_ATTACH_EXTRA_INFO_CSFB_NOT_PREFERRED,
77 LTE_ATTACH_EXTRA_INFO_SMS_ONLY
78 })
79 public @interface LteAttachExtraInfo {}
80
81 /**
82 * Default value.
83 */
84 public static final int LTE_ATTACH_EXTRA_INFO_NONE = 0;
85
86 /**
87 * CSFB is not preferred.
88 * Applicable for LTE only.
89 *
90 * Reference: 3GPP TS 24.301 9.9.3 EMM information elements.
91 */
92 public static final int LTE_ATTACH_EXTRA_INFO_CSFB_NOT_PREFERRED = 1 << 0;
93
94 /**
95 * Attached for SMS only.
96 * Applicable for LTE only.
97 *
98 * Reference: 3GPP TS 24.301 9.9.3 EMM information elements.
99 */
100 public static final int LTE_ATTACH_EXTRA_INFO_SMS_ONLY = 1 << 1;
101
102 /**
103 * @hide
104 * The maximum number of simultaneous Data Calls that
105 * must be established using setupDataCall().
106 */
107 public final int maxDataCalls;
108
109 /**
110 * @hide
111 * Indicates if the use of dual connectivity with NR is restricted.
112 * Reference: 3GPP TS 24.301 v15.03 section 9.3.3.12A.
113 */
114 public final boolean isDcNrRestricted;
115
116 /**
117 * Indicates if NR is supported by the selected PLMN.
118 * @hide
119 * {@code true} if the bit N is in the PLMN-InfoList-r15 is true and the selected PLMN is
120 * present in plmn-IdentityList at position N.
121 * Reference: 3GPP TS 36.331 v15.2.2 section 6.3.1 PLMN-InfoList-r15.
122 * 3GPP TS 36.331 v15.2.2 section 6.2.2 SystemInformationBlockType1 message.
123 */
124 public final boolean isNrAvailable;
125
126 /**
127 * @hide
128 * Indicates that if E-UTRA-NR Dual Connectivity (EN-DC) is supported by the primary serving
129 * cell.
130 *
131 * True the primary serving cell is LTE cell and the plmn-InfoList-r15 is present in SIB2 and
132 * at least one bit in this list is true, otherwise this value should be false.
133 *
134 * Reference: 3GPP TS 36.331 v15.2.2 6.3.1 System information blocks.
135 */
136 public final boolean isEnDcAvailable;
137
138 /**
139 * Provides network support info for VoPS and Emergency bearer support
140 */
141 @Nullable
142 private final VopsSupportInfo mVopsSupportInfo;
143
144 /** The type of network attachment */
145 private final @LteAttachResultType int mLteAttachResultType;
146
147 /** LTE attach extra info */
148 private final @LteAttachExtraInfo int mLteAttachExtraInfo;
149
150 private DataSpecificRegistrationInfo(Builder builder) {
151 this.maxDataCalls = builder.mMaxDataCalls;
152 this.isDcNrRestricted = builder.mIsDcNrRestricted;
153 this.isNrAvailable = builder.mIsNrAvailable;
154 this.isEnDcAvailable = builder.mIsEnDcAvailable;
155 this.mVopsSupportInfo = builder.mVopsSupportInfo;
156 this.mLteAttachResultType = builder.mLteAttachResultType;
157 this.mLteAttachExtraInfo = builder.mLteAttachExtraInfo;
158 }
159
160 /**
161 * @hide
162 */
163 @VisibleForTesting
164 public DataSpecificRegistrationInfo(
165 int maxDataCalls, boolean isDcNrRestricted, boolean isNrAvailable,
166 boolean isEnDcAvailable, @Nullable VopsSupportInfo vops) {
167 this.maxDataCalls = maxDataCalls;
168 this.isDcNrRestricted = isDcNrRestricted;
169 this.isNrAvailable = isNrAvailable;
170 this.isEnDcAvailable = isEnDcAvailable;
171 this.mVopsSupportInfo = vops;
172 this.mLteAttachResultType = LTE_ATTACH_TYPE_UNKNOWN;
173 this.mLteAttachExtraInfo = LTE_ATTACH_EXTRA_INFO_NONE;
174 }
175
176 /**
177 * Constructor from another data specific registration info
178 *
179 * @param dsri another data specific registration info
180 * @hide
181 */
182 DataSpecificRegistrationInfo(@NonNull DataSpecificRegistrationInfo dsri) {
183 maxDataCalls = dsri.maxDataCalls;
184 isDcNrRestricted = dsri.isDcNrRestricted;
185 isNrAvailable = dsri.isNrAvailable;
186 isEnDcAvailable = dsri.isEnDcAvailable;
187 mVopsSupportInfo = dsri.mVopsSupportInfo;
188 mLteAttachResultType = dsri.mLteAttachResultType;
189 mLteAttachExtraInfo = dsri.mLteAttachExtraInfo;
190 }
191
192 private DataSpecificRegistrationInfo(/* @NonNull */ Parcel source) {
193 maxDataCalls = source.readInt();
194 isDcNrRestricted = source.readBoolean();
195 isNrAvailable = source.readBoolean();
196 isEnDcAvailable = source.readBoolean();
197 mVopsSupportInfo = source.readParcelable(VopsSupportInfo.class.getClassLoader(), android.telephony.VopsSupportInfo.class);
198 mLteAttachResultType = source.readInt();
199 mLteAttachExtraInfo = source.readInt();
200 }
201
202 @Override
203 public void writeToParcel(/* @NonNull */ Parcel dest, int flags) {
204 dest.writeInt(maxDataCalls);
205 dest.writeBoolean(isDcNrRestricted);
206 dest.writeBoolean(isNrAvailable);
207 dest.writeBoolean(isEnDcAvailable);
208 dest.writeParcelable(mVopsSupportInfo, flags);
209 dest.writeInt(mLteAttachResultType);
210 dest.writeInt(mLteAttachExtraInfo);
211 }
212
213 @Override
214 public int describeContents() {
215 return 0;
216 }
217
218 @NonNull
219 @Override
220 public String toString() {
221 return new StringBuilder().append(this.getClass().getName())
222 .append(" :{")
223 .append(" maxDataCalls = " + maxDataCalls)
224 .append(" isDcNrRestricted = " + isDcNrRestricted)
225 .append(" isNrAvailable = " + isNrAvailable)
226 .append(" isEnDcAvailable = " + isEnDcAvailable)
227 .append(" mLteAttachResultType = " + mLteAttachResultType)
228 .append(" mLteAttachExtraInfo = " + mLteAttachExtraInfo)
229 .append(" " + mVopsSupportInfo)
230 .append(" }")
231 .toString();
232 }
233
234 @Override
235 public int hashCode() {
236 return Objects.hash(maxDataCalls, isDcNrRestricted, isNrAvailable,
237 isEnDcAvailable, mVopsSupportInfo,
238 mLteAttachResultType, mLteAttachExtraInfo);
239 }
240
241 @Override
242 public boolean equals(@Nullable Object o) {
243 if (this == o) return true;
244
245 if (!(o instanceof DataSpecificRegistrationInfo)) return false;
246
247 DataSpecificRegistrationInfo other = (DataSpecificRegistrationInfo) o;
248 return this.maxDataCalls == other.maxDataCalls
249 && this.isDcNrRestricted == other.isDcNrRestricted
250 && this.isNrAvailable == other.isNrAvailable
251 && this.isEnDcAvailable == other.isEnDcAvailable
252 && Objects.equals(mVopsSupportInfo, other.mVopsSupportInfo)
253 && this.mLteAttachResultType == other.mLteAttachResultType
254 && this.mLteAttachExtraInfo == other.mLteAttachExtraInfo;
255 }
256
257 public static final @NonNull Parcelable.Creator<DataSpecificRegistrationInfo> CREATOR =
258 new Parcelable.Creator<DataSpecificRegistrationInfo>() {
259 @Override
260 public DataSpecificRegistrationInfo createFromParcel(Parcel source) {
261 return new DataSpecificRegistrationInfo(source);
262 }
263
264 @Override
265 public DataSpecificRegistrationInfo[] newArray(int size) {
266 return new DataSpecificRegistrationInfo[size];
267 }
268 };
269
270 /**
271 * @return The LTE VOPS (Voice over Packet Switched) support information
272 *
273 * @deprecated use {@link #getVopsSupportInfo()}
274 */
275 @Deprecated
276 @NonNull
277 public LteVopsSupportInfo getLteVopsSupportInfo() {
278 return mVopsSupportInfo instanceof LteVopsSupportInfo
279 ? (LteVopsSupportInfo) mVopsSupportInfo
280 : new LteVopsSupportInfo(LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE,
281 LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE);
282 }
283
284 /**
285 * @return The VOPS (Voice over Packet Switched) support information.
286 *
287 * The instance of {@link LteVopsSupportInfo}, or {@link NrVopsSupportInfo},
288 * null if there is there is no VOPS support information available.
289 */
290 @Nullable
291 public VopsSupportInfo getVopsSupportInfo() {
292 return mVopsSupportInfo;
293 }
294
295 /**
296 * Provides the LTE attach type.
297 */
298 public @LteAttachResultType int getLteAttachResultType() {
299 return mLteAttachResultType;
300 }
301
302 /**
303 * Provides the extra information of LTE attachment.
304 *
305 * @return the bitwise OR of {@link LteAttachExtraInfo}.
306 */
307 public @LteAttachExtraInfo int getLteAttachExtraInfo() {
308 return mLteAttachExtraInfo;
309 }
310
311 /**
312 * Builds {@link DataSpecificRegistrationInfo} instances, which may include optional parameters.
313 * @hide
314 */
315 public static final class Builder {
316 private final int mMaxDataCalls;
317
318 private boolean mIsDcNrRestricted;
319 private boolean mIsNrAvailable;
320 private boolean mIsEnDcAvailable;
321 private @Nullable VopsSupportInfo mVopsSupportInfo;
322 private @LteAttachResultType int mLteAttachResultType = LTE_ATTACH_TYPE_UNKNOWN;
323 private @LteAttachExtraInfo int mLteAttachExtraInfo = LTE_ATTACH_EXTRA_INFO_NONE;
324
325 public Builder(int maxDataCalls) {
326 mMaxDataCalls = maxDataCalls;
327 }
328
329 /**
330 * Ses whether the use of dual connectivity with NR is restricted.
331 * @param isDcNrRestricted {@code true} if the use of dual connectivity with NR is
332 * restricted.
333 */
334 public @NonNull Builder setDcNrRestricted(boolean isDcNrRestricted) {
335 mIsDcNrRestricted = isDcNrRestricted;
336 return this;
337 }
338
339 /**
340 * Sets whether NR is supported by the selected PLMN.
341 * @param isNrAvailable {@code true} if NR is supported.
342 */
343 public @NonNull Builder setNrAvailable(boolean isNrAvailable) {
344 mIsNrAvailable = isNrAvailable;
345 return this;
346 }
347
348 /**
349 * Sets whether E-UTRA-NR Dual Connectivity (EN-DC) is supported by the primary serving
350 * cell.
351 * @param isEnDcAvailable {@code true} if EN_DC is supported.
352 */
353 public @NonNull Builder setEnDcAvailable(boolean isEnDcAvailable) {
354 mIsEnDcAvailable = isEnDcAvailable;
355 return this;
356 }
357
358 /**
359 * Sets the network support info for VoPS and Emergency bearer support.
360 * @param vops The network support info for VoPS and Emergency bearer support.
361 */
362 @Nullable
363 public @NonNull Builder setVopsSupportInfo(VopsSupportInfo vops) {
364 mVopsSupportInfo = vops;
365 return this;
366 }
367
368 /**
369 * Sets the LTE attach type.
370 * @param lteAttachResultType the Lte attach type
371 */
372 public @NonNull Builder setLteAttachResultType(
373 @LteAttachResultType int lteAttachResultType) {
374 mLteAttachResultType = lteAttachResultType;
375 return this;
376 }
377
378 /**
379 * Sets the extra information of LTE attachment.
380 * @param lteAttachExtraInfo the extra information of LTE attachment.
381 */
382 public @NonNull Builder setLteAttachExtraInfo(
383 @LteAttachExtraInfo int lteAttachExtraInfo) {
384 mLteAttachExtraInfo = lteAttachExtraInfo;
385 return this;
386 }
387
388 /**
389 * @return a built {@link DataSpecificRegistrationInfo} instance.
390 */
391 public @NonNull DataSpecificRegistrationInfo build() {
392 return new DataSpecificRegistrationInfo(this);
393 }
394 }
395}