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

Commit 7864c6c3 authored by Jordan Liu's avatar Jordan Liu
Browse files

Unlock mUiccCard access in UiccProfile

Waiting on locks for the parent mUiccCard in the UiccProfile class has
the potential to cause deadlocks. Unlocking it is safe because
UiccCard#getCardState is read only, and EuiccCard#unregisterForEidReady
and #registerForEidReady are guarded within the RegistrantList class.

Bug: 78601499
Test: builds and boots, makes calls, siminfo table is correct
Change-Id: I6bd56dadd6a2ec9849ab934002c435ee6dc33ef9
Merged-In: I6bd56dadd6a2ec9849ab934002c435ee6dc33ef9
parent ad228a6d
Loading
Loading
Loading
Loading
+15 −15
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ public class UiccProfile extends IccCard {
            new UiccCardApplication[IccCardStatus.CARD_MAX_APPS];
    private Context mContext;
    private CommandsInterface mCi;
    private UiccCard mUiccCard; //parent
    private final UiccCard mUiccCard; //parent
    private CatService mCatService;
    private UiccCarrierPrivilegeRules mCarrierPrivilegeRules;
    private boolean mDisposed = false;
@@ -242,15 +242,16 @@ public class UiccProfile extends IccCard {
     * Dispose the UiccProfile.
     */
    public void dispose() {
        synchronized (mLock) {
        if (DBG) log("Disposing profile");

            unregisterAllAppEvents();
            unregisterCurrAppEvents();

        // mUiccCard is outside of mLock in order to prevent deadlocking. This is safe because
        // EuiccCard#unregisterForEidReady handles its own lock
        if (mUiccCard instanceof EuiccCard) {
            ((EuiccCard) mUiccCard).unregisterForEidReady(mHandler);
        }
        synchronized (mLock) {
            unregisterAllAppEvents();
            unregisterCurrAppEvents();

            mCi.unregisterForOffOrNotAvailable(mHandler);
            mContext.unregisterReceiver(mReceiver);
@@ -849,8 +850,8 @@ public class UiccProfile extends IccCard {

    @Override
    public boolean hasIccCard() {
        synchronized (mLock) {
            if (mUiccCard != null && mUiccCard.getCardState()
        // mUiccCard is initialized in constructor, so won't be null
        if (mUiccCard.getCardState()
                != IccCardStatus.CardState.CARDSTATE_ABSENT) {
            return true;
        }
@@ -858,7 +859,6 @@ public class UiccProfile extends IccCard {
                + "ABSENT");
        return false;
    }
    }

    /**
     * Update the UiccProfile.