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