From 3f96d0e127542a5fc1eb00e2c327d909669c4f52 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Tue, 11 Dec 2012 12:48:08 -0800 Subject: If freeCache deletes APK, give out of space error After DownloadManager has downloaded an application to cache to install during low memory condition, we try to free cache to fit the new application. The free cache function deletes older files first, but it will also delete the downloaded application (since it's in cache) as a last resort since installd has no context about it. This just changes the error code returned in this case so that we'll give something more meaningful to the user. A later fix should actually make this more sane. For instance: know which file to avoid deleting, not even trying to delete anything if it won't arrive at the desired free space. Bug: 7684538 Change-Id: Ide77320fc51a4f692ef8042cb0eafe17b5cd279d --- .../java/com/android/server/pm/PackageManagerService.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index fd649a16b970..2238f17621f1 100644 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -6353,6 +6353,18 @@ public class PackageManagerService extends IPackageManager.Stub { pkgLite = mContainerService.getMinimalPackageInfo(packageFilePath, flags, lowThreshold); } + /* + * The cache free must have deleted the file we + * downloaded to install. + * + * TODO: fix the "freeCache" call to not delete + * the file we care about. + */ + if (pkgLite.recommendedInstallLocation + == PackageHelper.RECOMMEND_FAILED_INVALID_URI) { + pkgLite.recommendedInstallLocation + = PackageHelper.RECOMMEND_FAILED_INSUFFICIENT_STORAGE; + } } } } finally { -- cgit v1.2.3-59-g8ed1b