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

Commit 3b918889 authored by Sandeep Kunta's avatar Sandeep Kunta
Browse files

Stk: dispose objects properly for hotswap

During hotswap, CatService object is disposed and new
object is created. However RilMessageDecoder still
holds reference to old object of CatService, and hence sends
decoded command to old object of CatService leading to stk failure.
In this fix below objects are disposed properly when CatService
is disposed.

1) RilMessageDecoder
2) CommandParamsFactory
3) IconLoader

Change-Id: Idf6b1ad3fad4b633e7dcf8082151de12abc83899
CRs-Fixed: 489025
parent c18087c8
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -164,8 +164,8 @@ public class CatService extends Handler implements AppInterface {
    }

    public void dispose() {
        CatLog.d(this, "Disposing CatService object");
        mIccRecords.unregisterForRecordsLoaded(this);

        // Clean up stk icon if dispose is called
        broadcastCardStateAndIccRefreshResp(CardState.CARDSTATE_ABSENT, null);

@@ -175,13 +175,19 @@ public class CatService extends Handler implements AppInterface {
        mCmdIf.unSetOnCatCallSetUp(this);
        mCmdIf.unSetOnCatCcAlphaNotify(this);
        mCmdIf.unregisterForIccRefresh(this);
        mCmdIf.unSetOnCatCcAlphaNotify(this);
        if (mUiccController != null) {
            mUiccController.unregisterForIccChanged(this);
            mUiccController = null;
        }
        if (mUiccApplication != null) {
            mUiccApplication.unregisterForReady(this);
        }
        mMsgDecoder.dispose();
        mMsgDecoder = null;
        disposeHandlerThread();
        sInstance = null;
        removeCallbacksAndMessages(null);
        sInstance = null;
    }

    protected void disposeHandlerThread() {
+7 −0
Original line number Diff line number Diff line
@@ -1008,4 +1008,11 @@ public class CommandParamsFactory extends Handler {
        }
        return false;
    }
    public void dispose() {
        mIconLoader.dispose();
        mIconLoader = null;
        mCmdParams = null;
        mCaller = null;
        sInstance = null;
    }
}
+13 −3
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ public class IconLoader extends Handler {
    protected HashMap<Integer, Bitmap> mIconsCache = null;

    private static IconLoader sLoader = null;
    private static HandlerThread sThread = null;

    // Loader state values.
    private static final int STATE_SINGLE_ICON = 1;
@@ -81,9 +82,9 @@ public class IconLoader extends Handler {
            return sLoader;
        }
        if (fh != null) {
            HandlerThread thread = new HandlerThread("Cat Icon Loader");
            thread.start();
            return new IconLoader(thread.getLooper(), fh);
            sThread = new HandlerThread("Cat Icon Loader");
            sThread.start();
            return new IconLoader(sThread.getLooper(), fh);
        }
        return null;
    }
@@ -363,4 +364,13 @@ public class IconLoader extends Handler {
        }
        return mask;
    }
    public void dispose() {
        mSimFH = null;
        if (sThread != null) {
            sThread.quit();
            sThread = null;
        }
        mIconsCache = null;
        sLoader = null;
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -178,4 +178,14 @@ public class RilMessageDecoder extends StateMachine {
        }
        return decodingStarted;
    }

    public void dispose() {
        mStateStart = null;
        mStateCmdParamsReady = null;
        mCmdParamsFactory.dispose();
        mCmdParamsFactory = null;
        mCurrentRilMessage = null;
        mCaller = null;
        sInstance = null;
    }
}