android_packages_modules_Co.../tests/unit/java
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Junyu Lai 48c3c2bf10 Update start timestamp for querying data usage
The previous implementation used a fixed start timestamp for
querying network usage statistics, initialized based on the
device's boot time. This caused the query window to grow
indefinitely as the device uptime increased, leading to
inefficient queries that fetched and processed a large
ever-expanding amount of historical data.

This change refactors the logic to use a rolling start
timestamp. The `mStartTime` is now updated after each
usage report is generated (in `onLost`). By resetting
the start time to a more recent point (current time
minus one bucket duration), we ensure that subsequent
queries for usage snapshots are performed over a small,
manageable time window.

This optimization prevents fetching excessive data
from the NetworkStatsManager, improving the efficiency
of the metrics collector. Dependencies for time and
duration have also been abstracted for better testability.

Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.metrics.SatelliteCoarseUsageMetricsCollectorTest \
  --update-device
Flag: EXEMPT controlled with kill switch
Bug: 419123367
Change-Id: I49d3b044f0a038093060f5541ea263d2d0d253a2
2025-05-31 16:37:59 +08:00
..
android Support matches transport types in NetworkTemplate 2025-05-27 20:35:40 +08:00
com/android Update start timestamp for querying data usage 2025-05-31 16:37:59 +08:00