Loading services/core/java/com/android/server/pm/InstallParams.java +9 −7 Original line number Diff line number Diff line Loading @@ -169,8 +169,9 @@ final class InstallParams extends HandlerParams { final long sizeBytes = PackageManagerServiceUtils.calculateInstalledSize( mOriginInfo.mResolvedPath, mPackageAbiOverride); if (sizeBytes >= 0) { synchronized (mPm.mInstallLock) { try { mPm.mInstaller.freeCache(null, sizeBytes + lowThreshold, 0, 0); mPm.mInstaller.freeCache(null, sizeBytes + lowThreshold, 0); pkgLite = PackageManagerServiceUtils.getMinimalPackageInfo(mPm.mContext, mPackageLite, mOriginInfo.mResolvedPath, mInstallFlags, mPackageAbiOverride); Loading @@ -178,6 +179,7 @@ final class InstallParams extends HandlerParams { Slog.w(TAG, "Failed to free cache", e); } } } /* * The cache free must have deleted the file we downloaded to install. Loading services/core/java/com/android/server/pm/Installer.java +7 −3 Original line number Diff line number Diff line Loading @@ -632,11 +632,15 @@ public class Installer extends SystemService { } } public void freeCache(String uuid, long targetFreeBytes, long cacheReservedBytes, int flags) throws InstallerException { /** * Deletes cache from specified uuid until targetFreeBytes amount of space is free. * flag denotes aggressive or non-aggresive mode where cache under quota is eligible or not * respectively for clearing. */ public void freeCache(String uuid, long targetFreeBytes, int flags) throws InstallerException { if (!checkBeforeRemote()) return; try { mInstalld.freeCache(uuid, targetFreeBytes, cacheReservedBytes, flags); mInstalld.freeCache(uuid, targetFreeBytes, flags); } catch (Exception e) { throw InstallerException.from(e); } Loading services/core/java/com/android/server/pm/PackageManagerService.java +16 −12 Original line number Diff line number Diff line Loading @@ -2909,7 +2909,6 @@ public class PackageManagerService extends IPackageManager.Stub volumeUuid); final boolean aggressive = (storageFlags & StorageManager.FLAG_ALLOCATE_AGGRESSIVE) != 0; final long reservedBytes = storage.getStorageCacheBytes(file, storageFlags); // 1. Pre-flight to determine if we have any chance to succeed // 2. Consider preloaded data (after 1w honeymoon, unless aggressive) Loading @@ -2926,11 +2925,12 @@ public class PackageManagerService extends IPackageManager.Stub } // 4. Consider cached app data (above quotas) synchronized (mInstallLock) { try { mInstaller.freeCache(volumeUuid, bytes, reservedBytes, Installer.FLAG_FREE_CACHE_V2); mInstaller.freeCache(volumeUuid, bytes, Installer.FLAG_FREE_CACHE_V2); } catch (InstallerException ignored) { } } if (file.getUsableSpace() >= bytes) return; // 5. Consider shared libraries with refcount=0 and age>min cache period Loading @@ -2953,11 +2953,13 @@ public class PackageManagerService extends IPackageManager.Stub } // 8. Consider cached app data (below quotas) synchronized (mInstallLock) { try { mInstaller.freeCache(volumeUuid, bytes, reservedBytes, mInstaller.freeCache(volumeUuid, bytes, Installer.FLAG_FREE_CACHE_V2 | Installer.FLAG_FREE_CACHE_V2_DEFY_QUOTA); } catch (InstallerException ignored) { } } if (file.getUsableSpace() >= bytes) return; // 9. Consider DropBox entries Loading @@ -2982,11 +2984,13 @@ public class PackageManagerService extends IPackageManager.Stub // 12. Clear temp install session files mInstallerService.freeStageDirs(volumeUuid); } else { synchronized (mInstallLock) { try { mInstaller.freeCache(volumeUuid, bytes, 0, 0); mInstaller.freeCache(volumeUuid, bytes, 0); } catch (InstallerException ignored) { } } } if (file.getUsableSpace() >= bytes) return; throw new IOException("Failed to free " + bytes + " on storage device at " + file); Loading Loading
services/core/java/com/android/server/pm/InstallParams.java +9 −7 Original line number Diff line number Diff line Loading @@ -169,8 +169,9 @@ final class InstallParams extends HandlerParams { final long sizeBytes = PackageManagerServiceUtils.calculateInstalledSize( mOriginInfo.mResolvedPath, mPackageAbiOverride); if (sizeBytes >= 0) { synchronized (mPm.mInstallLock) { try { mPm.mInstaller.freeCache(null, sizeBytes + lowThreshold, 0, 0); mPm.mInstaller.freeCache(null, sizeBytes + lowThreshold, 0); pkgLite = PackageManagerServiceUtils.getMinimalPackageInfo(mPm.mContext, mPackageLite, mOriginInfo.mResolvedPath, mInstallFlags, mPackageAbiOverride); Loading @@ -178,6 +179,7 @@ final class InstallParams extends HandlerParams { Slog.w(TAG, "Failed to free cache", e); } } } /* * The cache free must have deleted the file we downloaded to install. Loading
services/core/java/com/android/server/pm/Installer.java +7 −3 Original line number Diff line number Diff line Loading @@ -632,11 +632,15 @@ public class Installer extends SystemService { } } public void freeCache(String uuid, long targetFreeBytes, long cacheReservedBytes, int flags) throws InstallerException { /** * Deletes cache from specified uuid until targetFreeBytes amount of space is free. * flag denotes aggressive or non-aggresive mode where cache under quota is eligible or not * respectively for clearing. */ public void freeCache(String uuid, long targetFreeBytes, int flags) throws InstallerException { if (!checkBeforeRemote()) return; try { mInstalld.freeCache(uuid, targetFreeBytes, cacheReservedBytes, flags); mInstalld.freeCache(uuid, targetFreeBytes, flags); } catch (Exception e) { throw InstallerException.from(e); } Loading
services/core/java/com/android/server/pm/PackageManagerService.java +16 −12 Original line number Diff line number Diff line Loading @@ -2909,7 +2909,6 @@ public class PackageManagerService extends IPackageManager.Stub volumeUuid); final boolean aggressive = (storageFlags & StorageManager.FLAG_ALLOCATE_AGGRESSIVE) != 0; final long reservedBytes = storage.getStorageCacheBytes(file, storageFlags); // 1. Pre-flight to determine if we have any chance to succeed // 2. Consider preloaded data (after 1w honeymoon, unless aggressive) Loading @@ -2926,11 +2925,12 @@ public class PackageManagerService extends IPackageManager.Stub } // 4. Consider cached app data (above quotas) synchronized (mInstallLock) { try { mInstaller.freeCache(volumeUuid, bytes, reservedBytes, Installer.FLAG_FREE_CACHE_V2); mInstaller.freeCache(volumeUuid, bytes, Installer.FLAG_FREE_CACHE_V2); } catch (InstallerException ignored) { } } if (file.getUsableSpace() >= bytes) return; // 5. Consider shared libraries with refcount=0 and age>min cache period Loading @@ -2953,11 +2953,13 @@ public class PackageManagerService extends IPackageManager.Stub } // 8. Consider cached app data (below quotas) synchronized (mInstallLock) { try { mInstaller.freeCache(volumeUuid, bytes, reservedBytes, mInstaller.freeCache(volumeUuid, bytes, Installer.FLAG_FREE_CACHE_V2 | Installer.FLAG_FREE_CACHE_V2_DEFY_QUOTA); } catch (InstallerException ignored) { } } if (file.getUsableSpace() >= bytes) return; // 9. Consider DropBox entries Loading @@ -2982,11 +2984,13 @@ public class PackageManagerService extends IPackageManager.Stub // 12. Clear temp install session files mInstallerService.freeStageDirs(volumeUuid); } else { synchronized (mInstallLock) { try { mInstaller.freeCache(volumeUuid, bytes, 0, 0); mInstaller.freeCache(volumeUuid, bytes, 0); } catch (InstallerException ignored) { } } } if (file.getUsableSpace() >= bytes) return; throw new IOException("Failed to free " + bytes + " on storage device at " + file); Loading