blob: d0fb51180c1d4cfac7169c37d85735fab41fb87a [file] [log] [blame]
Jeff Davidson35cda392017-02-27 09:46:00 -08001/*
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 */
16package android.service.euicc;
17
Jeff Davidson35cda392017-02-27 09:46:00 -080018import android.annotation.Nullable;
Holly Jiuyu Sun4f73b9c2017-12-12 20:17:09 -080019import android.annotation.SystemApi;
Artur Satayev53ada2a2019-12-10 17:47:56 +000020import android.compat.annotation.UnsupportedAppUsage;
Jeff Davidson35cda392017-02-27 09:46:00 -080021import android.os.Parcel;
22import android.os.Parcelable;
23import android.telephony.euicc.DownloadableSubscription;
24
Jeff Davidson35cda392017-02-27 09:46:00 -080025/**
Jeff Davidson91c3d072017-04-12 12:17:11 -070026 * Result of a {@link EuiccService#onGetDownloadableSubscriptionMetadata} operation.
Jeff Davidson35cda392017-02-27 09:46:00 -080027 * @hide
Jeff Davidson35cda392017-02-27 09:46:00 -080028 */
Holly Jiuyu Sun4f73b9c2017-12-12 20:17:09 -080029@SystemApi
Jeff Davidson35cda392017-02-27 09:46:00 -080030public final class GetDownloadableSubscriptionMetadataResult implements Parcelable {
31
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070032 public static final @android.annotation.NonNull Creator<GetDownloadableSubscriptionMetadataResult> CREATOR =
Jeff Davidson35cda392017-02-27 09:46:00 -080033 new Creator<GetDownloadableSubscriptionMetadataResult>() {
34 @Override
35 public GetDownloadableSubscriptionMetadataResult createFromParcel(Parcel in) {
36 return new GetDownloadableSubscriptionMetadataResult(in);
37 }
38
39 @Override
40 public GetDownloadableSubscriptionMetadataResult[] newArray(int size) {
41 return new GetDownloadableSubscriptionMetadataResult[size];
42 }
43 };
44
Jeff Davidson83f8bc82017-05-15 10:22:20 -070045 /**
Holly Jiuyu Sun4f73b9c2017-12-12 20:17:09 -080046 * @hide
47 * @deprecated - Do no use. Use getResult() instead.
48 */
49 @Deprecated
Mathew Inwoode3807372018-08-10 09:51:03 +010050 @UnsupportedAppUsage
Holly Jiuyu Sun4f73b9c2017-12-12 20:17:09 -080051 public final int result;
52
53 @Nullable
54 private final DownloadableSubscription mSubscription;
55
56 /**
57 * Gets the result of the operation.
Jeff Davidson83f8bc82017-05-15 10:22:20 -070058 *
59 * <p>May be one of the predefined {@code RESULT_} constants in EuiccService or any
60 * implementation-specific code starting with {@link EuiccService#RESULT_FIRST_USER}.
61 */
Holly Jiuyu Sun4f73b9c2017-12-12 20:17:09 -080062 public int getResult() {
63 return result;
64 }
Jeff Davidson35cda392017-02-27 09:46:00 -080065
66 /**
Holly Jiuyu Sun4f73b9c2017-12-12 20:17:09 -080067 * Gets the {@link DownloadableSubscription} with filled-in metadata.
Jeff Davidson35cda392017-02-27 09:46:00 -080068 *
Jeff Davidson83f8bc82017-05-15 10:22:20 -070069 * <p>Only non-null if {@link #result} is {@link EuiccService#RESULT_OK}.
Jeff Davidson35cda392017-02-27 09:46:00 -080070 */
71 @Nullable
Holly Jiuyu Sun4f73b9c2017-12-12 20:17:09 -080072 public DownloadableSubscription getDownloadableSubscription() {
73 return mSubscription;
74 }
Jeff Davidson35cda392017-02-27 09:46:00 -080075
Jeff Davidson83f8bc82017-05-15 10:22:20 -070076 /**
77 * Construct a new {@link GetDownloadableSubscriptionMetadataResult}.
78 *
79 * @param result Result of the operation. May be one of the predefined {@code RESULT_} constants
80 * in EuiccService or any implementation-specific code starting with
81 * {@link EuiccService#RESULT_FIRST_USER}.
82 * @param subscription The subscription with filled-in metadata. Should only be provided if the
83 * result is {@link EuiccService#RESULT_OK}.
84 */
85 public GetDownloadableSubscriptionMetadataResult(int result,
86 @Nullable DownloadableSubscription subscription) {
Jeff Davidson35cda392017-02-27 09:46:00 -080087 this.result = result;
Jeff Davidson83f8bc82017-05-15 10:22:20 -070088 if (this.result == EuiccService.RESULT_OK) {
Holly Jiuyu Sun4f73b9c2017-12-12 20:17:09 -080089 this.mSubscription = subscription;
Jeff Davidson83f8bc82017-05-15 10:22:20 -070090 } else {
91 if (subscription != null) {
92 throw new IllegalArgumentException(
93 "Error result with non-null subscription: " + result);
94 }
Holly Jiuyu Sun4f73b9c2017-12-12 20:17:09 -080095 this.mSubscription = null;
Jeff Davidson83f8bc82017-05-15 10:22:20 -070096 }
Jeff Davidson35cda392017-02-27 09:46:00 -080097 }
98
99 private GetDownloadableSubscriptionMetadataResult(Parcel in) {
100 this.result = in.readInt();
Holly Jiuyu Sun4f73b9c2017-12-12 20:17:09 -0800101 this.mSubscription = in.readTypedObject(DownloadableSubscription.CREATOR);
Jeff Davidson35cda392017-02-27 09:46:00 -0800102 }
103
104 @Override
105 public void writeToParcel(Parcel dest, int flags) {
106 dest.writeInt(result);
Holly Jiuyu Sun4f73b9c2017-12-12 20:17:09 -0800107 dest.writeTypedObject(this.mSubscription, flags);
Jeff Davidson35cda392017-02-27 09:46:00 -0800108 }
109
110 @Override
111 public int describeContents() {
112 return 0;
113 }
114}