Merge "Merge EuiccProfile into EuiccProfileInfo."

am: b01bd54b11

Change-Id: I98c726fc7d6fb91e16234773fe6423b7e111126e
This commit is contained in:
Holly Jiuyu Sun
2018-01-10 05:35:48 +00:00
committed by android-build-merger
5 changed files with 692 additions and 11 deletions

View File

@@ -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();

View File

@@ -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.
@@ -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;
@@ -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);
@@ -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;

View File

@@ -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.
*
@@ -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) {
@@ -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)) {
@@ -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)
+ ")";
}
}

View File

@@ -0,0 +1,247 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.service.euicc;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import android.os.Parcel;
import android.service.carrier.CarrierIdentifier;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
import android.telephony.UiccAccessRule;
import org.junit.Test;
import org.junit.runner.RunWith;
@SmallTest
@RunWith(AndroidJUnit4.class)
public class EuiccProfileInfoTest {
@Test
public void testWriteToParcel() {
EuiccProfileInfo p =
new EuiccProfileInfo.Builder()
.setIccid("21430000000000006587")
.setNickname("profile nickname")
.setServiceProviderName("service provider")
.setProfileName("profile name")
.setProfileClass(EuiccProfileInfo.PROFILE_CLASS_OPERATIONAL)
.setState(EuiccProfileInfo.PROFILE_STATE_ENABLED)
.setCarrierIdentifier(
new CarrierIdentifier(
new byte[] {0x23, 0x45, 0x67},
"123",
"45"))
.setPolicyRules(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE)
.setUiccAccessRule(
new UiccAccessRule[] {
new UiccAccessRule(new byte[] {}, "package", 12345L)
})
.build();
Parcel parcel = Parcel.obtain();
assertTrue(parcel != null);
p.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
EuiccProfileInfo fromParcel = EuiccProfileInfo.CREATOR.createFromParcel(parcel);
assertEquals(p, fromParcel);
}
@Test
public void testWriteToParcelNullCarrierId() {
EuiccProfileInfo p =
new EuiccProfileInfo.Builder()
.setIccid("21430000000000006587")
.setNickname("profile nickname")
.setServiceProviderName("service provider")
.setProfileName("profile name")
.setProfileClass(EuiccProfileInfo.PROFILE_CLASS_OPERATIONAL)
.setState(EuiccProfileInfo.PROFILE_STATE_ENABLED)
.setPolicyRules(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE)
.setUiccAccessRule(
new UiccAccessRule[] {
new UiccAccessRule(new byte[] {}, "package", 12345L)
})
.build();
Parcel parcel = Parcel.obtain();
assertTrue(parcel != null);
p.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
EuiccProfileInfo fromParcel = EuiccProfileInfo.CREATOR.createFromParcel(parcel);
assertEquals(p, fromParcel);
}
@Test
public void testBuilderAndGetters() {
EuiccProfileInfo p =
new EuiccProfileInfo.Builder()
.setIccid("21430000000000006587")
.setNickname("profile nickname")
.setProfileName("profile name")
.setServiceProviderName("service provider")
.setCarrierIdentifier(
new CarrierIdentifier(
new byte[] {0x23, 0x45, 0x67},
"123",
"45"))
.setState(EuiccProfileInfo.PROFILE_STATE_ENABLED)
.setProfileClass(EuiccProfileInfo.PROFILE_CLASS_OPERATIONAL)
.setPolicyRules(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE)
.setUiccAccessRule(
new UiccAccessRule[] {
new UiccAccessRule(new byte[0], null, 0)
})
.build();
assertEquals("21430000000000006587", p.getIccid());
assertEquals("profile nickname", p.getNickname());
assertEquals("profile name", p.getProfileName());
assertEquals("service provider", p.getServiceProviderName());
assertEquals("325", p.getCarrierIdentifier().getMcc());
assertEquals("764", p.getCarrierIdentifier().getMnc());
assertEquals("123", p.getCarrierIdentifier().getGid1());
assertEquals("45", p.getCarrierIdentifier().getGid2());
assertEquals(EuiccProfileInfo.PROFILE_STATE_ENABLED, p.getState());
assertEquals(EuiccProfileInfo.PROFILE_CLASS_OPERATIONAL, p.getProfileClass());
assertEquals(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, p.getPolicyRules());
assertTrue(p.hasPolicyRules());
assertTrue(p.hasPolicyRule(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE));
assertFalse(p.hasPolicyRule(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE));
assertArrayEquals(
new UiccAccessRule[] {new UiccAccessRule(new byte[0], null, 0)},
p.getUiccAccessRules());
}
@Test
public void testBuilder_BasedOnAnotherProfile() {
EuiccProfileInfo p =
new EuiccProfileInfo.Builder()
.setIccid("21430000000000006587")
.setNickname("profile nickname")
.setProfileName("profile name")
.setServiceProviderName("service provider")
.setCarrierIdentifier(
new CarrierIdentifier(
new byte[] {0x23, 0x45, 0x67},
"123",
"45"))
.setState(EuiccProfileInfo.PROFILE_STATE_ENABLED)
.setProfileClass(EuiccProfileInfo.PROFILE_CLASS_OPERATIONAL)
.setPolicyRules(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE)
.setUiccAccessRule(
new UiccAccessRule[] {
new UiccAccessRule(new byte[0], null, 0)
})
.build();
EuiccProfileInfo copied = new EuiccProfileInfo.Builder(p).build();
assertEquals(p, copied);
assertEquals(p.hashCode(), copied.hashCode());
}
@Test
public void testEqualsHashCode() {
EuiccProfileInfo p =
new EuiccProfileInfo.Builder()
.setIccid("21430000000000006587")
.setNickname("profile nickname")
.setProfileName("profile name")
.setServiceProviderName("service provider")
.setCarrierIdentifier(
new CarrierIdentifier(
new byte[] {0x23, 0x45, 0x67},
"123",
"45"))
.setState(EuiccProfileInfo.PROFILE_STATE_ENABLED)
.setProfileClass(EuiccProfileInfo.PROFILE_STATE_ENABLED)
.setPolicyRules(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE)
.setUiccAccessRule(
new UiccAccessRule[] {
new UiccAccessRule(new byte[0], null, 0)
})
.build();
assertTrue(p.equals(p));
assertFalse(p.equals(new Object()));
EuiccProfileInfo t = null;
assertFalse(p.equals(t));
t = new EuiccProfileInfo.Builder(p).setIccid("21").build();
assertFalse(p.equals(t));
assertNotEquals(p.hashCode(), t.hashCode());
t = new EuiccProfileInfo.Builder(p).setNickname(null).build();
assertFalse(p.equals(t));
assertNotEquals(p.hashCode(), t.hashCode());
t = new EuiccProfileInfo.Builder(p).setProfileName(null).build();
assertFalse(p.equals(t));
assertNotEquals(p.hashCode(), t.hashCode());
t = new EuiccProfileInfo.Builder(p).setServiceProviderName(null).build();
assertFalse(p.equals(t));
assertNotEquals(p.hashCode(), t.hashCode());
t = new EuiccProfileInfo.Builder(p).setCarrierIdentifier(null).build();
assertFalse(p.equals(t));
assertNotEquals(p.hashCode(), t.hashCode());
t = new EuiccProfileInfo.Builder(p)
.setState(EuiccProfileInfo.PROFILE_STATE_DISABLED).build();
assertFalse(p.equals(t));
assertNotEquals(p.hashCode(), t.hashCode());
t = new EuiccProfileInfo.Builder(p)
.setProfileClass(EuiccProfileInfo.PROFILE_CLASS_TESTING).build();
assertFalse(p.equals(t));
assertNotEquals(p.hashCode(), t.hashCode());
t = new EuiccProfileInfo.Builder(p).setPolicyRules(0).build();
assertFalse(p.equals(t));
assertNotEquals(p.hashCode(), t.hashCode());
t = new EuiccProfileInfo.Builder(p).setUiccAccessRule(null).build();
assertFalse(p.equals(t));
assertNotEquals(p.hashCode(), t.hashCode());
}
@Test(expected = IllegalStateException.class)
public void testBuilderBuild_NoIccid() {
new EuiccProfileInfo.Builder().build();
}
@Test(expected = IllegalArgumentException.class)
public void testBuilderSetOperatorMccMnc_Illegal() {
new EuiccProfileInfo.Builder()
.setCarrierIdentifier(new CarrierIdentifier(new byte[] {1, 2, 3, 4}, null, null));
}
@Test
public void testCreatorNewArray() {
EuiccProfileInfo[] profiles = EuiccProfileInfo.CREATOR.newArray(123);
assertEquals(123, profiles.length);
}
}

View File

@@ -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
@@ -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: " +