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 | |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 18 | import android.annotation.IntDef; |
Aurimas Liutikas | 00be951 | 2019-08-28 13:01:05 -0700 | [diff] [blame] | 19 | import android.annotation.NonNull; |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 20 | import android.annotation.Nullable; |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 21 | import android.annotation.SystemApi; |
Artur Satayev | 53ada2a | 2019-12-10 17:47:56 +0000 | [diff] [blame^] | 22 | import android.compat.annotation.UnsupportedAppUsage; |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 23 | import android.os.Parcel; |
| 24 | import android.os.Parcelable; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 25 | import android.service.carrier.CarrierIdentifier; |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 26 | import android.telephony.UiccAccessRule; |
| 27 | import android.text.TextUtils; |
| 28 | |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 29 | import java.lang.annotation.Retention; |
| 30 | import java.lang.annotation.RetentionPolicy; |
| 31 | import java.util.Arrays; |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 32 | import java.util.List; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 33 | import java.util.Objects; |
| 34 | |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 35 | /** |
| 36 | * Information about an embedded profile (subscription) on an eUICC. |
| 37 | * |
| 38 | * @hide |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 39 | */ |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 40 | @SystemApi |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 41 | public final class EuiccProfileInfo implements Parcelable { |
| 42 | |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 43 | /** Profile policy rules (bit mask) */ |
| 44 | @Retention(RetentionPolicy.SOURCE) |
| 45 | @IntDef(flag = true, prefix = { "POLICY_RULE_" }, value = { |
| 46 | POLICY_RULE_DO_NOT_DISABLE, |
| 47 | POLICY_RULE_DO_NOT_DELETE, |
| 48 | POLICY_RULE_DELETE_AFTER_DISABLING |
| 49 | }) |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 50 | /** @hide */ |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 51 | public @interface PolicyRule {} |
| 52 | /** Once this profile is enabled, it cannot be disabled. */ |
| 53 | public static final int POLICY_RULE_DO_NOT_DISABLE = 1; |
| 54 | /** This profile cannot be deleted. */ |
| 55 | public static final int POLICY_RULE_DO_NOT_DELETE = 1 << 1; |
| 56 | /** This profile should be deleted after being disabled. */ |
| 57 | public static final int POLICY_RULE_DELETE_AFTER_DISABLING = 1 << 2; |
| 58 | |
| 59 | /** Class of the profile */ |
| 60 | @Retention(RetentionPolicy.SOURCE) |
| 61 | @IntDef(prefix = { "PROFILE_CLASS_" }, value = { |
| 62 | PROFILE_CLASS_TESTING, |
| 63 | PROFILE_CLASS_PROVISIONING, |
| 64 | PROFILE_CLASS_OPERATIONAL, |
| 65 | PROFILE_CLASS_UNSET |
| 66 | }) |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 67 | /** @hide */ |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 68 | public @interface ProfileClass {} |
| 69 | /** Testing profiles */ |
| 70 | public static final int PROFILE_CLASS_TESTING = 0; |
| 71 | /** Provisioning profiles which are pre-loaded on eUICC */ |
| 72 | public static final int PROFILE_CLASS_PROVISIONING = 1; |
| 73 | /** Operational profiles which can be pre-loaded or downloaded */ |
| 74 | public static final int PROFILE_CLASS_OPERATIONAL = 2; |
| 75 | /** |
| 76 | * Profile class not set. |
| 77 | * @hide |
| 78 | */ |
| 79 | public static final int PROFILE_CLASS_UNSET = -1; |
| 80 | |
| 81 | /** State of the profile */ |
| 82 | @Retention(RetentionPolicy.SOURCE) |
| 83 | @IntDef(prefix = { "PROFILE_STATE_" }, value = { |
| 84 | PROFILE_STATE_DISABLED, |
| 85 | PROFILE_STATE_ENABLED, |
| 86 | PROFILE_STATE_UNSET |
| 87 | }) |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 88 | /** @hide */ |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 89 | public @interface ProfileState {} |
| 90 | /** Disabled profiles */ |
| 91 | public static final int PROFILE_STATE_DISABLED = 0; |
| 92 | /** Enabled profile */ |
| 93 | public static final int PROFILE_STATE_ENABLED = 1; |
| 94 | /** |
| 95 | * Profile state not set. |
| 96 | * @hide |
| 97 | */ |
| 98 | public static final int PROFILE_STATE_UNSET = -1; |
| 99 | |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 100 | /** The iccid of the subscription. */ |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 101 | private final String mIccid; |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 102 | |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 103 | /** An optional nickname for the subscription. */ |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 104 | private final @Nullable String mNickname; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 105 | |
| 106 | /** The service provider name for the subscription. */ |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 107 | private final String mServiceProviderName; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 108 | |
| 109 | /** The profile name for the subscription. */ |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 110 | private final String mProfileName; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 111 | |
| 112 | /** Profile class for the subscription. */ |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 113 | @ProfileClass private final int mProfileClass; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 114 | |
| 115 | /** The profile state of the subscription. */ |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 116 | @ProfileState private final int mState; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 117 | |
| 118 | /** The operator Id of the subscription. */ |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 119 | private final CarrierIdentifier mCarrierIdentifier; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 120 | |
| 121 | /** The policy rules of the subscription. */ |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 122 | @PolicyRule private final int mPolicyRules; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 123 | |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 124 | /** |
| 125 | * Optional access rules defining which apps can manage this subscription. If unset, only the |
| 126 | * platform can manage it. |
| 127 | */ |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 128 | private final @Nullable UiccAccessRule[] mAccessRules; |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 129 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 130 | public static final @android.annotation.NonNull Creator<EuiccProfileInfo> CREATOR = new Creator<EuiccProfileInfo>() { |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 131 | @Override |
| 132 | public EuiccProfileInfo createFromParcel(Parcel in) { |
| 133 | return new EuiccProfileInfo(in); |
| 134 | } |
| 135 | |
| 136 | @Override |
| 137 | public EuiccProfileInfo[] newArray(int size) { |
| 138 | return new EuiccProfileInfo[size]; |
| 139 | } |
| 140 | }; |
| 141 | |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 142 | // TODO(b/70292228): Remove this method when LPA can be updated. |
| 143 | /** |
| 144 | * @hide |
| 145 | * @deprecated - Do not use. |
| 146 | */ |
| 147 | @Deprecated |
Mathew Inwood | e380737 | 2018-08-10 09:51:03 +0100 | [diff] [blame] | 148 | @UnsupportedAppUsage |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 149 | public EuiccProfileInfo(String iccid, @Nullable UiccAccessRule[] accessRules, |
| 150 | @Nullable String nickname) { |
| 151 | if (!TextUtils.isDigitsOnly(iccid)) { |
| 152 | throw new IllegalArgumentException("iccid contains invalid characters: " + iccid); |
| 153 | } |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 154 | this.mIccid = iccid; |
| 155 | this.mAccessRules = accessRules; |
| 156 | this.mNickname = nickname; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 157 | |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 158 | this.mServiceProviderName = null; |
| 159 | this.mProfileName = null; |
| 160 | this.mProfileClass = PROFILE_CLASS_UNSET; |
| 161 | this.mState = PROFILE_STATE_UNSET; |
| 162 | this.mCarrierIdentifier = null; |
| 163 | this.mPolicyRules = 0; |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | private EuiccProfileInfo(Parcel in) { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 167 | mIccid = in.readString(); |
| 168 | mNickname = in.readString(); |
| 169 | mServiceProviderName = in.readString(); |
| 170 | mProfileName = in.readString(); |
| 171 | mProfileClass = in.readInt(); |
| 172 | mState = in.readInt(); |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 173 | byte exist = in.readByte(); |
| 174 | if (exist == (byte) 1) { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 175 | mCarrierIdentifier = CarrierIdentifier.CREATOR.createFromParcel(in); |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 176 | } else { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 177 | mCarrierIdentifier = null; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 178 | } |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 179 | mPolicyRules = in.readInt(); |
| 180 | mAccessRules = in.createTypedArray(UiccAccessRule.CREATOR); |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | @Override |
| 184 | public void writeToParcel(Parcel dest, int flags) { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 185 | dest.writeString(mIccid); |
| 186 | dest.writeString(mNickname); |
| 187 | dest.writeString(mServiceProviderName); |
| 188 | dest.writeString(mProfileName); |
| 189 | dest.writeInt(mProfileClass); |
| 190 | dest.writeInt(mState); |
| 191 | if (mCarrierIdentifier != null) { |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 192 | dest.writeByte((byte) 1); |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 193 | mCarrierIdentifier.writeToParcel(dest, flags); |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 194 | } else { |
| 195 | dest.writeByte((byte) 0); |
| 196 | } |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 197 | dest.writeInt(mPolicyRules); |
| 198 | dest.writeTypedArray(mAccessRules, flags); |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | @Override |
| 202 | public int describeContents() { |
| 203 | return 0; |
| 204 | } |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 205 | |
| 206 | /** The builder to build a new {@link EuiccProfileInfo} instance. */ |
| 207 | public static final class Builder { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 208 | private String mIccid; |
| 209 | private List<UiccAccessRule> mAccessRules; |
| 210 | private String mNickname; |
| 211 | private String mServiceProviderName; |
| 212 | private String mProfileName; |
| 213 | @ProfileClass private int mProfileClass; |
| 214 | @ProfileState private int mState; |
| 215 | private CarrierIdentifier mCarrierIdentifier; |
| 216 | @PolicyRule private int mPolicyRules; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 217 | |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 218 | public Builder(String value) { |
| 219 | if (!TextUtils.isDigitsOnly(value)) { |
| 220 | throw new IllegalArgumentException("iccid contains invalid characters: " + value); |
| 221 | } |
| 222 | mIccid = value; |
| 223 | } |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 224 | |
| 225 | public Builder(EuiccProfileInfo baseProfile) { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 226 | mIccid = baseProfile.mIccid; |
| 227 | mNickname = baseProfile.mNickname; |
| 228 | mServiceProviderName = baseProfile.mServiceProviderName; |
| 229 | mProfileName = baseProfile.mProfileName; |
| 230 | mProfileClass = baseProfile.mProfileClass; |
| 231 | mState = baseProfile.mState; |
| 232 | mCarrierIdentifier = baseProfile.mCarrierIdentifier; |
| 233 | mPolicyRules = baseProfile.mPolicyRules; |
| 234 | mAccessRules = Arrays.asList(baseProfile.mAccessRules); |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | /** Builds the profile instance. */ |
| 238 | public EuiccProfileInfo build() { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 239 | if (mIccid == null) { |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 240 | throw new IllegalStateException("ICCID must be set for a profile."); |
| 241 | } |
| 242 | return new EuiccProfileInfo( |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 243 | mIccid, |
| 244 | mNickname, |
| 245 | mServiceProviderName, |
| 246 | mProfileName, |
| 247 | mProfileClass, |
| 248 | mState, |
| 249 | mCarrierIdentifier, |
| 250 | mPolicyRules, |
| 251 | mAccessRules); |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | /** Sets the iccId of the subscription. */ |
| 255 | public Builder setIccid(String value) { |
| 256 | if (!TextUtils.isDigitsOnly(value)) { |
| 257 | throw new IllegalArgumentException("iccid contains invalid characters: " + value); |
| 258 | } |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 259 | mIccid = value; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 260 | return this; |
| 261 | } |
| 262 | |
| 263 | /** Sets the nickname of the subscription. */ |
| 264 | public Builder setNickname(String value) { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 265 | mNickname = value; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 266 | return this; |
| 267 | } |
| 268 | |
| 269 | /** Sets the service provider name of the subscription. */ |
| 270 | public Builder setServiceProviderName(String value) { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 271 | mServiceProviderName = value; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 272 | return this; |
| 273 | } |
| 274 | |
| 275 | /** Sets the profile name of the subscription. */ |
| 276 | public Builder setProfileName(String value) { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 277 | mProfileName = value; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 278 | return this; |
| 279 | } |
| 280 | |
| 281 | /** Sets the profile class of the subscription. */ |
| 282 | public Builder setProfileClass(@ProfileClass int value) { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 283 | mProfileClass = value; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 284 | return this; |
| 285 | } |
| 286 | |
| 287 | /** Sets the state of the subscription. */ |
| 288 | public Builder setState(@ProfileState int value) { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 289 | mState = value; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 290 | return this; |
| 291 | } |
| 292 | |
| 293 | /** Sets the carrier identifier of the subscription. */ |
| 294 | public Builder setCarrierIdentifier(CarrierIdentifier value) { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 295 | mCarrierIdentifier = value; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 296 | return this; |
| 297 | } |
| 298 | |
| 299 | /** Sets the policy rules of the subscription. */ |
| 300 | public Builder setPolicyRules(@PolicyRule int value) { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 301 | mPolicyRules = value; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 302 | return this; |
| 303 | } |
| 304 | |
| 305 | /** Sets the access rules of the subscription. */ |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 306 | public Builder setUiccAccessRule(@Nullable List<UiccAccessRule> value) { |
| 307 | mAccessRules = value; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 308 | return this; |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | private EuiccProfileInfo( |
| 313 | String iccid, |
| 314 | @Nullable String nickname, |
| 315 | String serviceProviderName, |
| 316 | String profileName, |
| 317 | @ProfileClass int profileClass, |
| 318 | @ProfileState int state, |
| 319 | CarrierIdentifier carrierIdentifier, |
| 320 | @PolicyRule int policyRules, |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 321 | @Nullable List<UiccAccessRule> accessRules) { |
| 322 | this.mIccid = iccid; |
| 323 | this.mNickname = nickname; |
| 324 | this.mServiceProviderName = serviceProviderName; |
| 325 | this.mProfileName = profileName; |
| 326 | this.mProfileClass = profileClass; |
| 327 | this.mState = state; |
| 328 | this.mCarrierIdentifier = carrierIdentifier; |
| 329 | this.mPolicyRules = policyRules; |
| 330 | if (accessRules != null && accessRules.size() > 0) { |
| 331 | this.mAccessRules = accessRules.toArray(new UiccAccessRule[accessRules.size()]); |
| 332 | } else { |
| 333 | this.mAccessRules = null; |
| 334 | } |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | /** Gets the ICCID string. */ |
| 338 | public String getIccid() { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 339 | return mIccid; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | /** Gets the access rules. */ |
| 343 | @Nullable |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 344 | public List<UiccAccessRule> getUiccAccessRules() { |
| 345 | if (mAccessRules == null) return null; |
| 346 | return Arrays.asList(mAccessRules); |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | /** Gets the nickname. */ |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 350 | @Nullable |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 351 | public String getNickname() { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 352 | return mNickname; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | /** Gets the service provider name. */ |
| 356 | public String getServiceProviderName() { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 357 | return mServiceProviderName; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | /** Gets the profile name. */ |
| 361 | public String getProfileName() { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 362 | return mProfileName; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | /** Gets the profile class. */ |
| 366 | @ProfileClass |
| 367 | public int getProfileClass() { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 368 | return mProfileClass; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | /** Gets the state of the subscription. */ |
| 372 | @ProfileState |
| 373 | public int getState() { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 374 | return mState; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | /** Gets the carrier identifier. */ |
| 378 | public CarrierIdentifier getCarrierIdentifier() { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 379 | return mCarrierIdentifier; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | /** Gets the policy rules. */ |
| 383 | @PolicyRule |
| 384 | public int getPolicyRules() { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 385 | return mPolicyRules; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | /** Returns whether any policy rule exists. */ |
| 389 | public boolean hasPolicyRules() { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 390 | return mPolicyRules != 0; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | /** Checks whether a certain policy rule exists. */ |
| 394 | public boolean hasPolicyRule(@PolicyRule int policy) { |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 395 | return (mPolicyRules & policy) != 0; |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | @Override |
Aurimas Liutikas | 00be951 | 2019-08-28 13:01:05 -0700 | [diff] [blame] | 399 | public boolean equals(@Nullable Object obj) { |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 400 | if (this == obj) { |
| 401 | return true; |
| 402 | } |
| 403 | if (obj == null || getClass() != obj.getClass()) { |
| 404 | return false; |
| 405 | } |
| 406 | |
| 407 | EuiccProfileInfo that = (EuiccProfileInfo) obj; |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 408 | return Objects.equals(mIccid, that.mIccid) |
| 409 | && Objects.equals(mNickname, that.mNickname) |
| 410 | && Objects.equals(mServiceProviderName, that.mServiceProviderName) |
| 411 | && Objects.equals(mProfileName, that.mProfileName) |
| 412 | && mProfileClass == that.mProfileClass |
| 413 | && mState == that.mState |
| 414 | && Objects.equals(mCarrierIdentifier, that.mCarrierIdentifier) |
| 415 | && mPolicyRules == that.mPolicyRules |
| 416 | && Arrays.equals(mAccessRules, that.mAccessRules); |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | @Override |
| 420 | public int hashCode() { |
| 421 | int result = 1; |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 422 | result = 31 * result + Objects.hashCode(mIccid); |
| 423 | result = 31 * result + Objects.hashCode(mNickname); |
| 424 | result = 31 * result + Objects.hashCode(mServiceProviderName); |
| 425 | result = 31 * result + Objects.hashCode(mProfileName); |
| 426 | result = 31 * result + mProfileClass; |
| 427 | result = 31 * result + mState; |
| 428 | result = 31 * result + Objects.hashCode(mCarrierIdentifier); |
| 429 | result = 31 * result + mPolicyRules; |
| 430 | result = 31 * result + Arrays.hashCode(mAccessRules); |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 431 | return result; |
| 432 | } |
| 433 | |
Aurimas Liutikas | 00be951 | 2019-08-28 13:01:05 -0700 | [diff] [blame] | 434 | @NonNull |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 435 | @Override |
| 436 | public String toString() { |
| 437 | return "EuiccProfileInfo (nickname=" |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 438 | + mNickname |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 439 | + ", serviceProviderName=" |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 440 | + mServiceProviderName |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 441 | + ", profileName=" |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 442 | + mProfileName |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 443 | + ", profileClass=" |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 444 | + mProfileClass |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 445 | + ", state=" |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 446 | + mState |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 447 | + ", CarrierIdentifier=" |
Holly Jiuyu Sun | af50f169 | 2018-03-05 16:07:37 -0800 | [diff] [blame] | 448 | + mCarrierIdentifier |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 449 | + ", policyRules=" |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 450 | + mPolicyRules |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 451 | + ", accessRules=" |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 452 | + Arrays.toString(mAccessRules) |
Holly Jiuyu Sun | e6153b9 | 2017-12-07 15:35:49 -0800 | [diff] [blame] | 453 | + ")"; |
| 454 | } |
Jeff Davidson | d02731f | 2017-04-09 14:31:09 -0700 | [diff] [blame] | 455 | } |