Increase max metrics duration deviation to 2 hours

A lot of WTF logs reported were barely 1 second over the 1 hour
limit. AlarmManager has a maximum window of 1 hour so these cases
are possible and expected.
Increase the max metrics duration deviation to 2 hours to avoid
this log.

Bug: 297292877
Test: Manual test
Change-Id: I9a476e8061944c6499fe1b1d6e9ad1e19e6ce2b9
This commit is contained in:
Hansen Kurli 2024-01-30 20:41:13 +08:00
commit d85482534c
2 changed files with 5 additions and 4 deletions

View file

@ -74,9 +74,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class KeepaliveStatsTracker {
private static final String TAG = KeepaliveStatsTracker.class.getSimpleName();
private static final int INVALID_KEEPALIVE_ID = -1;
// 1 hour acceptable deviation in metrics collection duration time.
// 2 hour acceptable deviation in metrics collection duration time to account for the 1 hour
// window of AlarmManager.
private static final long MAX_EXPECTED_DURATION_MS =
AutomaticOnOffKeepaliveTracker.METRICS_COLLECTION_DURATION_MS + 1 * 60 * 60 * 1_000L;
AutomaticOnOffKeepaliveTracker.METRICS_COLLECTION_DURATION_MS + 2 * 60 * 60 * 1_000L;
@NonNull private final Handler mConnectivityServiceHandler;
@NonNull private final Dependencies mDependencies;

View file

@ -1297,8 +1297,8 @@ public class KeepaliveStatsTrackerTest {
assertTrue(mKeepaliveStatsTracker.allMetricsExpected(dailyKeepaliveInfoReported));
// Write time after 26 hours.
final int writeTime2 = 26 * 60 * 60 * 1000;
// Write time after 27 hours.
final int writeTime2 = 27 * 60 * 60 * 1000;
setElapsedRealtime(writeTime2);
visibleOnHandlerThread(mTestHandler, () -> mKeepaliveStatsTracker.writeAndResetMetrics());