1 /*
2  * Copyright (C) 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 package android.service.euicc;
17 
18 import android.annotation.SystemApi;
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 import android.service.euicc.EuiccService.ResolvableError;
22 import android.service.euicc.EuiccService.Result;
23 
24 /**
25  * Result of a {@link EuiccService#onDownloadSubscription} operation.
26  * @hide
27  */
28 @SystemApi
29 public final class DownloadSubscriptionResult implements Parcelable {
30 
31     public static final @android.annotation.NonNull Creator<DownloadSubscriptionResult> CREATOR =
32             new Creator<DownloadSubscriptionResult>() {
33         @Override
34         public DownloadSubscriptionResult createFromParcel(Parcel in) {
35             return new DownloadSubscriptionResult(in);
36         }
37 
38         @Override
39         public DownloadSubscriptionResult[] newArray(int size) {
40             return new DownloadSubscriptionResult[size];
41         }
42     };
43 
44     private final @Result int mResult;
45     private final @ResolvableError int mResolvableErrors;
46     private final int mCardId;
47 
DownloadSubscriptionResult(@esult int result, @ResolvableError int resolvableErrors, int cardId)48     public DownloadSubscriptionResult(@Result int result, @ResolvableError int resolvableErrors,
49             int cardId) {
50         this.mResult = result;
51         this.mResolvableErrors = resolvableErrors;
52         this.mCardId = cardId;
53     }
54 
55     /** Gets the result of the operation. */
getResult()56     public @Result int getResult() {
57         return mResult;
58     }
59 
60     /**
61      * Gets the bit map of resolvable errors.
62      *
63      * <p>The value is passed from EuiccService. The values can be
64      *
65      * <ul>
66      * <li>{@link EuiccService#RESOLVABLE_ERROR_CONFIRMATION_CODE}
67      * <li>{@link EuiccService#RESOLVABLE_ERROR_POLICY_RULES}
68      * </ul>
69      */
getResolvableErrors()70     public @ResolvableError int getResolvableErrors() {
71         return mResolvableErrors;
72     }
73 
74     /**
75      * Gets the card Id. This is used when resolving resolvable errors. The value is passed from
76      * EuiccService.
77      */
getCardId()78     public int getCardId() {
79         return mCardId;
80     }
81 
82     @Override
writeToParcel(Parcel dest, int flags)83     public void writeToParcel(Parcel dest, int flags) {
84         dest.writeInt(mResult);
85         dest.writeInt(mResolvableErrors);
86         dest.writeInt(mCardId);
87     }
88 
89     @Override
describeContents()90     public int describeContents() {
91         return 0;
92     }
93 
DownloadSubscriptionResult(Parcel in)94     private DownloadSubscriptionResult(Parcel in) {
95         this.mResult = in.readInt();
96         this.mResolvableErrors = in.readInt();
97         this.mCardId = in.readInt();
98     }
99 }
100