blob: ba6c9a2d1b57298fd2abb9cdfa04b606510147f6 [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
18import android.annotation.Nullable;
19import android.os.Parcel;
20import android.os.Parcelable;
21import android.telephony.UiccAccessRule;
22import android.text.TextUtils;
23
24/**
25 * Information about an embedded profile (subscription) on an eUICC.
26 *
27 * @hide
28 *
29 * TODO(b/35851809): Make this a SystemApi.
30 */
31public final class EuiccProfileInfo implements Parcelable {
32
33 /** The iccid of the subscription. */
34 public final String iccid;
35
36 /**
37 * Optional access rules defining which apps can manage this subscription. If unset, only the
38 * platform can manage it.
39 */
40 public final @Nullable UiccAccessRule[] accessRules;
41
42 /** An optional nickname for the subscription. */
43 public final @Nullable String nickname;
44
45 public static final Creator<EuiccProfileInfo> CREATOR = new Creator<EuiccProfileInfo>() {
46 @Override
47 public EuiccProfileInfo createFromParcel(Parcel in) {
48 return new EuiccProfileInfo(in);
49 }
50
51 @Override
52 public EuiccProfileInfo[] newArray(int size) {
53 return new EuiccProfileInfo[size];
54 }
55 };
56
57 public EuiccProfileInfo(String iccid, @Nullable UiccAccessRule[] accessRules,
58 @Nullable String nickname) {
59 if (!TextUtils.isDigitsOnly(iccid)) {
60 throw new IllegalArgumentException("iccid contains invalid characters: " + iccid);
61 }
62 this.iccid = iccid;
63 this.accessRules = accessRules;
64 this.nickname = nickname;
65 }
66
67 private EuiccProfileInfo(Parcel in) {
68 iccid = in.readString();
69 accessRules = in.createTypedArray(UiccAccessRule.CREATOR);
70 nickname = in.readString();
71 }
72
73 @Override
74 public void writeToParcel(Parcel dest, int flags) {
75 dest.writeString(iccid);
76 dest.writeTypedArray(accessRules, flags);
77 dest.writeString(nickname);
78 }
79
80 @Override
81 public int describeContents() {
82 return 0;
83 }
84}