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

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

Update isEmptyProfile of UiccProfile.

am: d9b6a368

Change-Id: I1755ff2ffca134f3f9926ffba303b9e502da069f
parents d6ebc3d0 d9b6a368
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());

    }
}