Loading core/java/android/os/StatFs.java +6 −6 Original line number Diff line number Diff line Loading @@ -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; } /** Loading Loading @@ -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; } /** Loading @@ -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; } } packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java +2 −8 Original line number Diff line number Diff line Loading @@ -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 Loading packages/ExtServices/src/android/ext/services/storage/CacheQuotaServiceImpl.java +2 −3 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * Loading Loading @@ -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); } Loading packages/ExtServices/tests/src/android/ext/services/storage/CacheQuotaServiceImplTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); Loading packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java +1 −1 Original line number Diff line number Diff line Loading @@ -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 Loading
core/java/android/os/StatFs.java +6 −6 Original line number Diff line number Diff line Loading @@ -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; } /** Loading Loading @@ -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; } /** Loading @@ -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; } }
packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java +2 −8 Original line number Diff line number Diff line Loading @@ -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 Loading
packages/ExtServices/src/android/ext/services/storage/CacheQuotaServiceImpl.java +2 −3 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * Loading Loading @@ -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); } Loading
packages/ExtServices/tests/src/android/ext/services/storage/CacheQuotaServiceImplTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); Loading
packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java +1 −1 Original line number Diff line number Diff line Loading @@ -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