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

Commit a48a023e authored by Tobias Thierer's avatar Tobias Thierer Committed by android-build-merger
Browse files

Merge "Fix for DropBoxManagerService on devices with large storage"

am: 52cd14f1

Change-Id: Iecf0747f43655ef6e99681f55dd64a2b51b38c28
parents 51aa3312 52cd14f1
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;
        }