Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [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 | d02731f | 2017-04-09 14:31:09 -0700 | [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; |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 20 | import android.os.Parcel; |
| 21 | import android.os.Parcelable; |
| 22 | |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 23 | import java.util.Arrays; |
| 24 | import java.util.List; |
| 25 | |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 26 | /** |
| 27 | * Result of a {@link EuiccService#onGetEuiccProfileInfoList} operation. |
| 28 | * @hide |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 29 | */ |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 30 | @SystemApi |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 31 | public final class GetEuiccProfileInfoListResult implements Parcelable { |
| 32 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 33 | public static final @android.annotation.NonNull Creator<GetEuiccProfileInfoListResult> CREATOR = |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 34 | new Creator<GetEuiccProfileInfoListResult>() { |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 35 | @Override |
| 36 | public GetEuiccProfileInfoListResult createFromParcel(Parcel in) { |
| 37 | return new GetEuiccProfileInfoListResult(in); |
| 38 | } |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 39 | |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 40 | @Override |
| 41 | public GetEuiccProfileInfoListResult[] newArray(int size) { |
| 42 | return new GetEuiccProfileInfoListResult[size]; |
| 43 | } |
| 44 | }; |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 45 | |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 46 | /** |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 47 | * @hide |
| 48 | * @deprecated - Do no use. Use getResult() instead. |
| 49 | */ |
| 50 | @Deprecated |
| 51 | public final int result; |
| 52 | |
| 53 | @Nullable |
| 54 | private final EuiccProfileInfo[] mProfiles; |
| 55 | |
| 56 | private final boolean mIsRemovable; |
| 57 | |
| 58 | /** |
| 59 | * Gets the result of the operation. |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 60 | * |
| 61 | * <p>May be one of the predefined {@code RESULT_} constants in EuiccService or any |
| 62 | * implementation-specific code starting with {@link EuiccService#RESULT_FIRST_USER}. |
| 63 | */ |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 64 | public int getResult() { |
| 65 | return result; |
| 66 | } |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 67 | |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 68 | /** Gets the profile list (only upon success). */ |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 69 | @Nullable |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 70 | public List<EuiccProfileInfo> getProfiles() { |
| 71 | if (mProfiles == null) return null; |
| 72 | return Arrays.asList(mProfiles); |
| 73 | } |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 74 | |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 75 | /** Gets whether the eUICC is removable. */ |
| 76 | public boolean getIsRemovable() { |
| 77 | return mIsRemovable; |
| 78 | } |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 79 | |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 80 | /** |
| 81 | * Construct a new {@link GetEuiccProfileInfoListResult}. |
| 82 | * |
| 83 | * @param result Result of the operation. May be one of the predefined {@code RESULT_} constants |
| 84 | * in EuiccService or any implementation-specific code starting with |
| 85 | * {@link EuiccService#RESULT_FIRST_USER}. |
| 86 | * @param profiles the list of profiles. Should only be provided if the result is |
| 87 | * {@link EuiccService#RESULT_OK}. |
| 88 | * @param isRemovable whether the eUICC in this slot is removable. If true, the profiles |
| 89 | * returned here will only be considered accessible as long as this eUICC is present. |
| 90 | * Otherwise, they will remain accessible until the next time a response with isRemovable |
| 91 | * set to false is returned. |
| 92 | */ |
| 93 | public GetEuiccProfileInfoListResult( |
| 94 | int result, @Nullable EuiccProfileInfo[] profiles, boolean isRemovable) { |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 95 | this.result = result; |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 96 | this.mIsRemovable = isRemovable; |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 97 | if (this.result == EuiccService.RESULT_OK) { |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 98 | this.mProfiles = profiles; |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 99 | } else { |
| 100 | if (profiles != null) { |
| 101 | throw new IllegalArgumentException( |
| 102 | "Error result with non-null profiles: " + result); |
| 103 | } |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 104 | this.mProfiles = null; |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 105 | } |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | private GetEuiccProfileInfoListResult(Parcel in) { |
| 109 | this.result = in.readInt(); |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 110 | this.mProfiles = in.createTypedArray(EuiccProfileInfo.CREATOR); |
| 111 | this.mIsRemovable = in.readBoolean(); |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | @Override |
| 115 | public void writeToParcel(Parcel dest, int flags) { |
| 116 | dest.writeInt(result); |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 117 | dest.writeTypedArray(mProfiles, flags); |
| 118 | dest.writeBoolean(mIsRemovable); |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 119 | } |
| 120 | |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 121 | @Override |
| 122 | public int describeContents() { |
| 123 | return 0; |
| 124 | } |
| 125 | } |