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

Commit addf36e8 authored by Nitin Arora's avatar Nitin Arora Committed by Gerrit - the friendly Code Review server
Browse files

Bluetooth: Prevent scan start if already in progress

The logic checks the number ofscan clients in queue
before starting an LE scan and triggers an LE scan
only if there is only one scanclient in the queue
to ensure that an LE scan is not progress.

CRs-Fixed: 600877
Change-Id: I411ca751cb6c696b62d79f488141b71e5cc34605
parent c107026b
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -904,8 +904,15 @@ public class GattService extends ProfileService {
            LeScanRequestArbitrator.instance().RequestLeScan(LeScanRequestArbitrator.LE_NORMAL_SCAN_TYPE)) {
            if (DBG) Log.d(TAG, "startScan() - adding client=" + appIf);
            mScanQueue.add(new ScanClient(appIf, isServer));
            if(mScanQueue.size()==1)//start scan only if it is not already started
            {
                gattClientScanNative(appIf, true);
            }
            else
            {
                Log.d(TAG, "startScan scan already in progress for appifs-queue=" + mScanQueue.size());
            }
        }
    }

    void startScanWithUuids(int appIf, boolean isServer, UUID[] uuids) {
@@ -917,8 +924,15 @@ public class GattService extends ProfileService {
            LeScanRequestArbitrator.instance().RequestLeScan(LeScanRequestArbitrator.LE_NORMAL_SCAN_TYPE)) {
            if (DBG) Log.d(TAG, "startScanWithUuids() - adding client=" + appIf);
            mScanQueue.add(new ScanClient(appIf, isServer, uuids));
            if(mScanQueue.size()==1)//start scan only if it is not already started
            {
                gattClientScanNative(appIf, true);
            }
            else
            {
                Log.d(TAG, "startScanWithUuids scan already in progress for appifs-queue=" + mScanQueue.size());
            }
        }
    }

    void stopScan(int appIf, boolean isServer) {