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

Commit d23a7c4f authored by Michael Wachenschwanz's avatar Michael Wachenschwanz
Browse files

Introduce MeasuredEnergyStats to BatteryStatsImpl

Initial checkin that plumbs the flow of energy consumption data through
BatteryStatsService, BatteryStatsImpl, and BatteryExternalStatsWorker.

Also, start monitoring the display subsystem measured enegy consumption
and attribute energy to screen on and screen doze state.

Fixes: 171728122
Test: atest FrameworksCoreTests:MeasuredEnergyStatsTest
Change-Id: I014c2ee99da773ebc93e18d026b2e2e694d0d4b2
parent 892ddc11
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -2481,6 +2481,29 @@ public abstract class BatteryStats implements Parcelable {
        "group", "compl", "dorm", "uninit"
    };

    /**
     * Returned value if energy data is unavailable
     *
     * {@hide}
     */
    public static final long ENERGY_DATA_UNAVAILABLE = -1;

    /**
     * Returns the energy in microjoules that the screen consumed while on.
     * Will return {@link #ENERGY_DATA_UNAVAILABLE} if data is unavailable
     *
     * {@hide}
     */
    public abstract long getScreenOnEnergy();

    /**
     * Returns the energy in microjoules that the screen consumed while in doze
     * Will return {@link #ENERGY_DATA_UNAVAILABLE} if data is unavailable
     *
     * {@hide}
     */
    public abstract long getScreenDozeEnergy();

    public static final BitDescription[] HISTORY_STATE_DESCRIPTIONS = new BitDescription[] {
        new BitDescription(HistoryItem.STATE_CPU_RUNNING_FLAG, "running", "r"),
        new BitDescription(HistoryItem.STATE_WAKE_LOCK_FLAG, "wake_lock", "w"),
+17 −0
Original line number Diff line number Diff line
@@ -1390,6 +1390,23 @@ public final class Display {
        return state == STATE_ON || state == STATE_VR;
    }

    /**
     * Returns true if the display is in an off state such as {@link #STATE_OFF}.
     * @hide
     */
    public static boolean isOffState(int state) {
        return state == STATE_OFF;
    }

    /**
     * Returns true if the display is in an on state such as {@link #STATE_ON}
     * or {@link #STATE_VR} or {@link #STATE_ON_SUSPEND}.
     * @hide
     */
    public static boolean isOnState(int state) {
        return state == STATE_ON || state == STATE_VR || state == STATE_ON_SUSPEND;
    }

    /**
     * A mode supported by a given display.
     *
+165 −56

File changed.

Preview size limit exceeded, changes collapsed.

+66 −0

File added.

Preview size limit exceeded, changes collapsed.

+307 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading