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

Commit ea6eec14 authored by Srinu Jella's avatar Srinu Jella Committed by Gerrit - the friendly Code Review server
Browse files

Bluetooth: Avoid cleanup the scan manager if already cleaned up

- Avoid cleanup the scan manager if already cleaned up, scan
  manager can be cleared on receiving the stop request or
  when the service is destroyed.

- There is a case, where destroy and stop called one after
  the other, it will try to cleanup twice, that leads to
  crash.

CRs-Fixed: 797597

Change-Id: I0adc5cb683bbf47f12598e6c54eae7df87cdbbc4
parent 4b4d8147
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -198,16 +198,28 @@ public class GattService extends ProfileService {
        mServiceDeclarations.clear();
        mActiveServiceDeclarations.clear();
        mReliableQueue.clear();
        if (mAdvertiseManager != null) mAdvertiseManager.cleanup();
        if (mScanManager != null) mScanManager.cleanup();
        if (mAdvertiseManager != null) {
            mAdvertiseManager.cleanup();
            mAdvertiseManager = null;
        }
        if (mScanManager != null) {
            mScanManager.cleanup();
            mScanManager = null;
        }
        return true;
    }

    protected boolean cleanup() {
        if (DBG) Log.d(TAG, "cleanup()");
        cleanupNative();
        if (mAdvertiseManager != null) mAdvertiseManager.cleanup();
        if (mScanManager != null) mScanManager.cleanup();
        if (mAdvertiseManager != null) {
            mAdvertiseManager.cleanup();
            mAdvertiseManager = null;
        }
        if (mScanManager != null) {
            mScanManager.cleanup();
            mScanManager = null;
        }
        return true;
    }