diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2019-05-10 12:28:30 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-05-10 12:28:30 +0000 |
commit | 323e46bc26bdc77ce5210f32f620f065e87c65f5 (patch) | |
tree | 321c506bcf2ee1afec12f6b9b10cf3580770856e | |
parent | 21aa8d14946de227c60066ce3bfef84cc2a5a4f9 (diff) | |
parent | 5dd06798d8e100cbf99144204d278e45ac7ac8df (diff) | |
download | base-323e46bc26bdc77ce5210f32f620f065e87c65f5.tar.gz |
Merge "Fix for DropBoxManagerService on devices with large storage" into pie-dev
-rw-r--r-- | services/core/java/com/android/server/DropBoxManagerService.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/DropBoxManagerService.java b/services/core/java/com/android/server/DropBoxManagerService.java index 887de74f1cf9..09fa006c7669 100644 --- a/services/core/java/com/android/server/DropBoxManagerService.java +++ b/services/core/java/com/android/server/DropBoxManagerService.java @@ -861,10 +861,13 @@ public final class DropBoxManagerService extends SystemService { } catch (IllegalArgumentException e) { // restat throws this on error throw new IOException("Can't restat: " + mDropBoxDir); } - int available = mStatFs.getAvailableBlocks(); - int nonreserved = available - mStatFs.getBlockCount() * reservePercent / 100; + long available = mStatFs.getAvailableBlocksLong(); + long nonreserved = available - mStatFs.getBlockCountLong() * reservePercent / 100; + long maxAvailableLong = nonreserved * quotaPercent / 100; + int maxAvailable = Math.toIntExact(Math.max(0, + Math.min(maxAvailableLong, Integer.MAX_VALUE))); int maximum = quotaKb * 1024 / mBlockSize; - mCachedQuotaBlocks = Math.min(maximum, Math.max(0, nonreserved * quotaPercent / 100)); + mCachedQuotaBlocks = Math.min(maximum, maxAvailable); mCachedQuotaUptimeMillis = uptimeMillis; } |