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

Commit 98d4d5cf authored by Bookatz's avatar Bookatz
Browse files

Package wakeup alarms are now on screen-off timebase

Previously, wakeup alarms (for an app) were using the battery-on
timebase. Now they will instead use the battery-on-screen-off timebase.
In this way, apps won't be penalized for wakeups that occurred when
the device was being actively used anyway.

Also bumps up report version to 25.
Also bumps up parcel version.

Change-Id: I1b692a9137ff28d535e7a06b539f713b54a85ea9
Fixes: 64149996
Test: manually verified count doesn't increase when screen-on
parent 0a0bc5f8
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -206,8 +206,15 @@ public abstract class BatteryStats implements Parcelable {
     *   - CPU frequency time per uid
     * New in version 22:
     *   - BLE scan result background count, BLE unoptimized scan time
     */
    static final String CHECKIN_VERSION = "24";
     *   - Background partial wakelock time & count
     * New in version 23:
     *   - Logging smeared power model values
     * New in version 24:
     *   - Fixed bugs in background timers and BLE scan time
     * New in version 25:
     *   - Package wakeup alarms are now on screen-off timebase
     */
    static final String CHECKIN_VERSION = "25";

    /**
     * Old version, we hit 9 and ran out of room, need to remove.
+5 −4
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ public class BatteryStatsImpl extends BatteryStats {
    private static final int MAGIC = 0xBA757475; // 'BATSTATS'

    // Current on-disk Parcel version
    private static final int VERSION = 162 + (USE_OLD_HISTORY ? 1000 : 0);
    private static final int VERSION = 163 + (USE_OLD_HISTORY ? 1000 : 0);

    // Maximum number of items we will record in the history.
    private static final int MAX_HISTORY_ITEMS;
@@ -8038,6 +8038,7 @@ public class BatteryStatsImpl extends BatteryStats {

            /**
             * Number of times wakeup alarms have occurred for this app.
             * On screen-off timebase starting in report v25.
             */
            ArrayMap<String, Counter> mWakeupAlarms = new ArrayMap<>();

@@ -8066,7 +8067,7 @@ public class BatteryStatsImpl extends BatteryStats {
                mWakeupAlarms.clear();
                for (int i=0; i<numWA; i++) {
                    String tag = in.readString();
                    mWakeupAlarms.put(tag, new Counter(mBsi.mOnBatteryTimeBase, in));
                    mWakeupAlarms.put(tag, new Counter(mBsi.mOnBatteryScreenOffTimeBase, in));
                }

                int numServs = in.readInt();
@@ -8105,7 +8106,7 @@ public class BatteryStatsImpl extends BatteryStats {
            public void noteWakeupAlarmLocked(String tag) {
                Counter c = mWakeupAlarms.get(tag);
                if (c == null) {
                    c = new Counter(mBsi.mOnBatteryTimeBase);
                    c = new Counter(mBsi.mOnBatteryScreenOffTimeBase);
                    mWakeupAlarms.put(tag, c);
                }
                c.stepAtomic();
@@ -11862,7 +11863,7 @@ public class BatteryStatsImpl extends BatteryStats {
                p.mWakeupAlarms.clear();
                for (int iwa=0; iwa<NWA; iwa++) {
                    String tag = in.readString();
                    Counter c = new Counter(mOnBatteryTimeBase);
                    Counter c = new Counter(mOnBatteryScreenOffTimeBase);
                    c.readSummaryFromParcelLocked(in);
                    p.mWakeupAlarms.put(tag, c);
                }
+1 −1
Original line number Diff line number Diff line
@@ -488,7 +488,7 @@ public class BatteryStatsSensorTest extends TestCase {
        bi.noteStartSensorLocked(UID, SENSOR_ID);

        clocks.realtime += 111;
        clocks.uptime += 1111;
        clocks.uptime += 111;

        // Timebase and timer was on so times have increased.
        assertEquals(111_000, timer.getTotalTimeLocked(1000*clocks.realtime, which));