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

Commit 1f263134 authored by Muralidhar Reddy's avatar Muralidhar Reddy
Browse files

Clean up UiccPortInfo related assumptions to avoid FATAL exceptions.

Test: atest FrameworksTelephonyTests
Bug: 275743638, 257088526
Change-Id: Icd652658ac53f9adabde695fa47a3e4edbffc4b7
parent 754fb0b4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@ public final class UiccCardInfo implements Parcelable {
                + " Please Use UiccPortInfo API instead");
        }
        //always return ICCID from first port.
        return getPorts().stream().findFirst().get().getIccId();
        return mPortList.isEmpty() ? null : mPortList.get(0).getIccId();
    }

    /**
+6 −7
Original line number Diff line number Diff line
@@ -139,14 +139,16 @@ public class UiccSlotInfo implements Parcelable {
    public UiccSlotInfo(boolean isEuicc, String cardId,
            @CardStateInfo int cardStateInfo, boolean isExtendedApduSupported,
            boolean isRemovable, @NonNull List<UiccPortInfo> portList) {
        this.mIsActive = portList.get(0).isActive();
        this.mIsEuicc = isEuicc;
        this.mCardId = cardId;
        this.mCardStateInfo = cardStateInfo;
        this.mLogicalSlotIdx = portList.get(0).getLogicalSlotIndex();
        this.mIsExtendedApduSupported = isExtendedApduSupported;
        this.mIsRemovable = isRemovable;
        this.mPortList = portList;
        this.mIsActive = !portList.isEmpty() && portList.get(0).isActive();
        this.mLogicalSlotIdx = portList.isEmpty()
                ? SubscriptionManager.INVALID_PHONE_INDEX
                : portList.get(0).getLogicalSlotIndex();
    }

    /**
@@ -164,8 +166,7 @@ public class UiccSlotInfo implements Parcelable {
            throw new UnsupportedOperationException("getIsActive() is not supported by "
            + "UiccSlotInfo. Please Use UiccPortInfo API instead");
        }
        //always return status from first port.
        return getPorts().stream().findFirst().get().isActive();
        return mIsActive;
    }

    public boolean getIsEuicc() {
@@ -202,9 +203,7 @@ public class UiccSlotInfo implements Parcelable {
            throw new UnsupportedOperationException("getLogicalSlotIdx() is not supported by "
                + "UiccSlotInfo. Please use UiccPortInfo API instead");
        }
        //always return logical slot index from first port.
        //portList always have at least one element.
        return getPorts().stream().findFirst().get().getLogicalSlotIndex();
        return mLogicalSlotIdx;
    }

    /**