Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 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 | |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 18 | import android.annotation.Nullable; |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 19 | import android.annotation.SystemApi; |
Mathew Inwood | e380737 | 2018-08-10 09:51:03 +0100 | [diff] [blame^] | 20 | import android.annotation.UnsupportedAppUsage; |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 21 | import android.os.Parcel; |
| 22 | import android.os.Parcelable; |
| 23 | import android.telephony.euicc.DownloadableSubscription; |
| 24 | |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 25 | /** |
Jeff Davidson | 91c3d07 | 2017-04-12 12:17:11 -0700 | [diff] [blame] | 26 | * Result of a {@link EuiccService#onGetDownloadableSubscriptionMetadata} operation. |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 27 | * @hide |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 28 | */ |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 29 | @SystemApi |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 30 | public final class GetDownloadableSubscriptionMetadataResult implements Parcelable { |
| 31 | |
| 32 | public static final Creator<GetDownloadableSubscriptionMetadataResult> CREATOR = |
| 33 | 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 Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 45 | /** |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 46 | * @hide |
| 47 | * @deprecated - Do no use. Use getResult() instead. |
| 48 | */ |
| 49 | @Deprecated |
Mathew Inwood | e380737 | 2018-08-10 09:51:03 +0100 | [diff] [blame^] | 50 | @UnsupportedAppUsage |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 51 | public final int result; |
| 52 | |
| 53 | @Nullable |
| 54 | private final DownloadableSubscription mSubscription; |
| 55 | |
| 56 | /** |
| 57 | * Gets the result of the operation. |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 58 | * |
| 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 Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 62 | public int getResult() { |
| 63 | return result; |
| 64 | } |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 65 | |
| 66 | /** |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 67 | * Gets the {@link DownloadableSubscription} with filled-in metadata. |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 68 | * |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 69 | * <p>Only non-null if {@link #result} is {@link EuiccService#RESULT_OK}. |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 70 | */ |
| 71 | @Nullable |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 72 | public DownloadableSubscription getDownloadableSubscription() { |
| 73 | return mSubscription; |
| 74 | } |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 75 | |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 76 | /** |
| 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 Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 87 | this.result = result; |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 88 | if (this.result == EuiccService.RESULT_OK) { |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 89 | this.mSubscription = subscription; |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 90 | } else { |
| 91 | if (subscription != null) { |
| 92 | throw new IllegalArgumentException( |
| 93 | "Error result with non-null subscription: " + result); |
| 94 | } |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 95 | this.mSubscription = null; |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 96 | } |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | private GetDownloadableSubscriptionMetadataResult(Parcel in) { |
| 100 | this.result = in.readInt(); |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 101 | this.mSubscription = in.readTypedObject(DownloadableSubscription.CREATOR); |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | @Override |
| 105 | public void writeToParcel(Parcel dest, int flags) { |
| 106 | dest.writeInt(result); |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 107 | dest.writeTypedObject(this.mSubscription, flags); |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | @Override |
| 111 | public int describeContents() { |
| 112 | return 0; |
| 113 | } |
| 114 | } |