From 09734df8bc5a2b788c923ec1a8b78e4cb67f5e70 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Tue, 7 Mar 2017 20:50:27 -0700 Subject: Grumble, nobody likes kibibytes. All the cool kids are using storage in increments of 1000 instead of 1024, so find a balance somewhere between the two. We still round to nice values like 32GB, 64GB, etc, but we represent them using kilobytes under the hood. Test: runtest -x frameworks/base/core/tests/coretests/src/android/os/FileUtilsTest.java Bug: 28327846 Change-Id: I573aea43790816291e2b5c784b344b51b4444c06 --- core/java/android/os/FileUtils.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'core/java/android/os/FileUtils.java') diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java index af05ee7978ce..50b4f8c7facf 100644 --- a/core/java/android/os/FileUtils.java +++ b/core/java/android/os/FileUtils.java @@ -777,10 +777,15 @@ public class FileUtils { * "29.5GB" in UI. */ public static long roundStorageSize(long size) { - long res = 1; - while (res < size) { - res <<= 1; + long val = 1; + long pow = 1; + while ((val * pow) < size) { + val <<= 1; + if (val > 512) { + val = 1; + pow *= 1000; + } } - return res; + return val * pow; } } -- cgit v1.2.3