diff options
author | Chetan Gurjar <chetan.gurjar@mediatek.com> | 2019-07-24 19:35:33 +0800 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2022-01-26 11:42:56 +0800 |
commit | 17c5d5971540346bc018826675164f56b73b6a8f (patch) | |
tree | 8c8860d79f7dbb49596296c20df4df55f7c3d385 | |
parent | 88af878fce626d7fb3edfd62c665023e57e8ea54 (diff) |
Correction in logic of roundend size calculation of SD card
API FileUtils.roundStorageSize() rounded up the Storage size incorrectly
and caused the storage total size to be displayed twice the actual capacity
in storage Settings application.
Modifications done to appropriately roundup the storage size in the
multiple of power of 2 by making the loop iterations to be controlled by
1024 instead of 1000.
Test: Verified with the particular SD card with which bug reported.
Change-Id: I8f92248a457d6ac507d092df46e1cb0daaa55134
-rw-r--r-- | core/java/android/os/FileUtils.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java index edfcb3d6f12a..0621ebc9d942 100644 --- a/core/java/android/os/FileUtils.java +++ b/core/java/android/os/FileUtils.java @@ -1299,11 +1299,13 @@ public final class FileUtils { public static long roundStorageSize(long size) { long val = 1; long pow = 1; - while ((val * pow) < size) { + long pow1024 = 1; + while ((val * pow1024) < size) { val <<= 1; if (val > 512) { val = 1; pow *= 1000; + pow1024 *= 1024; } } return val * pow; |