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

Commit 50db797d 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

am: a48a023e

Change-Id: Ia9b1a4a3c5981b2c9a83a97c266f79cd33d7c3b3
parents 669dc6ce a48a023e
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -1036,10 +1036,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;
        }