summaryrefslogtreecommitdiff
path: root/core/java/android/os/FileUtils.java
diff options
context:
space:
mode:
authorChetan Gurjar <chetan.gurjar@mediatek.com>2019-07-24 19:35:33 +0800
committerSemavi Ulusoy <doc.divxm@gmail.com>2022-10-21 15:10:41 +0300
commit2633c372f203a642e8fb3415734f782b23551dd7 (patch)
treead0653e177f4c1e5d5de892f4d56bbf5ed32e97a /core/java/android/os/FileUtils.java
parent9fb5fb4070b311f7ca4e724e414ea52782f4ab47 (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
Diffstat (limited to 'core/java/android/os/FileUtils.java')
-rw-r--r--core/java/android/os/FileUtils.java4
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;