Merge "Cap user-visible cache size at quota." into oc-mr1-dev
This commit is contained in:
@@ -339,26 +339,35 @@ 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 {
|
() -> {
|
||||||
final StorageStats stats = mStats.queryStatsForPackage(
|
try {
|
||||||
entry.info.storageUuid, packageName, UserHandle.of(userId));
|
final StorageStats stats =
|
||||||
final PackageStats legacy = new PackageStats(packageName, userId);
|
mStats.queryStatsForPackage(
|
||||||
legacy.codeSize = stats.getCodeBytes();
|
entry.info.storageUuid,
|
||||||
legacy.dataSize = stats.getDataBytes();
|
packageName,
|
||||||
legacy.cacheSize = stats.getCacheBytes();
|
UserHandle.of(userId));
|
||||||
try {
|
final long cacheQuota =
|
||||||
mBackgroundHandler.mStatsObserver.onGetStatsCompleted(legacy, true);
|
mStats.getCacheQuotaBytes(
|
||||||
} catch (RemoteException ignored) {
|
entry.info.storageUuid.toString(), entry.info.uid);
|
||||||
}
|
final PackageStats legacy = new PackageStats(packageName, userId);
|
||||||
} catch (NameNotFoundException | IOException e) {
|
legacy.codeSize = stats.getCodeBytes();
|
||||||
Log.w(TAG, "Failed to query stats: " + e);
|
legacy.dataSize = stats.getDataBytes();
|
||||||
try {
|
legacy.cacheSize = Math.min(stats.getCacheBytes(), cacheQuota);
|
||||||
mBackgroundHandler.mStatsObserver.onGetStatsCompleted(null, false);
|
try {
|
||||||
} catch (RemoteException ignored) {
|
mBackgroundHandler.mStatsObserver.onGetStatsCompleted(
|
||||||
}
|
legacy, true);
|
||||||
}
|
} catch (RemoteException ignored) {
|
||||||
});
|
}
|
||||||
|
} catch (NameNotFoundException | IOException e) {
|
||||||
|
Log.w(TAG, "Failed to query stats: " + e);
|
||||||
|
try {
|
||||||
|
mBackgroundHandler.mStatsObserver.onGetStatsCompleted(
|
||||||
|
null, false);
|
||||||
|
} catch (RemoteException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (DEBUG_LOCKING) Log.v(TAG, "...requestSize releasing lock");
|
if (DEBUG_LOCKING) Log.v(TAG, "...requestSize releasing lock");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user