Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -37411,6 +37411,7 @@ package android.service.carrier { public class CarrierIdentifier implements android.os.Parcelable { ctor public CarrierIdentifier(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String); ctor public CarrierIdentifier(byte[], java.lang.String, java.lang.String); method public int describeContents(); method public java.lang.String getGid1(); method public java.lang.String getGid2(); core/java/android/service/carrier/CarrierIdentifier.java +71 −6 Original line number Diff line number Diff line Loading @@ -16,9 +16,14 @@ package android.service.carrier; import android.annotation.Nullable; import android.os.Parcel; import android.os.Parcelable; import com.android.internal.telephony.uicc.IccUtils; import java.util.Objects; /** * Used to pass info to CarrierConfigService implementations so they can decide what values to * return. Loading @@ -40,13 +45,13 @@ public class CarrierIdentifier implements Parcelable { private String mMcc; private String mMnc; private String mSpn; private String mImsi; private String mGid1; private String mGid2; private @Nullable String mSpn; private @Nullable String mImsi; private @Nullable String mGid1; private @Nullable String mGid2; public CarrierIdentifier(String mcc, String mnc, String spn, String imsi, String gid1, String gid2) { public CarrierIdentifier(String mcc, String mnc, @Nullable String spn, @Nullable String imsi, @Nullable String gid1, @Nullable String gid2) { mMcc = mcc; mMnc = mnc; mSpn = spn; Loading @@ -55,6 +60,32 @@ public class CarrierIdentifier implements Parcelable { mGid2 = gid2; } /** * Creates a carrier identifier instance. * * @param mccMnc A 3-byte array as defined by 3GPP TS 24.008. * @param gid1 The group identifier level 1. * @param gid2 The group identifier level 2. * @throws IllegalArgumentException If the length of {@code mccMnc} is not 3. */ public CarrierIdentifier(byte[] mccMnc, @Nullable String gid1, @Nullable String gid2) { if (mccMnc.length != 3) { throw new IllegalArgumentException( "MCC & MNC must be set by a 3-byte array: byte[" + mccMnc.length + "]"); } String hex = IccUtils.bytesToHexString(mccMnc); mMcc = new String(new char[] {hex.charAt(1), hex.charAt(0), hex.charAt(3)}); if (hex.charAt(2) == 'F') { mMnc = new String(new char[] {hex.charAt(5), hex.charAt(4)}); } else { mMnc = new String(new char[] {hex.charAt(5), hex.charAt(4), hex.charAt(2)}); } mGid1 = gid1; mGid2 = gid2; mSpn = null; mImsi = null; } /** @hide */ public CarrierIdentifier(Parcel parcel) { readFromParcel(parcel); Loading @@ -71,25 +102,59 @@ public class CarrierIdentifier implements Parcelable { } /** Get the service provider name. */ @Nullable public String getSpn() { return mSpn; } /** Get the international mobile subscriber identity. */ @Nullable public String getImsi() { return mImsi; } /** Get the group identifier level 1. */ @Nullable public String getGid1() { return mGid1; } /** Get the group identifier level 2. */ @Nullable public String getGid2() { return mGid2; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } CarrierIdentifier that = (CarrierIdentifier) obj; return Objects.equals(mMcc, that.mMcc) && Objects.equals(mMnc, that.mMnc) && Objects.equals(mSpn, that.mSpn) && Objects.equals(mImsi, that.mImsi) && Objects.equals(mGid1, that.mGid1) && Objects.equals(mGid2, that.mGid2); } @Override public int hashCode() { int result = 1; result = 31 * result + Objects.hashCode(mMcc); result = 31 * result + Objects.hashCode(mMnc); result = 31 * result + Objects.hashCode(mSpn); result = 31 * result + Objects.hashCode(mImsi); result = 31 * result + Objects.hashCode(mGid1); result = 31 * result + Objects.hashCode(mGid2); return result; } @Override public int describeContents() { return 0; Loading core/java/android/service/euicc/EuiccProfileInfo.java +357 −5 Original line number Diff line number Diff line Loading @@ -15,12 +15,19 @@ */ package android.service.euicc; import android.annotation.IntDef; import android.annotation.Nullable; import android.os.Parcel; import android.os.Parcelable; import android.service.carrier.CarrierIdentifier; import android.telephony.UiccAccessRule; import android.text.TextUtils; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.Arrays; import java.util.Objects; /** * Information about an embedded profile (subscription) on an eUICC. * Loading @@ -30,18 +37,90 @@ import android.text.TextUtils; */ public final class EuiccProfileInfo implements Parcelable { /** Profile policy rules (bit mask) */ @Retention(RetentionPolicy.SOURCE) @IntDef(flag = true, prefix = { "POLICY_RULE_" }, value = { POLICY_RULE_DO_NOT_DISABLE, POLICY_RULE_DO_NOT_DELETE, POLICY_RULE_DELETE_AFTER_DISABLING }) public @interface PolicyRule {} /** Once this profile is enabled, it cannot be disabled. */ public static final int POLICY_RULE_DO_NOT_DISABLE = 1; /** This profile cannot be deleted. */ public static final int POLICY_RULE_DO_NOT_DELETE = 1 << 1; /** This profile should be deleted after being disabled. */ public static final int POLICY_RULE_DELETE_AFTER_DISABLING = 1 << 2; /** Class of the profile */ @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = { "PROFILE_CLASS_" }, value = { PROFILE_CLASS_TESTING, PROFILE_CLASS_PROVISIONING, PROFILE_CLASS_OPERATIONAL, PROFILE_CLASS_UNSET }) public @interface ProfileClass {} /** Testing profiles */ public static final int PROFILE_CLASS_TESTING = 0; /** Provisioning profiles which are pre-loaded on eUICC */ public static final int PROFILE_CLASS_PROVISIONING = 1; /** Operational profiles which can be pre-loaded or downloaded */ public static final int PROFILE_CLASS_OPERATIONAL = 2; /** * Profile class not set. * @hide */ public static final int PROFILE_CLASS_UNSET = -1; /** State of the profile */ @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = { "PROFILE_STATE_" }, value = { PROFILE_STATE_DISABLED, PROFILE_STATE_ENABLED, PROFILE_STATE_UNSET }) public @interface ProfileState {} /** Disabled profiles */ public static final int PROFILE_STATE_DISABLED = 0; /** Enabled profile */ public static final int PROFILE_STATE_ENABLED = 1; /** * Profile state not set. * @hide */ public static final int PROFILE_STATE_UNSET = -1; /** The iccid of the subscription. */ public final String iccid; /** An optional nickname for the subscription. */ public final @Nullable String nickname; /** The service provider name for the subscription. */ public final String serviceProviderName; /** The profile name for the subscription. */ public final String profileName; /** Profile class for the subscription. */ @ProfileClass public final int profileClass; /** The profile state of the subscription. */ @ProfileState public final int state; /** The operator Id of the subscription. */ public final CarrierIdentifier carrierIdentifier; /** The policy rules of the subscription. */ @PolicyRule public final int policyRules; /** * Optional access rules defining which apps can manage this subscription. If unset, only the * platform can manage it. */ public final @Nullable UiccAccessRule[] accessRules; /** An optional nickname for the subscription. */ public final @Nullable String nickname; public static final Creator<EuiccProfileInfo> CREATOR = new Creator<EuiccProfileInfo>() { @Override public EuiccProfileInfo createFromParcel(Parcel in) { Loading @@ -54,6 +133,12 @@ public final class EuiccProfileInfo implements Parcelable { } }; // TODO(b/70292228): Remove this method when LPA can be updated. /** * @hide * @deprecated - Do not use. */ @Deprecated public EuiccProfileInfo(String iccid, @Nullable UiccAccessRule[] accessRules, @Nullable String nickname) { if (!TextUtils.isDigitsOnly(iccid)) { Loading @@ -62,23 +147,290 @@ public final class EuiccProfileInfo implements Parcelable { this.iccid = iccid; this.accessRules = accessRules; this.nickname = nickname; this.serviceProviderName = null; this.profileName = null; this.profileClass = PROFILE_CLASS_UNSET; this.state = PROFILE_CLASS_UNSET; this.carrierIdentifier = null; this.policyRules = 0; } private EuiccProfileInfo(Parcel in) { iccid = in.readString(); accessRules = in.createTypedArray(UiccAccessRule.CREATOR); nickname = in.readString(); serviceProviderName = in.readString(); profileName = in.readString(); profileClass = in.readInt(); state = in.readInt(); byte exist = in.readByte(); if (exist == (byte) 1) { carrierIdentifier = CarrierIdentifier.CREATOR.createFromParcel(in); } else { carrierIdentifier = null; } policyRules = in.readInt(); accessRules = in.createTypedArray(UiccAccessRule.CREATOR); } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(iccid); dest.writeTypedArray(accessRules, flags); dest.writeString(nickname); dest.writeString(serviceProviderName); dest.writeString(profileName); dest.writeInt(profileClass); dest.writeInt(state); if (carrierIdentifier != null) { dest.writeByte((byte) 1); carrierIdentifier.writeToParcel(dest, flags); } else { dest.writeByte((byte) 0); } dest.writeInt(policyRules); dest.writeTypedArray(accessRules, flags); } @Override public int describeContents() { return 0; } /** The builder to build a new {@link EuiccProfileInfo} instance. */ public static final class Builder { public String iccid; public UiccAccessRule[] accessRules; public String nickname; public String serviceProviderName; public String profileName; @ProfileClass public int profileClass; @ProfileState public int state; public CarrierIdentifier carrierIdentifier; @PolicyRule public int policyRules; public Builder() {} public Builder(EuiccProfileInfo baseProfile) { iccid = baseProfile.iccid; nickname = baseProfile.nickname; serviceProviderName = baseProfile.serviceProviderName; profileName = baseProfile.profileName; profileClass = baseProfile.profileClass; state = baseProfile.state; carrierIdentifier = baseProfile.carrierIdentifier; policyRules = baseProfile.policyRules; accessRules = baseProfile.accessRules; } /** Builds the profile instance. */ public EuiccProfileInfo build() { if (iccid == null) { throw new IllegalStateException("ICCID must be set for a profile."); } return new EuiccProfileInfo( iccid, nickname, serviceProviderName, profileName, profileClass, state, carrierIdentifier, policyRules, accessRules); } /** Sets the iccId of the subscription. */ public Builder setIccid(String value) { if (!TextUtils.isDigitsOnly(value)) { throw new IllegalArgumentException("iccid contains invalid characters: " + value); } iccid = value; return this; } /** Sets the nickname of the subscription. */ public Builder setNickname(String value) { nickname = value; return this; } /** Sets the service provider name of the subscription. */ public Builder setServiceProviderName(String value) { serviceProviderName = value; return this; } /** Sets the profile name of the subscription. */ public Builder setProfileName(String value) { profileName = value; return this; } /** Sets the profile class of the subscription. */ public Builder setProfileClass(@ProfileClass int value) { profileClass = value; return this; } /** Sets the state of the subscription. */ public Builder setState(@ProfileState int value) { state = value; return this; } /** Sets the carrier identifier of the subscription. */ public Builder setCarrierIdentifier(CarrierIdentifier value) { carrierIdentifier = value; return this; } /** Sets the policy rules of the subscription. */ public Builder setPolicyRules(@PolicyRule int value) { policyRules = value; return this; } /** Sets the access rules of the subscription. */ public Builder setUiccAccessRule(@Nullable UiccAccessRule[] value) { accessRules = value; return this; } } private EuiccProfileInfo( String iccid, @Nullable String nickname, String serviceProviderName, String profileName, @ProfileClass int profileClass, @ProfileState int state, CarrierIdentifier carrierIdentifier, @PolicyRule int policyRules, @Nullable UiccAccessRule[] accessRules) { this.iccid = iccid; this.nickname = nickname; this.serviceProviderName = serviceProviderName; this.profileName = profileName; this.profileClass = profileClass; this.state = state; this.carrierIdentifier = carrierIdentifier; this.policyRules = policyRules; this.accessRules = accessRules; } /** Gets the ICCID string. */ public String getIccid() { return iccid; } /** Gets the access rules. */ @Nullable public UiccAccessRule[] getUiccAccessRules() { return accessRules; } /** Gets the nickname. */ public String getNickname() { return nickname; } /** Gets the service provider name. */ public String getServiceProviderName() { return serviceProviderName; } /** Gets the profile name. */ public String getProfileName() { return profileName; } /** Gets the profile class. */ @ProfileClass public int getProfileClass() { return profileClass; } /** Gets the state of the subscription. */ @ProfileState public int getState() { return state; } /** Gets the carrier identifier. */ public CarrierIdentifier getCarrierIdentifier() { return carrierIdentifier; } /** Gets the policy rules. */ @PolicyRule public int getPolicyRules() { return policyRules; } /** Returns whether any policy rule exists. */ public boolean hasPolicyRules() { return policyRules != 0; } /** Checks whether a certain policy rule exists. */ public boolean hasPolicyRule(@PolicyRule int policy) { return (policyRules & policy) != 0; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } EuiccProfileInfo that = (EuiccProfileInfo) obj; return Objects.equals(iccid, that.iccid) && Objects.equals(nickname, that.nickname) && Objects.equals(serviceProviderName, that.serviceProviderName) && Objects.equals(profileName, that.profileName) && profileClass == that.profileClass && state == that.state && Objects.equals(carrierIdentifier, that.carrierIdentifier) && policyRules == that.policyRules && Arrays.equals(accessRules, that.accessRules); } @Override public int hashCode() { int result = 1; result = 31 * result + Objects.hashCode(iccid); result = 31 * result + Objects.hashCode(nickname); result = 31 * result + Objects.hashCode(serviceProviderName); result = 31 * result + Objects.hashCode(profileName); result = 31 * result + profileClass; result = 31 * result + state; result = 31 * result + Objects.hashCode(carrierIdentifier); result = 31 * result + policyRules; result = 31 * result + Arrays.hashCode(accessRules); return result; } @Override public String toString() { return "EuiccProfileInfo (nickname=" + nickname + ", serviceProviderName=" + serviceProviderName + ", profileName=" + profileName + ", profileClass=" + profileClass + ", state=" + state + ", CarrierIdentifier=" + carrierIdentifier.toString() + ", policyRules=" + policyRules + ", accessRules=" + Arrays.toString(accessRules) + ")"; } } core/tests/coretests/src/android/service/euicc/EuiccProfileInfoTest.java 0 → 100644 +247 −0 File added.Preview size limit exceeded, changes collapsed. Show changes telephony/java/android/telephony/UiccAccessRule.java +16 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import java.io.IOException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; import java.util.Objects; /** * Describes a single UICC access rule according to the GlobalPlatform Secure Element Access Control Loading Loading @@ -204,6 +205,21 @@ public final class UiccAccessRule implements Parcelable { (TextUtils.isEmpty(this.mPackageName) || this.mPackageName.equals(packageName)); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } UiccAccessRule that = (UiccAccessRule) obj; return Arrays.equals(mCertificateHash, that.mCertificateHash) && Objects.equals(mPackageName, that.mPackageName) && mAccessType == that.mAccessType; } @Override public String toString() { return "cert: " + IccUtils.bytesToHexString(mCertificateHash) + " pkg: " + Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -37411,6 +37411,7 @@ package android.service.carrier { public class CarrierIdentifier implements android.os.Parcelable { ctor public CarrierIdentifier(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String); ctor public CarrierIdentifier(byte[], java.lang.String, java.lang.String); method public int describeContents(); method public java.lang.String getGid1(); method public java.lang.String getGid2();
core/java/android/service/carrier/CarrierIdentifier.java +71 −6 Original line number Diff line number Diff line Loading @@ -16,9 +16,14 @@ package android.service.carrier; import android.annotation.Nullable; import android.os.Parcel; import android.os.Parcelable; import com.android.internal.telephony.uicc.IccUtils; import java.util.Objects; /** * Used to pass info to CarrierConfigService implementations so they can decide what values to * return. Loading @@ -40,13 +45,13 @@ public class CarrierIdentifier implements Parcelable { private String mMcc; private String mMnc; private String mSpn; private String mImsi; private String mGid1; private String mGid2; private @Nullable String mSpn; private @Nullable String mImsi; private @Nullable String mGid1; private @Nullable String mGid2; public CarrierIdentifier(String mcc, String mnc, String spn, String imsi, String gid1, String gid2) { public CarrierIdentifier(String mcc, String mnc, @Nullable String spn, @Nullable String imsi, @Nullable String gid1, @Nullable String gid2) { mMcc = mcc; mMnc = mnc; mSpn = spn; Loading @@ -55,6 +60,32 @@ public class CarrierIdentifier implements Parcelable { mGid2 = gid2; } /** * Creates a carrier identifier instance. * * @param mccMnc A 3-byte array as defined by 3GPP TS 24.008. * @param gid1 The group identifier level 1. * @param gid2 The group identifier level 2. * @throws IllegalArgumentException If the length of {@code mccMnc} is not 3. */ public CarrierIdentifier(byte[] mccMnc, @Nullable String gid1, @Nullable String gid2) { if (mccMnc.length != 3) { throw new IllegalArgumentException( "MCC & MNC must be set by a 3-byte array: byte[" + mccMnc.length + "]"); } String hex = IccUtils.bytesToHexString(mccMnc); mMcc = new String(new char[] {hex.charAt(1), hex.charAt(0), hex.charAt(3)}); if (hex.charAt(2) == 'F') { mMnc = new String(new char[] {hex.charAt(5), hex.charAt(4)}); } else { mMnc = new String(new char[] {hex.charAt(5), hex.charAt(4), hex.charAt(2)}); } mGid1 = gid1; mGid2 = gid2; mSpn = null; mImsi = null; } /** @hide */ public CarrierIdentifier(Parcel parcel) { readFromParcel(parcel); Loading @@ -71,25 +102,59 @@ public class CarrierIdentifier implements Parcelable { } /** Get the service provider name. */ @Nullable public String getSpn() { return mSpn; } /** Get the international mobile subscriber identity. */ @Nullable public String getImsi() { return mImsi; } /** Get the group identifier level 1. */ @Nullable public String getGid1() { return mGid1; } /** Get the group identifier level 2. */ @Nullable public String getGid2() { return mGid2; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } CarrierIdentifier that = (CarrierIdentifier) obj; return Objects.equals(mMcc, that.mMcc) && Objects.equals(mMnc, that.mMnc) && Objects.equals(mSpn, that.mSpn) && Objects.equals(mImsi, that.mImsi) && Objects.equals(mGid1, that.mGid1) && Objects.equals(mGid2, that.mGid2); } @Override public int hashCode() { int result = 1; result = 31 * result + Objects.hashCode(mMcc); result = 31 * result + Objects.hashCode(mMnc); result = 31 * result + Objects.hashCode(mSpn); result = 31 * result + Objects.hashCode(mImsi); result = 31 * result + Objects.hashCode(mGid1); result = 31 * result + Objects.hashCode(mGid2); return result; } @Override public int describeContents() { return 0; Loading
core/java/android/service/euicc/EuiccProfileInfo.java +357 −5 Original line number Diff line number Diff line Loading @@ -15,12 +15,19 @@ */ package android.service.euicc; import android.annotation.IntDef; import android.annotation.Nullable; import android.os.Parcel; import android.os.Parcelable; import android.service.carrier.CarrierIdentifier; import android.telephony.UiccAccessRule; import android.text.TextUtils; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.Arrays; import java.util.Objects; /** * Information about an embedded profile (subscription) on an eUICC. * Loading @@ -30,18 +37,90 @@ import android.text.TextUtils; */ public final class EuiccProfileInfo implements Parcelable { /** Profile policy rules (bit mask) */ @Retention(RetentionPolicy.SOURCE) @IntDef(flag = true, prefix = { "POLICY_RULE_" }, value = { POLICY_RULE_DO_NOT_DISABLE, POLICY_RULE_DO_NOT_DELETE, POLICY_RULE_DELETE_AFTER_DISABLING }) public @interface PolicyRule {} /** Once this profile is enabled, it cannot be disabled. */ public static final int POLICY_RULE_DO_NOT_DISABLE = 1; /** This profile cannot be deleted. */ public static final int POLICY_RULE_DO_NOT_DELETE = 1 << 1; /** This profile should be deleted after being disabled. */ public static final int POLICY_RULE_DELETE_AFTER_DISABLING = 1 << 2; /** Class of the profile */ @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = { "PROFILE_CLASS_" }, value = { PROFILE_CLASS_TESTING, PROFILE_CLASS_PROVISIONING, PROFILE_CLASS_OPERATIONAL, PROFILE_CLASS_UNSET }) public @interface ProfileClass {} /** Testing profiles */ public static final int PROFILE_CLASS_TESTING = 0; /** Provisioning profiles which are pre-loaded on eUICC */ public static final int PROFILE_CLASS_PROVISIONING = 1; /** Operational profiles which can be pre-loaded or downloaded */ public static final int PROFILE_CLASS_OPERATIONAL = 2; /** * Profile class not set. * @hide */ public static final int PROFILE_CLASS_UNSET = -1; /** State of the profile */ @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = { "PROFILE_STATE_" }, value = { PROFILE_STATE_DISABLED, PROFILE_STATE_ENABLED, PROFILE_STATE_UNSET }) public @interface ProfileState {} /** Disabled profiles */ public static final int PROFILE_STATE_DISABLED = 0; /** Enabled profile */ public static final int PROFILE_STATE_ENABLED = 1; /** * Profile state not set. * @hide */ public static final int PROFILE_STATE_UNSET = -1; /** The iccid of the subscription. */ public final String iccid; /** An optional nickname for the subscription. */ public final @Nullable String nickname; /** The service provider name for the subscription. */ public final String serviceProviderName; /** The profile name for the subscription. */ public final String profileName; /** Profile class for the subscription. */ @ProfileClass public final int profileClass; /** The profile state of the subscription. */ @ProfileState public final int state; /** The operator Id of the subscription. */ public final CarrierIdentifier carrierIdentifier; /** The policy rules of the subscription. */ @PolicyRule public final int policyRules; /** * Optional access rules defining which apps can manage this subscription. If unset, only the * platform can manage it. */ public final @Nullable UiccAccessRule[] accessRules; /** An optional nickname for the subscription. */ public final @Nullable String nickname; public static final Creator<EuiccProfileInfo> CREATOR = new Creator<EuiccProfileInfo>() { @Override public EuiccProfileInfo createFromParcel(Parcel in) { Loading @@ -54,6 +133,12 @@ public final class EuiccProfileInfo implements Parcelable { } }; // TODO(b/70292228): Remove this method when LPA can be updated. /** * @hide * @deprecated - Do not use. */ @Deprecated public EuiccProfileInfo(String iccid, @Nullable UiccAccessRule[] accessRules, @Nullable String nickname) { if (!TextUtils.isDigitsOnly(iccid)) { Loading @@ -62,23 +147,290 @@ public final class EuiccProfileInfo implements Parcelable { this.iccid = iccid; this.accessRules = accessRules; this.nickname = nickname; this.serviceProviderName = null; this.profileName = null; this.profileClass = PROFILE_CLASS_UNSET; this.state = PROFILE_CLASS_UNSET; this.carrierIdentifier = null; this.policyRules = 0; } private EuiccProfileInfo(Parcel in) { iccid = in.readString(); accessRules = in.createTypedArray(UiccAccessRule.CREATOR); nickname = in.readString(); serviceProviderName = in.readString(); profileName = in.readString(); profileClass = in.readInt(); state = in.readInt(); byte exist = in.readByte(); if (exist == (byte) 1) { carrierIdentifier = CarrierIdentifier.CREATOR.createFromParcel(in); } else { carrierIdentifier = null; } policyRules = in.readInt(); accessRules = in.createTypedArray(UiccAccessRule.CREATOR); } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(iccid); dest.writeTypedArray(accessRules, flags); dest.writeString(nickname); dest.writeString(serviceProviderName); dest.writeString(profileName); dest.writeInt(profileClass); dest.writeInt(state); if (carrierIdentifier != null) { dest.writeByte((byte) 1); carrierIdentifier.writeToParcel(dest, flags); } else { dest.writeByte((byte) 0); } dest.writeInt(policyRules); dest.writeTypedArray(accessRules, flags); } @Override public int describeContents() { return 0; } /** The builder to build a new {@link EuiccProfileInfo} instance. */ public static final class Builder { public String iccid; public UiccAccessRule[] accessRules; public String nickname; public String serviceProviderName; public String profileName; @ProfileClass public int profileClass; @ProfileState public int state; public CarrierIdentifier carrierIdentifier; @PolicyRule public int policyRules; public Builder() {} public Builder(EuiccProfileInfo baseProfile) { iccid = baseProfile.iccid; nickname = baseProfile.nickname; serviceProviderName = baseProfile.serviceProviderName; profileName = baseProfile.profileName; profileClass = baseProfile.profileClass; state = baseProfile.state; carrierIdentifier = baseProfile.carrierIdentifier; policyRules = baseProfile.policyRules; accessRules = baseProfile.accessRules; } /** Builds the profile instance. */ public EuiccProfileInfo build() { if (iccid == null) { throw new IllegalStateException("ICCID must be set for a profile."); } return new EuiccProfileInfo( iccid, nickname, serviceProviderName, profileName, profileClass, state, carrierIdentifier, policyRules, accessRules); } /** Sets the iccId of the subscription. */ public Builder setIccid(String value) { if (!TextUtils.isDigitsOnly(value)) { throw new IllegalArgumentException("iccid contains invalid characters: " + value); } iccid = value; return this; } /** Sets the nickname of the subscription. */ public Builder setNickname(String value) { nickname = value; return this; } /** Sets the service provider name of the subscription. */ public Builder setServiceProviderName(String value) { serviceProviderName = value; return this; } /** Sets the profile name of the subscription. */ public Builder setProfileName(String value) { profileName = value; return this; } /** Sets the profile class of the subscription. */ public Builder setProfileClass(@ProfileClass int value) { profileClass = value; return this; } /** Sets the state of the subscription. */ public Builder setState(@ProfileState int value) { state = value; return this; } /** Sets the carrier identifier of the subscription. */ public Builder setCarrierIdentifier(CarrierIdentifier value) { carrierIdentifier = value; return this; } /** Sets the policy rules of the subscription. */ public Builder setPolicyRules(@PolicyRule int value) { policyRules = value; return this; } /** Sets the access rules of the subscription. */ public Builder setUiccAccessRule(@Nullable UiccAccessRule[] value) { accessRules = value; return this; } } private EuiccProfileInfo( String iccid, @Nullable String nickname, String serviceProviderName, String profileName, @ProfileClass int profileClass, @ProfileState int state, CarrierIdentifier carrierIdentifier, @PolicyRule int policyRules, @Nullable UiccAccessRule[] accessRules) { this.iccid = iccid; this.nickname = nickname; this.serviceProviderName = serviceProviderName; this.profileName = profileName; this.profileClass = profileClass; this.state = state; this.carrierIdentifier = carrierIdentifier; this.policyRules = policyRules; this.accessRules = accessRules; } /** Gets the ICCID string. */ public String getIccid() { return iccid; } /** Gets the access rules. */ @Nullable public UiccAccessRule[] getUiccAccessRules() { return accessRules; } /** Gets the nickname. */ public String getNickname() { return nickname; } /** Gets the service provider name. */ public String getServiceProviderName() { return serviceProviderName; } /** Gets the profile name. */ public String getProfileName() { return profileName; } /** Gets the profile class. */ @ProfileClass public int getProfileClass() { return profileClass; } /** Gets the state of the subscription. */ @ProfileState public int getState() { return state; } /** Gets the carrier identifier. */ public CarrierIdentifier getCarrierIdentifier() { return carrierIdentifier; } /** Gets the policy rules. */ @PolicyRule public int getPolicyRules() { return policyRules; } /** Returns whether any policy rule exists. */ public boolean hasPolicyRules() { return policyRules != 0; } /** Checks whether a certain policy rule exists. */ public boolean hasPolicyRule(@PolicyRule int policy) { return (policyRules & policy) != 0; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } EuiccProfileInfo that = (EuiccProfileInfo) obj; return Objects.equals(iccid, that.iccid) && Objects.equals(nickname, that.nickname) && Objects.equals(serviceProviderName, that.serviceProviderName) && Objects.equals(profileName, that.profileName) && profileClass == that.profileClass && state == that.state && Objects.equals(carrierIdentifier, that.carrierIdentifier) && policyRules == that.policyRules && Arrays.equals(accessRules, that.accessRules); } @Override public int hashCode() { int result = 1; result = 31 * result + Objects.hashCode(iccid); result = 31 * result + Objects.hashCode(nickname); result = 31 * result + Objects.hashCode(serviceProviderName); result = 31 * result + Objects.hashCode(profileName); result = 31 * result + profileClass; result = 31 * result + state; result = 31 * result + Objects.hashCode(carrierIdentifier); result = 31 * result + policyRules; result = 31 * result + Arrays.hashCode(accessRules); return result; } @Override public String toString() { return "EuiccProfileInfo (nickname=" + nickname + ", serviceProviderName=" + serviceProviderName + ", profileName=" + profileName + ", profileClass=" + profileClass + ", state=" + state + ", CarrierIdentifier=" + carrierIdentifier.toString() + ", policyRules=" + policyRules + ", accessRules=" + Arrays.toString(accessRules) + ")"; } }
core/tests/coretests/src/android/service/euicc/EuiccProfileInfoTest.java 0 → 100644 +247 −0 File added.Preview size limit exceeded, changes collapsed. Show changes
telephony/java/android/telephony/UiccAccessRule.java +16 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import java.io.IOException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; import java.util.Objects; /** * Describes a single UICC access rule according to the GlobalPlatform Secure Element Access Control Loading Loading @@ -204,6 +205,21 @@ public final class UiccAccessRule implements Parcelable { (TextUtils.isEmpty(this.mPackageName) || this.mPackageName.equals(packageName)); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } UiccAccessRule that = (UiccAccessRule) obj; return Arrays.equals(mCertificateHash, that.mCertificateHash) && Objects.equals(mPackageName, that.mPackageName) && mAccessType == that.mAccessType; } @Override public String toString() { return "cert: " + IccUtils.bytesToHexString(mCertificateHash) + " pkg: " + Loading