Free only the required bytes from StorageManagerService

Pass only the required number of bytes to StorageManagerService#freeCache
from PackageManagerService#freeStorage.

Test: m
Bug: 181846007
Change-Id: I065f84f16c5100d303bb637dce658273941294c2
This commit is contained in:
Biswarup Pal
2021-03-30 20:04:37 +00:00
parent 7ff8faf4af
commit 0d139c04fb

View File

@@ -8213,9 +8213,10 @@ public class PackageManagerService extends IPackageManager.Stub
// 11. Free storage service cache
StorageManagerInternal smInternal =
mInjector.getLocalService(StorageManagerInternal.class);
// TODO(b/170481432): Decide what value of bytes needs to be sent instead of
// sending the bytes parameter of freeStorage
smInternal.freeCache(volumeUuid, bytes);
long freeBytesRequired = bytes - file.getUsableSpace();
if (freeBytesRequired > 0) {
smInternal.freeCache(volumeUuid, freeBytesRequired);
}
if (file.getUsableSpace() >= bytes) return;
} else {
try {