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

Commit d3b1def2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Enable cache clearing v2 logic, fix bugs."

parents a98767ab e730ae87
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -81,9 +81,9 @@ public class StorageStatsManager {
    /**
     * Return the free space on the requested storage volume.
     * <p>
     * The free space is equivalent to {@link File#getFreeSpace()} plus the size
     * of any cached data that can be automatically deleted by the system as
     * additional space is needed.
     * The free space is equivalent to {@link File#getUsableSpace()} plus the
     * size of any cached data that can be automatically deleted by the system
     * as additional space is needed.
     * <p>
     * This method may take several seconds to calculate the requested values,
     * so it should only be called from a worker thread.
+1 −1
Original line number Diff line number Diff line
@@ -399,7 +399,7 @@ public class PackageManagerService extends IPackageManager.Stub {
    private static final boolean HIDE_EPHEMERAL_APIS = false;
    private static final boolean ENABLE_FREE_CACHE_V2 =
            SystemProperties.getBoolean("fw.free_cache_v2", false);
            SystemProperties.getBoolean("fw.free_cache_v2", true);
    private static final int RADIO_UID = Process.PHONE_UID;
    private static final int LOG_UID = Process.LOG_UID;
+13 −7
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ public class StorageStatsService extends IStorageStatsManager.Stub {
        invalidateMounts();

        mHandler = new H(IoThread.get().getLooper());
        mHandler.sendEmptyMessageDelayed(H.MSG_LOAD_CACHED_QUOTAS_FROM_FILE, DELAY_IN_MILLIS);
        mHandler.sendEmptyMessage(H.MSG_LOAD_CACHED_QUOTAS_FROM_FILE);

        mStorage.registerListener(new StorageEventListener() {
            @Override
@@ -137,7 +137,8 @@ public class StorageStatsService extends IStorageStatsManager.Stub {
                        android.Manifest.permission.PACKAGE_USAGE_STATS, TAG);
                return;
            default:
                throw new SecurityException("Blocked by mode " + mode);
                throw new SecurityException("Package " + callingPackage + " from UID " + callingUid
                        + " blocked by mode " + mode);
        }
    }

@@ -169,16 +170,21 @@ public class StorageStatsService extends IStorageStatsManager.Stub {
        enforcePermission(Binder.getCallingUid(), callingPackage);

        long cacheBytes = 0;
        final long token = Binder.clearCallingIdentity();
        try {
            for (UserInfo user : mUser.getUsers()) {
                final StorageStats stats = queryStatsForUser(volumeUuid, user.id, null);
                cacheBytes += stats.cacheBytes;
            }
        } finally {
            Binder.restoreCallingIdentity(token);
        }

        if (volumeUuid == StorageManager.UUID_PRIVATE_INTERNAL) {
            return Environment.getDataDirectory().getFreeSpace() + cacheBytes;
            return Environment.getDataDirectory().getUsableSpace() + cacheBytes;
        } else {
            final VolumeInfo vol = mStorage.findVolumeByUuid(volumeUuid);
            return vol.getPath().getFreeSpace() + cacheBytes;
            return vol.getPath().getUsableSpace() + cacheBytes;
        }
    }