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
This commit is contained in:
Sean Stout
2021-04-20 16:03:54 -07:00
parent 7f0b986741
commit 136f17dbc2
2 changed files with 14 additions and 1 deletions

View File

@@ -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;

View File

@@ -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));