From 9722971cb4a79e37165f636f9dd057707d2e620a Mon Sep 17 00:00:00 2001 From: Vinay Kalia Date: Fri, 28 Jul 2017 15:09:57 -0700 Subject: [PATCH] Fix BLE scan leaks If an app starts multiple scans with same callback then there is a collision in mLeScanClients hash map which results in leaking first scan. This change fixes it by not allowing the second scan with same callback. BUG: 62389939 BUG: 38198694 Test: Tested applications which started multiple scans with same callback. Change-Id: I569069a40b6f8b4b8bb070731225e732c6b23ec8 --- core/java/android/bluetooth/le/BluetoothLeScanner.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/android/bluetooth/le/BluetoothLeScanner.java b/core/java/android/bluetooth/le/BluetoothLeScanner.java index 1eac395bd06c4..e3bc78e5a2bb4 100644 --- a/core/java/android/bluetooth/le/BluetoothLeScanner.java +++ b/core/java/android/bluetooth/le/BluetoothLeScanner.java @@ -205,7 +205,8 @@ public final class BluetoothLeScanner { } synchronized (mLeScanClients) { if (callback != null && mLeScanClients.containsKey(callback)) { - postCallbackError(callback, ScanCallback.SCAN_FAILED_ALREADY_STARTED); + return postCallbackErrorOrReturn(callback, + ScanCallback.SCAN_FAILED_ALREADY_STARTED); } IBluetoothGatt gatt; try {