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

Commit fdeb6b8e authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Android (Google) Code Review
Browse files

Merge "Read cpu freq data only when needed." into oc-dev

parents 7f481760 671985f4
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -185,7 +185,7 @@ public class BatteryStatsImpl extends BatteryStats {
            switch (msg.what) {
                case MSG_UPDATE_WAKELOCKS:
                    synchronized (BatteryStatsImpl.this) {
                        updateCpuTimeLocked();
                        updateCpuTimeLocked(false /* updateCpuFreqData */);
                    }
                    if (cb != null) {
                        cb.batteryNeedsCpuUpdate();
@@ -3480,7 +3480,7 @@ public class BatteryStatsImpl extends BatteryStats {
                Slog.d(TAG, "Updating cpu time because screen is now " +
                        (unpluggedScreenOff ? "off" : "on"));
            }
            updateCpuTimeLocked();
            updateCpuTimeLocked(true /* updateCpuFreqData */);
            mOnBatteryScreenOffTimeBase.setRunning(unpluggedScreenOff, uptime, realtime);
            for (int i = 0; i < mUidStats.size(); i++) {
                mUidStats.valueAt(i).updateOnBatteryScreenOffBgTimeBase(uptime, realtime);
@@ -10002,7 +10002,7 @@ public class BatteryStatsImpl extends BatteryStats {
     * and we are on battery with screen off, we give more of the cpu time to those apps holding
     * wakelocks. If the screen is on, we just assign the actual cpu time an app used.
     */
    public void updateCpuTimeLocked() {
    public void updateCpuTimeLocked(boolean updateCpuFreqData) {
        if (mPowerProfile == null) {
            return;
        }
@@ -10117,7 +10117,9 @@ public class BatteryStatsImpl extends BatteryStats {
                    }
                });

        if (updateCpuFreqData) {
            readKernelUidCpuFreqTimesLocked();
        }

        final long elapse = (mClocks.elapsedRealtime() - startTimeMs);
        if (DEBUG_ENERGY_CPU || (elapse >= 100)) {
+5 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.am;

import static com.android.internal.os.BatteryStatsImpl.ExternalStatsSync.UPDATE_CPU;

import android.annotation.Nullable;
import android.bluetooth.BluetoothActivityEnergyInfo;
import android.bluetooth.BluetoothAdapter;
@@ -1549,7 +1551,9 @@ public final class BatteryStatsService extends IBatteryStats.Stub
                        BatteryStats.HistoryItem.EVENT_COLLECT_EXTERNAL_STATS,
                        reason, 0);

                mStats.updateCpuTimeLocked();
                if ((updateFlags & UPDATE_CPU) != 0) {
                    mStats.updateCpuTimeLocked(true /* updateCpuFreqData */);
                }
                mStats.updateKernelWakelocksLocked();
                mStats.updateKernelMemoryBandwidthLocked();