Merge "Add a null check for EuiccProfileInfo access rules at creation" am: 65f6068c8a am: 098fb8606a

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1364082

Change-Id: Icca17231fe6b7386e18b9c44a22eebdca2336f24
This commit is contained in:
Peter Wang
2020-07-16 09:34:33 +00:00
committed by Automerger Merge Worker
2 changed files with 27 additions and 1 deletions

View File

@@ -153,6 +153,29 @@ public class EuiccProfileInfoTest {
assertEquals(p.hashCode(), copied.hashCode());
}
@Test
public void testBuilder_BasedOnAnotherProfileWithEmptyAccessRules() {
EuiccProfileInfo p =
new EuiccProfileInfo.Builder("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(null)
.build();
EuiccProfileInfo copied = new EuiccProfileInfo.Builder(p).build();
assertEquals(null, copied.getUiccAccessRules());
}
@Test
public void testEqualsHashCode() {
EuiccProfileInfo p =

View File

@@ -29,6 +29,7 @@ import android.text.TextUtils;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -231,7 +232,9 @@ public final class EuiccProfileInfo implements Parcelable {
mState = baseProfile.mState;
mCarrierIdentifier = baseProfile.mCarrierIdentifier;
mPolicyRules = baseProfile.mPolicyRules;
mAccessRules = Arrays.asList(baseProfile.mAccessRules);
mAccessRules = baseProfile.mAccessRules == null
? Collections.emptyList()
: Arrays.asList(baseProfile.mAccessRules);
}
/** Builds the profile instance. */