summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads/DownloadService.java
diff options
context:
space:
mode:
authorVasu Nori <vnori@google.com>2010-12-13 16:29:29 -0800
committerVasu Nori <vnori@google.com>2010-12-14 15:11:19 -0800
commit9aadb4b3f2b3c914166ebfae8851fbecaf536f4f (patch)
tree56e8adaa5a2d5e6f649a24ea7acd270002c9e258 /src/com/android/providers/downloads/DownloadService.java
parent331d169b4a0099e888ff603abdb1be88c30bba21 (diff)
downloadandroid_packages_providers_DownloadProvider-9aadb4b3f2b3c914166ebfae8851fbecaf536f4f.tar.gz
android_packages_providers_DownloadProvider-9aadb4b3f2b3c914166ebfae8851fbecaf536f4f.tar.bz2
android_packages_providers_DownloadProvider-9aadb4b3f2b3c914166ebfae8851fbecaf536f4f.zip
Download dir: /data/data/com.android.providers.downloads/cache NOT /cache
bug:3264401 still to do: make sure only N bytes are taken up by downloads dir N = a value specific to each device. default = 100MB. Change-Id: I2a49f4b3831d3a8d7be13b5fd46d85d56e831e38
Diffstat (limited to 'src/com/android/providers/downloads/DownloadService.java')
-rw-r--r--src/com/android/providers/downloads/DownloadService.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/com/android/providers/downloads/DownloadService.java b/src/com/android/providers/downloads/DownloadService.java
index f93c5c2e..62e355c4 100644
--- a/src/com/android/providers/downloads/DownloadService.java
+++ b/src/com/android/providers/downloads/DownloadService.java
@@ -93,10 +93,14 @@ public class DownloadService extends Service {
private boolean mMediaScannerConnecting;
+ private static final int LOCATION_SYSTEM_CACHE = 1;
+ private static final int LOCATION_DOWNLOAD_DATA_DIR = 2;
+
/**
* The IPC interface to the Media Scanner
*/
private IMediaScannerService mMediaScannerService;
+ private File mDownloadsDataDir;
@VisibleForTesting
SystemFacade mSystemFacade;
@@ -218,7 +222,7 @@ public class DownloadService extends Service {
mNotifier = new DownloadNotification(this, mSystemFacade);
mSystemFacade.cancelAllNotifications();
-
+ mDownloadsDataDir = Helpers.getDownloadsDataDirectory(getApplicationContext());
updateFromProvider();
}
@@ -267,7 +271,10 @@ public class DownloadService extends Service {
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
trimDatabase();
- removeSpuriousFiles();
+ // remove spurious files from system cache
+ removeSpuriousFiles(LOCATION_SYSTEM_CACHE);
+ // remove spurious files from downloads dir
+ removeSpuriousFiles(LOCATION_DOWNLOAD_DATA_DIR);
boolean keepService = false;
// for each update from the database, remember which download is
@@ -423,10 +430,13 @@ public class DownloadService extends Service {
}
/**
- * Removes files that may have been left behind in the cache directory
+ * Removes files that may have been left behind in the systemcache or
+ * /data/downloads directory
*/
- private void removeSpuriousFiles() {
- File[] files = Environment.getDownloadCacheDirectory().listFiles();
+ private void removeSpuriousFiles(int location) {
+ File base = (location == LOCATION_SYSTEM_CACHE) ?
+ Environment.getDownloadCacheDirectory() : mDownloadsDataDir;
+ File[] files = base.listFiles();
if (files == null) {
// The cache folder doesn't appear to exist (this is likely the case
// when running the simulator).