From: Andre Eisenbach Date: Fri, 7 Oct 2016 00:39:31 +0000 (-0700) Subject: Ensure LE scan clients are removed when the related app dies X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=212ae6d734ecab7583065ee9136553a6f7c4a236;p=android-x86%2Fpackages-apps-Bluetooth.git Ensure LE scan clients are removed when the related app dies Use the passed in ScanClient in handleStopScan() to ensure that the client appDied flag is in the correct state to ensure proper removal of the client application reference. Bug: 30681588 Test: manual Change-Id: I0e0067a8e21ebd5f89870a7054b1f4092fe63ae1 (cherry picked from commit 5185d1989c93faa3ce4b4410ef49a0205f43b239) --- diff --git a/src/com/android/bluetooth/gatt/ScanManager.java b/src/com/android/bluetooth/gatt/ScanManager.java index ef103df3..62135972 100644 --- a/src/com/android/bluetooth/gatt/ScanManager.java +++ b/src/com/android/bluetooth/gatt/ScanManager.java @@ -263,10 +263,6 @@ public class ScanManager { if (client == null) return; if (mRegularScanClients.contains(client)) { - // The ScanClient passed in just holds the clientIf. We retrieve the real client, - // which may have workSource set. - client = mScanNative.getRegularScanClient(client.clientIf); - if (client == null) return; mScanNative.stopRegularScan(client); @@ -280,7 +276,11 @@ public class ScanManager { // Update BatteryStats with this workload. try { - mBatteryStats.noteBleScanStopped(client.workSource); + // The ScanClient passed in just holds the clientIf. We retrieve the real client, + // which may have workSource set. + ScanClient workClient = mScanNative.getRegularScanClient(client.clientIf); + if (workClient != null) + mBatteryStats.noteBleScanStopped(workClient.workSource); } catch (RemoteException e) { /* ignore */ }