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

Commit c0070e50 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

am: 50db797d

Change-Id: I7296490bdc4e2467565837de9b3d6abf56fd6f67
parents 9dd50a31 50db797d
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;
        }