Create AppDataUsageListController

For better organization and testings.

Bug: 240931350
Test: manual - on AppDataUsage
Test: unit test
Change-Id: I77ceeccc7055fcd948fe40d5dfb9cc4a9b9ad2ee
This commit is contained in:
Chaohui Wang
2023-09-28 16:54:38 +08:00
parent ec39446b76
commit b19eb9a4c2
10 changed files with 358 additions and 242 deletions

View File

@@ -126,12 +126,7 @@ class AppDataUsageRepository(
items = items,
)
}
// Map SDK sandbox back to its corresponding app
collapseKey = if (Process.isSdkSandboxUid(uid)) {
Process.getAppUidForSdkSandboxUid(uid)
} else {
uid
}
collapseKey = getAppUid(uid)
category = AppItem.CATEGORY_APP
} else {
// If it is a removed user add it to the removed users' key
@@ -200,6 +195,15 @@ class AppDataUsageRepository(
val bytes: Long,
)
@JvmStatic
fun getAppUid(uid: Int): Int {
if (Process.isSdkSandboxUid(uid)) {
// For a sandbox process, get the associated app UID
return Process.getAppUidForSdkSandboxUid(uid)
}
return uid
}
private fun convertToBuckets(stats: NetworkStats): List<Bucket> {
val buckets = mutableListOf<Bucket>()
stats.use {