summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChetan Gurjar <chetan.gurjar@mediatek.com>2019-07-24 11:35:33 (GMT)
committerBruno Martins <bgcngm@gmail.com>2019-08-12 07:37:18 (GMT)
commit8241472871287b56fee3831fec61a4b890494c3f (patch)
treef602bb791413085f4391d8a132122ac90b5904d9
parent86f624786016fcd90918747cab2b72ca086cd817 (diff)
downloadframeworks_base-8241472871287b56fee3831fec61a4b890494c3f.zip
frameworks_base-8241472871287b56fee3831fec61a4b890494c3f.tar.gz
frameworks_base-8241472871287b56fee3831fec61a4b890494c3f.tar.bz2
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.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 88d6e84..3b89c6c 100644
--- a/core/java/android/os/FileUtils.java
+++ b/core/java/android/os/FileUtils.java
@@ -1040,11 +1040,13 @@ public 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;