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