Debian Codegraph @

telephony/java/android/service/euicc/GetDefaultDownloadableSubscriptionListResult.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2017 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 package android.service.euicc;
17
18 import android.annotation.Nullable;
19 import android.annotation.SystemApi;
20 import android.compat.annotation.UnsupportedAppUsage;
21 import android.os.Build;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 import android.telephony.euicc.DownloadableSubscription;
25
26 import java.util.Arrays;
27 import java.util.List;
28
29 /**
30 * Result of a {@link EuiccService#onGetDefaultDownloadableSubscriptionList} operation.
31 * @hide
32 */
33 @SystemApi
34 public final class GetDefaultDownloadableSubscriptionListResult implements Parcelable {
35
36 public static final @android.annotation.NonNull Creator<GetDefaultDownloadableSubscriptionListResult> CREATOR =
37 new Creator<GetDefaultDownloadableSubscriptionListResult>() {
38 @Override
39 public GetDefaultDownloadableSubscriptionListResult createFromParcel(Parcel in) {
40 return new GetDefaultDownloadableSubscriptionListResult(in);
41 }
42
43 @Override
44 public GetDefaultDownloadableSubscriptionListResult[] newArray(int size) {
45 return new GetDefaultDownloadableSubscriptionListResult[size];
46 }
47 };
48
49 /**
50 * @hide
51 * @deprecated - Do no use. Use getResult() instead.
52 */
53 @Deprecated
54 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
55 public final int result;
56
57 @Nullable
58 private final DownloadableSubscription[] mSubscriptions;
59
60 /**
61 * Gets the result of the operation.
62 *
63 * <p>May be one of the predefined {@code RESULT_} constants in EuiccService or any
64 * implementation-specific code starting with {@link EuiccService#RESULT_FIRST_USER}.
65 */
66 public int getResult() {
67 return result;
68 }
69
70 /**
71 * Gets the available {@link DownloadableSubscription}s (with filled-in metadata).
72 *
73 * <p>Only non-null if {@link #result} is {@link EuiccService#RESULT_OK}.
74 */
75 @Nullable
76 public List<DownloadableSubscription> getDownloadableSubscriptions() {
77 if (mSubscriptions == null) return null;
78 return Arrays.asList(mSubscriptions);
79 }
80
81 /**
82 * Construct a new {@link GetDefaultDownloadableSubscriptionListResult}.
83 *
84 * @param result Result of the operation. May be one of the predefined {@code RESULT_} constants
85 * in EuiccService or any implementation-specific code starting with
86 * {@link EuiccService#RESULT_FIRST_USER}.
87 * @param subscriptions The available subscriptions. Should only be provided if the result is
88 * {@link EuiccService#RESULT_OK}.
89 */
90 public GetDefaultDownloadableSubscriptionListResult(int result,
91 @Nullable DownloadableSubscription[] subscriptions) {
92 this.result = result;
93 if (this.result == EuiccService.RESULT_OK) {
94 this.mSubscriptions = subscriptions;
95 } else {
96 if (subscriptions != null) {
97 throw new IllegalArgumentException(
98 "Error result with non-null subscriptions: " + result);
99 }
100 this.mSubscriptions = null;
101 }
102 }
103
104 private GetDefaultDownloadableSubscriptionListResult(Parcel in) {
105 this.result = in.readInt();
106 this.mSubscriptions = in.createTypedArray(DownloadableSubscription.CREATOR);
107 }
108
109 @Override
110 public void writeToParcel(Parcel dest, int flags) {
111 dest.writeInt(result);
112 dest.writeTypedArray(mSubscriptions, flags);
113 }
114
115 @Override
116 public int describeContents() {
117 return 0;
118 }
119 }