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

Commit 8c52e15c authored by KimJeongYeon's avatar KimJeongYeon
Browse files

BLE: Fix not freed onfound/onlost filter when stop scan



ScanManager doesn't freed allocated onfound/onlost filters when stop LE scan.
Therefore, scan always fails to start in next time when overflows of
onfound/onlost filters over total number of trackable advertisements.
This issue happens when apps try to scan with special callback types.
(e.g CALLBACK_TYPE_FIRST_MATCH, CALLBACK_TYPE_MATCH_LOST)
This patch retrieves 'client.settings' & 'client.filters' information
from set 'mRegularScanClients' to free onfound/onlost filters.

Bug: 143097315
Test: Scan with callback type 'CALLBACK_TYPE_MATCH_LOST' using BLE test app.

Change-Id: I6f1a134ee46931b8f4f6c763359ae1d84ae030eb
Signed-off-by: default avatarKimJeongYeon <jeongyeon.kim@samsung.com>
parent 8901181c
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -343,7 +343,7 @@ public class GattService extends ProfileService {
            if (isScanClient(mScannerId)) {
                ScanClient client = new ScanClient(mScannerId);
                client.appDied = true;
                stopScan(client);
                stopScan(client.scannerId);
            }
        }

@@ -500,7 +500,7 @@ public class GattService extends ProfileService {
            if (service == null) {
                return;
            }
            service.stopScan(new ScanClient(scannerId));
            service.stopScan(scannerId);
        }

        @Override
@@ -1031,7 +1031,7 @@ public class GattService extends ProfileService {
            } catch (RemoteException | PendingIntent.CanceledException e) {
                Log.e(TAG, "Exception: " + e);
                mScannerMap.remove(client.scannerId);
                mScanManager.stopScan(client);
                mScanManager.stopScan(client.scannerId);
            }
        }
    }
@@ -1043,7 +1043,7 @@ public class GattService extends ProfileService {
        try {
            sendResultsByPendingIntent(pii, results, callbackType);
        } catch (PendingIntent.CanceledException e) {
            stopScan(client);
            stopScan(client.scannerId);
            unregisterScanner(client.scannerId);
        }
    }
@@ -1595,7 +1595,7 @@ public class GattService extends ProfileService {
        } catch (RemoteException | PendingIntent.CanceledException e) {
            Log.e(TAG, "Exception: " + e);
            mScannerMap.remove(client.scannerId);
            mScanManager.stopScan(client);
            mScanManager.stopScan(client.scannerId);
        }
    }

@@ -2039,7 +2039,7 @@ public class GattService extends ProfileService {
        mScanManager.flushBatchScanResults(new ScanClient(scannerId));
    }

    void stopScan(ScanClient client) {
    void stopScan(int scannerId) {
        enforceAdminPermission();
        int scanQueueSize =
                mScanManager.getBatchScanQueue().size() + mScanManager.getRegularScanQueue().size();
@@ -2048,12 +2048,12 @@ public class GattService extends ProfileService {
        }

        AppScanStats app = null;
        app = mScannerMap.getAppScanStatsById(client.scannerId);
        app = mScannerMap.getAppScanStatsById(scannerId);
        if (app != null) {
            app.recordScanStop(client.scannerId);
            app.recordScanStop(scannerId);
        }

        mScanManager.stopScan(client);
        mScanManager.stopScan(scannerId);
    }

    void stopScan(PendingIntent intent, String callingPackage) {
@@ -2066,7 +2066,7 @@ public class GattService extends ProfileService {
        }
        if (app != null) {
            final int scannerId = app.id;
            stopScan(new ScanClient(scannerId));
            stopScan(scannerId);
            // Also unregister the scanner
            unregisterScanner(scannerId);
        }
+5 −1
Original line number Diff line number Diff line
@@ -223,7 +223,11 @@ public class ScanManager {
        sendMessage(MSG_START_BLE_SCAN, client);
    }

    void stopScan(ScanClient client) {
    void stopScan(int scannerId) {
        ScanClient client = mScanNative.getBatchScanClient(scannerId);
        if (client == null) {
            client = mScanNative.getRegularScanClient(scannerId);
        }
        sendMessage(MSG_STOP_BLE_SCAN, client);
    }