Fix the algorithm counting the package failures

Use the sliding window algorithm to detect if there exists a window
containing failures equal to or above the trigger threshold.

Bug: 140841942
Test: atest PackageWatchdogTest
Change-Id: I34a20e4d3b98a093dffa05fc7c7c026905834b53
2 files changed