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

Commit 136f17db authored by Sean Stout's avatar Sean Stout
Browse files

Fix "Screen on" time reporting

this CL fixes issues with "screen on" time reporting as there were
incidences of this time taking much longer than in reality.

Bug: 184765461
Test: Manual - check power on time reporting
Change-Id: If716e6842b8a214b5af0f66ba41f7f2b70fbc51b
parent 7f0b9867
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -141,6 +141,14 @@ public class DisplayGroupPowerStateMapper {
        return mDisplayGroupInfos.get(groupId).lastPowerOnTime;
    }

    void setPoweringOnLocked(int groupId, boolean poweringOn) {
        mDisplayGroupInfos.get(groupId).poweringOn = poweringOn;
    }

    boolean isPoweringOnLocked(int groupId) {
        return mDisplayGroupInfos.get(groupId).poweringOn;
    }

    /**
     * Returns the amalgamated wakefulness of all {@link DisplayGroup DisplayGroups}.
     *
@@ -300,6 +308,7 @@ public class DisplayGroupPowerStateMapper {
        public int wakefulness;
        public boolean ready;
        public long lastPowerOnTime;
        boolean poweringOn;
        public boolean sandmanSummoned;
        public long lastUserActivityTime;
        public long lastUserActivityTimeNoChangeLights;
+5 −1
Original line number Diff line number Diff line
@@ -1830,6 +1830,7 @@ public final class PowerManagerService extends SystemService
            setWakefulnessLocked(groupId, WAKEFULNESS_AWAKE, eventTime, uid, reason, opUid,
                    opPackageName, details);
            mDisplayGroupPowerStateMapper.setLastPowerOnTimeLocked(groupId, eventTime);
            mDisplayGroupPowerStateMapper.setPoweringOnLocked(groupId, true);
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_POWER);
        }
@@ -3192,9 +3193,12 @@ public final class PowerManagerService extends SystemService

                final boolean displayReadyStateChanged =
                        mDisplayGroupPowerStateMapper.setDisplayGroupReadyLocked(groupId, ready);
                if (ready && displayReadyStateChanged
                final boolean poweringOn =
                        mDisplayGroupPowerStateMapper.isPoweringOnLocked(groupId);
                if (ready && displayReadyStateChanged && poweringOn
                        && mDisplayGroupPowerStateMapper.getWakefulnessLocked(
                        groupId) == WAKEFULNESS_AWAKE) {
                    mDisplayGroupPowerStateMapper.setPoweringOnLocked(groupId, false);
                    Trace.asyncTraceEnd(Trace.TRACE_TAG_POWER, TRACE_SCREEN_ON, groupId);
                    final int latencyMs = (int) (mClock.uptimeMillis()
                            - mDisplayGroupPowerStateMapper.getLastPowerOnTimeLocked(groupId));