blob: 7ad84888dc829c096e59552be4fe0fe8a04db2a0 [file] [log] [blame]
Jeff Davidsond02731f2017-04-09 14:31:09 -07001/*
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 Davidsond02731f2017-04-09 14:31:09 -070018import android.annotation.Nullable;
19import android.os.Parcel;
20import android.os.Parcelable;
21
Jeff Davidsond02731f2017-04-09 14:31:09 -070022/**
23 * Result of a {@link EuiccService#onGetEuiccProfileInfoList} operation.
24 * @hide
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +000025 *
26 * TODO(b/35851809): Make this a SystemApi.
Jeff Davidsond02731f2017-04-09 14:31:09 -070027 */
28public final class GetEuiccProfileInfoListResult implements Parcelable {
29
30 public static final Creator<GetEuiccProfileInfoListResult> CREATOR =
31 new Creator<GetEuiccProfileInfoListResult>() {
Jeff Davidson83f8bc82017-05-15 10:22:20 -070032 @Override
33 public GetEuiccProfileInfoListResult createFromParcel(Parcel in) {
34 return new GetEuiccProfileInfoListResult(in);
35 }
Jeff Davidsond02731f2017-04-09 14:31:09 -070036
Jeff Davidson83f8bc82017-05-15 10:22:20 -070037 @Override
38 public GetEuiccProfileInfoListResult[] newArray(int size) {
39 return new GetEuiccProfileInfoListResult[size];
40 }
41 };
Jeff Davidsond02731f2017-04-09 14:31:09 -070042
Jeff Davidson83f8bc82017-05-15 10:22:20 -070043 /**
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +000044 * Result of the operation.
Jeff Davidson83f8bc82017-05-15 10:22:20 -070045 *
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 Sund3bb4ae2018-02-08 16:38:26 +000049 public final int result;
Jeff Davidsond02731f2017-04-09 14:31:09 -070050
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +000051 /** The profile list (only upon success). */
Jeff Davidsond02731f2017-04-09 14:31:09 -070052 @Nullable
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +000053 public final EuiccProfileInfo[] profiles;
Jeff Davidsond02731f2017-04-09 14:31:09 -070054
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +000055 /** Whether the eUICC is removable. */
56 public final boolean isRemovable;
Jeff Davidsond02731f2017-04-09 14:31:09 -070057
Jeff Davidson83f8bc82017-05-15 10:22:20 -070058 /**
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 Davidsond02731f2017-04-09 14:31:09 -070073 this.result = result;
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +000074 this.isRemovable = isRemovable;
Jeff Davidson83f8bc82017-05-15 10:22:20 -070075 if (this.result == EuiccService.RESULT_OK) {
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +000076 this.profiles = profiles;
Jeff Davidson83f8bc82017-05-15 10:22:20 -070077 } else {
78 if (profiles != null) {
79 throw new IllegalArgumentException(
80 "Error result with non-null profiles: " + result);
81 }
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +000082 this.profiles = null;
Jeff Davidson83f8bc82017-05-15 10:22:20 -070083 }
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +000084
Jeff Davidsond02731f2017-04-09 14:31:09 -070085 }
86
87 private GetEuiccProfileInfoListResult(Parcel in) {
88 this.result = in.readInt();
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +000089 this.profiles = in.createTypedArray(EuiccProfileInfo.CREATOR);
90 this.isRemovable = in.readBoolean();
Jeff Davidsond02731f2017-04-09 14:31:09 -070091 }
92
93 @Override
94 public void writeToParcel(Parcel dest, int flags) {
95 dest.writeInt(result);
Jiuyu Sund3bb4ae2018-02-08 16:38:26 +000096 dest.writeTypedArray(profiles, flags);
97 dest.writeBoolean(isRemovable);
Jeff Davidsond02731f2017-04-09 14:31:09 -070098 }
99
Jeff Davidsond02731f2017-04-09 14:31:09 -0700100 @Override
101 public int describeContents() {
102 return 0;
103 }
104}