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

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

Merge "We really want f_frsize and f_bavail." into oc-dev

parents e1df48d3 dafb17e7
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -61,15 +61,15 @@ public class StatFs {
     */
    @Deprecated
    public int getBlockSize() {
        return (int) mStat.f_bsize;
        return (int) mStat.f_frsize;
    }

    /**
     * The size, in bytes, of a block on the file system. This corresponds to
     * the Unix {@code statvfs.f_bsize} field.
     * the Unix {@code statvfs.f_frsize} field.
     */
    public long getBlockSizeLong() {
        return mStat.f_bsize;
        return mStat.f_frsize;
    }

    /**
@@ -112,7 +112,7 @@ public class StatFs {
     * will want to use {@link #getAvailableBytes()} instead.
     */
    public long getFreeBytes() {
        return mStat.f_bfree * mStat.f_bsize;
        return mStat.f_bfree * mStat.f_frsize;
    }

    /**
@@ -136,13 +136,13 @@ public class StatFs {
     * applications.
     */
    public long getAvailableBytes() {
        return mStat.f_bavail * mStat.f_bsize;
        return mStat.f_bavail * mStat.f_frsize;
    }

    /**
     * The total number of bytes supported by the file system.
     */
    public long getTotalBytes() {
        return mStat.f_blocks * mStat.f_bsize;
        return mStat.f_blocks * mStat.f_frsize;
    }
}
+2 −8
Original line number Diff line number Diff line
@@ -220,14 +220,8 @@ public class DefaultContainerService extends IntentService {
        public long[] getFileSystemStats(String path) {
            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);

            try {
                final StructStatVfs stat = Os.statvfs(path);
                final long totalSize = stat.f_blocks * stat.f_bsize;
                final long availSize = stat.f_bavail * stat.f_bsize;
                return new long[] { totalSize, availSize };
            } catch (ErrnoException e) {
                throw new IllegalStateException(e);
            }
            final File file = new File(path);
            return new long[] { file.getTotalSpace(), file.getUsableSpace() };
        }

        @Override
+2 −3
Original line number Diff line number Diff line

/*
 * Copyright (C) 2017 The Android Open Source Project
 *
@@ -123,10 +122,10 @@ public class CacheQuotaServiceImpl extends CacheQuotaService {
        StorageManager storageManager = getSystemService(StorageManager.class);
        long freeBytes = 0;
        if (uuid == StorageManager.UUID_PRIVATE_INTERNAL) { // regular equals because of null
            freeBytes = Environment.getDataDirectory().getFreeSpace();
            freeBytes = Environment.getDataDirectory().getUsableSpace();
        } else {
            final VolumeInfo vol = storageManager.findVolumeByUuid(uuid);
            freeBytes = vol.getPath().getFreeSpace();
            freeBytes = vol.getPath().getUsableSpace();
        }
        return Math.round(freeBytes * CACHE_RESERVE_RATIO);
    }
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ public class CacheQuotaServiceImplTest extends ServiceTestCase<CacheQuotaService
        setContext(mContext);
        when(mContext.getSystemService(Context.STORAGE_SERVICE)).thenReturn(mStorageManager);

        when(mFile.getFreeSpace()).thenReturn(10000L);
        when(mFile.getUsableSpace()).thenReturn(10000L);
        when(mVolume.getPath()).thenReturn(mFile);
        when(mStorageManager.findVolumeByUuid(sTestVolUuid)).thenReturn(mVolume);
        when(mStorageManager.findVolumeByUuid(sSecondTestVolUuid)).thenReturn(mVolume);
+1 −1
Original line number Diff line number Diff line
@@ -386,7 +386,7 @@ public class ExternalStorageProvider extends FileSystemProvider {
                row.add(Root.COLUMN_TITLE, root.title);
                row.add(Root.COLUMN_DOCUMENT_ID, root.docId);
                row.add(Root.COLUMN_AVAILABLE_BYTES,
                        root.reportAvailableBytes ? root.path.getFreeSpace() : -1);
                        root.reportAvailableBytes ? root.path.getUsableSpace() : -1);
            }
        }
        return result;
Loading