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

Commit 7fb36dc6 authored by KimJeongYeon's avatar KimJeongYeon Committed by android-build-merger
Browse files

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

am: 1dbf281d

Change-Id: I8458f878841d174e58f092ee8b449d6a568a67fe
parents 6d326446 1dbf281d
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);
    }