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

Commit c477c9d8 authored by Hall Liu's avatar Hall Liu
Browse files

Fix various thread and memory leaks

Fix several places in Telephony tests where threads were being leaked.
Also remove telephony tests from TestableLooper during teardown in order
to avoid a memory leak.

Fixes: 156287358
Test: atest FrameworksTelephonyTests
Change-Id: I89cae577965db9d912a979627bcd8175159d7d72
Merged-In: I89cae577965db9d912a979627bcd8175159d7d72
parent 9d7ed998
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -209,8 +209,10 @@ public class RIL extends BaseCommands implements CommandsInterface {
    //***** Instance Variables

    @UnsupportedAppUsage
    final WakeLock mWakeLock;           // Wake lock associated with request/response
    final WakeLock mAckWakeLock;        // Wake lock associated with ack sent
    @VisibleForTesting
    public final WakeLock mWakeLock;           // Wake lock associated with request/response
    @VisibleForTesting
    public final WakeLock mAckWakeLock;        // Wake lock associated with ack sent
    final int mWakeLockTimeout;         // Timeout associated with request/response
    final int mAckWakeLockTimeout;      // Timeout associated with ack sent
    // The number of wakelock requests currently active.  Don't release the lock
+14 −3
Original line number Diff line number Diff line
@@ -654,6 +654,7 @@ public class DcTracker extends Handler {
    private final int mTransportType;

    private DataStallRecoveryHandler mDsRecoveryHandler;
    private HandlerThread mHandlerThread;

    /**
     * Request network completion message map. Key is the APN type, value is the list of completion
@@ -710,9 +711,9 @@ public class DcTracker extends Handler {
                .getSystemService(Context.NETWORK_POLICY_SERVICE);
        mNetworkPolicyManager.registerSubscriptionCallback(mSubscriptionCallback);

        HandlerThread dcHandlerThread = new HandlerThread("DcHandlerThread");
        dcHandlerThread.start();
        Handler dcHandler = new Handler(dcHandlerThread.getLooper());
        mHandlerThread = new HandlerThread("DcHandlerThread");
        mHandlerThread.start();
        Handler dcHandler = new Handler(mHandlerThread.getLooper());
        mDcc = DcController.makeDcc(mPhone, this, mDataServiceManager, dcHandler, tagSuffix);
        mDcTesterFailBringUpAll = new DcTesterFailBringUpAll(mPhone, dcHandler);

@@ -829,6 +830,16 @@ public class DcTracker extends Handler {
        destroyDataConnections();
    }

    /**
     * Stop the internal handler thread
     *
     * TESTING ONLY
     */
    @VisibleForTesting
    public void stopHandlerThread() {
        mHandlerThread.quit();
    }

    private void unregisterForAllEvents() {
         //Unregister for all events
        if (mTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) {
+3 −0
Original line number Diff line number Diff line
@@ -89,6 +89,9 @@ public class CellularNetworkServiceTest extends TelephonyTest {

    @After
    public void tearDown() throws Exception {
        if (mCellularNetworkService != null) {
            mCellularNetworkService.onDestroy();
        }
        super.tearDown();
    }

+2 −0
Original line number Diff line number Diff line
@@ -311,6 +311,8 @@ public class RILTest extends TelephonyTest {

    @After
    public void tearDown() throws Exception {
        mRILUnderTest.mWakeLock.release();
        mRILUnderTest.mAckWakeLock.release();
        super.tearDown();
    }

+3 −0
Original line number Diff line number Diff line
@@ -334,6 +334,9 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        sst = null;
        mSSTTestHandler.quit();
        mSSTTestHandler.join();
        if (mCellularNetworkService != null) {
            mCellularNetworkService.onDestroy();
        }
        super.tearDown();
    }

Loading