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

Commit c427f95e authored by Malcolm Chen's avatar Malcolm Chen Committed by android-build-merger
Browse files

Update isEmptyProfile of UiccProfile.

am: 2401960e

Change-Id: If2de1cdca37f3558941fd03e9113dee9661250fc
parents 4898663a 2401960e
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -136,6 +136,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
@@ -839,10 +844,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
@@ -939,6 +945,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());

    }
}