Merge "Cap user-visible cache size at quota." into oc-mr1-dev
am: ea842b4e4c
Change-Id: I5e7e5b93e639166dd350701b5228088ca5f5b19b
This commit is contained in:
@@ -339,22 +339,31 @@ public class ApplicationsState {
|
|||||||
synchronized (mEntriesMap) {
|
synchronized (mEntriesMap) {
|
||||||
AppEntry entry = mEntriesMap.get(userId).get(packageName);
|
AppEntry entry = mEntriesMap.get(userId).get(packageName);
|
||||||
if (entry != null && (entry.info.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
|
if (entry != null && (entry.info.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
|
||||||
mBackgroundHandler.post(() -> {
|
mBackgroundHandler.post(
|
||||||
|
() -> {
|
||||||
try {
|
try {
|
||||||
final StorageStats stats = mStats.queryStatsForPackage(
|
final StorageStats stats =
|
||||||
entry.info.storageUuid, packageName, UserHandle.of(userId));
|
mStats.queryStatsForPackage(
|
||||||
|
entry.info.storageUuid,
|
||||||
|
packageName,
|
||||||
|
UserHandle.of(userId));
|
||||||
|
final long cacheQuota =
|
||||||
|
mStats.getCacheQuotaBytes(
|
||||||
|
entry.info.storageUuid.toString(), entry.info.uid);
|
||||||
final PackageStats legacy = new PackageStats(packageName, userId);
|
final PackageStats legacy = new PackageStats(packageName, userId);
|
||||||
legacy.codeSize = stats.getCodeBytes();
|
legacy.codeSize = stats.getCodeBytes();
|
||||||
legacy.dataSize = stats.getDataBytes();
|
legacy.dataSize = stats.getDataBytes();
|
||||||
legacy.cacheSize = stats.getCacheBytes();
|
legacy.cacheSize = Math.min(stats.getCacheBytes(), cacheQuota);
|
||||||
try {
|
try {
|
||||||
mBackgroundHandler.mStatsObserver.onGetStatsCompleted(legacy, true);
|
mBackgroundHandler.mStatsObserver.onGetStatsCompleted(
|
||||||
|
legacy, true);
|
||||||
} catch (RemoteException ignored) {
|
} catch (RemoteException ignored) {
|
||||||
}
|
}
|
||||||
} catch (NameNotFoundException | IOException e) {
|
} catch (NameNotFoundException | IOException e) {
|
||||||
Log.w(TAG, "Failed to query stats: " + e);
|
Log.w(TAG, "Failed to query stats: " + e);
|
||||||
try {
|
try {
|
||||||
mBackgroundHandler.mStatsObserver.onGetStatsCompleted(null, false);
|
mBackgroundHandler.mStatsObserver.onGetStatsCompleted(
|
||||||
|
null, false);
|
||||||
} catch (RemoteException ignored) {
|
} catch (RemoteException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user