OSDN Git Service

Log battery stats before ScanClient gets removed
authorAjay Panicker <apanicke@google.com>
Thu, 20 Apr 2017 01:16:42 +0000 (18:16 -0700)
committerAjay Panicker <apanicke@google.com>
Thu, 20 Apr 2017 19:33:00 +0000 (19:33 +0000)
Bug: 36977250
Test: run cts-dev -m CtsIncidentHostTestCases -t com.android.server.cts.BatteryStatsValidationTest
Change-Id: I8b926b7eeb9bdd8b54c7655a4951d21e8dffddfc

src/com/android/bluetooth/gatt/ScanManager.java

index b5b6df5..b7b64f0 100644 (file)
@@ -269,6 +269,15 @@ public class ScanManager {
             if (client == null) return;
 
             if (mRegularScanClients.contains(client)) {
+                // Update BatteryStats with this workload.
+                try {
+                    // The ScanClient passed in just holds the scannerId. We retrieve the real
+                    // client, which may have workSource set.
+                    ScanClient workClient = mScanNative.getRegularScanClient(client.scannerId);
+                    if (workClient != null) mBatteryStats.noteBleScanStopped(workClient.workSource);
+                } catch (RemoteException e) {
+                    /* ignore */
+                }
 
                 mScanNative.stopRegularScan(client);
 
@@ -279,17 +288,6 @@ public class ScanManager {
                 if (!mScanNative.isOpportunisticScanClient(client)) {
                     mScanNative.configureRegularScanParams();
                 }
-
-                // Update BatteryStats with this workload.
-                try {
-                    // The ScanClient passed in just holds the scannerId. We retrieve the real client,
-                    // which may have workSource set.
-                    ScanClient workClient = mScanNative.getRegularScanClient(client.scannerId);
-                    if (workClient != null)
-                        mBatteryStats.noteBleScanStopped(workClient.workSource);
-                } catch (RemoteException e) {
-                    /* ignore */
-                }
             } else {
                 mScanNative.stopBatchScan(client);
             }