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

Commit be0c935e authored by Sudheer Shanka's avatar Sudheer Shanka Committed by android-build-merger
Browse files

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

am: 7c1598d5

Change-Id: I82502ee6740a451b23fcef8c5383988615ff7651
parents e9e82ef6 7c1598d5
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();