Count cache in storage categories.

This makes the System size more consistent because cache is not
attributed to the system (when the cache is under quota).

Change-Id: I680e70daf5e98b9a205023a218dfd1dcc8ee8334
Fixes: 62623731
Test: Settings Unit Test
This commit is contained in:
Daniel Nishi
2017-06-22 17:09:59 -07:00
parent 1138397336
commit b22b85b593
2 changed files with 29 additions and 5 deletions

View File

@@ -105,7 +105,17 @@ public class StorageAsyncLoader
continue;
}
long blamedSize = stats.getDataBytes() - stats.getCacheBytes();
final long dataSize = stats.getDataBytes();
final long cacheQuota = mStatsManager.getCacheQuotaBytes(mUuid, app.uid);
final long cacheBytes = stats.getCacheBytes();
long blamedSize = dataSize;
// Technically, we could overages as freeable on the storage settings screen.
// If the app is using more cache than its quota, we would accidentally subtract the
// overage from the system size (because it shows up as unused) during our attribution.
// Thus, we cap the attribution at the quota size.
if (cacheQuota < cacheBytes) {
blamedSize = blamedSize - cacheBytes + cacheQuota;
}
// This isn't quite right because it slams the first user by user id with the whole code
// size, but this ensures that we count all apps seen once.