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

Commit f68fa9e3 authored by Blake Kragten's avatar Blake Kragten
Browse files

Update Rail Data Collection Frequency

Fixed the frequency of the rail updates by updating the rails when
either the wifi or radio activity info is updated.

Test: Compiled onto phone, ran wifi and modem test cases and collected
bug report. Viewed a more accurate frequency of rail energy data.

Bug: 130174319

Change-Id: I4d79e58dfcc90e1c30253f524c85f26a8299f8d6
parent 6d38898c
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -609,9 +609,7 @@ public class BatteryStatsImpl extends BatteryStats {
        int UPDATE_RADIO = 0x04;
        int UPDATE_BT = 0x08;
        int UPDATE_RPM = 0x10; // 16
        int UPDATE_RAIL = 0x20; // 32
        int UPDATE_ALL = UPDATE_CPU | UPDATE_WIFI | UPDATE_RADIO | UPDATE_BT | UPDATE_RPM
                | UPDATE_RAIL;
        int UPDATE_ALL = UPDATE_CPU | UPDATE_WIFI | UPDATE_RADIO | UPDATE_BT | UPDATE_RPM;
        Future<?> scheduleSync(String reason, int flags);
        Future<?> scheduleCpuSyncDueToRemovedUid(int uid);
+10 −4
Original line number Diff line number Diff line
@@ -407,6 +407,7 @@ class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStatsSync {
        SynchronousResultReceiver wifiReceiver = null;
        SynchronousResultReceiver bluetoothReceiver = null;
        SynchronousResultReceiver modemReceiver = null;
        boolean railUpdated = false;

        if ((updateFlags & BatteryStatsImpl.ExternalStatsSync.UPDATE_WIFI) != 0) {
            // We were asked to fetch WiFi data.
@@ -426,6 +427,10 @@ class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStatsSync {
                    // Oh well.
                }
            }
            synchronized (mStats) {
                mStats.updateRailStatsLocked();
            }
            railUpdated = true;
        }

        if ((updateFlags & BatteryStatsImpl.ExternalStatsSync.UPDATE_BT) != 0) {
@@ -447,6 +452,11 @@ class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStatsSync {
                modemReceiver = new SynchronousResultReceiver("telephony");
                mTelephony.requestModemActivityInfo(modemReceiver);
            }
            if (!railUpdated) {
                synchronized (mStats) {
                    mStats.updateRailStatsLocked();
                }
            }
        }

        final WifiActivityEnergyInfo wifiInfo = awaitControllerInfo(wifiReceiver);
@@ -477,10 +487,6 @@ class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStatsSync {
                mStats.updateRpmStatsLocked();
            }

            if ((updateFlags & UPDATE_RAIL) != 0) {
                mStats.updateRailStatsLocked();
            }

            if (bluetoothInfo != null) {
                if (bluetoothInfo.isValid()) {
                    mStats.updateBluetoothStateLocked(bluetoothInfo);