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

Commit e44aac03 authored by Romain Hunault's avatar Romain Hunault 💻
Browse files

Merge branch 'v1-nougat-sprint_cordoba' into 'v1-nougat'

[RELEASE] Sprint Cordoba

See merge request e/os/android_frameworks_base!36
parents 2a9bb036 bd5683d1
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -752,4 +752,27 @@ public class FileUtils {
    public static @Nullable File newFileOrNull(@Nullable String path) {
        return (path != null) ? new File(path) : null;
    }

    /**
     * Round the given size of a storage device to a nice round power-of-two
     * value, such as 256MB or 32GB. This avoids showing weird values like
     * "29.5GB" in UI.
     *
     * @hide
     */
    public static long roundStorageSize(long size) {
        long val = 1;
        long pow = 1;
        long pow1024 = 1;
        while ((val * pow1024) < size) {
            val <<= 1;
            if (val > 512) {
                val = 1;
                pow *= 1000;
                pow1024 *= 1024;
            }
        }
        return val * pow;
    }

}
+1 −7
Original line number Diff line number Diff line
@@ -932,13 +932,7 @@ public class StorageManager {

    /** {@hide} */
    public long getPrimaryStorageSize() {
        for (String path : INTERNAL_STORAGE_SIZE_PATHS) {
            final long numberBlocks = readLong(path);
            if (numberBlocks > 0) {
                return numberBlocks * INTERNAL_STORAGE_SECTOR_SIZE;
            }
        }
        return 0;
        return FileUtils.roundStorageSize(Environment.getDataDirectory().getTotalSpace());
    }

    private long readLong(String path) {