Merge "Fix taking actions without considering pending health checks" into qt-dev

This commit is contained in:
TreeHugger Robot
2019-05-07 19:01:40 +00:00
committed by Android (Google) Code Review

View File

@@ -529,8 +529,7 @@ public class PackageWatchdog {
while (pit.hasNext()) {
MonitoredPackage monitoredPackage = pit.next();
String packageName = monitoredPackage.getName();
if (monitoredPackage.getHealthCheckStateLocked()
!= MonitoredPackage.STATE_PASSED) {
if (monitoredPackage.isPendingHealthChecksLocked()) {
packages.add(packageName);
}
}
@@ -1093,7 +1092,10 @@ public class PackageWatchdog {
*/
@GuardedBy("mLock")
public long getShortestScheduleDurationMsLocked() {
return Math.min(toPositive(mDurationMs), toPositive(mHealthCheckDurationMs));
// Consider health check duration only if #isPendingHealthChecksLocked is true
return Math.min(toPositive(mDurationMs),
isPendingHealthChecksLocked()
? toPositive(mHealthCheckDurationMs) : Long.MAX_VALUE);
}
/**
@@ -1105,6 +1107,15 @@ public class PackageWatchdog {
return mDurationMs <= 0;
}
/**
* Returns {@code true} if the package, {@link #getName} is expecting health check results
* {@code false} otherwise.
*/
@GuardedBy("mLock")
public boolean isPendingHealthChecksLocked() {
return mHealthCheckState == STATE_ACTIVE || mHealthCheckState == STATE_INACTIVE;
}
/**
* Updates the health check state based on {@link #mHasPassedHealthCheck}
* and {@link #mHealthCheckDurationMs}.