Revert "Merge "downloadmanager should use "files" dir - not "cache" dir to store...
Vasu Nori [Fri, 7 Jan 2011 23:01:50 +0000 (15:01 -0800)]
This reverts commit 7d96bafa59111d9ca735e5ef86dc0598f946b2be, reversing
changes made to 2ce876d2d7000b0c3a1430c5f4932568090f5170.

src/com/android/providers/downloads/DownloadThread.java
src/com/android/providers/downloads/StorageManager.java
tests/src/com/android/providers/downloads/DownloadManagerFunctionalTest.java

index 9aa0a30..fefbe1d 100644 (file)
@@ -270,8 +270,8 @@ public class DownloadThread extends Thread {
             reportProgress(state, innerState);
 
             if (Constants.LOGVV) {
-                Log.v(Constants.TAG, "downloaded " + innerState.mBytesSoFar +
-                      ", file: " + mInfo.mFileName + ", uri: " + mInfo.mUri);
+                Log.v(Constants.TAG, "downloaded " + innerState.mBytesSoFar + " for "
+                      + mInfo.mUri);
             }
 
             checkPausedOrCanceled(state);
index e17a3a3..d7d0a7a 100644 (file)
@@ -89,7 +89,7 @@ class StorageManager {
 
     private StorageManager(Context context) { // constructor is private
         mContext = context;
-        mDownloadDataDir = context.getFilesDir();
+        mDownloadDataDir = context.getCacheDir();
         mExternalStorageDir = Environment.getExternalStorageDirectory();
         mSystemCacheDir = Environment.getDownloadCacheDirectory();
         startThreadToCleanupDatabaseAndPurgeFileSystem();
@@ -419,14 +419,8 @@ 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, id);
-                    if (Constants.LOGV) {
-                        Log.i(Constants.TAG, "in trimDatabase, deleing _id: " + id +
-                                ", file: " +
-                                cursor.getString(cursor.getColumnIndex(Downloads.Impl._DATA)));
-                    }
+                            Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, cursor.getLong(columnId));
                     mContext.getContentResolver().delete(downloadUri, null, null);
                     if (!cursor.moveToNext()) {
                         break;
index fac905f..c3ac890 100644 (file)
@@ -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().getFilesDir().getAbsolutePath(),
+        assertStartsWith(getContext().getCacheDir().getAbsolutePath(),
                          getDownloadFilename(downloadUri));
     }