Loading src/com/android/settings/datausage/lib/NetworkStatsRepository.kt +9 −7 Original line number Diff line number Diff line Loading @@ -93,6 +93,7 @@ class NetworkStatsRepository(context: Context, private val template: NetworkTemp val buckets = mutableListOf<Bucket>() val bucket = NetworkStats.Bucket() while (getNextBucket(bucket)) { if (bucket.bytes > 0) { buckets += Bucket( uid = bucket.uid, bytes = bucket.bytes, Loading @@ -101,6 +102,7 @@ class NetworkStatsRepository(context: Context, private val template: NetworkTemp endTimeStamp = bucket.endTimeStamp, ) } } buckets } Loading tests/spa_unit/src/com/android/settings/datausage/lib/AppDataUsageDetailsRepositoryTest.kt +26 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,32 @@ class AppDataUsageDetailsRepositoryTest { ) } @Test fun queryDetailsForCycles_appWithZeroUsage_filtered(): Unit = runBlocking { networkStatsRepository.stub { on { queryBuckets(CYCLE1_END_TIME, CYCLE2_END_TIME) } doReturn listOf( Bucket( uid = UID, bytes = 0L, startTimeStamp = 0L, endTimeStamp = 0L, ), ) } val repository = AppDataUsageDetailsRepository( context = context, cycles = null, template = template, uids = listOf(UID), networkCycleDataRepository = networkCycleDataRepository, networkStatsRepository = networkStatsRepository, ) val detailsForCycles = repository.queryDetailsForCycles() assertThat(detailsForCycles).isEmpty() } private companion object { const val CYCLE1_START_TIME = 1694444444000L const val CYCLE1_END_TIME = 1695555555000L Loading Loading
src/com/android/settings/datausage/lib/NetworkStatsRepository.kt +9 −7 Original line number Diff line number Diff line Loading @@ -93,6 +93,7 @@ class NetworkStatsRepository(context: Context, private val template: NetworkTemp val buckets = mutableListOf<Bucket>() val bucket = NetworkStats.Bucket() while (getNextBucket(bucket)) { if (bucket.bytes > 0) { buckets += Bucket( uid = bucket.uid, bytes = bucket.bytes, Loading @@ -101,6 +102,7 @@ class NetworkStatsRepository(context: Context, private val template: NetworkTemp endTimeStamp = bucket.endTimeStamp, ) } } buckets } Loading
tests/spa_unit/src/com/android/settings/datausage/lib/AppDataUsageDetailsRepositoryTest.kt +26 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,32 @@ class AppDataUsageDetailsRepositoryTest { ) } @Test fun queryDetailsForCycles_appWithZeroUsage_filtered(): Unit = runBlocking { networkStatsRepository.stub { on { queryBuckets(CYCLE1_END_TIME, CYCLE2_END_TIME) } doReturn listOf( Bucket( uid = UID, bytes = 0L, startTimeStamp = 0L, endTimeStamp = 0L, ), ) } val repository = AppDataUsageDetailsRepository( context = context, cycles = null, template = template, uids = listOf(UID), networkCycleDataRepository = networkCycleDataRepository, networkStatsRepository = networkStatsRepository, ) val detailsForCycles = repository.queryDetailsForCycles() assertThat(detailsForCycles).isEmpty() } private companion object { const val CYCLE1_START_TIME = 1694444444000L const val CYCLE1_END_TIME = 1695555555000L Loading