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

Commit b5d471c1 authored by Salvador Martinez's avatar Salvador Martinez
Browse files

Fix null pointer in SubscriptionUtil

Sometimes we get null sub info which causes a crash. This just
makes it so that if we see that we treat it as inactive since
there isn't really a world where an active null sub info makes
sense.

Test: atest SubscriptionUtilTest
Bug: 131603073
Change-Id: Id5ecbecf011e19ff02d9465e0571b1d17c83de9a
parent 8b285f23
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -59,7 +59,11 @@ public class SubscriptionUtil {
        return subscriptions;
    }

    private static boolean isInactiveInsertedPSim(UiccSlotInfo slotInfo) {
    @VisibleForTesting
    static boolean isInactiveInsertedPSim(UiccSlotInfo slotInfo) {
        if (slotInfo == null)  {
            return false;
        }
        return !slotInfo.getIsEuicc() && !slotInfo.getIsActive() &&
                slotInfo.getCardStateInfo() == CARD_STATE_INFO_PRESENT;
    }
+5 −0
Original line number Diff line number Diff line
@@ -187,4 +187,9 @@ public class SubscriptionUtilTest {
        assertThat(subs).isNotNull();
        assertThat(subs).hasSize(2);
    }

    @Test
    public void isInactiveInsertedPSim_nullSubInfo_doesNotCrash() {
        assertThat(SubscriptionUtil.isInactiveInsertedPSim(null)).isFalse();
    }
}