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

Commit d9b6a368 authored by Malcolm Chen's avatar Malcolm Chen
Browse files

Update isEmptyProfile of UiccProfile.

If no UiccApplications is reported from modem, we assert it's empty
profile. But at start of SIM_REFRESH we internally clear UiccApplications
which sometimes confuses us to believe it's empty profile. So we'll add
a cache of last reported num of UiccApplications from modem, which is
more reliable to determine whether modem has landed on empty profile or
not.

Bug: 131919246
Test: manual
Change-Id: I9a3fccbd4af9dfcfdb6ede04e6c1926a0d392e9a
Merged-In: I9a3fccbd4af9dfcfdb6ede04e6c1926a0d392e9a
parent e30823a1
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -137,6 +137,11 @@ public class UiccProfile extends IccCard {
    private IccRecords mIccRecords = null;
    private IccCardConstants.State mExternalState = IccCardConstants.State.UNKNOWN;

    // The number of UiccApplications modem reported. It's different from mUiccApplications.length
    // which is always CARD_MAX_APPS, and only updated when modem sends an update, and NOT updated
    // during SIM refresh. It's currently only used to help identify empty profile.
    private int mLastReportedNumOfUiccApplications;

    private final ContentObserver mProvisionCompleteContentObserver =
            new ContentObserver(new Handler()) {
                @Override
@@ -864,10 +869,11 @@ public class UiccProfile extends IccCard {
    public boolean isEmptyProfile() {
        // If there's no UiccCardApplication, it's an empty profile.
        // Empty profile is a valid case of eSIM (default boot profile).
        for (UiccCardApplication app : mUiccApplications) {
            if (app != null) return false;
        }
        return true;
        // But we clear all apps of mUiccCardApplication to be null during refresh (see
        // resetAppWithAid) but not mLastReportedNumOfUiccApplications.
        // So if mLastReportedNumOfUiccApplications == 0, it means modem confirmed that we landed
        // on empty profile.
        return mLastReportedNumOfUiccApplications == 0;
    }

    @Override
@@ -964,6 +970,8 @@ public class UiccProfile extends IccCard {

            //update applications
            if (DBG) log(ics.mApplications.length + " applications");
            mLastReportedNumOfUiccApplications = ics.mApplications.length;

            for (int i = 0; i < mUiccApplications.length; i++) {
                if (mUiccApplications[i] == null) {
                    //Create newly added Applications
+16 −0
Original line number Diff line number Diff line
@@ -630,4 +630,20 @@ public class UiccProfileTest extends TelephonyTest {
        }
        assertTrue(carrierFound);
    }

    @Test
    @SmallTest
    public void testIsEmptyProfile() {
        testUpdateUiccProfileApplication();
        assertFalse(mUiccProfile.isEmptyProfile());

        // Manually resetting app shouldn't indicate we are on empty profile.
        mUiccProfile.resetAppWithAid("", true);
        assertFalse(mUiccProfile.isEmptyProfile());

        // If we update there's no application, then we are on empty profile.
        testUpdateUiccProfileApplicationNoApplication();
        assertTrue(mUiccProfile.isEmptyProfile());

    }
}