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; |
| 19 | import android.os.Parcel; |
| 20 | import android.os.Parcelable; |
| 21 | |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 22 | /** |
| 23 | * Result of a {@link EuiccService#onGetEuiccProfileInfoList} operation. |
| 24 | * @hide |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 25 | * |
| 26 | * TODO(b/35851809): Make this a SystemApi. |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 27 | */ |
| 28 | public final class GetEuiccProfileInfoListResult implements Parcelable { |
| 29 | |
| 30 | public static final Creator<GetEuiccProfileInfoListResult> CREATOR = |
| 31 | new Creator<GetEuiccProfileInfoListResult>() { |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 32 | @Override |
| 33 | public GetEuiccProfileInfoListResult createFromParcel(Parcel in) { |
| 34 | return new GetEuiccProfileInfoListResult(in); |
| 35 | } |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 36 | |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 37 | @Override |
| 38 | public GetEuiccProfileInfoListResult[] newArray(int size) { |
| 39 | return new GetEuiccProfileInfoListResult[size]; |
| 40 | } |
| 41 | }; |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 42 | |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 43 | /** |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 44 | * Result of the operation. |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 45 | * |
| 46 | * <p>May be one of the predefined {@code RESULT_} constants in EuiccService or any |
| 47 | * implementation-specific code starting with {@link EuiccService#RESULT_FIRST_USER}. |
| 48 | */ |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 49 | public final int result; |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 50 | |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 51 | /** The profile list (only upon success). */ |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 52 | @Nullable |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 53 | public final EuiccProfileInfo[] profiles; |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 54 | |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 55 | /** Whether the eUICC is removable. */ |
| 56 | public final boolean isRemovable; |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 57 | |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 58 | /** |
| 59 | * Construct a new {@link GetEuiccProfileInfoListResult}. |
| 60 | * |
| 61 | * @param result Result of the operation. May be one of the predefined {@code RESULT_} constants |
| 62 | * in EuiccService or any implementation-specific code starting with |
| 63 | * {@link EuiccService#RESULT_FIRST_USER}. |
| 64 | * @param profiles the list of profiles. Should only be provided if the result is |
| 65 | * {@link EuiccService#RESULT_OK}. |
| 66 | * @param isRemovable whether the eUICC in this slot is removable. If true, the profiles |
| 67 | * returned here will only be considered accessible as long as this eUICC is present. |
| 68 | * Otherwise, they will remain accessible until the next time a response with isRemovable |
| 69 | * set to false is returned. |
| 70 | */ |
| 71 | public GetEuiccProfileInfoListResult( |
| 72 | int result, @Nullable EuiccProfileInfo[] profiles, boolean isRemovable) { |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 73 | this.result = result; |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 74 | this.isRemovable = isRemovable; |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 75 | if (this.result == EuiccService.RESULT_OK) { |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 76 | this.profiles = profiles; |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 77 | } else { |
| 78 | if (profiles != null) { |
| 79 | throw new IllegalArgumentException( |
| 80 | "Error result with non-null profiles: " + result); |
| 81 | } |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 82 | this.profiles = null; |
Jeff Davidson | 83f8bc8 | 2017-05-15 10:22:20 -0700 | [diff] [blame] | 83 | } |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 84 | |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | private GetEuiccProfileInfoListResult(Parcel in) { |
| 88 | this.result = in.readInt(); |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 89 | this.profiles = in.createTypedArray(EuiccProfileInfo.CREATOR); |
| 90 | this.isRemovable = in.readBoolean(); |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | @Override |
| 94 | public void writeToParcel(Parcel dest, int flags) { |
| 95 | dest.writeInt(result); |
Jiuyu Sun | d3bb4ae | 2018-02-08 16:38:26 +0000 | [diff] [blame] | 96 | dest.writeTypedArray(profiles, flags); |
| 97 | dest.writeBoolean(isRemovable); |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 98 | } |
| 99 | |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 100 | @Override |
| 101 | public int describeContents() { |
| 102 | return 0; |
| 103 | } |
| 104 | } |