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

Commit 0b09de78 authored by rambowang's avatar rambowang Committed by Rambo Wang
Browse files

Introduce utility methods to redact sensitive info in UiccCard/PortInfo

Bug: 401006757
Test: atest CtsTelephony2TestCases CtsTelephonyTestCases
Flag: com.android.internal.telephony.flags.macro_based_opportunistic_networks
Change-Id: I5791366d9f650a4ad774612af31bc0d92892f62d
parent 1760dc38
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -231,6 +231,38 @@ public final class UiccCardInfo implements Parcelable {
        this.mIccIdAccessRestricted = iccIdAccessRestricted;
    }

    /**
     * Return a copy of the current UiccCardInfo but with sensitive info redacted.
     *
     * @hide
     */
    public UiccCardInfo createSensitiveInfoSanitizedCopy(boolean hasCarrierPrivileges) {
        if (hasCarrierPrivileges) {
            List<UiccPortInfo> portInfos = new  ArrayList<>();
            for (UiccPortInfo portInfo : this.getPorts()) {
                portInfos.add(portInfo.createSensitiveInfoSanitizedCopy());
            }
            return new UiccCardInfo(
                    this.isEuicc(),
                    this.getCardId(),
                    null,
                    this.getPhysicalSlotIndex(),
                    this.isRemovable(),
                    this.isMultipleEnabledProfilesSupported(),
                    portInfos);
        } else {
            // Without carrier privileges, treat it as READ_BASIC_PHONE_STATE, copy minimum info
            return new UiccCardInfo(
                    this.isEuicc(),
                    TelephonyManager.UNINITIALIZED_CARD_ID,
                    null,
                    this.getPhysicalSlotIndex(),
                    this.isRemovable(),
                    this.isMultipleEnabledProfilesSupported(),
                    List.of());
        }
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
+13 −0
Original line number Diff line number Diff line
@@ -138,6 +138,19 @@ public final class UiccPortInfo implements Parcelable{
        return mLogicalSlotIndex;
    }

    /**
     * Return a copy of the current UiccPortInfo but with sensitive info (ICCID) redacted.
     *
     * @hide
     */
    public UiccPortInfo createSensitiveInfoSanitizedCopy() {
        return new UiccPortInfo(
                UiccPortInfo.ICCID_REDACTED,
                this.getPortIndex(),
                this.getLogicalSlotIndex(),
                this.isActive());
    }

    @Override
    public boolean equals(@Nullable Object obj) {
        if (this == obj) {