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