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

Commit a588c0ef authored by Bhakthavatsala Raghavendra's avatar Bhakthavatsala Raghavendra Committed by Gerrit - the friendly Code Review server
Browse files

Bluetooth: Cleanup the handler threads properly

Cleanup the handler threads in Advertisementmanager
and ScanManager so that there are no resource leaks

CRs-fixed: 749335

Change-Id: Ia51899f449d57c1ef68a9516b8472d1fd492572b
parent 5475aebf
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -87,6 +87,16 @@ class AdvertiseManager {
    void cleanup() {
        logd("advertise clients cleared");
        mAdvertiseClients.clear();

        if (mHandler != null) {
            // Shut down the thread
            mHandler.removeCallbacksAndMessages(null);
            Looper looper = mHandler.getLooper();
            if (looper != null) {
                looper.quit();
            }
            mHandler = null;
        }
    }

    /**
+10 −0
Original line number Diff line number Diff line
@@ -101,6 +101,16 @@ public class ScanManager {
        mRegularScanClients.clear();
        mBatchClients.clear();
        mScanNative.cleanup();

        if (mHandler != null) {
            // Shut down the thread
            mHandler.removeCallbacksAndMessages(null);
            Looper looper = mHandler.getLooper();
            if (looper != null) {
                looper.quit();
            }
            mHandler = null;
        }
    }

    /**