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

Commit 997b3bb8 authored by Ajay Panicker's avatar Ajay Panicker
Browse files

Log battery stats before ScanClient gets removed

Bug: 36977250
Test: run cts-dev -m CtsIncidentHostTestCases -t com.android.server.cts.BatteryStatsValidationTest
Change-Id: I8b926b7eeb9bdd8b54c7655a4951d21e8dffddfc
parent 41b339ef
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -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);
            }