Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8066ab49 authored by Daniel Nishi's avatar Daniel Nishi Committed by android-build-merger
Browse files

Merge "Cap user-visible cache size at quota." into oc-mr1-dev am: ea842b4e

am: f917c621

Change-Id: I18c707611fb03cccee51531f3f5463f75a8f6690
parents 26cf6252 f917c621
Loading
Loading
Loading
Loading
+29 −20
Original line number Diff line number Diff line
@@ -339,22 +339,31 @@ public class ApplicationsState {
        synchronized (mEntriesMap) {
            AppEntry entry = mEntriesMap.get(userId).get(packageName);
            if (entry != null && (entry.info.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
                mBackgroundHandler.post(() -> {
                mBackgroundHandler.post(
                        () -> {
                            try {
                        final StorageStats stats = mStats.queryStatsForPackage(
                                entry.info.storageUuid, packageName, UserHandle.of(userId));
                                final StorageStats stats =
                                        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);
                                legacy.codeSize = stats.getCodeBytes();
                                legacy.dataSize = stats.getDataBytes();
                        legacy.cacheSize = stats.getCacheBytes();
                                legacy.cacheSize = Math.min(stats.getCacheBytes(), cacheQuota);
                                try {
                            mBackgroundHandler.mStatsObserver.onGetStatsCompleted(legacy, true);
                                    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);
                                    mBackgroundHandler.mStatsObserver.onGetStatsCompleted(
                                            null, false);
                                } catch (RemoteException ignored) {
                                }
                            }