merge in nyc-mr1-release history after reset to nyc-mr1-dev
diff --git a/src/com/android/bluetooth/gatt/ScanManager.java b/src/com/android/bluetooth/gatt/ScanManager.java
index 5eb31e1..7dceb28 100644
--- a/src/com/android/bluetooth/gatt/ScanManager.java
+++ b/src/com/android/bluetooth/gatt/ScanManager.java
@@ -253,10 +253,6 @@
             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);
 
@@ -270,7 +266,11 @@
 
                 // 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 */
                 }