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

Commit a4aadd26 authored by Vinay Kalia's avatar Vinay Kalia
Browse files

Unregister display listener

Display listener must be unregistered in ScanManager::cleanup()
to avoid getting display state change callbacks between
ScanManager::cleanup() and ScanManager object destruction.

BUG: 64253576
Test: Screen on and screen off during BLE scanning.
      Screen on and screen off with Bluetooth off.

Change-Id: I5b1f26696c44aaaca3720a200d85983afc8d2759
(cherry picked from commit 465c10d3)
parent ecc3edf6
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -107,13 +107,15 @@ public class ScanManager {
        mScanNative = new ScanNative();
        curUsedTrackableAdvertisements = 0;
        mDm = (DisplayManager) mService.getSystemService(Context.DISPLAY_SERVICE);
        mDm.registerDisplayListener(mDisplayListener, null);
    }

    void start() {
        HandlerThread thread = new HandlerThread("BluetoothScanManager");
        thread.start();
        mHandler = new ClientHandler(thread.getLooper());
        if (mDm != null) {
            mDm.registerDisplayListener(mDisplayListener, null);
        }
    }

    void cleanup() {
@@ -122,6 +124,10 @@ public class ScanManager {
        mSuspendedScanClients.clear();
        mScanNative.cleanup();

        if (mDm != null) {
            mDm.unregisterDisplayListener(mDisplayListener);
        }

        if (mHandler != null) {
            // Shut down the thread
            mHandler.removeCallbacksAndMessages(null);