Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52cd14f1 authored by Tobias Thierer's avatar Tobias Thierer Committed by Gerrit Code Review
Browse files

Merge "Fix for DropBoxManagerService on devices with large storage"

parents abfef617 cbb5000b
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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;
        }