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

Commit 0cba51e9 authored by Zimuzo's avatar Zimuzo Committed by android-build-merger
Browse files

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

am: 9192a430

Change-Id: I069620eb5f96c8d63ade4cffc945612607282173
parents 5fbbf66e 9192a430
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -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}.