Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 548f34b4 authored by Peter Wang's avatar Peter Wang
Browse files

Add a null check for EuiccProfileInfo access rules at creation

Bug: 158780604
Fix: 158780604
Test: Build
Change-Id: I6432499309115c7ca29f4704e0f5cfc871eb4d00
Merged-In: I6432499309115c7ca29f4704e0f5cfc871eb4d00
parent 06b1ba18
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -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 =
+4 −1
Original line number Diff line number Diff line
@@ -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. */