summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasu Nori <vnori@google.com>2011-01-07 11:39:25 -0800
committerVasu Nori <vnori@google.com>2011-01-07 13:34:10 -0800
commitf5699308bc41c39ccbb388feb00a248304f30c54 (patch)
tree8135617c9f2e957adb28187c0334e0a3a4f0c522
parent6eeee34a2cf4fb477cb789c7a232d09fc6565023 (diff)
downloadandroid_packages_providers_DownloadProvider-f5699308bc41c39ccbb388feb00a248304f30c54.tar.gz
android_packages_providers_DownloadProvider-f5699308bc41c39ccbb388feb00a248304f30c54.tar.bz2
android_packages_providers_DownloadProvider-f5699308bc41c39ccbb388feb00a248304f30c54.zip
downloadmanager should use "files" dir - not "cache" dir to store its files
data/data/com.android.providers.downlaods/cache is being used to store the downloaded files, when the user doesn't specify the destination path. but system seems to remove files from this dir EVEN when space is running low. bug:3324673 instead, let DownloadManager use data/data/com.android.providers.downlaods/files dir Downlaodmanager manages its space anyway. Change-Id: I2eb15570395a214477891f50f635fada0b466544
-rw-r--r--src/com/android/providers/downloads/DownloadThread.java4
-rw-r--r--src/com/android/providers/downloads/StorageManager.java10
-rw-r--r--tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java2
3 files changed, 11 insertions, 5 deletions
diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java
index fefbe1d8..9aa0a309 100644
--- a/src/com/android/providers/downloads/DownloadThread.java
+++ b/src/com/android/providers/downloads/DownloadThread.java
@@ -270,8 +270,8 @@ public class DownloadThread extends Thread {
reportProgress(state, innerState);
if (Constants.LOGVV) {
- Log.v(Constants.TAG, "downloaded " + innerState.mBytesSoFar + " for "
- + mInfo.mUri);
+ Log.v(Constants.TAG, "downloaded " + innerState.mBytesSoFar +
+ ", file: " + mInfo.mFileName + ", uri: " + mInfo.mUri);
}
checkPausedOrCanceled(state);
diff --git a/src/com/android/providers/downloads/StorageManager.java b/src/com/android/providers/downloads/StorageManager.java
index d7d0a7ad..e17a3a39 100644
--- a/src/com/android/providers/downloads/StorageManager.java
+++ b/src/com/android/providers/downloads/StorageManager.java
@@ -89,7 +89,7 @@ class StorageManager {
private StorageManager(Context context) { // constructor is private
mContext = context;
- mDownloadDataDir = context.getCacheDir();
+ mDownloadDataDir = context.getFilesDir();
mExternalStorageDir = Environment.getExternalStorageDirectory();
mSystemCacheDir = Environment.getDownloadCacheDirectory();
startThreadToCleanupDatabaseAndPurgeFileSystem();
@@ -419,8 +419,14 @@ class StorageManager {
int numDelete = cursor.getCount() - Constants.MAX_DOWNLOADS;
int columnId = cursor.getColumnIndexOrThrow(Downloads.Impl._ID);
while (numDelete > 0) {
+ long id = cursor.getLong(columnId);
Uri downloadUri = ContentUris.withAppendedId(
- Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, cursor.getLong(columnId));
+ Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, id);
+ if (Constants.LOGV) {
+ Log.i(Constants.TAG, "in trimDatabase, deleing _id: " + id +
+ ", file: " +
+ cursor.getString(cursor.getColumnIndex(Downloads.Impl._DATA)));
+ }
mContext.getContentResolver().delete(downloadUri, null, null);
if (!cursor.moveToNext()) {
break;
diff --git a/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java b/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
index c3ac8904..fac905f8 100644
--- a/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
+++ b/tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java
@@ -65,7 +65,7 @@ public class DownloadManagerFunctionalTest extends AbstractDownloadManagerFuncti
Integer.toString(Downloads.Impl.DESTINATION_CACHE_PARTITION));
runUntilStatus(downloadUri, Downloads.Impl.STATUS_SUCCESS);
assertEquals(FILE_CONTENT, getDownloadContents(downloadUri));
- assertStartsWith(getContext().getCacheDir().getAbsolutePath(),
+ assertStartsWith(getContext().getFilesDir().getAbsolutePath(),
getDownloadFilename(downloadUri));
}